编译器
0.8.20+commit.a1b79de6
文件 1 的 11:DN404Mirror.sol
pragma solidity ^0.8.4;
contract DN404Mirror {
event Transfer(address indexed from, address indexed to, uint256 indexed id);
event Approval(address indexed owner, address indexed account, uint256 indexed id);
event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);
uint256 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
uint256 private constant _APPROVAL_EVENT_SIGNATURE =
0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;
uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =
0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;
error SenderNotBase();
error SenderNotDeployer();
error TransferToNonERC721ReceiverImplementer();
error CannotLink();
error AlreadyLinked();
error NotLinked();
struct DN404NFTStorage {
address baseERC20;
address deployer;
}
function _getDN404NFTStorage() internal pure virtual returns (DN404NFTStorage storage $) {
assembly {
$.slot := 0x3602298b8c10b01230
}
}
constructor(address deployer) {
_getDN404NFTStorage().deployer = deployer;
}
function name() public view virtual returns (string memory result) {
address base = baseERC20();
assembly {
result := mload(0x40)
mstore(0x00, 0x06fdde03)
if iszero(staticcall(gas(), base, 0x1c, 0x04, 0x00, 0x00)) {
returndatacopy(result, 0x00, returndatasize())
revert(result, returndatasize())
}
returndatacopy(0x00, 0x00, 0x20)
returndatacopy(result, mload(0x00), 0x20)
returndatacopy(add(result, 0x20), add(mload(0x00), 0x20), mload(result))
mstore(0x40, add(add(result, 0x20), mload(result)))
}
}
function symbol() public view virtual returns (string memory result) {
address base = baseERC20();
assembly {
result := mload(0x40)
mstore(0x00, 0x95d89b41)
if iszero(staticcall(gas(), base, 0x1c, 0x04, 0x00, 0x00)) {
returndatacopy(result, 0x00, returndatasize())
revert(result, returndatasize())
}
returndatacopy(0x00, 0x00, 0x20)
returndatacopy(result, mload(0x00), 0x20)
returndatacopy(add(result, 0x20), add(mload(0x00), 0x20), mload(result))
mstore(0x40, add(add(result, 0x20), mload(result)))
}
}
function tokenURI(uint256 id) public view virtual returns (string memory result) {
address base = baseERC20();
assembly {
result := mload(0x40)
mstore(0x20, id)
mstore(0x00, 0xc87b56dd)
if iszero(staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x00)) {
returndatacopy(result, 0x00, returndatasize())
revert(result, returndatasize())
}
returndatacopy(0x00, 0x00, 0x20)
returndatacopy(result, mload(0x00), 0x20)
returndatacopy(add(result, 0x20), add(mload(0x00), 0x20), mload(result))
mstore(0x40, add(add(result, 0x20), mload(result)))
}
}
function totalSupply() public view virtual returns (uint256 result) {
address base = baseERC20();
assembly {
mstore(0x00, 0xe2c79281)
if iszero(
and(gt(returndatasize(), 0x1f), staticcall(gas(), base, 0x1c, 0x04, 0x00, 0x20))
) {
returndatacopy(mload(0x40), 0x00, returndatasize())
revert(mload(0x40), returndatasize())
}
result := mload(0x00)
}
}
function balanceOf(address owner) public view virtual returns (uint256 result) {
address base = baseERC20();
assembly {
mstore(0x20, shr(96, shl(96, owner)))
mstore(0x00, 0xf5b100ea)
if iszero(
and(gt(returndatasize(), 0x1f), staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x20))
) {
returndatacopy(mload(0x40), 0x00, returndatasize())
revert(mload(0x40), returndatasize())
}
result := mload(0x00)
}
}
function ownerOf(uint256 id) public view virtual returns (address result) {
address base = baseERC20();
assembly {
mstore(0x00, 0x6352211e)
mstore(0x20, id)
if iszero(
and(gt(returndatasize(), 0x1f), staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x20))
) {
returndatacopy(mload(0x40), 0x00, returndatasize())
revert(mload(0x40), returndatasize())
}
result := shr(96, mload(0x0c))
}
}
function approve(address spender, uint256 id) public virtual {
address base = baseERC20();
assembly {
spender := shr(96, shl(96, spender))
let m := mload(0x40)
mstore(0x00, 0xd10b6e0c)
mstore(0x20, spender)
mstore(0x40, id)
mstore(0x60, caller())
if iszero(
and(
gt(returndatasize(), 0x1f),
call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)
)
) {
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
mstore(0x40, m)
mstore(0x60, 0)
log4(codesize(), 0x00, _APPROVAL_EVENT_SIGNATURE, shr(96, mload(0x0c)), spender, id)
}
}
function getApproved(uint256 id) public view virtual returns (address result) {
address base = baseERC20();
assembly {
mstore(0x00, 0x081812fc)
mstore(0x20, id)
if iszero(
and(gt(returndatasize(), 0x1f), staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x20))
) {
returndatacopy(mload(0x40), 0x00, returndatasize())
revert(mload(0x40), returndatasize())
}
result := shr(96, mload(0x0c))
}
}
function setApprovalForAll(address operator, bool approved) public virtual {
address base = baseERC20();
assembly {
operator := shr(96, shl(96, operator))
let m := mload(0x40)
mstore(0x00, 0x813500fc)
mstore(0x20, operator)
mstore(0x40, iszero(iszero(approved)))
mstore(0x60, caller())
if iszero(
and(eq(mload(0x00), 1), call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20))
) {
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
log3(0x40, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), operator)
mstore(0x40, m)
mstore(0x60, 0)
}
}
function isApprovedForAll(address owner, address operator)
public
view
virtual
returns (bool result)
{
address base = baseERC20();
assembly {
let m := mload(0x40)
mstore(0x40, operator)
mstore(0x2c, shl(96, owner))
mstore(0x0c, 0xe985e9c5000000000000000000000000)
if iszero(
and(gt(returndatasize(), 0x1f), staticcall(gas(), base, 0x1c, 0x44, 0x00, 0x20))
) {
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
mstore(0x40, m)
result := iszero(iszero(mload(0x00)))
}
}
function transferFrom(address from, address to, uint256 id) public virtual {
address base = baseERC20();
assembly {
from := shr(96, shl(96, from))
to := shr(96, shl(96, to))
let m := mload(0x40)
mstore(m, 0xe5eb36c8)
mstore(add(m, 0x20), from)
mstore(add(m, 0x40), to)
mstore(add(m, 0x60), id)
mstore(add(m, 0x80), caller())
if iszero(
and(eq(mload(m), 1), call(gas(), base, callvalue(), add(m, 0x1c), 0x84, m, 0x20))
) {
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id)
}
}
function safeTransferFrom(address from, address to, uint256 id) public payable virtual {
transferFrom(from, to, id);
if (_hasCode(to)) _checkOnERC721Received(from, to, id, "");
}
function safeTransferFrom(address from, address to, uint256 id, bytes calldata data)
public
virtual
{
transferFrom(from, to, id);
if (_hasCode(to)) _checkOnERC721Received(from, to, id, data);
}
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {
assembly {
let s := shr(224, interfaceId)
result := or(or(eq(s, 0x01ffc9a7), eq(s, 0x80ac58cd)), eq(s, 0x5b5e139f))
}
}
function baseERC20() public view virtual returns (address base) {
base = _getDN404NFTStorage().baseERC20;
if (base == address(0)) revert NotLinked();
}
modifier dn404NFTFallback() virtual {
DN404NFTStorage storage $ = _getDN404NFTStorage();
uint256 fnSelector = _calldataload(0x00) >> 224;
if (fnSelector == 0x263c69d6) {
if (msg.sender != $.baseERC20) revert SenderNotBase();
assembly {
returndatacopy(0x00, returndatasize(), lt(calldatasize(), 0x20))
let o := add(0x24, calldataload(0x04))
returndatacopy(0x00, returndatasize(), lt(calldatasize(), o))
let end := add(o, shl(5, calldataload(sub(o, 0x20))))
returndatacopy(0x00, returndatasize(), lt(calldatasize(), end))
for {} iszero(eq(o, end)) { o := add(0x20, o) } {
let d := calldataload(o)
let a := shr(96, d)
let b := and(1, d)
log4(
codesize(),
0x00,
_TRANSFER_EVENT_SIGNATURE,
mul(a, b),
mul(a, iszero(b)),
shr(168, shl(160, d))
)
}
mstore(0x00, 0x01)
return(0x00, 0x20)
}
}
if (fnSelector == 0x0f4599e5) {
if ($.deployer != address(0)) {
if (address(uint160(_calldataload(0x04))) != $.deployer) {
revert SenderNotDeployer();
}
}
if ($.baseERC20 != address(0)) revert AlreadyLinked();
$.baseERC20 = msg.sender;
assembly {
mstore(0x00, 0x01)
return(0x00, 0x20)
}
}
_;
}
fallback() external payable virtual dn404NFTFallback {}
receive() external payable virtual {}
function _calldataload(uint256 offset) private pure returns (uint256 value) {
assembly {
value := calldataload(offset)
}
}
function _hasCode(address a) private view returns (bool result) {
assembly {
result := extcodesize(a)
}
}
function _checkOnERC721Received(address from, address to, uint256 id, bytes memory data)
private
{
assembly {
let m := mload(0x40)
let onERC721ReceivedSelector := 0x150b7a02
mstore(m, onERC721ReceivedSelector)
mstore(add(m, 0x20), caller())
mstore(add(m, 0x40), shr(96, shl(96, from)))
mstore(add(m, 0x60), id)
mstore(add(m, 0x80), 0x80)
let n := mload(data)
mstore(add(m, 0xa0), n)
if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xc0), n)) }
if iszero(call(gas(), to, 0, add(m, 0x1c), add(n, 0xa4), m, 0x20)) {
if returndatasize() {
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
}
if iszero(eq(mload(m), shl(224, onERC721ReceivedSelector))) {
mstore(0x00, 0xd1a57ed6)
revert(0x1c, 0x04)
}
}
}
}
文件 2 的 11:DN404Reflect.sol
pragma solidity ^0.8.4;
import "./DN404Mirror.sol";
abstract contract DN404Reflect {
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(
address indexed owner,
address indexed spender,
uint256 amount
);
event SkipNFTSet(address indexed target, bool status);
error DNAlreadyInitialized();
error InsufficientBalance();
error InsufficientAllowance();
error TotalSupplyOverflow();
error SenderNotMirror();
error TransferToZeroAddress();
error MirrorAddressIsZero();
error LinkMirrorContractFailed();
error ApprovalCallerNotOwnerNorApproved();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TokenDoesNotExist();
uint256 internal _WAD;
uint256 internal constant _MAX_TOKEN_ID = 0xffffffff;
uint256 internal constant _MAX_SUPPLY = 10 ** 18 * 0xffffffff - 1;
uint8 internal constant _ADDRESS_DATA_INITIALIZED_FLAG = 1 << 0;
uint8 internal constant _ADDRESS_DATA_SKIP_NFT_FLAG = 1 << 1;
struct AddressData {
uint88 aux;
uint8 flags;
uint32 addressAlias;
uint32 ownedLength;
uint96 balance;
uint256 tOwned;
uint256 rOwned;
bool isExcluded;
}
struct Uint32Map {
mapping(uint256 => uint256) map;
}
struct DN404Storage {
uint32 numAliases;
uint32 nextTokenId;
uint32 totalNFTSupply;
uint96 totalSupply;
uint256 tTotal;
uint256 rTotal;
uint256 tFeeTotal;
uint256 taxFee;
address mirrorERC721;
mapping(uint32 => address) aliasToAddress;
mapping(address => mapping(address => bool)) operatorApprovals;
mapping(uint256 => address) tokenApprovals;
mapping(address => mapping(address => uint256)) allowance;
mapping(address => Uint32Map) owned;
Uint32Map oo;
mapping(address => AddressData) addressData;
address[] excluded;
bool functionsRenounced;
bool tradingEnabled;
}
function _getDN404Storage()
internal
pure
virtual
returns (DN404Storage storage $)
{
assembly {
$.slot := 0xa20d6e21d0e5255308
}
}
function _initializeDN404Reflect(
uint256 initialTokenSupply,
address initialSupplyOwner,
address mirror,
uint256 wad
) internal virtual {
DN404Storage storage $ = _getDN404Storage();
if ($.nextTokenId != 0) revert DNAlreadyInitialized();
if (mirror == address(0)) revert MirrorAddressIsZero();
_linkMirrorContract(mirror);
$.nextTokenId = 1;
$.mirrorERC721 = mirror;
_WAD = wad;
if (initialTokenSupply > 0) {
if (initialSupplyOwner == address(0))
revert TransferToZeroAddress();
if (initialTokenSupply > _MAX_SUPPLY) revert TotalSupplyOverflow();
$.totalSupply = uint96(initialTokenSupply);
$.tTotal = initialTokenSupply;
uint256 MAX = ~uint256(0);
$.rTotal = (MAX - (MAX % $.tTotal));
AddressData storage initialOwnerAddressData = _addressData(
initialSupplyOwner
);
initialOwnerAddressData.balance = uint96(initialTokenSupply);
initialOwnerAddressData.rOwned = $.rTotal;
emit Transfer(address(0), initialSupplyOwner, initialTokenSupply);
_setSkipNFT(initialSupplyOwner, true);
}
}
function name() public view virtual returns (string memory);
function symbol() public view virtual returns (string memory);
function tokenURI(
uint256 id
) public view virtual returns (string memory result);
function decimals() public pure returns (uint8) {
return 18;
}
function totalSupply() public view virtual returns (uint256) {
return uint256(_getDN404Storage().totalSupply);
}
function balanceOf(address owner) public view virtual returns (uint256) {
AddressData storage ownerAddressData = _getDN404Storage().addressData[
owner
];
if (ownerAddressData.isExcluded) return ownerAddressData.tOwned;
return tokenFromReflection(ownerAddressData.rOwned);
}
function allowance(
address owner,
address spender
) public view returns (uint256) {
return _getDN404Storage().allowance[owner][spender];
}
function approve(
address spender,
uint256 amount
) public virtual returns (bool) {
DN404Storage storage $ = _getDN404Storage();
$.allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(
address to,
uint256 amount
) public virtual returns (bool) {
_transfer(msg.sender, to, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual returns (bool) {
DN404Storage storage $ = _getDN404Storage();
uint256 allowed = $.allowance[from][msg.sender];
if (allowed != type(uint256).max) {
if (amount > allowed) revert InsufficientAllowance();
unchecked {
$.allowance[from][msg.sender] = allowed - amount;
}
}
_transfer(from, to, amount);
return true;
}
function reflect(uint256 tAmount) public {
DN404Storage storage $ = _getDN404Storage();
address sender = msg.sender;
AddressData storage senderAddressData = _addressData(sender);
require(
!senderAddressData.isExcluded,
"Excluded addresses cannot call this function"
);
(uint256 rAmount, , , , ) = _getValues(tAmount);
senderAddressData.rOwned = senderAddressData.rOwned - rAmount;
$.rTotal = $.rTotal - rAmount;
$.tFeeTotal = $.tFeeTotal + tAmount;
}
function reflectionFromToken(
uint256 tAmount,
bool deductTransferFee
) public view returns (uint256) {
require(
tAmount <= _getDN404Storage().tTotal,
"Amount must be less than supply"
);
if (!deductTransferFee) {
(uint256 rAmount, , , , ) = _getValues(tAmount);
return rAmount;
} else {
(, uint256 rTransferAmount, , , ) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(
uint256 rAmount
) public view returns (uint256) {
require(
rAmount <= _getDN404Storage().rTotal,
"Amount must be less than total reflections"
);
uint256 currentRate = _getRate();
return rAmount / currentRate;
}
function _mint(address to, uint256 amount) internal virtual {
if (to == address(0)) revert TransferToZeroAddress();
DN404Storage storage $ = _getDN404Storage();
AddressData storage toAddressData = _addressData(to);
unchecked {
uint256 currentTokenSupply = uint256($.totalSupply) + amount;
if (amount > _MAX_SUPPLY || currentTokenSupply > _MAX_SUPPLY) {
revert TotalSupplyOverflow();
}
$.totalSupply = uint96(currentTokenSupply);
uint256 toBalance = toAddressData.balance + amount;
toAddressData.balance = uint96(toBalance);
if (toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG == 0) {
Uint32Map storage toOwned = $.owned[to];
uint256 toIndex = toAddressData.ownedLength;
uint256 toEnd = toBalance / _WAD;
_PackedLogs memory packedLogs = _packedLogsMalloc(
_zeroFloorSub(toEnd, toIndex)
);
if (packedLogs.logs.length != 0) {
uint256 maxNFTId = $.totalSupply / _WAD;
uint32 toAlias = _registerAndResolveAlias(
toAddressData,
to
);
uint256 id = $.nextTokenId;
$.totalNFTSupply += uint32(packedLogs.logs.length);
toAddressData.ownedLength = uint32(toEnd);
do {
while (_get($.oo, _ownershipIndex(id)) != 0) {
if (++id > maxNFTId) id = 1;
}
_set(toOwned, toIndex, uint32(id));
_setOwnerAliasAndOwnedIndex(
$.oo,
id,
toAlias,
uint32(toIndex++)
);
_packedLogsAppend(packedLogs, to, id, 0);
if (++id > maxNFTId) id = 1;
} while (toIndex != toEnd);
$.nextTokenId = uint32(id);
_packedLogsSend(packedLogs, $.mirrorERC721);
}
}
}
emit Transfer(address(0), to, amount);
}
function _burn(address from, uint256 amount) internal virtual {
DN404Storage storage $ = _getDN404Storage();
AddressData storage fromAddressData = _addressData(from);
uint256 fromBalance = fromAddressData.balance;
if (amount > fromBalance) revert InsufficientBalance();
uint256 currentTokenSupply = $.totalSupply;
unchecked {
fromBalance -= amount;
fromAddressData.balance = uint96(fromBalance);
currentTokenSupply -= amount;
$.totalSupply = uint96(currentTokenSupply);
Uint32Map storage fromOwned = $.owned[from];
uint256 fromIndex = fromAddressData.ownedLength;
uint256 nftAmountToBurn = _zeroFloorSub(
fromIndex,
fromBalance / _WAD
);
if (nftAmountToBurn != 0) {
$.totalNFTSupply -= uint32(nftAmountToBurn);
_PackedLogs memory packedLogs = _packedLogsMalloc(
nftAmountToBurn
);
uint256 fromEnd = fromIndex - nftAmountToBurn;
do {
uint256 id = _get(fromOwned, --fromIndex);
_setOwnerAliasAndOwnedIndex($.oo, id, 0, 0);
delete $.tokenApprovals[id];
_packedLogsAppend(packedLogs, from, id, 1);
} while (fromIndex != fromEnd);
fromAddressData.ownedLength = uint32(fromIndex);
_packedLogsSend(packedLogs, $.mirrorERC721);
}
}
emit Transfer(from, address(0), amount);
}
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
if (to == address(0)) revert TransferToZeroAddress();
require(from != to, "Cannot transfer to self");
DN404Storage storage $ = _getDN404Storage();
AddressData storage fromAddressData = _addressData(from);
AddressData storage toAddressData = _addressData(to);
_TransferTemps memory t;
t.fromOwnedLength = fromAddressData.ownedLength;
t.toOwnedLength = toAddressData.ownedLength;
if (amount > balanceOf(from)) revert InsufficientBalance();
unchecked {
(
uint256 rAmount,
uint256 rTransferAmount,
uint256 rFee,
uint256 tTransferAmount,
uint256 tFee
) = _getValues(amount);
if (fromAddressData.isExcluded && !toAddressData.isExcluded) {
fromAddressData.tOwned = fromAddressData.tOwned - amount;
fromAddressData.rOwned = fromAddressData.rOwned - rAmount;
toAddressData.rOwned = toAddressData.rOwned + rTransferAmount;
fromAddressData.balance = uint96(fromAddressData.tOwned);
toAddressData.balance = uint96(tokenFromReflection(toAddressData.rOwned));
}
else if (!fromAddressData.isExcluded && toAddressData.isExcluded) {
fromAddressData.rOwned = fromAddressData.rOwned - rAmount;
toAddressData.rOwned = toAddressData.rOwned + rTransferAmount;
toAddressData.tOwned = toAddressData.tOwned + tTransferAmount;
fromAddressData.balance = uint96(tokenFromReflection(fromAddressData.rOwned));
toAddressData.balance = uint96(toAddressData.tOwned);
}
else if (!fromAddressData.isExcluded && !toAddressData.isExcluded) {
fromAddressData.rOwned = fromAddressData.rOwned - rAmount;
toAddressData.rOwned = toAddressData.rOwned + rTransferAmount;
fromAddressData.balance = uint96(tokenFromReflection(fromAddressData.rOwned));
toAddressData.balance = uint96(tokenFromReflection(toAddressData.rOwned));
}
else if (fromAddressData.isExcluded && toAddressData.isExcluded) {
fromAddressData.tOwned = fromAddressData.tOwned - amount;
fromAddressData.rOwned = fromAddressData.rOwned - rAmount;
toAddressData.rOwned = toAddressData.rOwned + rTransferAmount;
toAddressData.tOwned = toAddressData.tOwned + tTransferAmount;
fromAddressData.balance = uint96(fromAddressData.tOwned);
toAddressData.balance = uint96(toAddressData.tOwned);
}
_reflectFee(rFee, tFee);
t.nftAmountToBurn = _zeroFloorSub(
t.fromOwnedLength,
fromAddressData.balance / _WAD
);
if (toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG == 0) {
if (from == to)
t.toOwnedLength = t.fromOwnedLength - t.nftAmountToBurn;
t.nftAmountToMint = _zeroFloorSub(
toAddressData.balance / _WAD,
t.toOwnedLength
);
}
_PackedLogs memory packedLogs = _packedLogsMalloc(
t.nftAmountToBurn + t.nftAmountToMint
);
if (t.nftAmountToBurn != 0) {
Uint32Map storage fromOwned = $.owned[from];
uint256 fromIndex = t.fromOwnedLength;
uint256 fromEnd = fromIndex - t.nftAmountToBurn;
$.totalNFTSupply -= uint32(t.nftAmountToBurn);
fromAddressData.ownedLength = uint32(fromEnd);
do {
uint256 id = _get(fromOwned, --fromIndex);
_setOwnerAliasAndOwnedIndex($.oo, id, 0, 0);
delete $.tokenApprovals[id];
_packedLogsAppend(packedLogs, from, id, 1);
} while (fromIndex != fromEnd);
}
if (t.nftAmountToMint != 0) {
Uint32Map storage toOwned = $.owned[to];
uint256 toIndex = t.toOwnedLength;
uint256 toEnd = toIndex + t.nftAmountToMint;
uint32 toAlias = _registerAndResolveAlias(toAddressData, to);
uint256 maxNFTId = $.totalSupply / _WAD;
uint256 id = $.nextTokenId;
$.totalNFTSupply += uint32(t.nftAmountToMint);
toAddressData.ownedLength = uint32(toEnd);
do {
while (_get($.oo, _ownershipIndex(id)) != 0) {
if (++id > maxNFTId) id = 1;
}
_set(toOwned, toIndex, uint32(id));
_setOwnerAliasAndOwnedIndex(
$.oo,
id,
toAlias,
uint32(toIndex++)
);
_packedLogsAppend(packedLogs, to, id, 0);
if (++id > maxNFTId) id = 1;
} while (toIndex != toEnd);
$.nextTokenId = uint32(id);
}
if (packedLogs.logs.length != 0) {
_packedLogsSend(packedLogs, $.mirrorERC721);
}
}
emit Transfer(from, to, amount);
}
function _transferFromNFT(
address from,
address to,
uint256 id,
address msgSender
) internal virtual {
DN404Storage storage $ = _getDN404Storage();
if (to == address(0)) revert TransferToZeroAddress();
require(to != from, "Cannot transfer to self");
address owner = $.aliasToAddress[_get($.oo, _ownershipIndex(id))];
if (from != owner) revert TransferFromIncorrectOwner();
if (msgSender != from) {
if (!$.operatorApprovals[from][msgSender]) {
if (msgSender != $.tokenApprovals[id]) {
revert TransferCallerNotOwnerNorApproved();
}
}
}
AddressData storage fromAddressData = _addressData(from);
AddressData storage toAddressData = _addressData(to);
(uint256 rAmount, , , , ) = _getValues(_WAD);
if (fromAddressData.isExcluded) {
fromAddressData.tOwned -= _WAD;
}
if (toAddressData.isExcluded) {
toAddressData.tOwned += _WAD;
}
fromAddressData.rOwned -= rAmount;
fromAddressData.balance -= uint96(_WAD);
unchecked {
toAddressData.balance += uint96(_WAD);
toAddressData.rOwned += rAmount;
_set(
$.oo,
_ownershipIndex(id),
_registerAndResolveAlias(toAddressData, to)
);
delete $.tokenApprovals[id];
uint256 updatedId = _get(
$.owned[from],
--fromAddressData.ownedLength
);
_set($.owned[from], _get($.oo, _ownedIndex(id)), uint32(updatedId));
uint256 n = toAddressData.ownedLength++;
_set($.oo, _ownedIndex(updatedId), _get($.oo, _ownedIndex(id)));
_set($.owned[to], n, uint32(id));
_set($.oo, _ownedIndex(id), uint32(n));
}
emit Transfer(from, to, _WAD);
}
function _getAux(address owner) internal view virtual returns (uint88) {
return _getDN404Storage().addressData[owner].aux;
}
function _setAux(address owner, uint88 value) internal virtual {
_getDN404Storage().addressData[owner].aux = value;
}
function getSkipNFT(address a) public view virtual returns (bool) {
AddressData storage d = _getDN404Storage().addressData[a];
if (d.flags & _ADDRESS_DATA_INITIALIZED_FLAG == 0) return _hasCode(a);
return d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0;
}
function setSkipNFT(bool skipNFT) public virtual {
_setSkipNFT(msg.sender, skipNFT);
}
function _setSkipNFT(address a, bool state) internal virtual {
AddressData storage d = _addressData(a);
if ((d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0) != state) {
d.flags ^= _ADDRESS_DATA_SKIP_NFT_FLAG;
}
emit SkipNFTSet(a, state);
}
function _addressData(
address a
) internal virtual returns (AddressData storage d) {
DN404Storage storage $ = _getDN404Storage();
d = $.addressData[a];
if (d.flags & _ADDRESS_DATA_INITIALIZED_FLAG == 0) {
uint8 flags = _ADDRESS_DATA_INITIALIZED_FLAG;
if (_hasCode(a)) flags |= _ADDRESS_DATA_SKIP_NFT_FLAG;
d.flags = flags;
}
}
function _registerAndResolveAlias(
AddressData storage toAddressData,
address to
) internal virtual returns (uint32 addressAlias) {
DN404Storage storage $ = _getDN404Storage();
addressAlias = toAddressData.addressAlias;
if (addressAlias == 0) {
addressAlias = ++$.numAliases;
toAddressData.addressAlias = addressAlias;
$.aliasToAddress[addressAlias] = to;
}
}
function mirrorERC721() public view virtual returns (address) {
return _getDN404Storage().mirrorERC721;
}
function _totalNFTSupply() internal view virtual returns (uint256) {
return _getDN404Storage().totalNFTSupply;
}
function _balanceOfNFT(
address owner
) internal view virtual returns (uint256) {
return _getDN404Storage().addressData[owner].ownedLength;
}
function _ownerAt(uint256 id) internal view virtual returns (address) {
DN404Storage storage $ = _getDN404Storage();
return $.aliasToAddress[_get($.oo, _ownershipIndex(id))];
}
function _ownerOf(uint256 id) internal view virtual returns (address) {
if (!_exists(id)) revert TokenDoesNotExist();
return _ownerAt(id);
}
function _exists(uint256 id) internal view virtual returns (bool) {
return _ownerAt(id) != address(0);
}
function _getApproved(uint256 id) internal view virtual returns (address) {
if (!_exists(id)) revert TokenDoesNotExist();
return _getDN404Storage().tokenApprovals[id];
}
function _approveNFT(
address spender,
uint256 id,
address msgSender
) internal virtual returns (address) {
DN404Storage storage $ = _getDN404Storage();
address owner = $.aliasToAddress[_get($.oo, _ownershipIndex(id))];
if (msgSender != owner) {
if (!$.operatorApprovals[owner][msgSender]) {
revert ApprovalCallerNotOwnerNorApproved();
}
}
$.tokenApprovals[id] = spender;
return owner;
}
function _setApprovalForAll(
address operator,
bool approved,
address msgSender
) internal virtual {
_getDN404Storage().operatorApprovals[msgSender][operator] = approved;
}
function _linkMirrorContract(address mirror) internal virtual {
assembly {
mstore(0x00, 0x0f4599e5)
mstore(0x20, caller())
if iszero(
and(
eq(mload(0x00), 1),
call(gas(), mirror, 0, 0x1c, 0x24, 0x00, 0x20)
)
) {
mstore(0x00, 0xd125259c)
revert(0x1c, 0x04)
}
}
}
modifier dn404Fallback() virtual {
DN404Storage storage $ = _getDN404Storage();
uint256 fnSelector = _calldataload(0x00) >> 224;
if (fnSelector == 0xe985e9c5) {
if (msg.sender != $.mirrorERC721) revert SenderNotMirror();
if (msg.data.length < 0x44) revert();
address owner = address(uint160(_calldataload(0x04)));
address operator = address(uint160(_calldataload(0x24)));
_return($.operatorApprovals[owner][operator] ? 1 : 0);
}
if (fnSelector == 0x6352211e) {
if (msg.sender != $.mirrorERC721) revert SenderNotMirror();
if (msg.data.length < 0x24) revert();
uint256 id = _calldataload(0x04);
_return(uint160(_ownerOf(id)));
}
if (fnSelector == 0xe5eb36c8) {
if (msg.sender != $.mirrorERC721) revert SenderNotMirror();
if (msg.data.length < 0x84) revert();
address from = address(uint160(_calldataload(0x04)));
address to = address(uint160(_calldataload(0x24)));
uint256 id = _calldataload(0x44);
address msgSender = address(uint160(_calldataload(0x64)));
_transferFromNFT(from, to, id, msgSender);
_return(1);
}
if (fnSelector == 0x813500fc) {
if (msg.sender != $.mirrorERC721) revert SenderNotMirror();
if (msg.data.length < 0x64) revert();
address spender = address(uint160(_calldataload(0x04)));
bool status = _calldataload(0x24) != 0;
address msgSender = address(uint160(_calldataload(0x44)));
_setApprovalForAll(spender, status, msgSender);
_return(1);
}
if (fnSelector == 0xd10b6e0c) {
if (msg.sender != $.mirrorERC721) revert SenderNotMirror();
if (msg.data.length < 0x64) revert();
address spender = address(uint160(_calldataload(0x04)));
uint256 id = _calldataload(0x24);
address msgSender = address(uint160(_calldataload(0x44)));
_return(uint160(_approveNFT(spender, id, msgSender)));
}
if (fnSelector == 0x081812fc) {
if (msg.sender != $.mirrorERC721) revert SenderNotMirror();
if (msg.data.length < 0x24) revert();
uint256 id = _calldataload(0x04);
_return(uint160(_getApproved(id)));
}
if (fnSelector == 0xf5b100ea) {
if (msg.sender != $.mirrorERC721) revert SenderNotMirror();
if (msg.data.length < 0x24) revert();
address owner = address(uint160(_calldataload(0x04)));
_return(_balanceOfNFT(owner));
}
if (fnSelector == 0xe2c79281) {
if (msg.sender != $.mirrorERC721) revert SenderNotMirror();
if (msg.data.length < 0x04) revert();
_return(_totalNFTSupply());
}
if (fnSelector == 0xb7a94eb8) {
_return(1);
}
_;
}
fallback() external payable virtual dn404Fallback {}
receive() external payable virtual {}
struct _PackedLogs {
uint256[] logs;
uint256 offset;
}
function _packedLogsMalloc(
uint256 n
) private pure returns (_PackedLogs memory p) {
assembly {
let logs := add(mload(0x40), 0x40)
mstore(logs, n)
let offset := add(0x20, logs)
mstore(0x40, add(offset, shl(5, n)))
mstore(p, logs)
mstore(add(0x20, p), offset)
}
}
function _packedLogsAppend(
_PackedLogs memory p,
address a,
uint256 id,
uint256 burnBit
) private pure {
assembly {
let offset := mload(add(0x20, p))
mstore(offset, or(or(shl(96, a), shl(8, id)), burnBit))
mstore(add(0x20, p), add(offset, 0x20))
}
}
function _packedLogsSend(_PackedLogs memory p, address mirror) private {
assembly {
let logs := mload(p)
let o := sub(logs, 0x40)
mstore(o, 0x263c69d6)
mstore(add(o, 0x20), 0x20)
let n := add(0x44, shl(5, mload(logs)))
if iszero(
and(
eq(mload(o), 1),
call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20)
)
) {
revert(o, 0x00)
}
}
}
struct _TransferTemps {
uint256 nftAmountToBurn;
uint256 nftAmountToMint;
uint256 fromBalance;
uint256 toBalance;
uint256 fromOwnedLength;
uint256 toOwnedLength;
}
function _hasCode(address a) private view returns (bool result) {
assembly {
result := extcodesize(a)
}
}
function _calldataload(
uint256 offset
) private pure returns (uint256 value) {
assembly {
value := calldataload(offset)
}
}
function _return(uint256 x) private pure {
assembly {
mstore(0x00, x)
return(0x00, 0x20)
}
}
function _zeroFloorSub(
uint256 x,
uint256 y
) private pure returns (uint256 z) {
assembly {
z := mul(gt(x, y), sub(x, y))
}
}
function _ownershipIndex(uint256 i) private pure returns (uint256) {
return i << 1;
}
function _ownedIndex(uint256 i) private pure returns (uint256) {
unchecked {
return (i << 1) + 1;
}
}
function _get(
Uint32Map storage map,
uint256 index
) private view returns (uint32 result) {
result = uint32(map.map[index >> 3] >> ((index & 7) << 5));
}
function _set(Uint32Map storage map, uint256 index, uint32 value) private {
assembly {
mstore(0x20, map.slot)
mstore(0x00, shr(3, index))
let s := keccak256(0x00, 0x40)
let o := shl(5, and(index, 7))
let v := sload(s)
let m := 0xffffffff
sstore(s, xor(v, shl(o, and(m, xor(shr(o, v), value)))))
}
}
function _setOwnerAliasAndOwnedIndex(
Uint32Map storage map,
uint256 id,
uint32 ownership,
uint32 ownedIndex
) private {
assembly {
let value := or(shl(32, ownedIndex), and(0xffffffff, ownership))
mstore(0x20, map.slot)
mstore(0x00, shr(2, id))
let s := keccak256(0x00, 0x40)
let o := shl(6, and(id, 3))
let v := sload(s)
let m := 0xffffffffffffffff
sstore(s, xor(v, shl(o, and(m, xor(shr(o, v), value)))))
}
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
DN404Storage storage $ = _getDN404Storage();
$.rTotal = $.rTotal - rFee;
$.tFeeTotal = $.tFeeTotal + tFee;
}
function _getValues(
uint256 tAmount
) private view returns (uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(
tAmount,
tFee,
currentRate
);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(
uint256 tAmount
) private view returns (uint256, uint256) {
uint256 tFee = _calculateTaxFee(tAmount);
uint256 tTransferAmount = tAmount - tFee;
return (tTransferAmount, tFee);
}
function _getRValues(
uint256 tAmount,
uint256 tFee,
uint256 currentRate
) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount * currentRate;
uint256 rFee = tFee * currentRate;
uint256 rTransferAmount = rAmount - rFee;
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns (uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return (rSupply / tSupply);
}
function _getCurrentSupply() private view returns (uint256, uint256) {
DN404Storage storage $ = _getDN404Storage();
uint256 rSupply = $.rTotal;
uint256 tSupply = $.tTotal;
for (uint256 i = 0; i < $.excluded.length; i++) {
AddressData storage excludedAddressData = $.addressData[
$.excluded[i]
];
if (
excludedAddressData.rOwned > rSupply ||
excludedAddressData.tOwned > tSupply
) return ($.rTotal, $.tTotal);
rSupply = rSupply - excludedAddressData.rOwned;
tSupply = tSupply - excludedAddressData.tOwned;
}
if (rSupply < $.rTotal / $.tTotal) return ($.rTotal, $.tTotal);
return (rSupply, tSupply);
}
function getTotalReflections() public view returns (uint256) {
return _getDN404Storage().tFeeTotal;
}
function _calculateTaxFee(uint256 amount) private view returns (uint256) {
return (amount * _getDN404Storage().taxFee) / (10 ** 3);
}
}
文件 3 的 11:DN420.sol
pragma solidity ^0.8.4;
import "./DN404Reflect.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import {DailyOutflowCounterLib} from "./DailyOutflowCounterLib.sol";
import {OwnableRoles} from "solady/src/auth/OwnableRoles.sol";
import {SafeTransferLib} from "solady/src/utils/SafeTransferLib.sol";
import {GasBurnerLib} from "solady/src/utils/GasBurnerLib.sol";
contract DN420 is DN404Reflect, OwnableRoles {
using DailyOutflowCounterLib for *;
uint256 public constant ADMIN_ROLE = _ROLE_0;
error Locked();
error MaxBalanceLimitReached();
string internal _name;
string internal _symbol;
string internal _baseURI;
bool public baseURILocked;
bool public nameAndSymbolLocked;
bool public gasBurnFactorLocked;
bool public whitelistLocked;
bool public maxBalanceLimitLocked;
uint32 public maxBalanceLimit;
uint32 public gasBurnFactor;
bool private tradingEnabled;
address private uniswapV2Router;
address private gasliteDrop;
constructor() {
_construct(tx.origin);
}
function _construct(address initialOwner) internal {
_initializeOwner(initialOwner);
_setWhitelisted(initialOwner, true);
_name = "DeezNutz";
_symbol = "DN";
gasBurnFactor = 0;
maxBalanceLimit = 348;
}
function name() public view override returns (string memory) {
return _name;
}
function symbol() public view override returns (string memory) {
return _symbol;
}
function tokenURI(uint256 id) public view override returns (string memory result) {
if (!_exists(id)) revert TokenDoesNotExist();
return string.concat(_baseURI, Strings.toString(id), ".json");
}
function _transfer(address from, address to, uint256 amount) internal override {
if (!tradingEnabled) {
require(msg.sender == owner() || (msg.sender == uniswapV2Router && from == owner() || msg.sender == gasliteDrop), "Trading is not enabled");
}
DN404Reflect._transfer(from, to, amount);
_applyMaxBalanceLimit(from, to);
if (from != to) _applyGasBurn(from, amount);
}
function _transferFromNFT(address from, address to, uint256 id, address msgSender)
internal
override
{
if (!tradingEnabled) {
require(msg.sender == owner(), "Trading is not enabled");
}
DN404Reflect._transferFromNFT(from, to, id, msgSender);
_applyMaxBalanceLimit(from, to);
if (from != to) _applyGasBurn(from, _WAD);
}
function _applyMaxBalanceLimit(address from, address to) internal view {
unchecked {
uint256 limit = maxBalanceLimit;
if (limit == 0) return;
if (balanceOf(to) <= _WAD * limit) return;
if (_getAux(to).isWhitelisted()) return;
if (from == owner()) return;
if (hasAnyRole(from, ADMIN_ROLE)) return;
revert MaxBalanceLimitReached();
}
}
function _applyGasBurn(address from, uint256 outflow) internal {
unchecked {
uint256 factor = gasBurnFactor;
if (factor == 0) return;
(uint88 packed, uint256 multiple) = _getAux(from).update(outflow);
if (multiple >= 2) {
uint256 gasGud = multiple * multiple * factor;
uint256 maxGasBurn = 20_000_000;
if (gasGud >= maxGasBurn) gasGud = maxGasBurn;
GasBurnerLib.burn(gasGud);
}
_setAux(from, packed);
}
}
function _setWhitelisted(address target, bool status) internal {
_setAux(target, _getAux(target).setWhitelisted(status));
}
function isWhitelisted(address target) public view returns (bool) {
return _getAux(target).isWhitelisted();
}
function initialize(uint256 initialTokenSupply, uint256 wad, address mirror, address uniswapV2Router_, address gasliteDrop_) public onlyOwnerOrRoles(ADMIN_ROLE) {
uniswapV2Router = uniswapV2Router_;
gasliteDrop = gasliteDrop_;
address initialSupplyOwner = msg.sender;
_initializeDN404Reflect(initialTokenSupply, initialSupplyOwner, mirror, wad);
_setWhitelisted(initialSupplyOwner, true);
}
function lockMaxBalanceLimit() public onlyOwnerOrRoles(ADMIN_ROLE) {
maxBalanceLimitLocked = true;
}
function setMaxBalanceLimit(uint32 value) public onlyOwnerOrRoles(ADMIN_ROLE) {
if (maxBalanceLimitLocked) revert Locked();
maxBalanceLimit = value;
}
function lockGasWhitelist() public onlyOwnerOrRoles(ADMIN_ROLE) {
whitelistLocked = true;
}
function setWhitelist(address target, bool status) public onlyOwnerOrRoles(ADMIN_ROLE) {
if (whitelistLocked) revert Locked();
_setWhitelisted(target, status);
}
function lockGasBurnFactor() public onlyOwnerOrRoles(ADMIN_ROLE) {
gasBurnFactorLocked = true;
}
function setGasBurnFactor(uint32 gasBurnFactor_) public onlyOwnerOrRoles(ADMIN_ROLE) {
if (gasBurnFactorLocked) revert Locked();
gasBurnFactor = gasBurnFactor_;
}
function lockBaseURI() public onlyOwnerOrRoles(ADMIN_ROLE) {
baseURILocked = true;
}
function setBaseURI(string calldata baseURI_) public onlyOwnerOrRoles(ADMIN_ROLE) {
if (baseURILocked) revert Locked();
_baseURI = baseURI_;
}
function lockNameAndSymbol() public onlyOwnerOrRoles(ADMIN_ROLE) {
nameAndSymbolLocked = true;
}
function setNameAndSymbol(string calldata name_, string calldata symbol_)
public
onlyOwnerOrRoles(ADMIN_ROLE)
{
if (nameAndSymbolLocked) revert Locked();
_name = name_;
_symbol = symbol_;
}
function withdraw() public onlyOwnerOrRoles(ADMIN_ROLE) {
SafeTransferLib.safeTransferAllETH(msg.sender);
}
function renounceFunctions() external onlyOwner {
_getDN404Storage().functionsRenounced = true;
}
function enableTrading() external onlyOwner {
tradingEnabled = true;
}
function excludeAccount(address account) external onlyOwner {
DN404Storage storage $ = _getDN404Storage();
require(!$.functionsRenounced, "Function is renounced");
AddressData storage accountAddressData = _addressData(account);
require(!accountAddressData.isExcluded, "Account is already excluded");
if (accountAddressData.rOwned > 0) {
accountAddressData.tOwned = tokenFromReflection(
accountAddressData.rOwned
);
}
accountAddressData.isExcluded = true;
$.excluded.push(account);
}
function includeAccount(address account) external onlyOwner {
DN404Storage storage $ = _getDN404Storage();
AddressData storage accountAddressData = _addressData(account);
require(!accountAddressData.isExcluded, "Account is already excluded");
for (uint256 i = 0; i < $.excluded.length; i++) {
if ($.excluded[i] == account) {
$.excluded[i] = $.excluded[$.excluded.length - 1];
accountAddressData.tOwned = 0;
accountAddressData.isExcluded = false;
$.excluded.pop();
break;
}
}
}
function setTaxFee(uint256 fee) external onlyOwner {
DN404Storage storage $ = _getDN404Storage();
require(!$.functionsRenounced, "Function is renounced");
require(fee <= 50, "Reflections fee must be 5% or less");
$.taxFee = fee;
}
function getTaxFee() external view returns (uint256) {
return _getDN404Storage().taxFee;
}
}
文件 4 的 11:DailyOutflowCounterLib.sol
pragma solidity ^0.8.4;
library DailyOutflowCounterLib {
uint256 internal constant WAD_TRUNCATED = 10 ** 18 >> 40;
uint256 internal constant OUTFLOW_TRUNCATED_MASK = 0xffffffffffffff;
uint256 internal constant DAY_BITPOS = 56;
uint256 internal constant DAY_MASK = 0x7fffffff;
uint256 internal constant OUTFLOW_TRUNCATE_SHR = 40;
uint256 internal constant WHITELISTED_BITPOS = 87;
function update(uint88 packed, uint256 outflow)
internal
view
returns (uint88 updated, uint256 multiple)
{
unchecked {
if (isWhitelisted(packed)) {
return (packed, 0);
}
uint256 currentDay = (block.timestamp / 86400) & DAY_MASK;
uint256 packedDay = (uint256(packed) >> DAY_BITPOS) & DAY_MASK;
uint256 totalOutflowTruncated = uint256(packed) & OUTFLOW_TRUNCATED_MASK;
if (packedDay != currentDay) {
totalOutflowTruncated = 0;
packedDay = currentDay;
}
uint256 result = packedDay << DAY_BITPOS;
uint256 todaysOutflowTruncated =
totalOutflowTruncated + ((outflow >> OUTFLOW_TRUNCATE_SHR) & OUTFLOW_TRUNCATED_MASK);
result |= todaysOutflowTruncated & OUTFLOW_TRUNCATED_MASK;
updated = uint88(result);
multiple = todaysOutflowTruncated / WAD_TRUNCATED;
}
}
function isWhitelisted(uint88 packed) internal pure returns (bool) {
return packed >> WHITELISTED_BITPOS != 0;
}
function setWhitelisted(uint88 packed, bool status) internal pure returns (uint88) {
if (isWhitelisted(packed) != status) {
packed ^= uint88(1 << WHITELISTED_BITPOS);
}
return packed;
}
}
文件 5 的 11:GasBurnerLib.sol
pragma solidity ^0.8.4;
library GasBurnerLib {
function burn(uint256 x) internal pure {
assembly {
mstore(0x10, or(1, x))
let n := mul(gt(x, 120), div(x, 91))
for { let i := 0 } iszero(eq(i, n)) { i := add(i, 1) } {
mstore(0x10, keccak256(0x10, 0x10))
}
if iszero(mload(0x10)) { invalid() }
}
}
}
文件 6 的 11:Math.sol
pragma solidity ^0.8.20;
library Math {
error MathOverflowedMulDiv();
enum Rounding {
Floor,
Ceil,
Trunc,
Expand
}
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
return a / b;
}
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
uint256 prod0 = x * y;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (0 - denominator);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}
文件 7 的 11:Ownable.sol
pragma solidity ^0.8.4;
abstract contract Ownable {
error Unauthorized();
error NewOwnerIsZeroAddress();
error NoHandoverRequest();
error AlreadyInitialized();
event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);
event OwnershipHandoverRequested(address indexed pendingOwner);
event OwnershipHandoverCanceled(address indexed pendingOwner);
uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =
0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;
uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =
0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;
uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =
0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;
bytes32 internal constant _OWNER_SLOT =
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927;
uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;
function _guardInitializeOwner() internal pure virtual returns (bool guard) {}
function _initializeOwner(address newOwner) internal virtual {
if (_guardInitializeOwner()) {
assembly {
let ownerSlot := _OWNER_SLOT
if sload(ownerSlot) {
mstore(0x00, 0x0dc149f0)
revert(0x1c, 0x04)
}
newOwner := shr(96, shl(96, newOwner))
sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
}
} else {
assembly {
newOwner := shr(96, shl(96, newOwner))
sstore(_OWNER_SLOT, newOwner)
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)
}
}
}
function _setOwner(address newOwner) internal virtual {
if (_guardInitializeOwner()) {
assembly {
let ownerSlot := _OWNER_SLOT
newOwner := shr(96, shl(96, newOwner))
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))
}
} else {
assembly {
let ownerSlot := _OWNER_SLOT
newOwner := shr(96, shl(96, newOwner))
log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)
sstore(ownerSlot, newOwner)
}
}
}
function _checkOwner() internal view virtual {
assembly {
if iszero(eq(caller(), sload(_OWNER_SLOT))) {
mstore(0x00, 0x82b42900)
revert(0x1c, 0x04)
}
}
}
function _ownershipHandoverValidFor() internal view virtual returns (uint64) {
return 48 * 3600;
}
function transferOwnership(address newOwner) public payable virtual onlyOwner {
assembly {
if iszero(shl(96, newOwner)) {
mstore(0x00, 0x7448fbae)
revert(0x1c, 0x04)
}
}
_setOwner(newOwner);
}
function renounceOwnership() public payable virtual onlyOwner {
_setOwner(address(0));
}
function requestOwnershipHandover() public payable virtual {
unchecked {
uint256 expires = block.timestamp + _ownershipHandoverValidFor();
assembly {
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, caller())
sstore(keccak256(0x0c, 0x20), expires)
log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())
}
}
}
function cancelOwnershipHandover() public payable virtual {
assembly {
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, caller())
sstore(keccak256(0x0c, 0x20), 0)
log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())
}
}
function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {
assembly {
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, pendingOwner)
let handoverSlot := keccak256(0x0c, 0x20)
if gt(timestamp(), sload(handoverSlot)) {
mstore(0x00, 0x6f5e8818)
revert(0x1c, 0x04)
}
sstore(handoverSlot, 0)
}
_setOwner(pendingOwner);
}
function owner() public view virtual returns (address result) {
assembly {
result := sload(_OWNER_SLOT)
}
}
function ownershipHandoverExpiresAt(address pendingOwner)
public
view
virtual
returns (uint256 result)
{
assembly {
mstore(0x0c, _HANDOVER_SLOT_SEED)
mstore(0x00, pendingOwner)
result := sload(keccak256(0x0c, 0x20))
}
}
modifier onlyOwner() virtual {
_checkOwner();
_;
}
}
文件 8 的 11:OwnableRoles.sol
pragma solidity ^0.8.4;
import {Ownable} from "./Ownable.sol";
abstract contract OwnableRoles is Ownable {
event RolesUpdated(address indexed user, uint256 indexed roles);
uint256 private constant _ROLES_UPDATED_EVENT_SIGNATURE =
0x715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe26;
uint256 private constant _ROLE_SLOT_SEED = 0x8b78c6d8;
function _setRoles(address user, uint256 roles) internal virtual {
assembly {
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, user)
sstore(keccak256(0x0c, 0x20), roles)
log3(0, 0, _ROLES_UPDATED_EVENT_SIGNATURE, shr(96, mload(0x0c)), roles)
}
}
function _updateRoles(address user, uint256 roles, bool on) internal virtual {
assembly {
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, user)
let roleSlot := keccak256(0x0c, 0x20)
let current := sload(roleSlot)
let updated := or(current, roles)
if iszero(on) { updated := xor(current, and(current, roles)) }
sstore(roleSlot, updated)
log3(0, 0, _ROLES_UPDATED_EVENT_SIGNATURE, shr(96, mload(0x0c)), updated)
}
}
function _grantRoles(address user, uint256 roles) internal virtual {
_updateRoles(user, roles, true);
}
function _removeRoles(address user, uint256 roles) internal virtual {
_updateRoles(user, roles, false);
}
function _checkRoles(uint256 roles) internal view virtual {
assembly {
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, caller())
if iszero(and(sload(keccak256(0x0c, 0x20)), roles)) {
mstore(0x00, 0x82b42900)
revert(0x1c, 0x04)
}
}
}
function _checkOwnerOrRoles(uint256 roles) internal view virtual {
assembly {
if iszero(eq(caller(), sload(not(_ROLE_SLOT_SEED)))) {
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, caller())
if iszero(and(sload(keccak256(0x0c, 0x20)), roles)) {
mstore(0x00, 0x82b42900)
revert(0x1c, 0x04)
}
}
}
}
function _checkRolesOrOwner(uint256 roles) internal view virtual {
assembly {
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, caller())
if iszero(and(sload(keccak256(0x0c, 0x20)), roles)) {
if iszero(eq(caller(), sload(not(_ROLE_SLOT_SEED)))) {
mstore(0x00, 0x82b42900)
revert(0x1c, 0x04)
}
}
}
}
function _rolesFromOrdinals(uint8[] memory ordinals) internal pure returns (uint256 roles) {
assembly {
for { let i := shl(5, mload(ordinals)) } i { i := sub(i, 0x20) } {
roles := or(shl(mload(add(ordinals, i)), 1), roles)
}
}
}
function _ordinalsFromRoles(uint256 roles) internal pure returns (uint8[] memory ordinals) {
assembly {
ordinals := mload(0x40)
let ptr := add(ordinals, 0x20)
let o := 0
for { let t := roles } 1 {} {
mstore(ptr, o)
ptr := add(ptr, shl(5, and(t, 1)))
o := add(o, 1)
t := shr(o, roles)
if iszero(t) { break }
}
mstore(ordinals, shr(5, sub(ptr, add(ordinals, 0x20))))
mstore(0x40, ptr)
}
}
function grantRoles(address user, uint256 roles) public payable virtual onlyOwner {
_grantRoles(user, roles);
}
function revokeRoles(address user, uint256 roles) public payable virtual onlyOwner {
_removeRoles(user, roles);
}
function renounceRoles(uint256 roles) public payable virtual {
_removeRoles(msg.sender, roles);
}
function rolesOf(address user) public view virtual returns (uint256 roles) {
assembly {
mstore(0x0c, _ROLE_SLOT_SEED)
mstore(0x00, user)
roles := sload(keccak256(0x0c, 0x20))
}
}
function hasAnyRole(address user, uint256 roles) public view virtual returns (bool) {
return rolesOf(user) & roles != 0;
}
function hasAllRoles(address user, uint256 roles) public view virtual returns (bool) {
return rolesOf(user) & roles == roles;
}
modifier onlyRoles(uint256 roles) virtual {
_checkRoles(roles);
_;
}
modifier onlyOwnerOrRoles(uint256 roles) virtual {
_checkOwnerOrRoles(roles);
_;
}
modifier onlyRolesOrOwner(uint256 roles) virtual {
_checkRolesOrOwner(roles);
_;
}
uint256 internal constant _ROLE_0 = 1 << 0;
uint256 internal constant _ROLE_1 = 1 << 1;
uint256 internal constant _ROLE_2 = 1 << 2;
uint256 internal constant _ROLE_3 = 1 << 3;
uint256 internal constant _ROLE_4 = 1 << 4;
uint256 internal constant _ROLE_5 = 1 << 5;
uint256 internal constant _ROLE_6 = 1 << 6;
uint256 internal constant _ROLE_7 = 1 << 7;
uint256 internal constant _ROLE_8 = 1 << 8;
uint256 internal constant _ROLE_9 = 1 << 9;
uint256 internal constant _ROLE_10 = 1 << 10;
uint256 internal constant _ROLE_11 = 1 << 11;
uint256 internal constant _ROLE_12 = 1 << 12;
uint256 internal constant _ROLE_13 = 1 << 13;
uint256 internal constant _ROLE_14 = 1 << 14;
uint256 internal constant _ROLE_15 = 1 << 15;
uint256 internal constant _ROLE_16 = 1 << 16;
uint256 internal constant _ROLE_17 = 1 << 17;
uint256 internal constant _ROLE_18 = 1 << 18;
uint256 internal constant _ROLE_19 = 1 << 19;
uint256 internal constant _ROLE_20 = 1 << 20;
uint256 internal constant _ROLE_21 = 1 << 21;
uint256 internal constant _ROLE_22 = 1 << 22;
uint256 internal constant _ROLE_23 = 1 << 23;
uint256 internal constant _ROLE_24 = 1 << 24;
uint256 internal constant _ROLE_25 = 1 << 25;
uint256 internal constant _ROLE_26 = 1 << 26;
uint256 internal constant _ROLE_27 = 1 << 27;
uint256 internal constant _ROLE_28 = 1 << 28;
uint256 internal constant _ROLE_29 = 1 << 29;
uint256 internal constant _ROLE_30 = 1 << 30;
uint256 internal constant _ROLE_31 = 1 << 31;
uint256 internal constant _ROLE_32 = 1 << 32;
uint256 internal constant _ROLE_33 = 1 << 33;
uint256 internal constant _ROLE_34 = 1 << 34;
uint256 internal constant _ROLE_35 = 1 << 35;
uint256 internal constant _ROLE_36 = 1 << 36;
uint256 internal constant _ROLE_37 = 1 << 37;
uint256 internal constant _ROLE_38 = 1 << 38;
uint256 internal constant _ROLE_39 = 1 << 39;
uint256 internal constant _ROLE_40 = 1 << 40;
uint256 internal constant _ROLE_41 = 1 << 41;
uint256 internal constant _ROLE_42 = 1 << 42;
uint256 internal constant _ROLE_43 = 1 << 43;
uint256 internal constant _ROLE_44 = 1 << 44;
uint256 internal constant _ROLE_45 = 1 << 45;
uint256 internal constant _ROLE_46 = 1 << 46;
uint256 internal constant _ROLE_47 = 1 << 47;
uint256 internal constant _ROLE_48 = 1 << 48;
uint256 internal constant _ROLE_49 = 1 << 49;
uint256 internal constant _ROLE_50 = 1 << 50;
uint256 internal constant _ROLE_51 = 1 << 51;
uint256 internal constant _ROLE_52 = 1 << 52;
uint256 internal constant _ROLE_53 = 1 << 53;
uint256 internal constant _ROLE_54 = 1 << 54;
uint256 internal constant _ROLE_55 = 1 << 55;
uint256 internal constant _ROLE_56 = 1 << 56;
uint256 internal constant _ROLE_57 = 1 << 57;
uint256 internal constant _ROLE_58 = 1 << 58;
uint256 internal constant _ROLE_59 = 1 << 59;
uint256 internal constant _ROLE_60 = 1 << 60;
uint256 internal constant _ROLE_61 = 1 << 61;
uint256 internal constant _ROLE_62 = 1 << 62;
uint256 internal constant _ROLE_63 = 1 << 63;
uint256 internal constant _ROLE_64 = 1 << 64;
uint256 internal constant _ROLE_65 = 1 << 65;
uint256 internal constant _ROLE_66 = 1 << 66;
uint256 internal constant _ROLE_67 = 1 << 67;
uint256 internal constant _ROLE_68 = 1 << 68;
uint256 internal constant _ROLE_69 = 1 << 69;
uint256 internal constant _ROLE_70 = 1 << 70;
uint256 internal constant _ROLE_71 = 1 << 71;
uint256 internal constant _ROLE_72 = 1 << 72;
uint256 internal constant _ROLE_73 = 1 << 73;
uint256 internal constant _ROLE_74 = 1 << 74;
uint256 internal constant _ROLE_75 = 1 << 75;
uint256 internal constant _ROLE_76 = 1 << 76;
uint256 internal constant _ROLE_77 = 1 << 77;
uint256 internal constant _ROLE_78 = 1 << 78;
uint256 internal constant _ROLE_79 = 1 << 79;
uint256 internal constant _ROLE_80 = 1 << 80;
uint256 internal constant _ROLE_81 = 1 << 81;
uint256 internal constant _ROLE_82 = 1 << 82;
uint256 internal constant _ROLE_83 = 1 << 83;
uint256 internal constant _ROLE_84 = 1 << 84;
uint256 internal constant _ROLE_85 = 1 << 85;
uint256 internal constant _ROLE_86 = 1 << 86;
uint256 internal constant _ROLE_87 = 1 << 87;
uint256 internal constant _ROLE_88 = 1 << 88;
uint256 internal constant _ROLE_89 = 1 << 89;
uint256 internal constant _ROLE_90 = 1 << 90;
uint256 internal constant _ROLE_91 = 1 << 91;
uint256 internal constant _ROLE_92 = 1 << 92;
uint256 internal constant _ROLE_93 = 1 << 93;
uint256 internal constant _ROLE_94 = 1 << 94;
uint256 internal constant _ROLE_95 = 1 << 95;
uint256 internal constant _ROLE_96 = 1 << 96;
uint256 internal constant _ROLE_97 = 1 << 97;
uint256 internal constant _ROLE_98 = 1 << 98;
uint256 internal constant _ROLE_99 = 1 << 99;
uint256 internal constant _ROLE_100 = 1 << 100;
uint256 internal constant _ROLE_101 = 1 << 101;
uint256 internal constant _ROLE_102 = 1 << 102;
uint256 internal constant _ROLE_103 = 1 << 103;
uint256 internal constant _ROLE_104 = 1 << 104;
uint256 internal constant _ROLE_105 = 1 << 105;
uint256 internal constant _ROLE_106 = 1 << 106;
uint256 internal constant _ROLE_107 = 1 << 107;
uint256 internal constant _ROLE_108 = 1 << 108;
uint256 internal constant _ROLE_109 = 1 << 109;
uint256 internal constant _ROLE_110 = 1 << 110;
uint256 internal constant _ROLE_111 = 1 << 111;
uint256 internal constant _ROLE_112 = 1 << 112;
uint256 internal constant _ROLE_113 = 1 << 113;
uint256 internal constant _ROLE_114 = 1 << 114;
uint256 internal constant _ROLE_115 = 1 << 115;
uint256 internal constant _ROLE_116 = 1 << 116;
uint256 internal constant _ROLE_117 = 1 << 117;
uint256 internal constant _ROLE_118 = 1 << 118;
uint256 internal constant _ROLE_119 = 1 << 119;
uint256 internal constant _ROLE_120 = 1 << 120;
uint256 internal constant _ROLE_121 = 1 << 121;
uint256 internal constant _ROLE_122 = 1 << 122;
uint256 internal constant _ROLE_123 = 1 << 123;
uint256 internal constant _ROLE_124 = 1 << 124;
uint256 internal constant _ROLE_125 = 1 << 125;
uint256 internal constant _ROLE_126 = 1 << 126;
uint256 internal constant _ROLE_127 = 1 << 127;
uint256 internal constant _ROLE_128 = 1 << 128;
uint256 internal constant _ROLE_129 = 1 << 129;
uint256 internal constant _ROLE_130 = 1 << 130;
uint256 internal constant _ROLE_131 = 1 << 131;
uint256 internal constant _ROLE_132 = 1 << 132;
uint256 internal constant _ROLE_133 = 1 << 133;
uint256 internal constant _ROLE_134 = 1 << 134;
uint256 internal constant _ROLE_135 = 1 << 135;
uint256 internal constant _ROLE_136 = 1 << 136;
uint256 internal constant _ROLE_137 = 1 << 137;
uint256 internal constant _ROLE_138 = 1 << 138;
uint256 internal constant _ROLE_139 = 1 << 139;
uint256 internal constant _ROLE_140 = 1 << 140;
uint256 internal constant _ROLE_141 = 1 << 141;
uint256 internal constant _ROLE_142 = 1 << 142;
uint256 internal constant _ROLE_143 = 1 << 143;
uint256 internal constant _ROLE_144 = 1 << 144;
uint256 internal constant _ROLE_145 = 1 << 145;
uint256 internal constant _ROLE_146 = 1 << 146;
uint256 internal constant _ROLE_147 = 1 << 147;
uint256 internal constant _ROLE_148 = 1 << 148;
uint256 internal constant _ROLE_149 = 1 << 149;
uint256 internal constant _ROLE_150 = 1 << 150;
uint256 internal constant _ROLE_151 = 1 << 151;
uint256 internal constant _ROLE_152 = 1 << 152;
uint256 internal constant _ROLE_153 = 1 << 153;
uint256 internal constant _ROLE_154 = 1 << 154;
uint256 internal constant _ROLE_155 = 1 << 155;
uint256 internal constant _ROLE_156 = 1 << 156;
uint256 internal constant _ROLE_157 = 1 << 157;
uint256 internal constant _ROLE_158 = 1 << 158;
uint256 internal constant _ROLE_159 = 1 << 159;
uint256 internal constant _ROLE_160 = 1 << 160;
uint256 internal constant _ROLE_161 = 1 << 161;
uint256 internal constant _ROLE_162 = 1 << 162;
uint256 internal constant _ROLE_163 = 1 << 163;
uint256 internal constant _ROLE_164 = 1 << 164;
uint256 internal constant _ROLE_165 = 1 << 165;
uint256 internal constant _ROLE_166 = 1 << 166;
uint256 internal constant _ROLE_167 = 1 << 167;
uint256 internal constant _ROLE_168 = 1 << 168;
uint256 internal constant _ROLE_169 = 1 << 169;
uint256 internal constant _ROLE_170 = 1 << 170;
uint256 internal constant _ROLE_171 = 1 << 171;
uint256 internal constant _ROLE_172 = 1 << 172;
uint256 internal constant _ROLE_173 = 1 << 173;
uint256 internal constant _ROLE_174 = 1 << 174;
uint256 internal constant _ROLE_175 = 1 << 175;
uint256 internal constant _ROLE_176 = 1 << 176;
uint256 internal constant _ROLE_177 = 1 << 177;
uint256 internal constant _ROLE_178 = 1 << 178;
uint256 internal constant _ROLE_179 = 1 << 179;
uint256 internal constant _ROLE_180 = 1 << 180;
uint256 internal constant _ROLE_181 = 1 << 181;
uint256 internal constant _ROLE_182 = 1 << 182;
uint256 internal constant _ROLE_183 = 1 << 183;
uint256 internal constant _ROLE_184 = 1 << 184;
uint256 internal constant _ROLE_185 = 1 << 185;
uint256 internal constant _ROLE_186 = 1 << 186;
uint256 internal constant _ROLE_187 = 1 << 187;
uint256 internal constant _ROLE_188 = 1 << 188;
uint256 internal constant _ROLE_189 = 1 << 189;
uint256 internal constant _ROLE_190 = 1 << 190;
uint256 internal constant _ROLE_191 = 1 << 191;
uint256 internal constant _ROLE_192 = 1 << 192;
uint256 internal constant _ROLE_193 = 1 << 193;
uint256 internal constant _ROLE_194 = 1 << 194;
uint256 internal constant _ROLE_195 = 1 << 195;
uint256 internal constant _ROLE_196 = 1 << 196;
uint256 internal constant _ROLE_197 = 1 << 197;
uint256 internal constant _ROLE_198 = 1 << 198;
uint256 internal constant _ROLE_199 = 1 << 199;
uint256 internal constant _ROLE_200 = 1 << 200;
uint256 internal constant _ROLE_201 = 1 << 201;
uint256 internal constant _ROLE_202 = 1 << 202;
uint256 internal constant _ROLE_203 = 1 << 203;
uint256 internal constant _ROLE_204 = 1 << 204;
uint256 internal constant _ROLE_205 = 1 << 205;
uint256 internal constant _ROLE_206 = 1 << 206;
uint256 internal constant _ROLE_207 = 1 << 207;
uint256 internal constant _ROLE_208 = 1 << 208;
uint256 internal constant _ROLE_209 = 1 << 209;
uint256 internal constant _ROLE_210 = 1 << 210;
uint256 internal constant _ROLE_211 = 1 << 211;
uint256 internal constant _ROLE_212 = 1 << 212;
uint256 internal constant _ROLE_213 = 1 << 213;
uint256 internal constant _ROLE_214 = 1 << 214;
uint256 internal constant _ROLE_215 = 1 << 215;
uint256 internal constant _ROLE_216 = 1 << 216;
uint256 internal constant _ROLE_217 = 1 << 217;
uint256 internal constant _ROLE_218 = 1 << 218;
uint256 internal constant _ROLE_219 = 1 << 219;
uint256 internal constant _ROLE_220 = 1 << 220;
uint256 internal constant _ROLE_221 = 1 << 221;
uint256 internal constant _ROLE_222 = 1 << 222;
uint256 internal constant _ROLE_223 = 1 << 223;
uint256 internal constant _ROLE_224 = 1 << 224;
uint256 internal constant _ROLE_225 = 1 << 225;
uint256 internal constant _ROLE_226 = 1 << 226;
uint256 internal constant _ROLE_227 = 1 << 227;
uint256 internal constant _ROLE_228 = 1 << 228;
uint256 internal constant _ROLE_229 = 1 << 229;
uint256 internal constant _ROLE_230 = 1 << 230;
uint256 internal constant _ROLE_231 = 1 << 231;
uint256 internal constant _ROLE_232 = 1 << 232;
uint256 internal constant _ROLE_233 = 1 << 233;
uint256 internal constant _ROLE_234 = 1 << 234;
uint256 internal constant _ROLE_235 = 1 << 235;
uint256 internal constant _ROLE_236 = 1 << 236;
uint256 internal constant _ROLE_237 = 1 << 237;
uint256 internal constant _ROLE_238 = 1 << 238;
uint256 internal constant _ROLE_239 = 1 << 239;
uint256 internal constant _ROLE_240 = 1 << 240;
uint256 internal constant _ROLE_241 = 1 << 241;
uint256 internal constant _ROLE_242 = 1 << 242;
uint256 internal constant _ROLE_243 = 1 << 243;
uint256 internal constant _ROLE_244 = 1 << 244;
uint256 internal constant _ROLE_245 = 1 << 245;
uint256 internal constant _ROLE_246 = 1 << 246;
uint256 internal constant _ROLE_247 = 1 << 247;
uint256 internal constant _ROLE_248 = 1 << 248;
uint256 internal constant _ROLE_249 = 1 << 249;
uint256 internal constant _ROLE_250 = 1 << 250;
uint256 internal constant _ROLE_251 = 1 << 251;
uint256 internal constant _ROLE_252 = 1 << 252;
uint256 internal constant _ROLE_253 = 1 << 253;
uint256 internal constant _ROLE_254 = 1 << 254;
uint256 internal constant _ROLE_255 = 1 << 255;
}
文件 9 的 11:SafeTransferLib.sol
pragma solidity ^0.8.4;
library SafeTransferLib {
error ETHTransferFailed();
error TransferFromFailed();
error TransferFailed();
error ApproveFailed();
uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300;
uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000;
function safeTransferETH(address to, uint256 amount) internal {
assembly {
if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, 0xb12d13eb)
revert(0x1c, 0x04)
}
}
}
function safeTransferAllETH(address to) internal {
assembly {
if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, 0xb12d13eb)
revert(0x1c, 0x04)
}
}
}
function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal {
assembly {
if lt(selfbalance(), amount) {
mstore(0x00, 0xb12d13eb)
revert(0x1c, 0x04)
}
if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, to)
mstore8(0x0b, 0x73)
mstore8(0x20, 0xff)
if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) }
}
}
}
function forceSafeTransferAllETH(address to, uint256 gasStipend) internal {
assembly {
if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, to)
mstore8(0x0b, 0x73)
mstore8(0x20, 0xff)
if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) }
}
}
}
function forceSafeTransferETH(address to, uint256 amount) internal {
assembly {
if lt(selfbalance(), amount) {
mstore(0x00, 0xb12d13eb)
revert(0x1c, 0x04)
}
if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, to)
mstore8(0x0b, 0x73)
mstore8(0x20, 0xff)
if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) }
}
}
}
function forceSafeTransferAllETH(address to) internal {
assembly {
if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {
mstore(0x00, to)
mstore8(0x0b, 0x73)
mstore8(0x20, 0xff)
if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) }
}
}
}
function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend)
internal
returns (bool success)
{
assembly {
success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)
}
}
function trySafeTransferAllETH(address to, uint256 gasStipend)
internal
returns (bool success)
{
assembly {
success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)
}
}
function safeTransferFrom(address token, address from, address to, uint256 amount) internal {
assembly {
let m := mload(0x40)
mstore(0x60, amount)
mstore(0x40, to)
mstore(0x2c, shl(96, from))
mstore(0x0c, 0x23b872dd000000000000000000000000)
if iszero(
and(
or(eq(mload(0x00), 1), iszero(returndatasize())),
call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
)
) {
mstore(0x00, 0x7939f424)
revert(0x1c, 0x04)
}
mstore(0x60, 0)
mstore(0x40, m)
}
}
function safeTransferAllFrom(address token, address from, address to)
internal
returns (uint256 amount)
{
assembly {
let m := mload(0x40)
mstore(0x40, to)
mstore(0x2c, shl(96, from))
mstore(0x0c, 0x70a08231000000000000000000000000)
if iszero(
and(
gt(returndatasize(), 0x1f),
staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20)
)
) {
mstore(0x00, 0x7939f424)
revert(0x1c, 0x04)
}
mstore(0x00, 0x23b872dd)
amount := mload(0x60)
if iszero(
and(
or(eq(mload(0x00), 1), iszero(returndatasize())),
call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
)
) {
mstore(0x00, 0x7939f424)
revert(0x1c, 0x04)
}
mstore(0x60, 0)
mstore(0x40, m)
}
}
function safeTransfer(address token, address to, uint256 amount) internal {
assembly {
mstore(0x14, to)
mstore(0x34, amount)
mstore(0x00, 0xa9059cbb000000000000000000000000)
if iszero(
and(
or(eq(mload(0x00), 1), iszero(returndatasize())),
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x00, 0x90b8ec18)
revert(0x1c, 0x04)
}
mstore(0x34, 0)
}
}
function safeTransferAll(address token, address to) internal returns (uint256 amount) {
assembly {
mstore(0x00, 0x70a08231)
mstore(0x20, address())
if iszero(
and(
gt(returndatasize(), 0x1f),
staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20)
)
) {
mstore(0x00, 0x90b8ec18)
revert(0x1c, 0x04)
}
mstore(0x14, to)
amount := mload(0x34)
mstore(0x00, 0xa9059cbb000000000000000000000000)
if iszero(
and(
or(eq(mload(0x00), 1), iszero(returndatasize())),
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x00, 0x90b8ec18)
revert(0x1c, 0x04)
}
mstore(0x34, 0)
}
}
function safeApprove(address token, address to, uint256 amount) internal {
assembly {
mstore(0x14, to)
mstore(0x34, amount)
mstore(0x00, 0x095ea7b3000000000000000000000000)
if iszero(
and(
or(eq(mload(0x00), 1), iszero(returndatasize())),
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x00, 0x3e3f8f73)
revert(0x1c, 0x04)
}
mstore(0x34, 0)
}
}
function safeApproveWithRetry(address token, address to, uint256 amount) internal {
assembly {
mstore(0x14, to)
mstore(0x34, amount)
mstore(0x00, 0x095ea7b3000000000000000000000000)
if iszero(
and(
or(eq(mload(0x00), 1), iszero(returndatasize())),
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x34, 0)
mstore(0x00, 0x095ea7b3000000000000000000000000)
pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00))
mstore(0x34, amount)
if iszero(
and(
or(eq(mload(0x00), 1), iszero(returndatasize())),
call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)
)
) {
mstore(0x00, 0x3e3f8f73)
revert(0x1c, 0x04)
}
}
mstore(0x34, 0)
}
}
function balanceOf(address token, address account) internal view returns (uint256 amount) {
assembly {
mstore(0x14, account)
mstore(0x00, 0x70a08231000000000000000000000000)
amount :=
mul(
mload(0x20),
and(
gt(returndatasize(), 0x1f),
staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)
)
)
}
}
}
文件 10 的 11:SignedMath.sol
pragma solidity ^0.8.20;
library SignedMath {
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
function average(int256 a, int256 b) internal pure returns (int256) {
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
function abs(int256 n) internal pure returns (uint256) {
unchecked {
return uint256(n >= 0 ? n : -n);
}
}
}
文件 11 的 11:Strings.sol
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
error StringsInsufficientHexLength(uint256 value, uint256 length);
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}
{
"compilationTarget": {
"contracts/DN420.sol": "DN420"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 100
},
"remappings": [],
"viaIR": true
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"DNAlreadyInitialized","type":"error"},{"inputs":[],"name":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"LinkMirrorContractFailed","type":"error"},{"inputs":[],"name":"Locked","type":"error"},{"inputs":[],"name":"MaxBalanceLimitReached","type":"error"},{"inputs":[],"name":"MirrorAddressIsZero","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[],"name":"SenderNotMirror","type":"error"},{"inputs":[],"name":"TokenDoesNotExist","type":"error"},{"inputs":[],"name":"TotalSupplyOverflow","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"roles","type":"uint256"}],"name":"RolesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"SkipNFTSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURILocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"enableTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"excludeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gasBurnFactor","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasBurnFactorLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"a","type":"address"}],"name":"getSkipNFT","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTaxFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalReflections","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"grantRoles","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"hasAllRoles","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"hasAnyRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"includeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"initialTokenSupply","type":"uint256"},{"internalType":"uint256","name":"wad","type":"uint256"},{"internalType":"address","name":"mirror","type":"address"},{"internalType":"address","name":"uniswapV2Router_","type":"address"},{"internalType":"address","name":"gasliteDrop_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"isWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockGasBurnFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockGasWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockMaxBalanceLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lockNameAndSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxBalanceLimit","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBalanceLimitLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mirrorERC721","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nameAndSymbolLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"ownershipHandoverExpiresAt","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"}],"name":"reflect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"},{"internalType":"bool","name":"deductTransferFee","type":"bool"}],"name":"reflectionFromToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceFunctions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"renounceRoles","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"roles","type":"uint256"}],"name":"revokeRoles","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"rolesOf","outputs":[{"internalType":"uint256","name":"roles","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI_","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"gasBurnFactor_","type":"uint32"}],"name":"setGasBurnFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"value","type":"uint32"}],"name":"setMaxBalanceLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"}],"name":"setNameAndSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"skipNFT","type":"bool"}],"name":"setSkipNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"setTaxFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"setWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rAmount","type":"uint256"}],"name":"tokenFromReflection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"result","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"whitelistLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]