From db9961e285acdb36e11c89627582e19470de4e79 Mon Sep 17 00:00:00 2001 From: atkinsonholly Date: Fri, 26 Apr 2024 14:48:36 +0200 Subject: [PATCH] add: amoy deployment --- packages/deploy/deployments/amoy/.chainId | 1 + .../deployments/amoy/TSBNFTMintDN404.json | 1113 +++++++++++++++++ .../deployments/amoy/TSBSimpleDN404.json | 894 +++++++++++++ .../efe1133fb66c7fcb6c05f983751390cd.json | 57 + 4 files changed, 2065 insertions(+) create mode 100644 packages/deploy/deployments/amoy/.chainId create mode 100644 packages/deploy/deployments/amoy/TSBNFTMintDN404.json create mode 100644 packages/deploy/deployments/amoy/TSBSimpleDN404.json create mode 100644 packages/deploy/deployments/amoy/solcInputs/efe1133fb66c7fcb6c05f983751390cd.json diff --git a/packages/deploy/deployments/amoy/.chainId b/packages/deploy/deployments/amoy/.chainId new file mode 100644 index 0000000000..b8ca3095d9 --- /dev/null +++ b/packages/deploy/deployments/amoy/.chainId @@ -0,0 +1 @@ +80002 \ No newline at end of file diff --git a/packages/deploy/deployments/amoy/TSBNFTMintDN404.json b/packages/deploy/deployments/amoy/TSBNFTMintDN404.json new file mode 100644 index 0000000000..79d09ec948 --- /dev/null +++ b/packages/deploy/deployments/amoy/TSBNFTMintDN404.json @@ -0,0 +1,1113 @@ +{ + "address": "0xDe1d2030f1Ba4671D5862e949945d324Dd882031", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "name_", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol_", + "type": "string" + }, + { + "internalType": "bytes32", + "name": "allowlistRoot_", + "type": "bytes32" + }, + { + "internalType": "uint96", + "name": "publicPrice_", + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "allowlistPrice_", + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "initialTokenSupply", + "type": "uint96" + }, + { + "internalType": "address", + "name": "initialSupplyOwner", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AlreadyInitialized", + "type": "error" + }, + { + "inputs": [], + "name": "ApprovalCallerNotOwnerNorApproved", + "type": "error" + }, + { + "inputs": [], + "name": "DNAlreadyInitialized", + "type": "error" + }, + { + "inputs": [], + "name": "DNNotInitialized", + "type": "error" + }, + { + "inputs": [], + "name": "FnSelectorNotRecognized", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientAllowance", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidMint", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidPrice", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidProof", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidUnit", + "type": "error" + }, + { + "inputs": [], + "name": "LinkMirrorContractFailed", + "type": "error" + }, + { + "inputs": [], + "name": "MirrorAddressIsZero", + "type": "error" + }, + { + "inputs": [], + "name": "NewOwnerIsZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "NoHandoverRequest", + "type": "error" + }, + { + "inputs": [], + "name": "NotLive", + "type": "error" + }, + { + "inputs": [], + "name": "SenderNotMirror", + "type": "error" + }, + { + "inputs": [], + "name": "TokenDoesNotExist", + "type": "error" + }, + { + "inputs": [], + "name": "TotalSupplyOverflow", + "type": "error" + }, + { + "inputs": [], + "name": "TotalSupplyReached", + "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": "owner", + "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": "MAX_PER_WALLET", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_SUPPLY", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "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": "uint256", + "name": "nftAmount", + "type": "uint256" + }, + { + "internalType": "bytes32[]", + "name": "proof", + "type": "bytes32[]" + } + ], + "name": "allowlistMint", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "allowlistPrice", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "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": "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": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "getSkipNFT", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "live", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "nftAmount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "payable", + "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": "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": [], + "name": "publicPrice", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "requestOwnershipHandover", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "baseURI_", + "type": "string" + } + ], + "name": "setBaseURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint96", + "name": "publicPrice_", + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "allowlistPrice_", + "type": "uint96" + } + ], + "name": "setPrices", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "skipNFT", + "type": "bool" + } + ], + "name": "setSkipNFT", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "toggleLive", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "totalMinted", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "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": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0x7fef95dc8201448da41ab14ac7129a3dd084a7da4b3fdb692bc24509724c9bbb", + "receipt": { + "to": null, + "from": "0x5F890c9522dCE5670d741D4277BFCC2d9cA8Af02", + "contractAddress": "0xDe1d2030f1Ba4671D5862e949945d324Dd882031", + "transactionIndex": 3, + "gasUsed": "3778469", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000004000002000000008400000000000000000000008000000000000000000000000000000000000000000000000008000000800001000000000000000100000000000008000000020000000000020000000800000000400000000080000010000000400000000000004000000000000000000000000000000000000000000000200000200000000000000000000000000200000000000000000000000000000000004000000002000000000001010000000000000000000020000000108000000020000000000000000000000000000000000000000000000000000000000000100000", + "blockHash": "0x5458e7340d77946f5218c2c19af88b230a35f59fbd28042a0f3129fec53f6556", + "transactionHash": "0x7fef95dc8201448da41ab14ac7129a3dd084a7da4b3fdb692bc24509724c9bbb", + "logs": [ + { + "transactionIndex": 3, + "blockNumber": 6324159, + "transactionHash": "0x7fef95dc8201448da41ab14ac7129a3dd084a7da4b3fdb692bc24509724c9bbb", + "address": "0xDe1d2030f1Ba4671D5862e949945d324Dd882031", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000005f890c9522dce5670d741d4277bfcc2d9ca8af02" + ], + "data": "0x", + "logIndex": 6, + "blockHash": "0x5458e7340d77946f5218c2c19af88b230a35f59fbd28042a0f3129fec53f6556" + }, + { + "transactionIndex": 3, + "blockNumber": 6324159, + "transactionHash": "0x7fef95dc8201448da41ab14ac7129a3dd084a7da4b3fdb692bc24509724c9bbb", + "address": "0xDe1d2030f1Ba4671D5862e949945d324Dd882031", + "topics": [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000049c4d4c94829b9c44052c5f5cb164fc612181165" + ], + "data": "0x0000000000000000000000000000000000000000000000a2a15d09519be00000", + "logIndex": 7, + "blockHash": "0x5458e7340d77946f5218c2c19af88b230a35f59fbd28042a0f3129fec53f6556" + }, + { + "transactionIndex": 3, + "blockNumber": 6324159, + "transactionHash": "0x7fef95dc8201448da41ab14ac7129a3dd084a7da4b3fdb692bc24509724c9bbb", + "address": "0xDe1d2030f1Ba4671D5862e949945d324Dd882031", + "topics": [ + "0xb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d6420393", + "0x00000000000000000000000049c4d4c94829b9c44052c5f5cb164fc612181165" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 8, + "blockHash": "0x5458e7340d77946f5218c2c19af88b230a35f59fbd28042a0f3129fec53f6556" + }, + { + "transactionIndex": 3, + "blockNumber": 6324159, + "transactionHash": "0x7fef95dc8201448da41ab14ac7129a3dd084a7da4b3fdb692bc24509724c9bbb", + "address": "0x0000000000000000000000000000000000001010", + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x0000000000000000000000005f890c9522dce5670d741d4277bfcc2d9ca8af02", + "0x00000000000000000000000004ba3ef4c023c1006019a0f9baf6e70455e41fcf" + ], + "data": "0x0000000000000000000000000000000000000000000000000192b6ed1431dc000000000000000000000000000000000000000000000000036821f65467089524000000000000000000000000000000000000000000000078f6d150a57c10d7c4000000000000000000000000000000000000000000000003668f3f6752d6b924000000000000000000000000000000000000000000000078f86407929042b3c4", + "logIndex": 9, + "blockHash": "0x5458e7340d77946f5218c2c19af88b230a35f59fbd28042a0f3129fec53f6556" + } + ], + "blockNumber": 6324159, + "cumulativeGasUsed": "3841469", + "status": 1, + "byzantium": true + }, + "args": [ + "Benjamin", + "BENJ", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "1000000000000000", + "500000000000000", + "3000000000000000000000", + "0x49c4D4C94829B9c44052C5f5Cb164Fc612181165" + ], + "numDeployments": 1, + "solcInputHash": "efe1133fb66c7fcb6c05f983751390cd", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"},{\"internalType\":\"bytes32\",\"name\":\"allowlistRoot_\",\"type\":\"bytes32\"},{\"internalType\":\"uint96\",\"name\":\"publicPrice_\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"allowlistPrice_\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"initialTokenSupply\",\"type\":\"uint96\"},{\"internalType\":\"address\",\"name\":\"initialSupplyOwner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AlreadyInitialized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ApprovalCallerNotOwnerNorApproved\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DNAlreadyInitialized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DNNotInitialized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FnSelectorNotRecognized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InsufficientAllowance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidMint\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidPrice\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidProof\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidUnit\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"LinkMirrorContractFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MirrorAddressIsZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NewOwnerIsZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NoHandoverRequest\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotLive\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SenderNotMirror\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TokenDoesNotExist\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TotalSupplyOverflow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TotalSupplyReached\",\"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\":\"owner\",\"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\":\"MAX_PER_WALLET\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_SUPPLY\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"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\":\"uint256\",\"name\":\"nftAmount\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"allowlistMint\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"allowlistPrice\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"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\":\"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\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"getSkipNFT\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"live\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"nftAmount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"payable\",\"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\":\"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\":[],\"name\":\"publicPrice\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"requestOwnershipHandover\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"baseURI_\",\"type\":\"string\"}],\"name\":\"setBaseURI\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"publicPrice_\",\"type\":\"uint96\"},{\"internalType\":\"uint96\",\"name\":\"allowlistPrice_\",\"type\":\"uint96\"}],\"name\":\"setPrices\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"skipNFT\",\"type\":\"bool\"}],\"name\":\"setSkipNFT\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"toggleLive\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalMinted\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"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\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"errors\":{\"AlreadyInitialized()\":[{\"details\":\"Cannot double-initialize.\"}],\"ApprovalCallerNotOwnerNorApproved()\":[{\"details\":\"Thrown when setting an NFT token approval and the caller is not the owner or an approved operator.\"}],\"DNAlreadyInitialized()\":[{\"details\":\"Thrown when attempting to double-initialize the contract.\"}],\"DNNotInitialized()\":[{\"details\":\"The function can only be called after the contract has been initialized.\"}],\"FnSelectorNotRecognized()\":[{\"details\":\"The function selector is not recognized.\"}],\"InsufficientAllowance()\":[{\"details\":\"Thrown when a spender attempts to transfer tokens with an insufficient allowance.\"}],\"InsufficientBalance()\":[{\"details\":\"Thrown when attempting to transfer or burn more tokens than sender's balance.\"}],\"InvalidUnit()\":[{\"details\":\"The unit must be greater than zero and less than `2**96`.\"}],\"LinkMirrorContractFailed()\":[{\"details\":\"Thrown when the link call to the mirror contract reverts.\"}],\"MirrorAddressIsZero()\":[{\"details\":\"Thrown when the mirror address provided for initialization is the zero address.\"}],\"NewOwnerIsZeroAddress()\":[{\"details\":\"The `newOwner` cannot be the zero address.\"}],\"NoHandoverRequest()\":[{\"details\":\"The `pendingOwner` does not have a valid handover request.\"}],\"SenderNotMirror()\":[{\"details\":\"Thrown when the caller for a fallback NFT function is not the mirror contract.\"}],\"TokenDoesNotExist()\":[{\"details\":\"Thrown when checking the owner or approved address for a non-existent NFT.\"}],\"TotalSupplyOverflow()\":[{\"details\":\"Thrown when minting an amount of tokens that would overflow the max tokens.\"}],\"TransferCallerNotOwnerNorApproved()\":[{\"details\":\"Thrown when transferring an NFT and the caller is not the owner or an approved operator.\"}],\"TransferFromIncorrectOwner()\":[{\"details\":\"Thrown when transferring an NFT and the from address is not the current owner.\"}],\"TransferToZeroAddress()\":[{\"details\":\"Thrown when attempting to transfer tokens to the zero address.\"}],\"Unauthorized()\":[{\"details\":\"The caller is not authorized to call the function.\"}]},\"events\":{\"Approval(address,address,uint256)\":{\"details\":\"Emitted when `amount` tokens is approved by `owner` to be used by `spender`.\"},\"OwnershipHandoverCanceled(address)\":{\"details\":\"The ownership handover to `pendingOwner` has been canceled.\"},\"OwnershipHandoverRequested(address)\":{\"details\":\"An ownership handover to `pendingOwner` has been requested.\"},\"OwnershipTransferred(address,address)\":{\"details\":\"The ownership is transferred from `oldOwner` to `newOwner`. This event is intentionally kept the same as OpenZeppelin's Ownable to be compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173), despite it not being as lightweight as a single argument event.\"},\"SkipNFTSet(address,bool)\":{\"details\":\"Emitted when `owner` sets their skipNFT flag to `status`.\"},\"Transfer(address,address,uint256)\":{\"details\":\"Emitted when `amount` tokens is transferred from `from` to `to`.\"}},\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"Returns the amount of tokens that `spender` can spend on behalf of `owner`.\"},\"approve(address,uint256)\":{\"details\":\"Sets `amount` as the allowance of `spender` over the caller's tokens. Emits a {Approval} event.\"},\"balanceOf(address)\":{\"details\":\"Returns the amount of tokens owned by `owner`.\"},\"cancelOwnershipHandover()\":{\"details\":\"Cancels the two-step ownership handover to the caller, if any.\"},\"completeOwnershipHandover(address)\":{\"details\":\"Allows the owner to complete the two-step ownership handover to `pendingOwner`. Reverts if there is no existing ownership handover requested by `pendingOwner`.\"},\"decimals()\":{\"details\":\"Returns the decimals places of the token. Defaults to 18. Does not affect DN404's internal calculations. Will only affect the frontend UI on most protocols.\"},\"getSkipNFT(address)\":{\"details\":\"Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs. Returns false otherwise.\"},\"mirrorERC721()\":{\"details\":\"Returns the address of the mirror NFT contract.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"owner()\":{\"details\":\"Returns the owner of the contract.\"},\"ownershipHandoverExpiresAt(address)\":{\"details\":\"Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.\"},\"renounceOwnership()\":{\"details\":\"Allows the owner to renounce their ownership.\"},\"requestOwnershipHandover()\":{\"details\":\"Request a two-step ownership handover to the caller. The request will automatically expire in 48 hours (172800 seconds) by default.\"},\"setSkipNFT(bool)\":{\"details\":\"Sets the caller's skipNFT flag to `skipNFT`. Returns true. Emits a {SkipNFTSet} event.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token.\"},\"totalSupply()\":{\"details\":\"Returns the amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"details\":\"Transfer `amount` tokens from the caller to `to`. Will burn sender NFTs if balance after transfer is less than the amount required to support the current NFT balance. Will mint NFTs to `to` if the recipient's new balance supports additional NFTs ***AND*** the `to` address's skipNFT flag is set to false. Requirements: - `from` must at least have `amount`. Emits a {Transfer} event.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"Transfers `amount` tokens from `from` to `to`. Note: Does not update the allowance if it is the maximum uint256 value. Will burn sender NFTs if balance after transfer is less than the amount required to support the current NFT balance. Will mint NFTs to `to` if the recipient's new balance supports additional NFTs ***AND*** the `to` address's skipNFT flag is set to false. Requirements: - `from` must at least have `amount`. - The caller must have at least `amount` of allowance to transfer the tokens of `from`. Emits a {Transfer} event.\"},\"transferOwnership(address)\":{\"details\":\"Allows the owner to transfer the ownership to `newOwner`.\"}},\"title\":\"NFTMintDN404\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"Sample DN404 contract that demonstrates the owner selling NFTs rather than the fungible token. The underlying call still mints ERC20 tokens, but to the end user it'll appear as a standard NFT mint. Each address is limited to MAX_PER_WALLET total mints.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol\":\"NFTMintDN404\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":2000},\"remappings\":[]},\"sources\":{\"@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity 0.8.25;\\n\\nimport {DN404} from \\\"dn404/src/DN404.sol\\\";\\nimport {DN404Mirror} from \\\"dn404/src/DN404Mirror.sol\\\";\\nimport {Ownable} from \\\"solady/src/auth/Ownable.sol\\\";\\nimport {LibString} from \\\"solady/src/utils/LibString.sol\\\";\\nimport {SafeTransferLib} from \\\"solady/src/utils/SafeTransferLib.sol\\\";\\nimport {MerkleProofLib} from \\\"solady/src/utils/MerkleProofLib.sol\\\";\\n\\n/**\\n * @title NFTMintDN404\\n * @notice Sample DN404 contract that demonstrates the owner selling NFTs rather than the fungible token.\\n * The underlying call still mints ERC20 tokens, but to the end user it'll appear as a standard NFT mint.\\n * Each address is limited to MAX_PER_WALLET total mints.\\n */\\ncontract NFTMintDN404 is DN404, Ownable {\\n string private _name;\\n string private _symbol;\\n string private _baseURI;\\n bytes32 private _allowlistRoot;\\n uint96 public publicPrice; // uint96 is sufficient to represent all ETH in existence.\\n uint96 public allowlistPrice; // uint96 is sufficient to represent all ETH in existence.\\n uint32 public totalMinted; // DN404 only supports up to `2**32 - 2` tokens.\\n bool public live;\\n\\n uint32 public constant MAX_PER_WALLET = 5;\\n uint32 public constant MAX_SUPPLY = 5000;\\n\\n error InvalidProof();\\n error InvalidMint();\\n error InvalidPrice();\\n error TotalSupplyReached();\\n error NotLive();\\n\\n constructor(\\n string memory name_,\\n string memory symbol_,\\n bytes32 allowlistRoot_,\\n uint96 publicPrice_,\\n uint96 allowlistPrice_,\\n uint96 initialTokenSupply,\\n address initialSupplyOwner\\n ) {\\n _initializeOwner(msg.sender);\\n\\n _name = name_;\\n _symbol = symbol_;\\n _allowlistRoot = allowlistRoot_;\\n publicPrice = publicPrice_;\\n allowlistPrice = allowlistPrice_;\\n\\n address mirror = address(new DN404Mirror(msg.sender));\\n _initializeDN404(initialTokenSupply, initialSupplyOwner, mirror);\\n }\\n\\n modifier onlyLive() {\\n if (!live) {\\n revert NotLive();\\n }\\n _;\\n }\\n\\n modifier checkPrice(uint256 price, uint256 nftAmount) {\\n if (price * nftAmount != msg.value) {\\n revert InvalidPrice();\\n }\\n _;\\n }\\n\\n modifier checkAndUpdateTotalMinted(uint256 nftAmount) {\\n uint256 newTotalMinted = uint256(totalMinted) + nftAmount;\\n if (newTotalMinted > MAX_SUPPLY) {\\n revert TotalSupplyReached();\\n }\\n totalMinted = uint32(newTotalMinted);\\n _;\\n }\\n\\n modifier checkAndUpdateBuyerMintCount(uint256 nftAmount) {\\n uint256 currentMintCount = _getAux(msg.sender);\\n uint256 newMintCount = currentMintCount + nftAmount;\\n if (newMintCount > MAX_PER_WALLET) {\\n revert InvalidMint();\\n }\\n _setAux(msg.sender, uint88(newMintCount));\\n _;\\n }\\n\\n function mint(\\n uint256 nftAmount\\n )\\n public\\n payable\\n onlyLive\\n checkPrice(publicPrice, nftAmount)\\n checkAndUpdateBuyerMintCount(nftAmount)\\n checkAndUpdateTotalMinted(nftAmount)\\n {\\n _mint(msg.sender, nftAmount * _unit());\\n }\\n\\n function allowlistMint(\\n uint256 nftAmount,\\n bytes32[] calldata proof\\n )\\n public\\n payable\\n onlyLive\\n checkPrice(allowlistPrice, nftAmount)\\n checkAndUpdateBuyerMintCount(nftAmount)\\n checkAndUpdateTotalMinted(nftAmount)\\n {\\n bytes32 leaf = keccak256(abi.encodePacked(msg.sender));\\n if (!MerkleProofLib.verifyCalldata(proof, _allowlistRoot, leaf)) {\\n revert InvalidProof();\\n }\\n _mint(msg.sender, nftAmount * _unit());\\n }\\n\\n function setBaseURI(string calldata baseURI_) public onlyOwner {\\n _baseURI = baseURI_;\\n }\\n\\n function setPrices(uint96 publicPrice_, uint96 allowlistPrice_) public onlyOwner {\\n publicPrice = publicPrice_;\\n allowlistPrice = allowlistPrice_;\\n }\\n\\n function toggleLive() public onlyOwner {\\n live = !live;\\n }\\n\\n function withdraw() public onlyOwner {\\n SafeTransferLib.safeTransferAllETH(msg.sender);\\n }\\n\\n function name() public view override returns (string memory) {\\n return _name;\\n }\\n\\n function symbol() public view override returns (string memory) {\\n return _symbol;\\n }\\n\\n function _tokenURI(uint256 tokenId) internal view override returns (string memory result) {\\n if (bytes(_baseURI).length != 0) {\\n result = string(abi.encodePacked(_baseURI, LibString.toString(tokenId)));\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7e2c0c3ef4710895a1cdf193ad89eec62b7bada8aa3bc3cbb4a4b17df2c0903a\",\"license\":\"MIT\"},\"dn404/src/DN404.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @title DN404\\n/// @notice DN404 is a hybrid ERC20 and ERC721 implementation that mints\\n/// and burns NFTs based on an account's ERC20 token balance.\\n///\\n/// @author vectorized.eth (@optimizoor)\\n/// @author Quit (@0xQuit)\\n/// @author Michael Amadi (@AmadiMichaels)\\n/// @author cygaar (@0xCygaar)\\n/// @author Thomas (@0xjustadev)\\n/// @author Harrison (@PopPunkOnChain)\\n///\\n/// @dev Note:\\n/// - The ERC721 data is stored in this base DN404 contract, however a\\n/// DN404Mirror contract ***MUST*** be deployed and linked during\\n/// initialization.\\nabstract contract DN404 {\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* EVENTS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Emitted when `amount` tokens is transferred from `from` to `to`.\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /// @dev Emitted when `amount` tokens is approved by `owner` to be used by `spender`.\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /// @dev Emitted when `owner` sets their skipNFT flag to `status`.\\n event SkipNFTSet(address indexed owner, bool status);\\n\\n /// @dev `keccak256(bytes(\\\"Transfer(address,address,uint256)\\\"))`.\\n uint256 private constant _TRANSFER_EVENT_SIGNATURE =\\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\\n\\n /// @dev `keccak256(bytes(\\\"Approval(address,address,uint256)\\\"))`.\\n uint256 private constant _APPROVAL_EVENT_SIGNATURE =\\n 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;\\n\\n /// @dev `keccak256(bytes(\\\"SkipNFTSet(address,bool)\\\"))`.\\n uint256 private constant _SKIP_NFT_SET_EVENT_SIGNATURE =\\n 0xb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d6420393;\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CUSTOM ERRORS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Thrown when attempting to double-initialize the contract.\\n error DNAlreadyInitialized();\\n\\n /// @dev The function can only be called after the contract has been initialized.\\n error DNNotInitialized();\\n\\n /// @dev Thrown when attempting to transfer or burn more tokens than sender's balance.\\n error InsufficientBalance();\\n\\n /// @dev Thrown when a spender attempts to transfer tokens with an insufficient allowance.\\n error InsufficientAllowance();\\n\\n /// @dev Thrown when minting an amount of tokens that would overflow the max tokens.\\n error TotalSupplyOverflow();\\n\\n /// @dev The unit must be greater than zero and less than `2**96`.\\n error InvalidUnit();\\n\\n /// @dev Thrown when the caller for a fallback NFT function is not the mirror contract.\\n error SenderNotMirror();\\n\\n /// @dev Thrown when attempting to transfer tokens to the zero address.\\n error TransferToZeroAddress();\\n\\n /// @dev Thrown when the mirror address provided for initialization is the zero address.\\n error MirrorAddressIsZero();\\n\\n /// @dev Thrown when the link call to the mirror contract reverts.\\n error LinkMirrorContractFailed();\\n\\n /// @dev Thrown when setting an NFT token approval\\n /// and the caller is not the owner or an approved operator.\\n error ApprovalCallerNotOwnerNorApproved();\\n\\n /// @dev Thrown when transferring an NFT\\n /// and the caller is not the owner or an approved operator.\\n error TransferCallerNotOwnerNorApproved();\\n\\n /// @dev Thrown when transferring an NFT and the from address is not the current owner.\\n error TransferFromIncorrectOwner();\\n\\n /// @dev Thrown when checking the owner or approved address for a non-existent NFT.\\n error TokenDoesNotExist();\\n\\n /// @dev The function selector is not recognized.\\n error FnSelectorNotRecognized();\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CONSTANTS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev The flag to denote that the address data is initialized.\\n uint8 internal constant _ADDRESS_DATA_INITIALIZED_FLAG = 1 << 0;\\n\\n /// @dev The flag to denote that the address should skip NFTs.\\n uint8 internal constant _ADDRESS_DATA_SKIP_NFT_FLAG = 1 << 1;\\n\\n /// @dev The flag to denote that the address has overridden the default Permit2 allowance.\\n uint8 internal constant _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG = 1 << 2;\\n\\n /// @dev The canonical Permit2 address.\\n /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.\\n /// To enable, override `_givePermit2DefaultInfiniteAllowance()`.\\n /// [Github](https://github.com/Uniswap/permit2)\\n /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)\\n address internal constant _PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* STORAGE */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Struct containing an address's token data and settings.\\n struct AddressData {\\n // Auxiliary data.\\n uint88 aux;\\n // Flags for `initialized` and `skipNFT`.\\n uint8 flags;\\n // The alias for the address. Zero means absence of an alias.\\n uint32 addressAlias;\\n // The number of NFT tokens.\\n uint32 ownedLength;\\n // The token balance in wei.\\n uint96 balance;\\n }\\n\\n /// @dev A uint32 map in storage.\\n struct Uint32Map {\\n uint256 spacer;\\n }\\n\\n /// @dev A bitmap in storage.\\n struct Bitmap {\\n uint256 spacer;\\n }\\n\\n /// @dev A struct to wrap a uint256 in storage.\\n struct Uint256Ref {\\n uint256 value;\\n }\\n\\n /// @dev A mapping of an address pair to a Uint256Ref.\\n struct AddressPairToUint256RefMap {\\n uint256 spacer;\\n }\\n\\n /// @dev Struct containing the base token contract storage.\\n struct DN404Storage {\\n // Current number of address aliases assigned.\\n uint32 numAliases;\\n // Next NFT ID to assign for a mint.\\n uint32 nextTokenId;\\n // The head of the burned pool.\\n uint32 burnedPoolHead;\\n // The tail of the burned pool.\\n uint32 burnedPoolTail;\\n // Total number of NFTs in existence.\\n uint32 totalNFTSupply;\\n // Total supply of tokens.\\n uint96 totalSupply;\\n // Address of the NFT mirror contract.\\n address mirrorERC721;\\n // Mapping of a user alias number to their address.\\n mapping(uint32 => address) aliasToAddress;\\n // Mapping of user operator approvals for NFTs.\\n AddressPairToUint256RefMap operatorApprovals;\\n // Mapping of NFT approvals to approved operators.\\n mapping(uint256 => address) nftApprovals;\\n // Bitmap of whether an non-zero NFT approval may exist.\\n Bitmap mayHaveNFTApproval;\\n // Bitmap of whether a NFT ID exists. Ignored if `_useExistsLookup()` returns false.\\n Bitmap exists;\\n // Mapping of user allowances for ERC20 spenders.\\n AddressPairToUint256RefMap allowance;\\n // Mapping of NFT IDs owned by an address.\\n mapping(address => Uint32Map) owned;\\n // The pool of burned NFT IDs.\\n Uint32Map burnedPool;\\n // Even indices: owner aliases. Odd indices: owned indices.\\n Uint32Map oo;\\n // Mapping of user account AddressData.\\n mapping(address => AddressData) addressData;\\n }\\n\\n /// @dev Returns a storage pointer for DN404Storage.\\n function _getDN404Storage() internal pure virtual returns (DN404Storage storage $) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // `uint72(bytes9(keccak256(\\\"DN404_STORAGE\\\")))`.\\n $.slot := 0xa20d6e21d0e5255308 // Truncate to 9 bytes to reduce bytecode size.\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INITIALIZER */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Initializes the DN404 contract with an\\n /// `initialTokenSupply`, `initialTokenOwner` and `mirror` NFT contract address.\\n function _initializeDN404(\\n uint256 initialTokenSupply,\\n address initialSupplyOwner,\\n address mirror\\n ) internal virtual {\\n DN404Storage storage $ = _getDN404Storage();\\n\\n unchecked {\\n if (_unit() - 1 >= 2 ** 96 - 1) revert InvalidUnit();\\n }\\n if ($.mirrorERC721 != address(0)) revert DNAlreadyInitialized();\\n if (mirror == address(0)) revert MirrorAddressIsZero();\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Make the call to link the mirror contract.\\n mstore(0x00, 0x0f4599e5) // `linkMirrorContract(address)`.\\n mstore(0x20, caller())\\n if iszero(and(eq(mload(0x00), 1), call(gas(), mirror, 0, 0x1c, 0x24, 0x00, 0x20))) {\\n mstore(0x00, 0xd125259c) // `LinkMirrorContractFailed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n\\n $.nextTokenId = 1;\\n $.mirrorERC721 = mirror;\\n\\n if (initialTokenSupply != 0) {\\n if (initialSupplyOwner == address(0)) revert TransferToZeroAddress();\\n if (_totalSupplyOverflows(initialTokenSupply)) revert TotalSupplyOverflow();\\n\\n $.totalSupply = uint96(initialTokenSupply);\\n AddressData storage initialOwnerAddressData = _addressData(initialSupplyOwner);\\n initialOwnerAddressData.balance = uint96(initialTokenSupply);\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, initialTokenSupply)\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, initialSupplyOwner)))\\n }\\n\\n _setSkipNFT(initialSupplyOwner, true);\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* BASE UNIT FUNCTION TO OVERRIDE */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Amount of token balance that is equal to one NFT.\\n function _unit() internal view virtual returns (uint256) {\\n return 10 ** 18;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* METADATA FUNCTIONS TO OVERRIDE */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the name of the token.\\n function name() public view virtual returns (string memory);\\n\\n /// @dev Returns the symbol of the token.\\n function symbol() public view virtual returns (string memory);\\n\\n /// @dev Returns the Uniform Resource Identifier (URI) for token `id`.\\n function _tokenURI(uint256 id) internal view virtual returns (string memory);\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CONFIGURABLES */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns if direct NFT transfers should be used during ERC20 transfers\\n /// whenever possible, instead of burning and re-minting.\\n function _useDirectTransfersIfPossible() internal view virtual returns (bool) {\\n return true;\\n }\\n\\n /// @dev Returns if burns should be added to the burn pool.\\n /// This returns false by default, which means the NFT IDs are re-minted in a cycle.\\n function _addToBurnedPool(uint256 totalNFTSupplyAfterBurn, uint256 totalSupplyAfterBurn)\\n internal\\n view\\n virtual\\n returns (bool)\\n {\\n // Silence unused variable compiler warning.\\n totalSupplyAfterBurn = totalNFTSupplyAfterBurn;\\n return false;\\n }\\n\\n /// @dev Returns whether to use the exists bitmap for more efficient\\n /// scanning of an empty token ID slot.\\n /// Recommended for collections that do not use the burn pool,\\n /// and are expected to have nearly all possible NFTs materialized.\\n ///\\n /// Note: The returned value must be constant after initialization.\\n function _useExistsLookup() internal view virtual returns (bool) {\\n return true;\\n }\\n\\n /// @dev Hook that is called after any NFT token transfers, including minting and burning.\\n function _afterNFTTransfer(address from, address to, uint256 id) internal virtual {}\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* ERC20 OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the decimals places of the token. Defaults to 18.\\n /// Does not affect DN404's internal calculations.\\n /// Will only affect the frontend UI on most protocols.\\n function decimals() public view virtual returns (uint8) {\\n return 18;\\n }\\n\\n /// @dev Returns the amount of tokens in existence.\\n function totalSupply() public view virtual returns (uint256) {\\n return uint256(_getDN404Storage().totalSupply);\\n }\\n\\n /// @dev Returns the amount of tokens owned by `owner`.\\n function balanceOf(address owner) public view virtual returns (uint256) {\\n return _getDN404Storage().addressData[owner].balance;\\n }\\n\\n /// @dev Returns the amount of tokens that `spender` can spend on behalf of `owner`.\\n function allowance(address owner, address spender) public view returns (uint256) {\\n if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {\\n uint8 flags = _getDN404Storage().addressData[owner].flags;\\n if (_isZero(flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG)) return type(uint256).max;\\n }\\n return _ref(_getDN404Storage().allowance, owner, spender).value;\\n }\\n\\n /// @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n ///\\n /// Emits a {Approval} event.\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @dev Transfer `amount` tokens from the caller to `to`.\\n ///\\n /// Will burn sender NFTs if balance after transfer is less than\\n /// the amount required to support the current NFT balance.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is\\n /// set to false.\\n ///\\n /// Requirements:\\n /// - `from` must at least have `amount`.\\n ///\\n /// Emits a {Transfer} event.\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n _transfer(msg.sender, to, amount);\\n return true;\\n }\\n\\n /// @dev Transfers `amount` tokens from `from` to `to`.\\n ///\\n /// Note: Does not update the allowance if it is the maximum uint256 value.\\n ///\\n /// Will burn sender NFTs if balance after transfer is less than\\n /// the amount required to support the current NFT balance.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is\\n /// set to false.\\n ///\\n /// Requirements:\\n /// - `from` must at least have `amount`.\\n /// - The caller must have at least `amount` of allowance to transfer the tokens of `from`.\\n ///\\n /// Emits a {Transfer} event.\\n function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) {\\n Uint256Ref storage a = _ref(_getDN404Storage().allowance, from, msg.sender);\\n\\n uint256 allowed = _givePermit2DefaultInfiniteAllowance() && msg.sender == _PERMIT2\\n && _isZero(_getDN404Storage().addressData[from].flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG)\\n ? type(uint256).max\\n : a.value;\\n\\n if (allowed != type(uint256).max) {\\n if (amount > allowed) revert InsufficientAllowance();\\n unchecked {\\n a.value = allowed - amount;\\n }\\n }\\n _transfer(from, to, amount);\\n return true;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* PERMIT2 */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Whether Permit2 has infinite allowances by default for all owners.\\n /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.\\n /// To enable, override this function to return true.\\n function _givePermit2DefaultInfiniteAllowance() internal view virtual returns (bool) {\\n return false;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL MINT FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Mints `amount` tokens to `to`, increasing the total supply.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.\\n ///\\n /// Emits a {Transfer} event.\\n function _mint(address to, uint256 amount) internal virtual {\\n if (to == address(0)) revert TransferToZeroAddress();\\n\\n AddressData storage toAddressData = _addressData(to);\\n DN404Storage storage $ = _getDN404Storage();\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n _DNMintTemps memory t;\\n unchecked {\\n uint256 toBalance = uint256(toAddressData.balance) + amount;\\n toAddressData.balance = uint96(toBalance);\\n t.toEnd = toBalance / _unit();\\n }\\n uint256 maxId;\\n unchecked {\\n uint256 totalSupply_ = uint256($.totalSupply) + amount;\\n $.totalSupply = uint96(totalSupply_);\\n uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));\\n if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();\\n maxId = totalSupply_ / _unit();\\n }\\n unchecked {\\n if (_isZero(toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG)) {\\n Uint32Map storage toOwned = $.owned[to];\\n Uint32Map storage oo = $.oo;\\n uint256 toIndex = toAddressData.ownedLength;\\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));\\n\\n if (packedLogs.logs.length != 0) {\\n _packedLogsSet(packedLogs, to, 0);\\n $.totalNFTSupply += uint32(packedLogs.logs.length);\\n toAddressData.ownedLength = uint32(t.toEnd);\\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\\n uint32 burnedPoolHead = $.burnedPoolHead;\\n t.burnedPoolTail = $.burnedPoolTail;\\n t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);\\n // Mint loop.\\n do {\\n uint256 id;\\n if (burnedPoolHead != t.burnedPoolTail) {\\n id = _get($.burnedPool, burnedPoolHead++);\\n } else {\\n id = t.nextTokenId;\\n while (_get(oo, _ownershipIndex(id)) != 0) {\\n id = _useExistsLookup()\\n ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId), maxId)\\n : _wrapNFTId(id + 1, maxId);\\n }\\n t.nextTokenId = _wrapNFTId(id + 1, maxId);\\n }\\n if (_useExistsLookup()) _set($.exists, id, true);\\n _set(toOwned, toIndex, uint32(id));\\n _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));\\n _packedLogsAppend(packedLogs, id);\\n _afterNFTTransfer(address(0), to, id);\\n } while (toIndex != t.toEnd);\\n\\n $.nextTokenId = uint32(t.nextTokenId);\\n $.burnedPoolHead = burnedPoolHead;\\n _packedLogsSend(packedLogs, $.mirrorERC721);\\n }\\n }\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, amount)\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))\\n }\\n }\\n\\n /// @dev Mints `amount` tokens to `to`, increasing the total supply.\\n /// This variant mints NFT tokens starting from ID `preTotalSupply / _unit() + 1`.\\n /// This variant will not touch the `burnedPool` and `nextTokenId`.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.\\n ///\\n /// Emits a {Transfer} event.\\n function _mintNext(address to, uint256 amount) internal virtual {\\n if (to == address(0)) revert TransferToZeroAddress();\\n\\n AddressData storage toAddressData = _addressData(to);\\n DN404Storage storage $ = _getDN404Storage();\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n _DNMintTemps memory t;\\n unchecked {\\n uint256 toBalance = uint256(toAddressData.balance) + amount;\\n toAddressData.balance = uint96(toBalance);\\n t.toEnd = toBalance / _unit();\\n }\\n uint256 startId;\\n uint256 maxId;\\n unchecked {\\n uint256 preTotalSupply = uint256($.totalSupply);\\n startId = preTotalSupply / _unit() + 1;\\n uint256 totalSupply_ = uint256(preTotalSupply) + amount;\\n $.totalSupply = uint96(totalSupply_);\\n uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));\\n if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();\\n maxId = totalSupply_ / _unit();\\n }\\n unchecked {\\n if (_isZero(toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG)) {\\n Uint32Map storage toOwned = $.owned[to];\\n Uint32Map storage oo = $.oo;\\n uint256 toIndex = toAddressData.ownedLength;\\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));\\n\\n if (packedLogs.logs.length != 0) {\\n _packedLogsSet(packedLogs, to, 0);\\n $.totalNFTSupply += uint32(packedLogs.logs.length);\\n toAddressData.ownedLength = uint32(t.toEnd);\\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\\n // Mint loop.\\n do {\\n uint256 id = startId;\\n while (_get(oo, _ownershipIndex(id)) != 0) {\\n id = _useExistsLookup()\\n ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId), maxId)\\n : _wrapNFTId(id + 1, maxId);\\n }\\n startId = _wrapNFTId(id + 1, maxId);\\n if (_useExistsLookup()) _set($.exists, id, true);\\n _set(toOwned, toIndex, uint32(id));\\n _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));\\n _packedLogsAppend(packedLogs, id);\\n _afterNFTTransfer(address(0), to, id);\\n } while (toIndex != t.toEnd);\\n\\n _packedLogsSend(packedLogs, $.mirrorERC721);\\n }\\n }\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, amount)\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL BURN FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Burns `amount` tokens from `from`, reducing the total supply.\\n ///\\n /// Will burn sender NFTs if balance after transfer is less than\\n /// the amount required to support the current NFT balance.\\n ///\\n /// Emits a {Transfer} event.\\n function _burn(address from, uint256 amount) internal virtual {\\n DN404Storage storage $ = _getDN404Storage();\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n AddressData storage fromAddressData = $.addressData[from];\\n uint256 fromBalance = fromAddressData.balance;\\n if (amount > fromBalance) revert InsufficientBalance();\\n\\n unchecked {\\n fromAddressData.balance = uint96(fromBalance -= amount);\\n uint256 totalSupply_ = uint256($.totalSupply) - amount;\\n $.totalSupply = uint96(totalSupply_);\\n\\n Uint32Map storage fromOwned = $.owned[from];\\n uint256 fromIndex = fromAddressData.ownedLength;\\n uint256 numNFTBurns = _zeroFloorSub(fromIndex, fromBalance / _unit());\\n\\n if (numNFTBurns != 0) {\\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(numNFTBurns);\\n _packedLogsSet(packedLogs, from, 1);\\n bool addToBurnedPool;\\n {\\n uint256 totalNFTSupply = uint256($.totalNFTSupply) - numNFTBurns;\\n $.totalNFTSupply = uint32(totalNFTSupply);\\n addToBurnedPool = _addToBurnedPool(totalNFTSupply, totalSupply_);\\n }\\n\\n Uint32Map storage oo = $.oo;\\n uint256 fromEnd = fromIndex - numNFTBurns;\\n fromAddressData.ownedLength = uint32(fromEnd);\\n uint32 burnedPoolTail = $.burnedPoolTail;\\n // Burn loop.\\n do {\\n uint256 id = _get(fromOwned, --fromIndex);\\n _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);\\n _packedLogsAppend(packedLogs, id);\\n if (_useExistsLookup()) _set($.exists, id, false);\\n if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));\\n if (_get($.mayHaveNFTApproval, id)) {\\n _set($.mayHaveNFTApproval, id, false);\\n delete $.nftApprovals[id];\\n }\\n _afterNFTTransfer(from, address(0), id);\\n } while (fromIndex != fromEnd);\\n\\n if (addToBurnedPool) $.burnedPoolTail = burnedPoolTail;\\n _packedLogsSend(packedLogs, $.mirrorERC721);\\n }\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, amount)\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), 0)\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL TRANSFER FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Moves `amount` of tokens from `from` to `to`.\\n ///\\n /// Will burn sender NFTs if balance after transfer is less than\\n /// the amount required to support the current NFT balance.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is\\n /// set to false.\\n ///\\n /// Emits a {Transfer} event.\\n function _transfer(address from, address to, uint256 amount) internal virtual {\\n if (to == address(0)) revert TransferToZeroAddress();\\n\\n DN404Storage storage $ = _getDN404Storage();\\n AddressData storage fromAddressData = $.addressData[from];\\n AddressData storage toAddressData = _addressData(to);\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n _DNTransferTemps memory t;\\n t.fromOwnedLength = fromAddressData.ownedLength;\\n t.toOwnedLength = toAddressData.ownedLength;\\n\\n unchecked {\\n {\\n uint256 fromBalance = fromAddressData.balance;\\n if (amount > fromBalance) revert InsufficientBalance();\\n fromAddressData.balance = uint96(fromBalance -= amount);\\n\\n uint256 toBalance = uint256(toAddressData.balance) + amount;\\n toAddressData.balance = uint96(toBalance);\\n t.numNFTBurns = _zeroFloorSub(t.fromOwnedLength, fromBalance / _unit());\\n\\n if (_isZero(toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG)) {\\n if (from == to) t.toOwnedLength = t.fromOwnedLength - t.numNFTBurns;\\n t.numNFTMints = _zeroFloorSub(toBalance / _unit(), t.toOwnedLength);\\n }\\n }\\n\\n while (_useDirectTransfersIfPossible()) {\\n uint256 n = _min(t.fromOwnedLength, _min(t.numNFTBurns, t.numNFTMints));\\n if (_isZero(n)) break;\\n t.numNFTBurns -= n;\\n t.numNFTMints -= n;\\n if (from == to) {\\n t.toOwnedLength += n;\\n break;\\n }\\n _DNDirectLogs memory directLogs = _directLogsMalloc(n, from, to);\\n Uint32Map storage fromOwned = $.owned[from];\\n Uint32Map storage toOwned = $.owned[to];\\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\\n uint256 toIndex = t.toOwnedLength;\\n n = toIndex + n;\\n // Direct transfer loop.\\n do {\\n uint256 id = _get(fromOwned, --t.fromOwnedLength);\\n _set(toOwned, toIndex, uint32(id));\\n _setOwnerAliasAndOwnedIndex($.oo, id, t.toAlias, uint32(toIndex));\\n _directLogsAppend(directLogs, id);\\n if (_get($.mayHaveNFTApproval, id)) {\\n _set($.mayHaveNFTApproval, id, false);\\n delete $.nftApprovals[id];\\n }\\n _afterNFTTransfer(from, to, id);\\n } while (++toIndex != n);\\n\\n toAddressData.ownedLength = uint32(t.toOwnedLength = toIndex);\\n fromAddressData.ownedLength = uint32(t.fromOwnedLength);\\n _directLogsSend(directLogs, $.mirrorERC721);\\n break;\\n }\\n\\n t.totalNFTSupply = uint256($.totalNFTSupply) + t.numNFTMints - t.numNFTBurns;\\n $.totalNFTSupply = uint32(t.totalNFTSupply);\\n\\n Uint32Map storage oo = $.oo;\\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(t.numNFTBurns + t.numNFTMints);\\n\\n t.burnedPoolTail = $.burnedPoolTail;\\n if (t.numNFTBurns != 0) {\\n _packedLogsSet(packedLogs, from, 1);\\n bool addToBurnedPool = _addToBurnedPool(t.totalNFTSupply, $.totalSupply);\\n Uint32Map storage fromOwned = $.owned[from];\\n uint256 fromIndex = t.fromOwnedLength;\\n fromAddressData.ownedLength = uint32(t.fromEnd = fromIndex - t.numNFTBurns);\\n uint32 burnedPoolTail = t.burnedPoolTail;\\n // Burn loop.\\n do {\\n uint256 id = _get(fromOwned, --fromIndex);\\n _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);\\n _packedLogsAppend(packedLogs, id);\\n if (_useExistsLookup()) _set($.exists, id, false);\\n if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));\\n if (_get($.mayHaveNFTApproval, id)) {\\n _set($.mayHaveNFTApproval, id, false);\\n delete $.nftApprovals[id];\\n }\\n _afterNFTTransfer(from, address(0), id);\\n } while (fromIndex != t.fromEnd);\\n\\n if (addToBurnedPool) $.burnedPoolTail = (t.burnedPoolTail = burnedPoolTail);\\n }\\n\\n if (t.numNFTMints != 0) {\\n _packedLogsSet(packedLogs, to, 0);\\n Uint32Map storage toOwned = $.owned[to];\\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\\n uint256 maxId = $.totalSupply / _unit();\\n t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);\\n uint256 toIndex = t.toOwnedLength;\\n toAddressData.ownedLength = uint32(t.toEnd = toIndex + t.numNFTMints);\\n uint32 burnedPoolHead = $.burnedPoolHead;\\n // Mint loop.\\n do {\\n uint256 id;\\n if (burnedPoolHead != t.burnedPoolTail) {\\n id = _get($.burnedPool, burnedPoolHead++);\\n } else {\\n id = t.nextTokenId;\\n while (_get(oo, _ownershipIndex(id)) != 0) {\\n id = _useExistsLookup()\\n ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId), maxId)\\n : _wrapNFTId(id + 1, maxId);\\n }\\n t.nextTokenId = _wrapNFTId(id + 1, maxId);\\n }\\n if (_useExistsLookup()) _set($.exists, id, true);\\n _set(toOwned, toIndex, uint32(id));\\n _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));\\n _packedLogsAppend(packedLogs, id);\\n _afterNFTTransfer(address(0), to, id);\\n } while (toIndex != t.toEnd);\\n\\n $.burnedPoolHead = burnedPoolHead;\\n $.nextTokenId = uint32(t.nextTokenId);\\n }\\n\\n if (packedLogs.logs.length != 0) _packedLogsSend(packedLogs, $.mirrorERC721);\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, amount)\\n // forgefmt: disable-next-item\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))\\n }\\n }\\n\\n /// @dev Transfers token `id` from `from` to `to`.\\n /// Also emits an ERC721 {Transfer} event on the `mirrorERC721`.\\n ///\\n /// Requirements:\\n ///\\n /// - Call must originate from the mirror contract.\\n /// - Token `id` must exist.\\n /// - `from` must be the owner of the token.\\n /// - `to` cannot be the zero address.\\n /// `msgSender` must be the owner of the token, or be approved to manage the token.\\n ///\\n /// Emits a {Transfer} event.\\n function _initiateTransferFromNFT(address from, address to, uint256 id, address msgSender)\\n internal\\n virtual\\n {\\n _transferFromNFT(from, to, id, msgSender);\\n // Emit ERC721 {Transfer} event.\\n _DNDirectLogs memory directLogs = _directLogsMalloc(1, from, to);\\n _directLogsAppend(directLogs, id);\\n _directLogsSend(directLogs, _getDN404Storage().mirrorERC721);\\n }\\n\\n /// @dev Transfers token `id` from `from` to `to`.\\n ///\\n /// Requirements:\\n ///\\n /// - Call must originate from the mirror contract.\\n /// - Token `id` must exist.\\n /// - `from` must be the owner of the token.\\n /// - `to` cannot be the zero address.\\n /// `msgSender` must be the owner of the token, or be approved to manage the token.\\n ///\\n /// Emits a {Transfer} event.\\n function _transferFromNFT(address from, address to, uint256 id, address msgSender)\\n internal\\n virtual\\n {\\n if (to == address(0)) revert TransferToZeroAddress();\\n\\n DN404Storage storage $ = _getDN404Storage();\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n Uint32Map storage oo = $.oo;\\n\\n if (from != $.aliasToAddress[_get(oo, _ownershipIndex(_restrictNFTId(id)))]) {\\n revert TransferFromIncorrectOwner();\\n }\\n\\n if (msgSender != from) {\\n if (!_isApprovedForAll(from, msgSender)) {\\n if (_getApproved(id) != msgSender) {\\n revert TransferCallerNotOwnerNorApproved();\\n }\\n }\\n }\\n\\n AddressData storage fromAddressData = $.addressData[from];\\n AddressData storage toAddressData = $.addressData[to];\\n\\n uint256 unit = _unit();\\n mapping(address => Uint32Map) storage owned = $.owned;\\n\\n unchecked {\\n uint256 fromBalance = fromAddressData.balance;\\n if (unit > fromBalance) revert InsufficientBalance();\\n fromAddressData.balance = uint96(fromBalance - unit);\\n toAddressData.balance += uint96(unit);\\n }\\n if (_get($.mayHaveNFTApproval, id)) {\\n _set($.mayHaveNFTApproval, id, false);\\n delete $.nftApprovals[id];\\n }\\n unchecked {\\n Uint32Map storage fromOwned = owned[from];\\n uint32 updatedId = _get(fromOwned, --fromAddressData.ownedLength);\\n uint32 i = _get(oo, _ownedIndex(id));\\n _set(fromOwned, i, updatedId);\\n _set(oo, _ownedIndex(updatedId), i);\\n }\\n unchecked {\\n uint32 n = toAddressData.ownedLength++;\\n _set(owned[to], n, uint32(id));\\n _setOwnerAliasAndOwnedIndex(oo, id, _registerAndResolveAlias(toAddressData, to), n);\\n }\\n _afterNFTTransfer(from, to, id);\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, unit)\\n // forgefmt: disable-next-item\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL APPROVE FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Sets `amount` as the allowance of `spender` over the tokens of `owner`.\\n ///\\n /// Emits a {Approval} event.\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {\\n _getDN404Storage().addressData[owner].flags |= _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG;\\n }\\n _ref(_getDN404Storage().allowance, owner, spender).value = amount;\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Approval} event.\\n mstore(0x00, amount)\\n // forgefmt: disable-next-item\\n log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, shr(96, shl(96, owner)), shr(96, shl(96, spender)))\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* DATA HITCHHIKING FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the auxiliary data for `owner`.\\n /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.\\n /// Auxiliary data can be set for any address, even if it does not have any tokens.\\n function _getAux(address owner) internal view virtual returns (uint88) {\\n return _getDN404Storage().addressData[owner].aux;\\n }\\n\\n /// @dev Set the auxiliary data for `owner` to `value`.\\n /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.\\n /// Auxiliary data can be set for any address, even if it does not have any tokens.\\n function _setAux(address owner, uint88 value) internal virtual {\\n _getDN404Storage().addressData[owner].aux = value;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* SKIP NFT FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs.\\n /// Returns false otherwise.\\n function getSkipNFT(address owner) public view virtual returns (bool) {\\n AddressData storage d = _getDN404Storage().addressData[owner];\\n if (_isZero(d.flags & _ADDRESS_DATA_INITIALIZED_FLAG)) return _hasCode(owner);\\n return d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0;\\n }\\n\\n /// @dev Sets the caller's skipNFT flag to `skipNFT`. Returns true.\\n ///\\n /// Emits a {SkipNFTSet} event.\\n function setSkipNFT(bool skipNFT) public virtual returns (bool) {\\n _setSkipNFT(msg.sender, skipNFT);\\n return true;\\n }\\n\\n /// @dev Internal function to set account `owner` skipNFT flag to `state`\\n ///\\n /// Initializes account `owner` AddressData if it is not currently initialized.\\n ///\\n /// Emits a {SkipNFTSet} event.\\n function _setSkipNFT(address owner, bool state) internal virtual {\\n AddressData storage d = _addressData(owner);\\n if ((d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0) != state) {\\n d.flags ^= _ADDRESS_DATA_SKIP_NFT_FLAG;\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, iszero(iszero(state)))\\n log2(0x00, 0x20, _SKIP_NFT_SET_EVENT_SIGNATURE, shr(96, shl(96, owner)))\\n }\\n }\\n\\n /// @dev Returns a storage data pointer for account `owner` AddressData\\n ///\\n /// Initializes account `owner` AddressData if it is not currently initialized.\\n function _addressData(address owner) internal virtual returns (AddressData storage d) {\\n d = _getDN404Storage().addressData[owner];\\n unchecked {\\n if (_isZero(d.flags & _ADDRESS_DATA_INITIALIZED_FLAG)) {\\n uint256 skipNFT = _toUint(_hasCode(owner)) * _ADDRESS_DATA_SKIP_NFT_FLAG;\\n d.flags = uint8(skipNFT | _ADDRESS_DATA_INITIALIZED_FLAG);\\n }\\n }\\n }\\n\\n /// @dev Returns the `addressAlias` of account `to`.\\n ///\\n /// Assigns and registers the next alias if `to` alias was not previously registered.\\n function _registerAndResolveAlias(AddressData storage toAddressData, address to)\\n internal\\n virtual\\n returns (uint32 addressAlias)\\n {\\n DN404Storage storage $ = _getDN404Storage();\\n addressAlias = toAddressData.addressAlias;\\n if (_isZero(addressAlias)) {\\n unchecked {\\n addressAlias = ++$.numAliases;\\n }\\n toAddressData.addressAlias = addressAlias;\\n $.aliasToAddress[addressAlias] = to;\\n if (_isZero(addressAlias)) revert(); // Overflow.\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* MIRROR OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the address of the mirror NFT contract.\\n function mirrorERC721() public view virtual returns (address) {\\n return _getDN404Storage().mirrorERC721;\\n }\\n\\n /// @dev Returns the total NFT supply.\\n function _totalNFTSupply() internal view virtual returns (uint256) {\\n return _getDN404Storage().totalNFTSupply;\\n }\\n\\n /// @dev Returns `owner` NFT balance.\\n function _balanceOfNFT(address owner) internal view virtual returns (uint256) {\\n return _getDN404Storage().addressData[owner].ownedLength;\\n }\\n\\n /// @dev Returns the owner of token `id`.\\n /// Returns the zero address instead of reverting if the token does not exist.\\n function _ownerAt(uint256 id) internal view virtual returns (address) {\\n DN404Storage storage $ = _getDN404Storage();\\n return $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];\\n }\\n\\n /// @dev Returns the owner of token `id`.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n function _ownerOf(uint256 id) internal view virtual returns (address) {\\n if (!_exists(id)) revert TokenDoesNotExist();\\n return _ownerAt(id);\\n }\\n\\n /// @dev Returns whether `operator` is approved to manage the NFT tokens of `owner`.\\n function _isApprovedForAll(address owner, address operator)\\n internal\\n view\\n virtual\\n returns (bool)\\n {\\n return !_isZero(_ref(_getDN404Storage().operatorApprovals, owner, operator).value);\\n }\\n\\n /// @dev Returns if token `id` exists.\\n function _exists(uint256 id) internal view virtual returns (bool) {\\n return _ownerAt(id) != address(0);\\n }\\n\\n /// @dev Returns the account approved to manage token `id`.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n function _getApproved(uint256 id) internal view virtual returns (address) {\\n if (!_exists(id)) revert TokenDoesNotExist();\\n return _getDN404Storage().nftApprovals[id];\\n }\\n\\n /// @dev Sets `spender` as the approved account to manage token `id`, using `msgSender`.\\n ///\\n /// Requirements:\\n /// - `msgSender` must be the owner or an approved operator for the token owner.\\n function _approveNFT(address spender, uint256 id, address msgSender)\\n internal\\n virtual\\n returns (address owner)\\n {\\n DN404Storage storage $ = _getDN404Storage();\\n\\n owner = $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];\\n\\n if (msgSender != owner) {\\n if (!_isApprovedForAll(owner, msgSender)) {\\n revert ApprovalCallerNotOwnerNorApproved();\\n }\\n }\\n\\n $.nftApprovals[id] = spender;\\n _set($.mayHaveNFTApproval, id, spender != address(0));\\n }\\n\\n /// @dev Approve or remove the `operator` as an operator for `msgSender`,\\n /// without authorization checks.\\n function _setApprovalForAll(address operator, bool approved, address msgSender)\\n internal\\n virtual\\n {\\n _ref(_getDN404Storage().operatorApprovals, msgSender, operator).value = _toUint(approved);\\n }\\n\\n /// @dev Returns the NFT IDs of `owner` in the range `[begin..end)` (exclusive of `end`).\\n /// `begin` and `end` are indices in the owner's token ID array, not the entire token range.\\n /// Optimized for smaller bytecode size, as this function is intended for off-chain calling.\\n function _ownedIds(address owner, uint256 begin, uint256 end)\\n internal\\n view\\n virtual\\n returns (uint256[] memory ids)\\n {\\n DN404Storage storage $ = _getDN404Storage();\\n Uint32Map storage owned = $.owned[owner];\\n end = _min($.addressData[owner].ownedLength, end);\\n /// @solidity memory-safe-assembly\\n assembly {\\n ids := mload(0x40)\\n let i := begin\\n for {} lt(i, end) { i := add(i, 1) } {\\n let s := add(shl(96, owned.slot), shr(3, i)) // Storage slot.\\n let id := and(0xffffffff, shr(shl(5, and(i, 7)), sload(s)))\\n mstore(add(add(ids, 0x20), shl(5, sub(i, begin))), id) // Append to.\\n }\\n mstore(ids, sub(i, begin)) // Store the length.\\n mstore(0x40, add(add(ids, 0x20), shl(5, sub(i, begin)))) // Allocate memory.\\n }\\n }\\n\\n /// @dev Fallback modifier to dispatch calls from the mirror NFT contract\\n /// to internal functions in this contract.\\n modifier dn404Fallback() virtual {\\n DN404Storage storage $ = _getDN404Storage();\\n\\n uint256 fnSelector = _calldataload(0x00) >> 224;\\n\\n // `transferFromNFT(address,address,uint256,address)`.\\n if (fnSelector == 0xe5eb36c8) {\\n if (msg.sender != $.mirrorERC721) revert SenderNotMirror();\\n _transferFromNFT(\\n address(uint160(_calldataload(0x04))), // `from`.\\n address(uint160(_calldataload(0x24))), // `to`.\\n _calldataload(0x44), // `id`.\\n address(uint160(_calldataload(0x64))) // `msgSender`.\\n );\\n _return(1);\\n }\\n // `setApprovalForAll(address,bool,address)`.\\n if (fnSelector == 0x813500fc) {\\n if (msg.sender != $.mirrorERC721) revert SenderNotMirror();\\n _setApprovalForAll(\\n address(uint160(_calldataload(0x04))), // `spender`.\\n _calldataload(0x24) != 0, // `status`.\\n address(uint160(_calldataload(0x44))) // `msgSender`.\\n );\\n _return(1);\\n }\\n // `isApprovedForAll(address,address)`.\\n if (fnSelector == 0xe985e9c5) {\\n bool result = _isApprovedForAll(\\n address(uint160(_calldataload(0x04))), // `owner`.\\n address(uint160(_calldataload(0x24))) // `operator`.\\n );\\n _return(_toUint(result));\\n }\\n // `ownerOf(uint256)`.\\n if (fnSelector == 0x6352211e) {\\n _return(uint160(_ownerOf(_calldataload(0x04))));\\n }\\n // `ownerAt(uint256)`.\\n if (fnSelector == 0x24359879) {\\n _return(uint160(_ownerAt(_calldataload(0x04))));\\n }\\n // `approveNFT(address,uint256,address)`.\\n if (fnSelector == 0xd10b6e0c) {\\n if (msg.sender != $.mirrorERC721) revert SenderNotMirror();\\n address owner = _approveNFT(\\n address(uint160(_calldataload(0x04))), // `spender`.\\n _calldataload(0x24), // `id`.\\n address(uint160(_calldataload(0x44))) // `msgSender`.\\n );\\n _return(uint160(owner));\\n }\\n // `getApproved(uint256)`.\\n if (fnSelector == 0x081812fc) {\\n _return(uint160(_getApproved(_calldataload(0x04))));\\n }\\n // `balanceOfNFT(address)`.\\n if (fnSelector == 0xf5b100ea) {\\n _return(_balanceOfNFT(address(uint160(_calldataload(0x04)))));\\n }\\n // `totalNFTSupply()`.\\n if (fnSelector == 0xe2c79281) {\\n _return(_totalNFTSupply());\\n }\\n // `tokenURI(uint256)`.\\n if (fnSelector == 0xc87b56dd) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x40, add(mload(0x40), 0x20))\\n }\\n string memory uri = _tokenURI(_calldataload(0x04));\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Memory safe, as we've advanced the free memory pointer by a word.\\n let o := sub(uri, 0x20)\\n mstore(o, 0x20) // Store the offset of `uri`.\\n return(o, add(0x60, mload(uri)))\\n }\\n }\\n // `implementsDN404()`.\\n if (fnSelector == 0xb7a94eb8) {\\n _return(1);\\n }\\n _;\\n }\\n\\n /// @dev Fallback function for calls from mirror NFT contract.\\n /// Override this if you need to implement your custom\\n /// fallback with utilities like Solady's `LibZip.cdFallback()`.\\n /// And always remember to always wrap the fallback with `dn404Fallback`.\\n fallback() external payable virtual dn404Fallback {\\n revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.\\n }\\n\\n /// @dev This is to silence the compiler warning.\\n /// Override and remove the revert if you want your contract to receive ETH via receive.\\n receive() external payable virtual {\\n if (msg.value != 0) revert();\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL / PRIVATE HELPERS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns `(i - 1) << 1`.\\n function _ownershipIndex(uint256 i) internal pure returns (uint256) {\\n unchecked {\\n return (i - 1) << 1; // Minus 1 as token IDs start from 1.\\n }\\n }\\n\\n /// @dev Returns `((i - 1) << 1) + 1`.\\n function _ownedIndex(uint256 i) internal pure returns (uint256) {\\n unchecked {\\n return ((i - 1) << 1) + 1; // Minus 1 as token IDs start from 1.\\n }\\n }\\n\\n /// @dev Returns the uint32 value at `index` in `map`.\\n function _get(Uint32Map storage map, uint256 index) internal view returns (uint32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.\\n result := and(0xffffffff, shr(shl(5, and(index, 7)), sload(s)))\\n }\\n }\\n\\n /// @dev Updates the uint32 value at `index` in `map`.\\n function _set(Uint32Map storage map, uint256 index, uint32 value) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.\\n let o := shl(5, and(index, 7)) // Storage slot offset (bits).\\n let v := sload(s) // Storage slot value.\\n sstore(s, xor(v, shl(o, and(0xffffffff, xor(value, shr(o, v))))))\\n }\\n }\\n\\n /// @dev Sets the owner alias and the owned index together.\\n function _setOwnerAliasAndOwnedIndex(\\n Uint32Map storage map,\\n uint256 id,\\n uint32 ownership,\\n uint32 ownedIndex\\n ) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let i := sub(id, 1) // Index of the uint64 combined value.\\n let s := add(shl(96, map.slot), shr(2, i)) // Storage slot.\\n let v := sload(s) // Storage slot value.\\n let o := shl(6, and(i, 3)) // Storage slot offset (bits).\\n let combined := or(shl(32, ownedIndex), and(0xffffffff, ownership))\\n sstore(s, xor(v, shl(o, and(0xffffffffffffffff, xor(shr(o, v), combined)))))\\n }\\n }\\n\\n /// @dev Returns the boolean value of the bit at `index` in `bitmap`.\\n function _get(Bitmap storage bitmap, uint256 index) internal view returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.\\n result := and(1, shr(and(0xff, index), sload(s)))\\n }\\n }\\n\\n /// @dev Updates the bit at `index` in `bitmap` to `value`.\\n function _set(Bitmap storage bitmap, uint256 index, bool value) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.\\n let o := and(0xff, index) // Storage slot offset (bits).\\n sstore(s, or(and(sload(s), not(shl(o, 1))), shl(o, iszero(iszero(value)))))\\n }\\n }\\n\\n /// @dev Returns the index of the least significant unset bit in `[begin..upTo]`.\\n /// If no set bit is found, returns `type(uint256).max`.\\n function _findFirstUnset(Bitmap storage bitmap, uint256 begin, uint256 upTo)\\n internal\\n view\\n returns (uint256 unsetBitIndex)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n unsetBitIndex := not(0) // Initialize to `type(uint256).max`.\\n let s := shl(96, bitmap.slot) // Storage offset of the bitmap.\\n let bucket := add(s, shr(8, begin))\\n let negBits := shl(and(0xff, begin), shr(and(0xff, begin), not(sload(bucket))))\\n if iszero(negBits) {\\n let lastBucket := add(s, shr(8, upTo))\\n for {} 1 {} {\\n bucket := add(bucket, 1)\\n negBits := not(sload(bucket))\\n if or(negBits, gt(bucket, lastBucket)) { break }\\n }\\n if gt(bucket, lastBucket) {\\n negBits := shr(and(0xff, not(upTo)), shl(and(0xff, not(upTo)), negBits))\\n }\\n }\\n if negBits {\\n // Find-first-set routine.\\n // From: https://github.com/vectorized/solady/blob/main/src/utils/LibBit.sol\\n let b := and(negBits, add(not(negBits), 1)) // Isolate the least significant bit.\\n // For the upper 3 bits of the result, use a De Bruijn-like lookup.\\n // Credit to adhusson: https://blog.adhusson.com/cheap-find-first-set-evm/\\n // forgefmt: disable-next-item\\n let r := shl(5, shr(252, shl(shl(2, shr(250, mul(b,\\n 0x2aaaaaaaba69a69a6db6db6db2cb2cb2ce739ce73def7bdeffffffff))),\\n 0x1412563212c14164235266736f7425221143267a45243675267677)))\\n // For the lower 5 bits of the result, use a De Bruijn lookup.\\n // forgefmt: disable-next-item\\n r := or(r, byte(and(div(0xd76453e0, shr(r, b)), 0x1f),\\n 0x001f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405))\\n r := or(shl(8, sub(bucket, s)), r)\\n unsetBitIndex := or(r, sub(0, or(gt(r, upTo), lt(r, begin))))\\n }\\n }\\n }\\n\\n /// @dev Returns a storage reference to the value at (`a0`, `a1`) in `map`.\\n function _ref(AddressPairToUint256RefMap storage map, address a0, address a1)\\n internal\\n pure\\n returns (Uint256Ref storage ref)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x28, a1)\\n mstore(0x14, a0)\\n mstore(0x00, map.slot)\\n ref.slot := keccak256(0x00, 0x48)\\n // Clear the part of the free memory pointer that was overwritten.\\n mstore(0x28, 0x00)\\n }\\n }\\n\\n /// @dev Wraps the NFT ID.\\n function _wrapNFTId(uint256 id, uint256 maxId) internal pure returns (uint256 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := or(mul(iszero(gt(id, maxId)), id), gt(id, maxId))\\n }\\n }\\n\\n /// @dev Returns `id > type(uint32).max ? 0 : id`.\\n function _restrictNFTId(uint256 id) internal pure returns (uint256 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := mul(id, lt(id, 0x100000000))\\n }\\n }\\n\\n /// @dev Returns whether `amount` is a valid `totalSupply`.\\n function _totalSupplyOverflows(uint256 amount) internal view returns (bool result) {\\n uint256 unit = _unit();\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := iszero(iszero(or(shr(96, amount), lt(0xfffffffe, div(amount, unit)))))\\n }\\n }\\n\\n /// @dev Returns `max(0, x - y)`.\\n function _zeroFloorSub(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n z := mul(gt(x, y), sub(x, y))\\n }\\n }\\n\\n /// @dev Returns `x < y ? x : y`.\\n function _min(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n z := xor(x, mul(xor(x, y), lt(y, x)))\\n }\\n }\\n\\n /// @dev Returns `b ? 1 : 0`.\\n function _toUint(bool b) internal pure returns (uint256 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := iszero(iszero(b))\\n }\\n }\\n\\n /// @dev Returns `b == 0`. This is because solc is sometimes dumb.\\n function _isZero(uint256 x) internal pure returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := iszero(x)\\n }\\n }\\n\\n /// @dev Struct containing direct transfer log data for {Transfer} events to be\\n /// emitted by the mirror NFT contract.\\n struct _DNDirectLogs {\\n uint256 offset;\\n uint256[] logs;\\n }\\n\\n /// @dev Initiates memory allocation for direct logs with `n` log items.\\n function _directLogsMalloc(uint256 n, address from, address to)\\n private\\n pure\\n returns (_DNDirectLogs memory p)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40)\\n mstore(m, 0x144027d3) // `logDirectTransfer(address,address,uint256[])`.\\n mstore(add(m, 0x20), shr(96, shl(96, from)))\\n mstore(add(m, 0x40), shr(96, shl(96, to)))\\n mstore(add(m, 0x60), 0x60) // Offset of `logs` in the calldata to send.\\n // Skip 4 words: `fnSelector`, `from`, `to`, `calldataLogsOffset`.\\n let logs := add(0x80, m)\\n mstore(logs, n) // Store the length.\\n let offset := add(0x20, logs) // Skip the word for `p.logs.length`.\\n mstore(0x40, add(offset, shl(5, n))) // Allocate memory.\\n mstore(add(0x20, p), logs) // Set `p.logs`.\\n mstore(p, offset) // Set `p.offset`.\\n }\\n }\\n\\n /// @dev Adds a direct log item to `p` with token `id`.\\n function _directLogsAppend(_DNDirectLogs memory p, uint256 id) private pure {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let offset := mload(p)\\n mstore(offset, id)\\n mstore(p, add(offset, 0x20))\\n }\\n }\\n\\n /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.\\n function _directLogsSend(_DNDirectLogs memory p, address mirror) private {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let logs := mload(add(p, 0x20))\\n let n := add(0x84, shl(5, mload(logs))) // Length of calldata to send.\\n let o := sub(logs, 0x80) // Start of calldata to send.\\n if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {\\n revert(o, 0x00)\\n }\\n }\\n }\\n\\n /// @dev Struct containing packed log data for {Transfer} events to be\\n /// emitted by the mirror NFT contract.\\n struct _DNPackedLogs {\\n uint256 offset;\\n uint256 addressAndBit;\\n uint256[] logs;\\n }\\n\\n /// @dev Initiates memory allocation for packed logs with `n` log items.\\n function _packedLogsMalloc(uint256 n) private pure returns (_DNPackedLogs memory p) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Note that `p` implicitly allocates and advances the free memory pointer by\\n // 3 words, which we can safely mutate in `_packedLogsSend`.\\n let logs := mload(0x40)\\n mstore(logs, n) // Store the length.\\n let offset := add(0x20, logs) // Skip the word for `p.logs.length`.\\n mstore(0x40, add(offset, shl(5, n))) // Allocate memory.\\n mstore(add(0x40, p), logs) // Set `p.logs`.\\n mstore(p, offset) // Set `p.offset`.\\n }\\n }\\n\\n /// @dev Set the current address and the burn bit.\\n function _packedLogsSet(_DNPackedLogs memory p, address a, uint256 burnBit) private pure {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(add(p, 0x20), or(shl(96, a), burnBit)) // Set `p.addressAndBit`.\\n }\\n }\\n\\n /// @dev Adds a packed log item to `p` with token `id`.\\n function _packedLogsAppend(_DNPackedLogs memory p, uint256 id) private pure {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let offset := mload(p)\\n mstore(offset, or(mload(add(p, 0x20)), shl(8, id))) // `p.addressAndBit | (id << 8)`.\\n mstore(p, add(offset, 0x20))\\n }\\n }\\n\\n /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.\\n function _packedLogsSend(_DNPackedLogs memory p, address mirror) private {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let logs := mload(add(p, 0x40))\\n let o := sub(logs, 0x40) // Start of calldata to send.\\n mstore(o, 0x263c69d6) // `logTransfer(uint256[])`.\\n mstore(add(o, 0x20), 0x20) // Offset of `logs` in the calldata to send.\\n let n := add(0x44, shl(5, mload(logs))) // Length of calldata to send.\\n if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {\\n revert(o, 0x00)\\n }\\n }\\n }\\n\\n /// @dev Struct of temporary variables for transfers.\\n struct _DNTransferTemps {\\n uint256 numNFTBurns;\\n uint256 numNFTMints;\\n uint256 fromOwnedLength;\\n uint256 toOwnedLength;\\n uint256 totalNFTSupply;\\n uint256 fromEnd;\\n uint256 toEnd;\\n uint32 toAlias;\\n uint256 nextTokenId;\\n uint32 burnedPoolTail;\\n }\\n\\n /// @dev Struct of temporary variables for mints.\\n struct _DNMintTemps {\\n uint256 nextTokenId;\\n uint32 burnedPoolTail;\\n uint256 toEnd;\\n uint32 toAlias;\\n }\\n\\n /// @dev Returns if `a` has bytecode of non-zero length.\\n function _hasCode(address a) private view returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := extcodesize(a) // Can handle dirty upper bits.\\n }\\n }\\n\\n /// @dev Returns the calldata value at `offset`.\\n function _calldataload(uint256 offset) private pure returns (uint256 value) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n value := calldataload(offset)\\n }\\n }\\n\\n /// @dev Executes a return opcode to return `x` and end the current call frame.\\n function _return(uint256 x) private pure {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, x)\\n return(0x00, 0x20)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2d80b1d76a7b1bf630fd12b4ea357b4770cc8f447b3be2bcbe73823a43d3b042\",\"license\":\"MIT\"},\"dn404/src/DN404Mirror.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @title DN404Mirror\\n/// @notice DN404Mirror provides an interface for interacting with the\\n/// NFT tokens in a DN404 implementation.\\n///\\n/// @author vectorized.eth (@optimizoor)\\n/// @author Quit (@0xQuit)\\n/// @author Michael Amadi (@AmadiMichaels)\\n/// @author cygaar (@0xCygaar)\\n/// @author Thomas (@0xjustadev)\\n/// @author Harrison (@PopPunkOnChain)\\n///\\n/// @dev Note:\\n/// - The ERC721 data is stored in the base DN404 contract.\\ncontract DN404Mirror {\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* EVENTS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Emitted when token `id` is transferred from `from` to `to`.\\n event Transfer(address indexed from, address indexed to, uint256 indexed id);\\n\\n /// @dev Emitted when `owner` enables `account` to manage the `id` token.\\n event Approval(address indexed owner, address indexed account, uint256 indexed id);\\n\\n /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.\\n event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);\\n\\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\\n /// This is for marketplace signaling purposes. This contract has a `pullOwner()`\\n /// function that will sync the owner from the base contract.\\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\\n\\n /// @dev `keccak256(bytes(\\\"Transfer(address,address,uint256)\\\"))`.\\n uint256 private constant _TRANSFER_EVENT_SIGNATURE =\\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\\n\\n /// @dev `keccak256(bytes(\\\"Approval(address,address,uint256)\\\"))`.\\n uint256 private constant _APPROVAL_EVENT_SIGNATURE =\\n 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;\\n\\n /// @dev `keccak256(bytes(\\\"ApprovalForAll(address,address,bool)\\\"))`.\\n uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =\\n 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CUSTOM ERRORS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Thrown when a call for an NFT function did not originate\\n /// from the base DN404 contract.\\n error SenderNotBase();\\n\\n /// @dev Thrown when a call for an NFT function did not originate from the deployer.\\n error SenderNotDeployer();\\n\\n /// @dev Thrown when transferring an NFT to a contract address that\\n /// does not implement ERC721Receiver.\\n error TransferToNonERC721ReceiverImplementer();\\n\\n /// @dev Thrown when linking to the DN404 base contract and the\\n /// DN404 supportsInterface check fails or the call reverts.\\n error CannotLink();\\n\\n /// @dev Thrown when a linkMirrorContract call is received and the\\n /// NFT mirror contract has already been linked to a DN404 base contract.\\n error AlreadyLinked();\\n\\n /// @dev Thrown when retrieving the base DN404 address when a link has not\\n /// been established.\\n error NotLinked();\\n\\n /// @dev The function selector is not recognized.\\n error FnSelectorNotRecognized();\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* STORAGE */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Struct contain the NFT mirror contract storage.\\n struct DN404NFTStorage {\\n // Address of the ERC20 base contract.\\n address baseERC20;\\n // The deployer, if provided. If non-zero, the initialization of the\\n // ERC20 <-> ERC721 link can only be done be the deployer via the ERC20 base contract.\\n address deployer;\\n // The owner of the ERC20 base contract. For marketplace signaling.\\n address owner;\\n }\\n\\n /// @dev Returns a storage pointer for DN404NFTStorage.\\n function _getDN404NFTStorage() internal pure virtual returns (DN404NFTStorage storage $) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // `uint72(bytes9(keccak256(\\\"DN404_MIRROR_STORAGE\\\")))`.\\n $.slot := 0x3602298b8c10b01230 // Truncate to 9 bytes to reduce bytecode size.\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CONSTRUCTOR */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n constructor(address deployer) {\\n // For non-proxies, we will store the deployer so that only the deployer can\\n // link the base contract.\\n _getDN404NFTStorage().deployer = deployer;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* ERC721 OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the token collection name from the base DN404 contract.\\n function name() public view virtual returns (string memory) {\\n return _readString(0x06fdde03, 0); // `name()`.\\n }\\n\\n /// @dev Returns the token collection symbol from the base DN404 contract.\\n function symbol() public view virtual returns (string memory) {\\n return _readString(0x95d89b41, 0); // `symbol()`.\\n }\\n\\n /// @dev Returns the Uniform Resource Identifier (URI) for token `id` from\\n /// the base DN404 contract.\\n function tokenURI(uint256 id) public view virtual returns (string memory) {\\n return _readString(0xc87b56dd, id); // `tokenURI(uint256)`.\\n }\\n\\n /// @dev Returns the total NFT supply from the base DN404 contract.\\n function totalSupply() public view virtual returns (uint256) {\\n return _readWord(0xe2c79281, 0, 0); // `totalNFTSupply()`.\\n }\\n\\n /// @dev Returns the number of NFT tokens owned by `nftOwner` from the base DN404 contract.\\n ///\\n /// Requirements:\\n /// - `nftOwner` must not be the zero address.\\n function balanceOf(address nftOwner) public view virtual returns (uint256) {\\n return _readWord(0xf5b100ea, uint160(nftOwner), 0); // `balanceOfNFT(address)`.\\n }\\n\\n /// @dev Returns the owner of token `id` from the base DN404 contract.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n function ownerOf(uint256 id) public view virtual returns (address) {\\n return address(uint160(_readWord(0x6352211e, id, 0))); // `ownerOf(uint256)`.\\n }\\n\\n /// @dev Returns the owner of token `id` from the base DN404 contract.\\n /// Returns `address(0)` instead of reverting if the token does not exist.\\n function ownerAt(uint256 id) public view virtual returns (address) {\\n return address(uint160(_readWord(0x24359879, id, 0))); // `ownerAt(uint256)`.\\n }\\n\\n /// @dev Sets `spender` as the approved account to manage token `id` in\\n /// the base DN404 contract.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n /// - The caller must be the owner of the token,\\n /// or an approved operator for the token owner.\\n ///\\n /// Emits an {Approval} event.\\n function approve(address spender, uint256 id) public payable virtual {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n spender := shr(96, shl(96, spender))\\n let m := mload(0x40)\\n mstore(0x00, 0xd10b6e0c) // `approveNFT(address,uint256,address)`.\\n mstore(0x20, spender)\\n mstore(0x40, id)\\n mstore(0x60, caller())\\n if iszero(\\n and( // Arguments of `and` are evaluated last to first.\\n gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.\\n call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)\\n )\\n ) {\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n mstore(0x40, m) // Restore the free memory pointer.\\n mstore(0x60, 0) // Restore the zero pointer.\\n // Emit the {Approval} event.\\n log4(codesize(), 0x00, _APPROVAL_EVENT_SIGNATURE, shr(96, mload(0x0c)), spender, id)\\n }\\n }\\n\\n /// @dev Returns the account approved to manage token `id` from\\n /// the base DN404 contract.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n function getApproved(uint256 id) public view virtual returns (address) {\\n return address(uint160(_readWord(0x081812fc, id, 0))); // `getApproved(uint256)`.\\n }\\n\\n /// @dev Sets whether `operator` is approved to manage the tokens of the caller in\\n /// the base DN404 contract.\\n ///\\n /// Emits an {ApprovalForAll} event.\\n function setApprovalForAll(address operator, bool approved) public virtual {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n operator := shr(96, shl(96, operator))\\n let m := mload(0x40)\\n mstore(0x00, 0x813500fc) // `setApprovalForAll(address,bool,address)`.\\n mstore(0x20, operator)\\n mstore(0x40, iszero(iszero(approved)))\\n mstore(0x60, caller())\\n if iszero(\\n and( // Arguments of `and` are evaluated last to first.\\n eq(mload(0x00), 1), // The call must return 1.\\n call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)\\n )\\n ) {\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n // Emit the {ApprovalForAll} event.\\n // The `approved` value is already at 0x40.\\n log3(0x40, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), operator)\\n mstore(0x40, m) // Restore the free memory pointer.\\n mstore(0x60, 0) // Restore the zero pointer.\\n }\\n }\\n\\n /// @dev Returns whether `operator` is approved to manage the tokens of `nftOwner` from\\n /// the base DN404 contract.\\n function isApprovedForAll(address nftOwner, address operator)\\n public\\n view\\n virtual\\n returns (bool)\\n {\\n // `isApprovedForAll(address,address)`.\\n return _readWord(0xe985e9c5, uint160(nftOwner), uint160(operator)) != 0;\\n }\\n\\n /// @dev Transfers token `id` from `from` to `to`.\\n ///\\n /// Requirements:\\n ///\\n /// - Token `id` must exist.\\n /// - `from` must be the owner of the token.\\n /// - `to` cannot be the zero address.\\n /// - The caller must be the owner of the token, or be approved to manage the token.\\n ///\\n /// Emits a {Transfer} event.\\n function transferFrom(address from, address to, uint256 id) public payable virtual {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n from := shr(96, shl(96, from))\\n to := shr(96, shl(96, to))\\n let m := mload(0x40)\\n mstore(m, 0xe5eb36c8) // `transferFromNFT(address,address,uint256,address)`.\\n mstore(add(m, 0x20), from)\\n mstore(add(m, 0x40), to)\\n mstore(add(m, 0x60), id)\\n mstore(add(m, 0x80), caller())\\n if iszero(\\n and( // Arguments of `and` are evaluated last to first.\\n eq(mload(m), 1), // The call must return 1.\\n call(gas(), base, callvalue(), add(m, 0x1c), 0x84, m, 0x20)\\n )\\n ) {\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n // Emit the {Transfer} event.\\n log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id)\\n }\\n }\\n\\n /// @dev Equivalent to `safeTransferFrom(from, to, id, \\\"\\\")`.\\n function safeTransferFrom(address from, address to, uint256 id) public payable virtual {\\n transferFrom(from, to, id);\\n if (_hasCode(to)) _checkOnERC721Received(from, to, id, \\\"\\\");\\n }\\n\\n /// @dev Transfers token `id` from `from` to `to`.\\n ///\\n /// Requirements:\\n ///\\n /// - Token `id` must exist.\\n /// - `from` must be the owner of the token.\\n /// - `to` cannot be the zero address.\\n /// - The caller must be the owner of the token, or be approved to manage the token.\\n /// - If `to` refers to a smart contract, it must implement\\n /// {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n ///\\n /// Emits a {Transfer} event.\\n function safeTransferFrom(address from, address to, uint256 id, bytes calldata data)\\n public\\n payable\\n virtual\\n {\\n transferFrom(from, to, id);\\n if (_hasCode(to)) _checkOnERC721Received(from, to, id, data);\\n }\\n\\n /// @dev Returns true if this contract implements the interface defined by `interfaceId`.\\n /// See: https://eips.ethereum.org/EIPS/eip-165\\n /// This function call must use less than 30000 gas.\\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := shr(224, interfaceId)\\n // ERC165: 0x01ffc9a7, ERC721: 0x80ac58cd, ERC721Metadata: 0x5b5e139f.\\n result := or(or(eq(s, 0x01ffc9a7), eq(s, 0x80ac58cd)), eq(s, 0x5b5e139f))\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* OWNER SYNCING OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the `owner` of the contract, for marketplace signaling purposes.\\n function owner() public view virtual returns (address) {\\n return _getDN404NFTStorage().owner;\\n }\\n\\n /// @dev Permissionless function to pull the owner from the base DN404 contract\\n /// if it implements ownable, for marketplace signaling purposes.\\n function pullOwner() public virtual returns (bool) {\\n address newOwner;\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, 0x8da5cb5b) // `owner()`.\\n let success := staticcall(gas(), base, 0x1c, 0x04, 0x00, 0x20)\\n newOwner := mul(shr(96, mload(0x0c)), and(gt(returndatasize(), 0x1f), success))\\n }\\n DN404NFTStorage storage $ = _getDN404NFTStorage();\\n address oldOwner = $.owner;\\n if (oldOwner != newOwner) {\\n $.owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n return true;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* MIRROR OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the address of the base DN404 contract.\\n function baseERC20() public view virtual returns (address base) {\\n base = _getDN404NFTStorage().baseERC20;\\n if (base == address(0)) revert NotLinked();\\n }\\n\\n /// @dev Fallback modifier to execute calls from the base DN404 contract.\\n modifier dn404NFTFallback() virtual {\\n DN404NFTStorage storage $ = _getDN404NFTStorage();\\n\\n uint256 fnSelector = _calldataload(0x00) >> 224;\\n\\n // `logTransfer(uint256[])`.\\n if (fnSelector == 0x263c69d6) {\\n if (msg.sender != $.baseERC20) revert SenderNotBase();\\n /// @solidity memory-safe-assembly\\n assembly {\\n let o := add(0x24, calldataload(0x04)) // Packed logs offset.\\n let end := add(o, shl(5, calldataload(sub(o, 0x20))))\\n for {} iszero(eq(o, end)) { o := add(0x20, o) } {\\n let d := calldataload(o) // Entry in the packed logs.\\n let a := shr(96, d) // The address.\\n let b := and(1, d) // Whether it is a burn.\\n log4(\\n codesize(),\\n 0x00,\\n _TRANSFER_EVENT_SIGNATURE,\\n mul(a, b), // `from`.\\n mul(a, iszero(b)), // `to`.\\n shr(168, shl(160, d)) // `id`.\\n )\\n }\\n mstore(0x00, 0x01)\\n return(0x00, 0x20)\\n }\\n }\\n // `logDirectTransfer(address,address,uint256[])`.\\n if (fnSelector == 0x144027d3) {\\n if (msg.sender != $.baseERC20) revert SenderNotBase();\\n /// @solidity memory-safe-assembly\\n assembly {\\n let from := calldataload(0x04)\\n let to := calldataload(0x24)\\n let o := add(0x24, calldataload(0x44)) // Direct logs offset.\\n let end := add(o, shl(5, calldataload(sub(o, 0x20))))\\n for {} iszero(eq(o, end)) { o := add(0x20, o) } {\\n log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, calldataload(o))\\n }\\n mstore(0x00, 0x01)\\n return(0x00, 0x20)\\n }\\n }\\n // `linkMirrorContract(address)`.\\n if (fnSelector == 0x0f4599e5) {\\n if ($.deployer != address(0)) {\\n if (address(uint160(_calldataload(0x04))) != $.deployer) {\\n revert SenderNotDeployer();\\n }\\n }\\n if ($.baseERC20 != address(0)) revert AlreadyLinked();\\n $.baseERC20 = msg.sender;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, 0x01)\\n return(0x00, 0x20)\\n }\\n }\\n _;\\n }\\n\\n /// @dev Fallback function for calls from base DN404 contract.\\n /// Override this if you need to implement your custom\\n /// fallback with utilities like Solady's `LibZip.cdFallback()`.\\n /// And always remember to always wrap the fallback with `dn404NFTFallback`.\\n fallback() external payable virtual dn404NFTFallback {\\n revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.\\n }\\n\\n /// @dev This is to silence the compiler warning.\\n /// Override and remove the revert if you want your contract to receive ETH via receive.\\n receive() external payable virtual {\\n if (msg.value != 0) revert();\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* PRIVATE HELPERS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Helper to read a string from the base DN404 contract.\\n function _readString(uint256 fnSelector, uint256 arg0)\\n private\\n view\\n returns (string memory result)\\n {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := mload(0x40)\\n mstore(0x00, fnSelector)\\n mstore(0x20, arg0)\\n if iszero(staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x00)) {\\n returndatacopy(result, 0x00, returndatasize())\\n revert(result, returndatasize())\\n }\\n returndatacopy(0x00, 0x00, 0x20) // Copy the offset of the string in returndata.\\n returndatacopy(result, mload(0x00), 0x20) // Copy the length of the string.\\n returndatacopy(add(result, 0x20), add(mload(0x00), 0x20), mload(result)) // Copy the string.\\n let end := add(add(result, 0x20), mload(result))\\n mstore(end, 0) // Zeroize the word after the string.\\n mstore(0x40, add(end, 0x20)) // Allocate memory.\\n }\\n }\\n\\n /// @dev Helper to read a word from the base DN404 contract.\\n function _readWord(uint256 fnSelector, uint256 arg0, uint256 arg1)\\n private\\n view\\n returns (uint256 result)\\n {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40)\\n mstore(0x00, fnSelector)\\n mstore(0x20, arg0)\\n mstore(0x40, arg1)\\n if iszero(\\n and( // Arguments of `and` are evaluated last to first.\\n gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.\\n staticcall(gas(), base, 0x1c, 0x44, 0x00, 0x20)\\n )\\n ) {\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n mstore(0x40, m) // Restore the free memory pointer.\\n result := mload(0x00)\\n }\\n }\\n\\n /// @dev Returns the calldata value at `offset`.\\n function _calldataload(uint256 offset) private pure returns (uint256 value) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n value := calldataload(offset)\\n }\\n }\\n\\n /// @dev Returns if `a` has bytecode of non-zero length.\\n function _hasCode(address a) private view returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := extcodesize(a) // Can handle dirty upper bits.\\n }\\n }\\n\\n /// @dev Perform a call to invoke {IERC721Receiver-onERC721Received} on `to`.\\n /// Reverts if the target does not support the function correctly.\\n function _checkOnERC721Received(address from, address to, uint256 id, bytes memory data)\\n private\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Prepare the calldata.\\n let m := mload(0x40)\\n let onERC721ReceivedSelector := 0x150b7a02\\n mstore(m, onERC721ReceivedSelector)\\n mstore(add(m, 0x20), caller()) // The `operator`, which is always `msg.sender`.\\n mstore(add(m, 0x40), shr(96, shl(96, from)))\\n mstore(add(m, 0x60), id)\\n mstore(add(m, 0x80), 0x80)\\n let n := mload(data)\\n mstore(add(m, 0xa0), n)\\n if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xc0), n)) }\\n // Revert if the call reverts.\\n if iszero(call(gas(), to, 0, add(m, 0x1c), add(n, 0xa4), m, 0x20)) {\\n if returndatasize() {\\n // Bubble up the revert if the call reverts.\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n }\\n // Load the returndata and compare it.\\n if iszero(eq(mload(m), shl(224, onERC721ReceivedSelector))) {\\n mstore(0x00, 0xd1a57ed6) // `TransferToNonERC721ReceiverImplementer()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe733b0633f67e2dae563882ff76b9aa429ffd98b0c008c29e1635b82614b513b\",\"license\":\"MIT\"},\"solady/src/auth/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @notice Simple single owner authorization mixin.\\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)\\n///\\n/// @dev Note:\\n/// This implementation does NOT auto-initialize the owner to `msg.sender`.\\n/// You MUST call the `_initializeOwner` in the constructor / initializer.\\n///\\n/// While the ownable portion follows\\n/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,\\n/// the nomenclature for the 2-step ownership handover may be unique to this codebase.\\nabstract contract Ownable {\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CUSTOM ERRORS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The caller is not authorized to call the function.\\n error Unauthorized();\\n\\n /// @dev The `newOwner` cannot be the zero address.\\n error NewOwnerIsZeroAddress();\\n\\n /// @dev The `pendingOwner` does not have a valid handover request.\\n error NoHandoverRequest();\\n\\n /// @dev Cannot double-initialize.\\n error AlreadyInitialized();\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* EVENTS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\\n /// This event is intentionally kept the same as OpenZeppelin's Ownable to be\\n /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),\\n /// despite it not being as lightweight as a single argument event.\\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\\n\\n /// @dev An ownership handover to `pendingOwner` has been requested.\\n event OwnershipHandoverRequested(address indexed pendingOwner);\\n\\n /// @dev The ownership handover to `pendingOwner` has been canceled.\\n event OwnershipHandoverCanceled(address indexed pendingOwner);\\n\\n /// @dev `keccak256(bytes(\\\"OwnershipTransferred(address,address)\\\"))`.\\n uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =\\n 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;\\n\\n /// @dev `keccak256(bytes(\\\"OwnershipHandoverRequested(address)\\\"))`.\\n uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =\\n 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;\\n\\n /// @dev `keccak256(bytes(\\\"OwnershipHandoverCanceled(address)\\\"))`.\\n uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =\\n 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* STORAGE */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The owner slot is given by:\\n /// `bytes32(~uint256(uint32(bytes4(keccak256(\\\"_OWNER_SLOT_NOT\\\")))))`.\\n /// It is intentionally chosen to be a high value\\n /// to avoid collision with lower slots.\\n /// The choice of manual storage layout is to enable compatibility\\n /// with both regular and upgradeable contracts.\\n bytes32 internal constant _OWNER_SLOT =\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927;\\n\\n /// The ownership handover slot of `newOwner` is given by:\\n /// ```\\n /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))\\n /// let handoverSlot := keccak256(0x00, 0x20)\\n /// ```\\n /// It stores the expiry timestamp of the two-step ownership handover.\\n uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* INTERNAL FUNCTIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Override to return true to make `_initializeOwner` prevent double-initialization.\\n function _guardInitializeOwner() internal pure virtual returns (bool guard) {}\\n\\n /// @dev Initializes the owner directly without authorization guard.\\n /// This function must be called upon initialization,\\n /// regardless of whether the contract is upgradeable or not.\\n /// This is to enable generalization to both regular and upgradeable contracts,\\n /// and to save gas in case the initial owner is not the caller.\\n /// For performance reasons, this function will not check if there\\n /// is an existing owner.\\n function _initializeOwner(address newOwner) internal virtual {\\n if (_guardInitializeOwner()) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ownerSlot := _OWNER_SLOT\\n if sload(ownerSlot) {\\n mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`.\\n revert(0x1c, 0x04)\\n }\\n // Clean the upper 96 bits.\\n newOwner := shr(96, shl(96, newOwner))\\n // Store the new value.\\n sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))\\n // Emit the {OwnershipTransferred} event.\\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\\n }\\n } else {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Clean the upper 96 bits.\\n newOwner := shr(96, shl(96, newOwner))\\n // Store the new value.\\n sstore(_OWNER_SLOT, newOwner)\\n // Emit the {OwnershipTransferred} event.\\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\\n }\\n }\\n }\\n\\n /// @dev Sets the owner directly without authorization guard.\\n function _setOwner(address newOwner) internal virtual {\\n if (_guardInitializeOwner()) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ownerSlot := _OWNER_SLOT\\n // Clean the upper 96 bits.\\n newOwner := shr(96, shl(96, newOwner))\\n // Emit the {OwnershipTransferred} event.\\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\\n // Store the new value.\\n sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))\\n }\\n } else {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ownerSlot := _OWNER_SLOT\\n // Clean the upper 96 bits.\\n newOwner := shr(96, shl(96, newOwner))\\n // Emit the {OwnershipTransferred} event.\\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\\n // Store the new value.\\n sstore(ownerSlot, newOwner)\\n }\\n }\\n }\\n\\n /// @dev Throws if the sender is not the owner.\\n function _checkOwner() internal view virtual {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // If the caller is not the stored owner, revert.\\n if iszero(eq(caller(), sload(_OWNER_SLOT))) {\\n mstore(0x00, 0x82b42900) // `Unauthorized()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n\\n /// @dev Returns how long a two-step ownership handover is valid for in seconds.\\n /// Override to return a different value if needed.\\n /// Made internal to conserve bytecode. Wrap it in a public function if needed.\\n function _ownershipHandoverValidFor() internal view virtual returns (uint64) {\\n return 48 * 3600;\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* PUBLIC UPDATE FUNCTIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Allows the owner to transfer the ownership to `newOwner`.\\n function transferOwnership(address newOwner) public payable virtual onlyOwner {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if iszero(shl(96, newOwner)) {\\n mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n _setOwner(newOwner);\\n }\\n\\n /// @dev Allows the owner to renounce their ownership.\\n function renounceOwnership() public payable virtual onlyOwner {\\n _setOwner(address(0));\\n }\\n\\n /// @dev Request a two-step ownership handover to the caller.\\n /// The request will automatically expire in 48 hours (172800 seconds) by default.\\n function requestOwnershipHandover() public payable virtual {\\n unchecked {\\n uint256 expires = block.timestamp + _ownershipHandoverValidFor();\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Compute and set the handover slot to `expires`.\\n mstore(0x0c, _HANDOVER_SLOT_SEED)\\n mstore(0x00, caller())\\n sstore(keccak256(0x0c, 0x20), expires)\\n // Emit the {OwnershipHandoverRequested} event.\\n log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())\\n }\\n }\\n }\\n\\n /// @dev Cancels the two-step ownership handover to the caller, if any.\\n function cancelOwnershipHandover() public payable virtual {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Compute and set the handover slot to 0.\\n mstore(0x0c, _HANDOVER_SLOT_SEED)\\n mstore(0x00, caller())\\n sstore(keccak256(0x0c, 0x20), 0)\\n // Emit the {OwnershipHandoverCanceled} event.\\n log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())\\n }\\n }\\n\\n /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.\\n /// Reverts if there is no existing ownership handover requested by `pendingOwner`.\\n function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Compute and set the handover slot to 0.\\n mstore(0x0c, _HANDOVER_SLOT_SEED)\\n mstore(0x00, pendingOwner)\\n let handoverSlot := keccak256(0x0c, 0x20)\\n // If the handover does not exist, or has expired.\\n if gt(timestamp(), sload(handoverSlot)) {\\n mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.\\n revert(0x1c, 0x04)\\n }\\n // Set the handover slot to 0.\\n sstore(handoverSlot, 0)\\n }\\n _setOwner(pendingOwner);\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* PUBLIC READ FUNCTIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns the owner of the contract.\\n function owner() public view virtual returns (address result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := sload(_OWNER_SLOT)\\n }\\n }\\n\\n /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.\\n function ownershipHandoverExpiresAt(address pendingOwner)\\n public\\n view\\n virtual\\n returns (uint256 result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Compute the handover slot.\\n mstore(0x0c, _HANDOVER_SLOT_SEED)\\n mstore(0x00, pendingOwner)\\n // Load the handover slot.\\n result := sload(keccak256(0x0c, 0x20))\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* MODIFIERS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Marks a function as only callable by the owner.\\n modifier onlyOwner() virtual {\\n _checkOwner();\\n _;\\n }\\n}\\n\",\"keccak256\":\"0xc208cdd9de02bbf4b5edad18b88e23a2be7ff56d2287d5649329dc7cda64b9a3\",\"license\":\"MIT\"},\"solady/src/utils/LibString.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @notice Library for converting numbers into strings and other string operations.\\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibString.sol)\\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol)\\n///\\n/// @dev Note:\\n/// For performance and bytecode compactness, most of the string operations are restricted to\\n/// byte strings (7-bit ASCII), except where otherwise specified.\\n/// Usage of byte string operations on charsets with runes spanning two or more bytes\\n/// can lead to undefined behavior.\\nlibrary LibString {\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CUSTOM ERRORS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The length of the output is too small to contain all the hex digits.\\n error HexLengthInsufficient();\\n\\n /// @dev The length of the string is more than 32 bytes.\\n error TooBigForSmallString();\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CONSTANTS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The constant returned when the `search` is not found in the string.\\n uint256 internal constant NOT_FOUND = type(uint256).max;\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* DECIMAL OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns the base 10 decimal representation of `value`.\\n function toString(uint256 value) internal pure returns (string memory str) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // The maximum value of a uint256 contains 78 digits (1 byte per digit), but\\n // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.\\n // We will need 1 word for the trailing zeros padding, 1 word for the length,\\n // and 3 words for a maximum of 78 digits.\\n str := add(mload(0x40), 0x80)\\n // Update the free memory pointer to allocate.\\n mstore(0x40, add(str, 0x20))\\n // Zeroize the slot after the string.\\n mstore(str, 0)\\n\\n // Cache the end of the memory to calculate the length later.\\n let end := str\\n\\n let w := not(0) // Tsk.\\n // We write the string from rightmost digit to leftmost digit.\\n // The following is essentially a do-while loop that also handles the zero case.\\n for { let temp := value } 1 {} {\\n str := add(str, w) // `sub(str, 1)`.\\n // Write the character to the pointer.\\n // The ASCII index of the '0' character is 48.\\n mstore8(str, add(48, mod(temp, 10)))\\n // Keep dividing `temp` until zero.\\n temp := div(temp, 10)\\n if iszero(temp) { break }\\n }\\n\\n let length := sub(end, str)\\n // Move the pointer 32 bytes leftwards to make room for the length.\\n str := sub(str, 0x20)\\n // Store the length.\\n mstore(str, length)\\n }\\n }\\n\\n /// @dev Returns the base 10 decimal representation of `value`.\\n function toString(int256 value) internal pure returns (string memory str) {\\n if (value >= 0) {\\n return toString(uint256(value));\\n }\\n unchecked {\\n str = toString(~uint256(value) + 1);\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // We still have some spare memory space on the left,\\n // as we have allocated 3 words (96 bytes) for up to 78 digits.\\n let length := mload(str) // Load the string length.\\n mstore(str, 0x2d) // Store the '-' character.\\n str := sub(str, 1) // Move back the string pointer by a byte.\\n mstore(str, add(length, 1)) // Update the string length.\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* HEXADECIMAL OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns the hexadecimal representation of `value`,\\n /// left-padded to an input length of `length` bytes.\\n /// The output is prefixed with \\\"0x\\\" encoded using 2 hexadecimal digits per byte,\\n /// giving a total length of `length * 2 + 2` bytes.\\n /// Reverts if `length` is too small for the output to contain all the digits.\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value, length);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(str, 0x3078) // Write the \\\"0x\\\" prefix.\\n str := sub(str, 2) // Move the pointer.\\n mstore(str, strLength) // Write the length.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`,\\n /// left-padded to an input length of `length` bytes.\\n /// The output is prefixed with \\\"0x\\\" encoded using 2 hexadecimal digits per byte,\\n /// giving a total length of `length * 2` bytes.\\n /// Reverts if `length` is too small for the output to contain all the digits.\\n function toHexStringNoPrefix(uint256 value, uint256 length)\\n internal\\n pure\\n returns (string memory str)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // We need 0x20 bytes for the trailing zeros padding, `length * 2` bytes\\n // for the digits, 0x02 bytes for the prefix, and 0x20 bytes for the length.\\n // We add 0x20 to the total and round down to a multiple of 0x20.\\n // (0x20 + 0x20 + 0x02 + 0x20) = 0x62.\\n str := add(mload(0x40), and(add(shl(1, length), 0x42), not(0x1f)))\\n // Allocate the memory.\\n mstore(0x40, add(str, 0x20))\\n // Zeroize the slot after the string.\\n mstore(str, 0)\\n\\n // Cache the end to calculate the length later.\\n let end := str\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n mstore(0x0f, 0x30313233343536373839616263646566)\\n\\n let start := sub(str, add(length, length))\\n let w := not(1) // Tsk.\\n let temp := value\\n // We write the string from rightmost digit to leftmost digit.\\n // The following is essentially a do-while loop that also handles the zero case.\\n for {} 1 {} {\\n str := add(str, w) // `sub(str, 2)`.\\n mstore8(add(str, 1), mload(and(temp, 15)))\\n mstore8(str, mload(and(shr(4, temp), 15)))\\n temp := shr(8, temp)\\n if iszero(xor(str, start)) { break }\\n }\\n\\n if temp {\\n mstore(0x00, 0x2194895a) // `HexLengthInsufficient()`.\\n revert(0x1c, 0x04)\\n }\\n\\n // Compute the string's length.\\n let strLength := sub(end, str)\\n // Move the pointer and write the length.\\n str := sub(str, 0x20)\\n mstore(str, strLength)\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is prefixed with \\\"0x\\\" and encoded using 2 hexadecimal digits per byte.\\n /// As address are 20 bytes long, the output will left-padded to have\\n /// a length of `20 * 2 + 2` bytes.\\n function toHexString(uint256 value) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(str, 0x3078) // Write the \\\"0x\\\" prefix.\\n str := sub(str, 2) // Move the pointer.\\n mstore(str, strLength) // Write the length.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is prefixed with \\\"0x\\\".\\n /// The output excludes leading \\\"0\\\" from the `toHexString` output.\\n /// `0x00: \\\"0x0\\\", 0x01: \\\"0x1\\\", 0x12: \\\"0x12\\\", 0x123: \\\"0x123\\\"`.\\n function toMinimalHexString(uint256 value) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present.\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(add(str, o), 0x3078) // Write the \\\"0x\\\" prefix, accounting for leading zero.\\n str := sub(add(str, o), 2) // Move the pointer, accounting for leading zero.\\n mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output excludes leading \\\"0\\\" from the `toHexStringNoPrefix` output.\\n /// `0x00: \\\"0\\\", 0x01: \\\"1\\\", 0x12: \\\"12\\\", 0x123: \\\"123\\\"`.\\n function toMinimalHexStringNoPrefix(uint256 value) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present.\\n let strLength := mload(str) // Get the length.\\n str := add(str, o) // Move the pointer, accounting for leading zero.\\n mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is encoded using 2 hexadecimal digits per byte.\\n /// As address are 20 bytes long, the output will left-padded to have\\n /// a length of `20 * 2` bytes.\\n function toHexStringNoPrefix(uint256 value) internal pure returns (string memory str) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,\\n // 0x02 bytes for the prefix, and 0x40 bytes for the digits.\\n // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x40) is 0xa0.\\n str := add(mload(0x40), 0x80)\\n // Allocate the memory.\\n mstore(0x40, add(str, 0x20))\\n // Zeroize the slot after the string.\\n mstore(str, 0)\\n\\n // Cache the end to calculate the length later.\\n let end := str\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n mstore(0x0f, 0x30313233343536373839616263646566)\\n\\n let w := not(1) // Tsk.\\n // We write the string from rightmost digit to leftmost digit.\\n // The following is essentially a do-while loop that also handles the zero case.\\n for { let temp := value } 1 {} {\\n str := add(str, w) // `sub(str, 2)`.\\n mstore8(add(str, 1), mload(and(temp, 15)))\\n mstore8(str, mload(and(shr(4, temp), 15)))\\n temp := shr(8, temp)\\n if iszero(temp) { break }\\n }\\n\\n // Compute the string's length.\\n let strLength := sub(end, str)\\n // Move the pointer and write the length.\\n str := sub(str, 0x20)\\n mstore(str, strLength)\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is prefixed with \\\"0x\\\", encoded using 2 hexadecimal digits per byte,\\n /// and the alphabets are capitalized conditionally according to\\n /// https://eips.ethereum.org/EIPS/eip-55\\n function toHexStringChecksummed(address value) internal pure returns (string memory str) {\\n str = toHexString(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...`\\n let o := add(str, 0x22)\\n let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... `\\n let t := shl(240, 136) // `0b10001000 << 240`\\n for { let i := 0 } 1 {} {\\n mstore(add(i, i), mul(t, byte(i, hashed)))\\n i := add(i, 1)\\n if eq(i, 20) { break }\\n }\\n mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask)))))\\n o := add(o, 0x20)\\n mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask)))))\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is prefixed with \\\"0x\\\" and encoded using 2 hexadecimal digits per byte.\\n function toHexString(address value) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(str, 0x3078) // Write the \\\"0x\\\" prefix.\\n str := sub(str, 2) // Move the pointer.\\n mstore(str, strLength) // Write the length.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is encoded using 2 hexadecimal digits per byte.\\n function toHexStringNoPrefix(address value) internal pure returns (string memory str) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n str := mload(0x40)\\n\\n // Allocate the memory.\\n // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,\\n // 0x02 bytes for the prefix, and 0x28 bytes for the digits.\\n // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80.\\n mstore(0x40, add(str, 0x80))\\n\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n mstore(0x0f, 0x30313233343536373839616263646566)\\n\\n str := add(str, 2)\\n mstore(str, 40)\\n\\n let o := add(str, 0x20)\\n mstore(add(o, 40), 0)\\n\\n value := shl(96, value)\\n\\n // We write the string from rightmost digit to leftmost digit.\\n // The following is essentially a do-while loop that also handles the zero case.\\n for { let i := 0 } 1 {} {\\n let p := add(o, add(i, i))\\n let temp := byte(i, value)\\n mstore8(add(p, 1), mload(and(temp, 15)))\\n mstore8(p, mload(shr(4, temp)))\\n i := add(i, 1)\\n if eq(i, 20) { break }\\n }\\n }\\n }\\n\\n /// @dev Returns the hex encoded string from the raw bytes.\\n /// The output is encoded using 2 hexadecimal digits per byte.\\n function toHexString(bytes memory raw) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(raw);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(str, 0x3078) // Write the \\\"0x\\\" prefix.\\n str := sub(str, 2) // Move the pointer.\\n mstore(str, strLength) // Write the length.\\n }\\n }\\n\\n /// @dev Returns the hex encoded string from the raw bytes.\\n /// The output is encoded using 2 hexadecimal digits per byte.\\n function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let length := mload(raw)\\n str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix.\\n mstore(str, add(length, length)) // Store the length of the output.\\n\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n mstore(0x0f, 0x30313233343536373839616263646566)\\n\\n let o := add(str, 0x20)\\n let end := add(raw, length)\\n\\n for {} iszero(eq(raw, end)) {} {\\n raw := add(raw, 1)\\n mstore8(add(o, 1), mload(and(mload(raw), 15)))\\n mstore8(o, mload(and(shr(4, mload(raw)), 15)))\\n o := add(o, 2)\\n }\\n mstore(o, 0) // Zeroize the slot after the string.\\n mstore(0x40, add(o, 0x20)) // Allocate the memory.\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* RUNE STRING OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns the number of UTF characters in the string.\\n function runeCount(string memory s) internal pure returns (uint256 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if mload(s) {\\n mstore(0x00, div(not(0), 255))\\n mstore(0x20, 0x0202020202020202020202020202020202020202020202020303030304040506)\\n let o := add(s, 0x20)\\n let end := add(o, mload(s))\\n for { result := 1 } 1 { result := add(result, 1) } {\\n o := add(o, byte(0, mload(shr(250, mload(o)))))\\n if iszero(lt(o, end)) { break }\\n }\\n }\\n }\\n }\\n\\n /// @dev Returns if this string is a 7-bit ASCII string.\\n /// (i.e. all characters codes are in [0..127])\\n function is7BitASCII(string memory s) internal pure returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let mask := shl(7, div(not(0), 255))\\n result := 1\\n let n := mload(s)\\n if n {\\n let o := add(s, 0x20)\\n let end := add(o, n)\\n let last := mload(end)\\n mstore(end, 0)\\n for {} 1 {} {\\n if and(mask, mload(o)) {\\n result := 0\\n break\\n }\\n o := add(o, 0x20)\\n if iszero(lt(o, end)) { break }\\n }\\n mstore(end, last)\\n }\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* BYTE STRING OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n // For performance and bytecode compactness, byte string operations are restricted\\n // to 7-bit ASCII strings. All offsets are byte offsets, not UTF character offsets.\\n // Usage of byte string operations on charsets with runes spanning two or more bytes\\n // can lead to undefined behavior.\\n\\n /// @dev Returns `subject` all occurrences of `search` replaced with `replacement`.\\n function replace(string memory subject, string memory search, string memory replacement)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let subjectLength := mload(subject)\\n let searchLength := mload(search)\\n let replacementLength := mload(replacement)\\n\\n subject := add(subject, 0x20)\\n search := add(search, 0x20)\\n replacement := add(replacement, 0x20)\\n result := add(mload(0x40), 0x20)\\n\\n let subjectEnd := add(subject, subjectLength)\\n if iszero(gt(searchLength, subjectLength)) {\\n let subjectSearchEnd := add(sub(subjectEnd, searchLength), 1)\\n let h := 0\\n if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) }\\n let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\\n let s := mload(search)\\n for {} 1 {} {\\n let t := mload(subject)\\n // Whether the first `searchLength % 32` bytes of\\n // `subject` and `search` matches.\\n if iszero(shr(m, xor(t, s))) {\\n if h {\\n if iszero(eq(keccak256(subject, searchLength), h)) {\\n mstore(result, t)\\n result := add(result, 1)\\n subject := add(subject, 1)\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n continue\\n }\\n }\\n // Copy the `replacement` one word at a time.\\n for { let o := 0 } 1 {} {\\n mstore(add(result, o), mload(add(replacement, o)))\\n o := add(o, 0x20)\\n if iszero(lt(o, replacementLength)) { break }\\n }\\n result := add(result, replacementLength)\\n subject := add(subject, searchLength)\\n if searchLength {\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n continue\\n }\\n }\\n mstore(result, t)\\n result := add(result, 1)\\n subject := add(subject, 1)\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n }\\n }\\n\\n let resultRemainder := result\\n result := add(mload(0x40), 0x20)\\n let k := add(sub(resultRemainder, result), sub(subjectEnd, subject))\\n // Copy the rest of the string one word at a time.\\n for {} lt(subject, subjectEnd) {} {\\n mstore(resultRemainder, mload(subject))\\n resultRemainder := add(resultRemainder, 0x20)\\n subject := add(subject, 0x20)\\n }\\n result := sub(result, 0x20)\\n let last := add(add(result, 0x20), k) // Zeroize the slot after the string.\\n mstore(last, 0)\\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\\n mstore(result, k) // Store the length.\\n }\\n }\\n\\n /// @dev Returns the byte index of the first location of `search` in `subject`,\\n /// searching from left to right, starting from `from`.\\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\\n function indexOf(string memory subject, string memory search, uint256 from)\\n internal\\n pure\\n returns (uint256 result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n for { let subjectLength := mload(subject) } 1 {} {\\n if iszero(mload(search)) {\\n if iszero(gt(from, subjectLength)) {\\n result := from\\n break\\n }\\n result := subjectLength\\n break\\n }\\n let searchLength := mload(search)\\n let subjectStart := add(subject, 0x20)\\n\\n result := not(0) // Initialize to `NOT_FOUND`.\\n\\n subject := add(subjectStart, from)\\n let end := add(sub(add(subjectStart, subjectLength), searchLength), 1)\\n\\n let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\\n let s := mload(add(search, 0x20))\\n\\n if iszero(and(lt(subject, end), lt(from, subjectLength))) { break }\\n\\n if iszero(lt(searchLength, 0x20)) {\\n for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} {\\n if iszero(shr(m, xor(mload(subject), s))) {\\n if eq(keccak256(subject, searchLength), h) {\\n result := sub(subject, subjectStart)\\n break\\n }\\n }\\n subject := add(subject, 1)\\n if iszero(lt(subject, end)) { break }\\n }\\n break\\n }\\n for {} 1 {} {\\n if iszero(shr(m, xor(mload(subject), s))) {\\n result := sub(subject, subjectStart)\\n break\\n }\\n subject := add(subject, 1)\\n if iszero(lt(subject, end)) { break }\\n }\\n break\\n }\\n }\\n }\\n\\n /// @dev Returns the byte index of the first location of `search` in `subject`,\\n /// searching from left to right.\\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\\n function indexOf(string memory subject, string memory search)\\n internal\\n pure\\n returns (uint256 result)\\n {\\n result = indexOf(subject, search, 0);\\n }\\n\\n /// @dev Returns the byte index of the first location of `search` in `subject`,\\n /// searching from right to left, starting from `from`.\\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\\n function lastIndexOf(string memory subject, string memory search, uint256 from)\\n internal\\n pure\\n returns (uint256 result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n for {} 1 {} {\\n result := not(0) // Initialize to `NOT_FOUND`.\\n let searchLength := mload(search)\\n if gt(searchLength, mload(subject)) { break }\\n let w := result\\n\\n let fromMax := sub(mload(subject), searchLength)\\n if iszero(gt(fromMax, from)) { from := fromMax }\\n\\n let end := add(add(subject, 0x20), w)\\n subject := add(add(subject, 0x20), from)\\n if iszero(gt(subject, end)) { break }\\n // As this function is not too often used,\\n // we shall simply use keccak256 for smaller bytecode size.\\n for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} {\\n if eq(keccak256(subject, searchLength), h) {\\n result := sub(subject, add(end, 1))\\n break\\n }\\n subject := add(subject, w) // `sub(subject, 1)`.\\n if iszero(gt(subject, end)) { break }\\n }\\n break\\n }\\n }\\n }\\n\\n /// @dev Returns the byte index of the first location of `search` in `subject`,\\n /// searching from right to left.\\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\\n function lastIndexOf(string memory subject, string memory search)\\n internal\\n pure\\n returns (uint256 result)\\n {\\n result = lastIndexOf(subject, search, uint256(int256(-1)));\\n }\\n\\n /// @dev Returns true if `search` is found in `subject`, false otherwise.\\n function contains(string memory subject, string memory search) internal pure returns (bool) {\\n return indexOf(subject, search) != NOT_FOUND;\\n }\\n\\n /// @dev Returns whether `subject` starts with `search`.\\n function startsWith(string memory subject, string memory search)\\n internal\\n pure\\n returns (bool result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let searchLength := mload(search)\\n // Just using keccak256 directly is actually cheaper.\\n // forgefmt: disable-next-item\\n result := and(\\n iszero(gt(searchLength, mload(subject))),\\n eq(\\n keccak256(add(subject, 0x20), searchLength),\\n keccak256(add(search, 0x20), searchLength)\\n )\\n )\\n }\\n }\\n\\n /// @dev Returns whether `subject` ends with `search`.\\n function endsWith(string memory subject, string memory search)\\n internal\\n pure\\n returns (bool result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let searchLength := mload(search)\\n let subjectLength := mload(subject)\\n // Whether `search` is not longer than `subject`.\\n let withinRange := iszero(gt(searchLength, subjectLength))\\n // Just using keccak256 directly is actually cheaper.\\n // forgefmt: disable-next-item\\n result := and(\\n withinRange,\\n eq(\\n keccak256(\\n // `subject + 0x20 + max(subjectLength - searchLength, 0)`.\\n add(add(subject, 0x20), mul(withinRange, sub(subjectLength, searchLength))),\\n searchLength\\n ),\\n keccak256(add(search, 0x20), searchLength)\\n )\\n )\\n }\\n }\\n\\n /// @dev Returns `subject` repeated `times`.\\n function repeat(string memory subject, uint256 times)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let subjectLength := mload(subject)\\n if iszero(or(iszero(times), iszero(subjectLength))) {\\n subject := add(subject, 0x20)\\n result := mload(0x40)\\n let output := add(result, 0x20)\\n for {} 1 {} {\\n // Copy the `subject` one word at a time.\\n for { let o := 0 } 1 {} {\\n mstore(add(output, o), mload(add(subject, o)))\\n o := add(o, 0x20)\\n if iszero(lt(o, subjectLength)) { break }\\n }\\n output := add(output, subjectLength)\\n times := sub(times, 1)\\n if iszero(times) { break }\\n }\\n mstore(output, 0) // Zeroize the slot after the string.\\n let resultLength := sub(output, add(result, 0x20))\\n mstore(result, resultLength) // Store the length.\\n // Allocate the memory.\\n mstore(0x40, add(result, add(resultLength, 0x20)))\\n }\\n }\\n }\\n\\n /// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).\\n /// `start` and `end` are byte offsets.\\n function slice(string memory subject, uint256 start, uint256 end)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let subjectLength := mload(subject)\\n if iszero(gt(subjectLength, end)) { end := subjectLength }\\n if iszero(gt(subjectLength, start)) { start := subjectLength }\\n if lt(start, end) {\\n result := mload(0x40)\\n let resultLength := sub(end, start)\\n mstore(result, resultLength)\\n subject := add(subject, start)\\n let w := not(0x1f)\\n // Copy the `subject` one word at a time, backwards.\\n for { let o := and(add(resultLength, 0x1f), w) } 1 {} {\\n mstore(add(result, o), mload(add(subject, o)))\\n o := add(o, w) // `sub(o, 0x20)`.\\n if iszero(o) { break }\\n }\\n // Zeroize the slot after the string.\\n mstore(add(add(result, 0x20), resultLength), 0)\\n // Allocate memory for the length and the bytes,\\n // rounded up to a multiple of 32.\\n mstore(0x40, add(result, and(add(resultLength, 0x3f), w)))\\n }\\n }\\n }\\n\\n /// @dev Returns a copy of `subject` sliced from `start` to the end of the string.\\n /// `start` is a byte offset.\\n function slice(string memory subject, uint256 start)\\n internal\\n pure\\n returns (string memory result)\\n {\\n result = slice(subject, start, uint256(int256(-1)));\\n }\\n\\n /// @dev Returns all the indices of `search` in `subject`.\\n /// The indices are byte offsets.\\n function indicesOf(string memory subject, string memory search)\\n internal\\n pure\\n returns (uint256[] memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let subjectLength := mload(subject)\\n let searchLength := mload(search)\\n\\n if iszero(gt(searchLength, subjectLength)) {\\n subject := add(subject, 0x20)\\n search := add(search, 0x20)\\n result := add(mload(0x40), 0x20)\\n\\n let subjectStart := subject\\n let subjectSearchEnd := add(sub(add(subject, subjectLength), searchLength), 1)\\n let h := 0\\n if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) }\\n let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\\n let s := mload(search)\\n for {} 1 {} {\\n let t := mload(subject)\\n // Whether the first `searchLength % 32` bytes of\\n // `subject` and `search` matches.\\n if iszero(shr(m, xor(t, s))) {\\n if h {\\n if iszero(eq(keccak256(subject, searchLength), h)) {\\n subject := add(subject, 1)\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n continue\\n }\\n }\\n // Append to `result`.\\n mstore(result, sub(subject, subjectStart))\\n result := add(result, 0x20)\\n // Advance `subject` by `searchLength`.\\n subject := add(subject, searchLength)\\n if searchLength {\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n continue\\n }\\n }\\n subject := add(subject, 1)\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n }\\n let resultEnd := result\\n // Assign `result` to the free memory pointer.\\n result := mload(0x40)\\n // Store the length of `result`.\\n mstore(result, shr(5, sub(resultEnd, add(result, 0x20))))\\n // Allocate memory for result.\\n // We allocate one more word, so this array can be recycled for {split}.\\n mstore(0x40, add(resultEnd, 0x20))\\n }\\n }\\n }\\n\\n /// @dev Returns a arrays of strings based on the `delimiter` inside of the `subject` string.\\n function split(string memory subject, string memory delimiter)\\n internal\\n pure\\n returns (string[] memory result)\\n {\\n uint256[] memory indices = indicesOf(subject, delimiter);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let w := not(0x1f)\\n let indexPtr := add(indices, 0x20)\\n let indicesEnd := add(indexPtr, shl(5, add(mload(indices), 1)))\\n mstore(add(indicesEnd, w), mload(subject))\\n mstore(indices, add(mload(indices), 1))\\n let prevIndex := 0\\n for {} 1 {} {\\n let index := mload(indexPtr)\\n mstore(indexPtr, 0x60)\\n if iszero(eq(index, prevIndex)) {\\n let element := mload(0x40)\\n let elementLength := sub(index, prevIndex)\\n mstore(element, elementLength)\\n // Copy the `subject` one word at a time, backwards.\\n for { let o := and(add(elementLength, 0x1f), w) } 1 {} {\\n mstore(add(element, o), mload(add(add(subject, prevIndex), o)))\\n o := add(o, w) // `sub(o, 0x20)`.\\n if iszero(o) { break }\\n }\\n // Zeroize the slot after the string.\\n mstore(add(add(element, 0x20), elementLength), 0)\\n // Allocate memory for the length and the bytes,\\n // rounded up to a multiple of 32.\\n mstore(0x40, add(element, and(add(elementLength, 0x3f), w)))\\n // Store the `element` into the array.\\n mstore(indexPtr, element)\\n }\\n prevIndex := add(index, mload(delimiter))\\n indexPtr := add(indexPtr, 0x20)\\n if iszero(lt(indexPtr, indicesEnd)) { break }\\n }\\n result := indices\\n if iszero(mload(delimiter)) {\\n result := add(indices, 0x20)\\n mstore(result, sub(mload(indices), 2))\\n }\\n }\\n }\\n\\n /// @dev Returns a concatenated string of `a` and `b`.\\n /// Cheaper than `string.concat()` and does not de-align the free memory pointer.\\n function concat(string memory a, string memory b)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let w := not(0x1f)\\n result := mload(0x40)\\n let aLength := mload(a)\\n // Copy `a` one word at a time, backwards.\\n for { let o := and(add(aLength, 0x20), w) } 1 {} {\\n mstore(add(result, o), mload(add(a, o)))\\n o := add(o, w) // `sub(o, 0x20)`.\\n if iszero(o) { break }\\n }\\n let bLength := mload(b)\\n let output := add(result, aLength)\\n // Copy `b` one word at a time, backwards.\\n for { let o := and(add(bLength, 0x20), w) } 1 {} {\\n mstore(add(output, o), mload(add(b, o)))\\n o := add(o, w) // `sub(o, 0x20)`.\\n if iszero(o) { break }\\n }\\n let totalLength := add(aLength, bLength)\\n let last := add(add(result, 0x20), totalLength)\\n // Zeroize the slot after the string.\\n mstore(last, 0)\\n // Stores the length.\\n mstore(result, totalLength)\\n // Allocate memory for the length and the bytes,\\n // rounded up to a multiple of 32.\\n mstore(0x40, and(add(last, 0x1f), w))\\n }\\n }\\n\\n /// @dev Returns a copy of the string in either lowercase or UPPERCASE.\\n /// WARNING! This function is only compatible with 7-bit ASCII strings.\\n function toCase(string memory subject, bool toUpper)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let length := mload(subject)\\n if length {\\n result := add(mload(0x40), 0x20)\\n subject := add(subject, 1)\\n let flags := shl(add(70, shl(5, toUpper)), 0x3ffffff)\\n let w := not(0)\\n for { let o := length } 1 {} {\\n o := add(o, w)\\n let b := and(0xff, mload(add(subject, o)))\\n mstore8(add(result, o), xor(b, and(shr(b, flags), 0x20)))\\n if iszero(o) { break }\\n }\\n result := mload(0x40)\\n mstore(result, length) // Store the length.\\n let last := add(add(result, 0x20), length)\\n mstore(last, 0) // Zeroize the slot after the string.\\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\\n }\\n }\\n }\\n\\n /// @dev Returns a string from a small bytes32 string.\\n /// `s` must be null-terminated, or behavior will be undefined.\\n function fromSmallString(bytes32 s) internal pure returns (string memory result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := mload(0x40)\\n let n := 0\\n for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\\\\0'.\\n mstore(result, n)\\n let o := add(result, 0x20)\\n mstore(o, s)\\n mstore(add(o, n), 0)\\n mstore(0x40, add(result, 0x40))\\n }\\n }\\n\\n /// @dev Returns the small string, with all bytes after the first null byte zeroized.\\n function normalizeSmallString(bytes32 s) internal pure returns (bytes32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n for {} byte(result, s) { result := add(result, 1) } {} // Scan for '\\\\0'.\\n mstore(0x00, s)\\n mstore(result, 0x00)\\n result := mload(0x00)\\n }\\n }\\n\\n /// @dev Returns the string as a normalized null-terminated small string.\\n function toSmallString(string memory s) internal pure returns (bytes32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := mload(s)\\n if iszero(lt(result, 33)) {\\n mstore(0x00, 0xec92f9a3) // `TooBigForSmallString()`.\\n revert(0x1c, 0x04)\\n }\\n result := shl(shl(3, sub(32, result)), mload(add(s, result)))\\n }\\n }\\n\\n /// @dev Returns a lowercased copy of the string.\\n /// WARNING! This function is only compatible with 7-bit ASCII strings.\\n function lower(string memory subject) internal pure returns (string memory result) {\\n result = toCase(subject, false);\\n }\\n\\n /// @dev Returns an UPPERCASED copy of the string.\\n /// WARNING! This function is only compatible with 7-bit ASCII strings.\\n function upper(string memory subject) internal pure returns (string memory result) {\\n result = toCase(subject, true);\\n }\\n\\n /// @dev Escapes the string to be used within HTML tags.\\n function escapeHTML(string memory s) internal pure returns (string memory result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let end := add(s, mload(s))\\n result := add(mload(0x40), 0x20)\\n // Store the bytes of the packed offsets and strides into the scratch space.\\n // `packed = (stride << 5) | offset`. Max offset is 20. Max stride is 6.\\n mstore(0x1f, 0x900094)\\n mstore(0x08, 0xc0000000a6ab)\\n // Store \\\""&'<>\\\" into the scratch space.\\n mstore(0x00, shl(64, 0x2671756f743b26616d703b262333393b266c743b2667743b))\\n for {} iszero(eq(s, end)) {} {\\n s := add(s, 1)\\n let c := and(mload(s), 0xff)\\n // Not in `[\\\"\\\\\\\"\\\",\\\"'\\\",\\\"&\\\",\\\"<\\\",\\\">\\\"]`.\\n if iszero(and(shl(c, 1), 0x500000c400000000)) {\\n mstore8(result, c)\\n result := add(result, 1)\\n continue\\n }\\n let t := shr(248, mload(c))\\n mstore(result, mload(and(t, 0x1f)))\\n result := add(result, shr(5, t))\\n }\\n let last := result\\n mstore(last, 0) // Zeroize the slot after the string.\\n result := mload(0x40)\\n mstore(result, sub(last, add(result, 0x20))) // Store the length.\\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\\n }\\n }\\n\\n /// @dev Escapes the string to be used within double-quotes in a JSON.\\n /// If `addDoubleQuotes` is true, the result will be enclosed in double-quotes.\\n function escapeJSON(string memory s, bool addDoubleQuotes)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let end := add(s, mload(s))\\n result := add(mload(0x40), 0x20)\\n if addDoubleQuotes {\\n mstore8(result, 34)\\n result := add(1, result)\\n }\\n // Store \\\"\\\\\\\\u0000\\\" in scratch space.\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n // Also, store `{0x08:\\\"b\\\", 0x09:\\\"t\\\", 0x0a:\\\"n\\\", 0x0c:\\\"f\\\", 0x0d:\\\"r\\\"}`.\\n // into the scratch space.\\n mstore(0x15, 0x5c75303030303031323334353637383961626364656662746e006672)\\n // Bitmask for detecting `[\\\"\\\\\\\"\\\",\\\"\\\\\\\\\\\"]`.\\n let e := or(shl(0x22, 1), shl(0x5c, 1))\\n for {} iszero(eq(s, end)) {} {\\n s := add(s, 1)\\n let c := and(mload(s), 0xff)\\n if iszero(lt(c, 0x20)) {\\n if iszero(and(shl(c, 1), e)) {\\n // Not in `[\\\"\\\\\\\"\\\",\\\"\\\\\\\\\\\"]`.\\n mstore8(result, c)\\n result := add(result, 1)\\n continue\\n }\\n mstore8(result, 0x5c) // \\\"\\\\\\\\\\\".\\n mstore8(add(result, 1), c)\\n result := add(result, 2)\\n continue\\n }\\n if iszero(and(shl(c, 1), 0x3700)) {\\n // Not in `[\\\"\\\\b\\\",\\\"\\\\t\\\",\\\"\\\\n\\\",\\\"\\\\f\\\",\\\"\\\\d\\\"]`.\\n mstore8(0x1d, mload(shr(4, c))) // Hex value.\\n mstore8(0x1e, mload(and(c, 15))) // Hex value.\\n mstore(result, mload(0x19)) // \\\"\\\\\\\\u00XX\\\".\\n result := add(result, 6)\\n continue\\n }\\n mstore8(result, 0x5c) // \\\"\\\\\\\\\\\".\\n mstore8(add(result, 1), mload(add(c, 8)))\\n result := add(result, 2)\\n }\\n if addDoubleQuotes {\\n mstore8(result, 34)\\n result := add(1, result)\\n }\\n let last := result\\n mstore(last, 0) // Zeroize the slot after the string.\\n result := mload(0x40)\\n mstore(result, sub(last, add(result, 0x20))) // Store the length.\\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\\n }\\n }\\n\\n /// @dev Escapes the string to be used within double-quotes in a JSON.\\n function escapeJSON(string memory s) internal pure returns (string memory result) {\\n result = escapeJSON(s, false);\\n }\\n\\n /// @dev Returns whether `a` equals `b`.\\n function eq(string memory a, string memory b) internal pure returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := eq(keccak256(add(a, 0x20), mload(a)), keccak256(add(b, 0x20), mload(b)))\\n }\\n }\\n\\n /// @dev Returns whether `a` equals `b`, where `b` is a null-terminated small string.\\n function eqs(string memory a, bytes32 b) internal pure returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // These should be evaluated on compile time, as far as possible.\\n let m := not(shl(7, div(not(iszero(b)), 255))) // `0x7f7f ...`.\\n let x := not(or(m, or(b, add(m, and(b, m)))))\\n let r := shl(7, iszero(iszero(shr(128, x))))\\n r := or(r, shl(6, iszero(iszero(shr(64, shr(r, x))))))\\n r := or(r, shl(5, lt(0xffffffff, shr(r, x))))\\n r := or(r, shl(4, lt(0xffff, shr(r, x))))\\n r := or(r, shl(3, lt(0xff, shr(r, x))))\\n // forgefmt: disable-next-item\\n result := gt(eq(mload(a), add(iszero(x), xor(31, shr(3, r)))),\\n xor(shr(add(8, r), b), shr(add(8, r), mload(add(a, 0x20)))))\\n }\\n }\\n\\n /// @dev Packs a single string with its length into a single word.\\n /// Returns `bytes32(0)` if the length is zero or greater than 31.\\n function packOne(string memory a) internal pure returns (bytes32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // We don't need to zero right pad the string,\\n // since this is our own custom non-standard packing scheme.\\n result :=\\n mul(\\n // Load the length and the bytes.\\n mload(add(a, 0x1f)),\\n // `length != 0 && length < 32`. Abuses underflow.\\n // Assumes that the length is valid and within the block gas limit.\\n lt(sub(mload(a), 1), 0x1f)\\n )\\n }\\n }\\n\\n /// @dev Unpacks a string packed using {packOne}.\\n /// Returns the empty string if `packed` is `bytes32(0)`.\\n /// If `packed` is not an output of {packOne}, the output behavior is undefined.\\n function unpackOne(bytes32 packed) internal pure returns (string memory result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Grab the free memory pointer.\\n result := mload(0x40)\\n // Allocate 2 words (1 for the length, 1 for the bytes).\\n mstore(0x40, add(result, 0x40))\\n // Zeroize the length slot.\\n mstore(result, 0)\\n // Store the length and bytes.\\n mstore(add(result, 0x1f), packed)\\n // Right pad with zeroes.\\n mstore(add(add(result, 0x20), mload(result)), 0)\\n }\\n }\\n\\n /// @dev Packs two strings with their lengths into a single word.\\n /// Returns `bytes32(0)` if combined length is zero or greater than 30.\\n function packTwo(string memory a, string memory b) internal pure returns (bytes32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let aLength := mload(a)\\n // We don't need to zero right pad the strings,\\n // since this is our own custom non-standard packing scheme.\\n result :=\\n mul(\\n // Load the length and the bytes of `a` and `b`.\\n or(\\n shl(shl(3, sub(0x1f, aLength)), mload(add(a, aLength))),\\n mload(sub(add(b, 0x1e), aLength))\\n ),\\n // `totalLength != 0 && totalLength < 31`. Abuses underflow.\\n // Assumes that the lengths are valid and within the block gas limit.\\n lt(sub(add(aLength, mload(b)), 1), 0x1e)\\n )\\n }\\n }\\n\\n /// @dev Unpacks strings packed using {packTwo}.\\n /// Returns the empty strings if `packed` is `bytes32(0)`.\\n /// If `packed` is not an output of {packTwo}, the output behavior is undefined.\\n function unpackTwo(bytes32 packed)\\n internal\\n pure\\n returns (string memory resultA, string memory resultB)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Grab the free memory pointer.\\n resultA := mload(0x40)\\n resultB := add(resultA, 0x40)\\n // Allocate 2 words for each string (1 for the length, 1 for the byte). Total 4 words.\\n mstore(0x40, add(resultB, 0x40))\\n // Zeroize the length slots.\\n mstore(resultA, 0)\\n mstore(resultB, 0)\\n // Store the lengths and bytes.\\n mstore(add(resultA, 0x1f), packed)\\n mstore(add(resultB, 0x1f), mload(add(add(resultA, 0x20), mload(resultA))))\\n // Right pad with zeroes.\\n mstore(add(add(resultA, 0x20), mload(resultA)), 0)\\n mstore(add(add(resultB, 0x20), mload(resultB)), 0)\\n }\\n }\\n\\n /// @dev Directly returns `a` without copying.\\n function directReturn(string memory a) internal pure {\\n assembly {\\n // Assumes that the string does not start from the scratch space.\\n let retStart := sub(a, 0x20)\\n let retSize := add(mload(a), 0x40)\\n // Right pad with zeroes. Just in case the string is produced\\n // by a method that doesn't zero right pad.\\n mstore(add(retStart, retSize), 0)\\n // Store the return offset.\\n mstore(retStart, 0x20)\\n // End the transaction, returning the string.\\n return(retStart, retSize)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4fc555fe1ceb29162b143ce1564ac936099071c853065efc289f6c30c712f125\",\"license\":\"MIT\"},\"solady/src/utils/MerkleProofLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @notice Gas optimized verification of proof of inclusion for a leaf in a Merkle tree.\\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/MerkleProofLib.sol)\\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol)\\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol)\\nlibrary MerkleProofLib {\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* MERKLE PROOF VERIFICATION OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`.\\n function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf)\\n internal\\n pure\\n returns (bool isValid)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if mload(proof) {\\n // Initialize `offset` to the offset of `proof` elements in memory.\\n let offset := add(proof, 0x20)\\n // Left shift by 5 is equivalent to multiplying by 0x20.\\n let end := add(offset, shl(5, mload(proof)))\\n // Iterate over proof elements to compute root hash.\\n for {} 1 {} {\\n // Slot of `leaf` in scratch space.\\n // If the condition is true: 0x20, otherwise: 0x00.\\n let scratch := shl(5, gt(leaf, mload(offset)))\\n // Store elements to hash contiguously in scratch space.\\n // Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes.\\n mstore(scratch, leaf)\\n mstore(xor(scratch, 0x20), mload(offset))\\n // Reuse `leaf` to store the hash to reduce stack operations.\\n leaf := keccak256(0x00, 0x40)\\n offset := add(offset, 0x20)\\n if iszero(lt(offset, end)) { break }\\n }\\n }\\n isValid := eq(leaf, root)\\n }\\n }\\n\\n /// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`.\\n function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf)\\n internal\\n pure\\n returns (bool isValid)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if proof.length {\\n // Left shift by 5 is equivalent to multiplying by 0x20.\\n let end := add(proof.offset, shl(5, proof.length))\\n // Initialize `offset` to the offset of `proof` in the calldata.\\n let offset := proof.offset\\n // Iterate over proof elements to compute root hash.\\n for {} 1 {} {\\n // Slot of `leaf` in scratch space.\\n // If the condition is true: 0x20, otherwise: 0x00.\\n let scratch := shl(5, gt(leaf, calldataload(offset)))\\n // Store elements to hash contiguously in scratch space.\\n // Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes.\\n mstore(scratch, leaf)\\n mstore(xor(scratch, 0x20), calldataload(offset))\\n // Reuse `leaf` to store the hash to reduce stack operations.\\n leaf := keccak256(0x00, 0x40)\\n offset := add(offset, 0x20)\\n if iszero(lt(offset, end)) { break }\\n }\\n }\\n isValid := eq(leaf, root)\\n }\\n }\\n\\n /// @dev Returns whether all `leaves` exist in the Merkle tree with `root`,\\n /// given `proof` and `flags`.\\n ///\\n /// Note:\\n /// - Breaking the invariant `flags.length == (leaves.length - 1) + proof.length`\\n /// will always return false.\\n /// - The sum of the lengths of `proof` and `leaves` must never overflow.\\n /// - Any non-zero word in the `flags` array is treated as true.\\n /// - The memory offset of `proof` must be non-zero\\n /// (i.e. `proof` is not pointing to the scratch space).\\n function verifyMultiProof(\\n bytes32[] memory proof,\\n bytes32 root,\\n bytes32[] memory leaves,\\n bool[] memory flags\\n ) internal pure returns (bool isValid) {\\n // Rebuilds the root by consuming and producing values on a queue.\\n // The queue starts with the `leaves` array, and goes into a `hashes` array.\\n // After the process, the last element on the queue is verified\\n // to be equal to the `root`.\\n //\\n // The `flags` array denotes whether the sibling\\n // should be popped from the queue (`flag == true`), or\\n // should be popped from the `proof` (`flag == false`).\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Cache the lengths of the arrays.\\n let leavesLength := mload(leaves)\\n let proofLength := mload(proof)\\n let flagsLength := mload(flags)\\n\\n // Advance the pointers of the arrays to point to the data.\\n leaves := add(0x20, leaves)\\n proof := add(0x20, proof)\\n flags := add(0x20, flags)\\n\\n // If the number of flags is correct.\\n for {} eq(add(leavesLength, proofLength), add(flagsLength, 1)) {} {\\n // For the case where `proof.length + leaves.length == 1`.\\n if iszero(flagsLength) {\\n // `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`.\\n isValid := eq(mload(xor(leaves, mul(xor(proof, leaves), proofLength))), root)\\n break\\n }\\n\\n // The required final proof offset if `flagsLength` is not zero, otherwise zero.\\n let proofEnd := add(proof, shl(5, proofLength))\\n // We can use the free memory space for the queue.\\n // We don't need to allocate, since the queue is temporary.\\n let hashesFront := mload(0x40)\\n // Copy the leaves into the hashes.\\n // Sometimes, a little memory expansion costs less than branching.\\n // Should cost less, even with a high free memory offset of 0x7d00.\\n leavesLength := shl(5, leavesLength)\\n for { let i := 0 } iszero(eq(i, leavesLength)) { i := add(i, 0x20) } {\\n mstore(add(hashesFront, i), mload(add(leaves, i)))\\n }\\n // Compute the back of the hashes.\\n let hashesBack := add(hashesFront, leavesLength)\\n // This is the end of the memory for the queue.\\n // We recycle `flagsLength` to save on stack variables (sometimes save gas).\\n flagsLength := add(hashesBack, shl(5, flagsLength))\\n\\n for {} 1 {} {\\n // Pop from `hashes`.\\n let a := mload(hashesFront)\\n // Pop from `hashes`.\\n let b := mload(add(hashesFront, 0x20))\\n hashesFront := add(hashesFront, 0x40)\\n\\n // If the flag is false, load the next proof,\\n // else, pops from the queue.\\n if iszero(mload(flags)) {\\n // Loads the next proof.\\n b := mload(proof)\\n proof := add(proof, 0x20)\\n // Unpop from `hashes`.\\n hashesFront := sub(hashesFront, 0x20)\\n }\\n\\n // Advance to the next flag.\\n flags := add(flags, 0x20)\\n\\n // Slot of `a` in scratch space.\\n // If the condition is true: 0x20, otherwise: 0x00.\\n let scratch := shl(5, gt(a, b))\\n // Hash the scratch space and push the result onto the queue.\\n mstore(scratch, a)\\n mstore(xor(scratch, 0x20), b)\\n mstore(hashesBack, keccak256(0x00, 0x40))\\n hashesBack := add(hashesBack, 0x20)\\n if iszero(lt(hashesBack, flagsLength)) { break }\\n }\\n isValid :=\\n and(\\n // Checks if the last value in the queue is same as the root.\\n eq(mload(sub(hashesBack, 0x20)), root),\\n // And whether all the proofs are used, if required.\\n eq(proofEnd, proof)\\n )\\n break\\n }\\n }\\n }\\n\\n /// @dev Returns whether all `leaves` exist in the Merkle tree with `root`,\\n /// given `proof` and `flags`.\\n ///\\n /// Note:\\n /// - Breaking the invariant `flags.length == (leaves.length - 1) + proof.length`\\n /// will always return false.\\n /// - Any non-zero word in the `flags` array is treated as true.\\n /// - The calldata offset of `proof` must be non-zero\\n /// (i.e. `proof` is from a regular Solidity function with a 4-byte selector).\\n function verifyMultiProofCalldata(\\n bytes32[] calldata proof,\\n bytes32 root,\\n bytes32[] calldata leaves,\\n bool[] calldata flags\\n ) internal pure returns (bool isValid) {\\n // Rebuilds the root by consuming and producing values on a queue.\\n // The queue starts with the `leaves` array, and goes into a `hashes` array.\\n // After the process, the last element on the queue is verified\\n // to be equal to the `root`.\\n //\\n // The `flags` array denotes whether the sibling\\n // should be popped from the queue (`flag == true`), or\\n // should be popped from the `proof` (`flag == false`).\\n /// @solidity memory-safe-assembly\\n assembly {\\n // If the number of flags is correct.\\n for {} eq(add(leaves.length, proof.length), add(flags.length, 1)) {} {\\n // For the case where `proof.length + leaves.length == 1`.\\n if iszero(flags.length) {\\n // `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`.\\n // forgefmt: disable-next-item\\n isValid := eq(\\n calldataload(\\n xor(leaves.offset, mul(xor(proof.offset, leaves.offset), proof.length))\\n ),\\n root\\n )\\n break\\n }\\n\\n // The required final proof offset if `flagsLength` is not zero, otherwise zero.\\n let proofEnd := add(proof.offset, shl(5, proof.length))\\n // We can use the free memory space for the queue.\\n // We don't need to allocate, since the queue is temporary.\\n let hashesFront := mload(0x40)\\n // Copy the leaves into the hashes.\\n // Sometimes, a little memory expansion costs less than branching.\\n // Should cost less, even with a high free memory offset of 0x7d00.\\n calldatacopy(hashesFront, leaves.offset, shl(5, leaves.length))\\n // Compute the back of the hashes.\\n let hashesBack := add(hashesFront, shl(5, leaves.length))\\n // This is the end of the memory for the queue.\\n // We recycle `flagsLength` to save on stack variables (sometimes save gas).\\n flags.length := add(hashesBack, shl(5, flags.length))\\n\\n // We don't need to make a copy of `proof.offset` or `flags.offset`,\\n // as they are pass-by-value (this trick may not always save gas).\\n\\n for {} 1 {} {\\n // Pop from `hashes`.\\n let a := mload(hashesFront)\\n // Pop from `hashes`.\\n let b := mload(add(hashesFront, 0x20))\\n hashesFront := add(hashesFront, 0x40)\\n\\n // If the flag is false, load the next proof,\\n // else, pops from the queue.\\n if iszero(calldataload(flags.offset)) {\\n // Loads the next proof.\\n b := calldataload(proof.offset)\\n proof.offset := add(proof.offset, 0x20)\\n // Unpop from `hashes`.\\n hashesFront := sub(hashesFront, 0x20)\\n }\\n\\n // Advance to the next flag offset.\\n flags.offset := add(flags.offset, 0x20)\\n\\n // Slot of `a` in scratch space.\\n // If the condition is true: 0x20, otherwise: 0x00.\\n let scratch := shl(5, gt(a, b))\\n // Hash the scratch space and push the result onto the queue.\\n mstore(scratch, a)\\n mstore(xor(scratch, 0x20), b)\\n mstore(hashesBack, keccak256(0x00, 0x40))\\n hashesBack := add(hashesBack, 0x20)\\n if iszero(lt(hashesBack, flags.length)) { break }\\n }\\n isValid :=\\n and(\\n // Checks if the last value in the queue is same as the root.\\n eq(mload(sub(hashesBack, 0x20)), root),\\n // And whether all the proofs are used, if required.\\n eq(proofEnd, proof.offset)\\n )\\n break\\n }\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* EMPTY CALLDATA HELPERS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns an empty calldata bytes32 array.\\n function emptyProof() internal pure returns (bytes32[] calldata proof) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n proof.length := 0\\n }\\n }\\n\\n /// @dev Returns an empty calldata bytes32 array.\\n function emptyLeaves() internal pure returns (bytes32[] calldata leaves) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n leaves.length := 0\\n }\\n }\\n\\n /// @dev Returns an empty calldata bool array.\\n function emptyFlags() internal pure returns (bool[] calldata flags) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n flags.length := 0\\n }\\n }\\n}\\n\",\"keccak256\":\"0x36e0da7695b2a2316db2ee41192cddb9327394920e38ee3fadea2308d796fbd2\",\"license\":\"MIT\"},\"solady/src/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)\\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @author Permit2 operations from (https://github.com/Uniswap/permit2/blob/main/src/libraries/Permit2Lib.sol)\\n///\\n/// @dev Note:\\n/// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection.\\n/// - For ERC20s, this implementation won't check that a token has code,\\n/// responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CUSTOM ERRORS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The ETH transfer has failed.\\n error ETHTransferFailed();\\n\\n /// @dev The ERC20 `transferFrom` has failed.\\n error TransferFromFailed();\\n\\n /// @dev The ERC20 `transfer` has failed.\\n error TransferFailed();\\n\\n /// @dev The ERC20 `approve` has failed.\\n error ApproveFailed();\\n\\n /// @dev The Permit2 operation has failed.\\n error Permit2Failed();\\n\\n /// @dev The Permit2 amount must be less than `2**160 - 1`.\\n error Permit2AmountOverflow();\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CONSTANTS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes.\\n uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300;\\n\\n /// @dev Suggested gas stipend for contract receiving ETH to perform a few\\n /// storage reads and writes, but low enough to prevent griefing.\\n uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000;\\n\\n /// @dev The unique EIP-712 domain domain separator for the DAI token contract.\\n bytes32 internal constant DAI_DOMAIN_SEPARATOR =\\n 0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;\\n\\n /// @dev The address for the WETH9 contract on Ethereum mainnet.\\n address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\\n\\n /// @dev The canonical Permit2 address.\\n /// [Github](https://github.com/Uniswap/permit2)\\n /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)\\n address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* ETH OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants.\\n //\\n // The regular variants:\\n // - Forwards all remaining gas to the target.\\n // - Reverts if the target reverts.\\n // - Reverts if the current contract has insufficient balance.\\n //\\n // The force variants:\\n // - Forwards with an optional gas stipend\\n // (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases).\\n // - If the target reverts, or if the gas stipend is exhausted,\\n // creates a temporary contract to force send the ETH via `SELFDESTRUCT`.\\n // Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758.\\n // - Reverts if the current contract has insufficient balance.\\n //\\n // The try variants:\\n // - Forwards with a mandatory gas stipend.\\n // - Instead of reverting, returns whether the transfer succeeded.\\n\\n /// @dev Sends `amount` (in wei) ETH to `to`.\\n function safeTransferETH(address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n\\n /// @dev Sends all the ETH in the current contract to `to`.\\n function safeTransferAllETH(address to) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Transfer all the ETH and check if it succeeded or not.\\n if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n\\n /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`.\\n function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if lt(selfbalance(), amount) {\\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, to) // Store the address in scratch space.\\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\\n if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\\n }\\n }\\n }\\n\\n /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`.\\n function forceSafeTransferAllETH(address to, uint256 gasStipend) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, to) // Store the address in scratch space.\\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\\n if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\\n }\\n }\\n }\\n\\n /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`.\\n function forceSafeTransferETH(address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if lt(selfbalance(), amount) {\\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, to) // Store the address in scratch space.\\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\\n if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\\n }\\n }\\n }\\n\\n /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`.\\n function forceSafeTransferAllETH(address to) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // forgefmt: disable-next-item\\n if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, to) // Store the address in scratch space.\\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\\n if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\\n }\\n }\\n }\\n\\n /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`.\\n function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend)\\n internal\\n returns (bool success)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)\\n }\\n }\\n\\n /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`.\\n function trySafeTransferAllETH(address to, uint256 gasStipend)\\n internal\\n returns (bool success)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* ERC20 OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\\n /// Reverts upon failure.\\n ///\\n /// The `from` account must have at least `amount` approved for\\n /// the current contract to manage.\\n function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40) // Cache the free memory pointer.\\n mstore(0x60, amount) // Store the `amount` argument.\\n mstore(0x40, to) // Store the `to` argument.\\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\\n mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.\\n // Perform the transfer, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, m) // Restore the free memory pointer.\\n }\\n }\\n\\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\\n ///\\n /// The `from` account must have at least `amount` approved for the current contract to manage.\\n function trySafeTransferFrom(address token, address from, address to, uint256 amount)\\n internal\\n returns (bool success)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40) // Cache the free memory pointer.\\n mstore(0x60, amount) // Store the `amount` argument.\\n mstore(0x40, to) // Store the `to` argument.\\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\\n mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.\\n success :=\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\\n )\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, m) // Restore the free memory pointer.\\n }\\n }\\n\\n /// @dev Sends all of ERC20 `token` from `from` to `to`.\\n /// Reverts upon failure.\\n ///\\n /// The `from` account must have their entire balance approved for the current contract to manage.\\n function safeTransferAllFrom(address token, address from, address to)\\n internal\\n returns (uint256 amount)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40) // Cache the free memory pointer.\\n mstore(0x40, to) // Store the `to` argument.\\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\\n mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`.\\n // Read the balance, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\\n staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`.\\n amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it.\\n // Perform the transfer, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, m) // Restore the free memory pointer.\\n }\\n }\\n\\n /// @dev Sends `amount` of ERC20 `token` from the current contract to `to`.\\n /// Reverts upon failure.\\n function safeTransfer(address token, address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x14, to) // Store the `to` argument.\\n mstore(0x34, amount) // Store the `amount` argument.\\n mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\\n // Perform the transfer, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\\n }\\n }\\n\\n /// @dev Sends all of ERC20 `token` from the current contract to `to`.\\n /// Reverts upon failure.\\n function safeTransferAll(address token, address to) internal returns (uint256 amount) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`.\\n mstore(0x20, address()) // Store the address of the current contract.\\n // Read the balance, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\\n staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x14, to) // Store the `to` argument.\\n amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it.\\n mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\\n // Perform the transfer, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\\n }\\n }\\n\\n /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.\\n /// Reverts upon failure.\\n function safeApprove(address token, address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x14, to) // Store the `to` argument.\\n mstore(0x34, amount) // Store the `amount` argument.\\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\\n // Perform the approval, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\\n }\\n }\\n\\n /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.\\n /// If the initial attempt to approve fails, attempts to reset the approved amount to zero,\\n /// then retries the approval again (some tokens, e.g. USDT, requires this).\\n /// Reverts upon failure.\\n function safeApproveWithRetry(address token, address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x14, to) // Store the `to` argument.\\n mstore(0x34, amount) // Store the `amount` argument.\\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\\n // Perform the approval, retrying upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x34, 0) // Store 0 for the `amount`.\\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\\n pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval.\\n mstore(0x34, amount) // Store back the original `amount`.\\n // Retry the approval, reverting upon failure.\\n if iszero(\\n and(\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\\n }\\n }\\n\\n /// @dev Returns the amount of ERC20 `token` owned by `account`.\\n /// Returns zero if the `token` does not exist.\\n function balanceOf(address token, address account) internal view returns (uint256 amount) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x14, account) // Store the `account` argument.\\n mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`.\\n amount :=\\n mul( // The arguments of `mul` are evaluated from right to left.\\n mload(0x20),\\n and( // The arguments of `and` are evaluated from right to left.\\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\\n staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)\\n )\\n )\\n }\\n }\\n\\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\\n /// If the initial attempt fails, try to use Permit2 to transfer the token.\\n /// Reverts upon failure.\\n ///\\n /// The `from` account must have at least `amount` approved for the current contract to manage.\\n function safeTransferFrom2(address token, address from, address to, uint256 amount) internal {\\n if (!trySafeTransferFrom(token, from, to, amount)) {\\n permit2TransferFrom(token, from, to, amount);\\n }\\n }\\n\\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2.\\n /// Reverts upon failure.\\n function permit2TransferFrom(address token, address from, address to, uint256 amount)\\n internal\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40)\\n mstore(add(m, 0x74), shr(96, shl(96, token)))\\n mstore(add(m, 0x54), amount)\\n mstore(add(m, 0x34), to)\\n mstore(add(m, 0x20), shl(96, from))\\n // `transferFrom(address,address,uint160,address)`.\\n mstore(m, 0x36c78516000000000000000000000000)\\n let p := PERMIT2\\n let exists := eq(chainid(), 1)\\n if iszero(exists) { exists := iszero(iszero(extcodesize(p))) }\\n if iszero(and(call(gas(), p, 0, add(m, 0x10), 0x84, codesize(), 0x00), exists)) {\\n mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`.\\n revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04)\\n }\\n }\\n }\\n\\n /// @dev Permit a user to spend a given amount of\\n /// another user's tokens via native EIP-2612 permit if possible, falling\\n /// back to Permit2 if native permit fails or is not implemented on the token.\\n function permit2(\\n address token,\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n bool success;\\n /// @solidity memory-safe-assembly\\n assembly {\\n for {} shl(96, xor(token, WETH9)) {} {\\n mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word.\\n // Gas stipend to limit gas burn for tokens that don't refund gas when\\n // an non-existing function is called. 5K should be enough for a SLOAD.\\n staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20)\\n )\\n ) { break }\\n // After here, we can be sure that token is a contract.\\n let m := mload(0x40)\\n mstore(add(m, 0x34), spender)\\n mstore(add(m, 0x20), shl(96, owner))\\n mstore(add(m, 0x74), deadline)\\n if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) {\\n mstore(0x14, owner)\\n mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`.\\n mstore(add(m, 0x94), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20))\\n mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`.\\n // `nonces` is already at `add(m, 0x54)`.\\n // `1` is already stored at `add(m, 0x94)`.\\n mstore(add(m, 0xb4), and(0xff, v))\\n mstore(add(m, 0xd4), r)\\n mstore(add(m, 0xf4), s)\\n success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00)\\n break\\n }\\n mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`.\\n mstore(add(m, 0x54), amount)\\n mstore(add(m, 0x94), and(0xff, v))\\n mstore(add(m, 0xb4), r)\\n mstore(add(m, 0xd4), s)\\n success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00)\\n break\\n }\\n }\\n if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s);\\n }\\n\\n /// @dev Simple permit on the Permit2 contract.\\n function simplePermit2(\\n address token,\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40)\\n mstore(m, 0x927da105) // `allowance(address,address,address)`.\\n {\\n let addressMask := shr(96, not(0))\\n mstore(add(m, 0x20), and(addressMask, owner))\\n mstore(add(m, 0x40), and(addressMask, token))\\n mstore(add(m, 0x60), and(addressMask, spender))\\n mstore(add(m, 0xc0), and(addressMask, spender))\\n }\\n let p := mul(PERMIT2, iszero(shr(160, amount)))\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`.\\n staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60)\\n )\\n ) {\\n mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`.\\n revert(add(0x18, shl(2, iszero(p))), 0x04)\\n }\\n mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant).\\n // `owner` is already `add(m, 0x20)`.\\n // `token` is already at `add(m, 0x40)`.\\n mstore(add(m, 0x60), amount)\\n mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`.\\n // `nonce` is already at `add(m, 0xa0)`.\\n // `spender` is already at `add(m, 0xc0)`.\\n mstore(add(m, 0xe0), deadline)\\n mstore(add(m, 0x100), 0x100) // `signature` offset.\\n mstore(add(m, 0x120), 0x41) // `signature` length.\\n mstore(add(m, 0x140), r)\\n mstore(add(m, 0x160), s)\\n mstore(add(m, 0x180), shl(248, v))\\n if iszero(call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00)) {\\n mstore(0x00, 0x6b836e6b) // `Permit2Failed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x583f47701d9b47bb3ef80fcabbbd62fbb58a01733b7a57e19658b4b02468883a\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506040516145ec3803806145ec83398101604081905261002f916104b2565b610038336100e9565b600061004488826105fd565b50600161005187826105fd565b506003859055600480546001600160601b038581166c01000000000000000000000000026001600160c01b0319909216908716171790556040516000903390610099906103d0565b6001600160a01b039091168152602001604051809103906000f0801580156100c5573d6000803e3d6000fd5b5090506100dc6001600160601b0384168383610125565b50505050505050506106bc565b6001600160a01b0316638b78c6d8198190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b03161561016257604051633ab534b960e21b815260040160405180910390fd5b6001600160a01b038216610189576040516339a84a7b60e01b815260040160405180910390fd5b630f4599e560005233602052602060006024601c6000865af1600160005114166101bb5763d125259c6000526004601cfd5b805463ffffffff60201b19166401000000001781556001810180546001600160a01b0384166001600160a01b031990911617905583156102d7576001600160a01b03831661021c57604051633a954ecd60e21b815260040160405180910390fd5b606084901c670de0b6b3a7640000850463fffffffe1017156102515760405163e5cfe95760e01b815260040160405180910390fd5b80546001600160a01b0316600160a01b6001600160601b03861602178155600061027a846102dd565b80546001600160601b038716600160a01b026001600160a01b0391821617825560008781529192508516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a36102d5846001610342565b505b50505050565b6001600160a01b038116600090815268a20d6e21d0e52553136020526040902080546b010000000000000000000000900460011661033d57805460ff60581b19166b01000000000000000000000060ff843b151560020260011716021781555b919050565b600061034d836102dd565b80549091506b010000000000000000000000900460021615158215151461039857805460ff6b01000000000000000000000080830482166002189091160260ff60581b199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b610ea18061374b83390190565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261040457600080fd5b81516001600160401b038082111561041e5761041e6103dd565b604051601f8301601f19908116603f01168101908282118183101715610446576104466103dd565b816040528381526020925086602085880101111561046357600080fd5b600091505b838210156104855785820183015181830184015290820190610468565b6000602085830101528094505050505092915050565b80516001600160601b038116811461033d57600080fd5b600080600080600080600060e0888a0312156104cd57600080fd5b87516001600160401b03808211156104e457600080fd5b6104f08b838c016103f3565b985060208a015191508082111561050657600080fd5b506105138a828b016103f3565b965050604088015194506105296060890161049b565b93506105376080890161049b565b925061054560a0890161049b565b60c08901519092506001600160a01b038116811461056257600080fd5b8091505092959891949750929550565b600181811c9082168061058657607f821691505b6020821081036105a657634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156105f8576000816000526020600020601f850160051c810160208610156105d55750805b601f850160051c820191505b818110156105f4578281556001016105e1565b5050505b505050565b81516001600160401b03811115610616576106166103dd565b61062a816106248454610572565b846105ac565b602080601f83116001811461065f57600084156106475750858301515b600019600386901b1c1916600185901b1785556105f4565b600085815260208120601f198616915b8281101561068e5788860151825594840194600190910190840161066f565b50858210156106ac5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b613080806106cb6000396000f3fe6080604052600436106101dc5760003560e01c806370a0823111610102578063a2309ff811610095578063ec0d755711610064578063ec0d755714610848578063f04e283e1461085d578063f2fde38b14610870578063fee81cf414610883576101ee565b8063a2309ff8146107a0578063a9059cbb146107c4578063a945bf80146107e4578063dd62ed3e14610809576101ee565b806390967a52116100d157806390967a521461070e578063957aa58c1461075757806395d89b4114610778578063a0712d681461078d576101ee565b806370a0823114610687578063715018a6146106da5780637bc9200e146106e25780638da5cb5b146106f5576101ee565b8063274e430b1161017a5780633ccfd60b116101495780633ccfd60b146106105780634ef41efc1461062557806354d1f13d1461065f57806355f804b314610667576101ee565b8063274e430b1461059e5780632a6a935d146105be578063313ce567146105de57806332cb6b0c146105fa576101ee565b806318160ddd116101b657806318160ddd1461051a57806323b872dd146105565780632569296214610576578063272afea91461057e576101ee565b806306fdde0314610495578063095ea7b3146104c05780630f2cdd6c146104f0576101ee565b366101ee5734156101ec57600080fd5b005b68a20d6e21d0e525530860003560e01c63e5eb36c88190036102555760018201546001600160a01b031633146102375760405163ce5a776b60e01b815260040160405180910390fd5b61024b6004356024356044356064356108b6565b6102556001610d53565b8063813500fc036102c15760018201546001600160a01b0316331461028d5760405163ce5a776b60e01b815260040160405180910390fd5b600435602890815260443560145268a20d6e21d0e525530b6000908152604881209152602435151590556102c16001610d53565b8063e985e9c5036102eb5760006102dc600435602435610d5d565b90506102e9811515610d53565b505b80636352211e0361031257610312610304600435610d86565b6001600160a01b0316610d53565b8063243598790361032b5761032b610304600435610dcc565b8063d10b6e0c0361038c5760018201546001600160a01b031633146103635760405163ce5a776b60e01b815260040160405180910390fd5b6000610376600435602435604435610e29565b905061038a816001600160a01b0316610d53565b505b8063081812fc036103a5576103a5610304600435610f34565b8063f5b100ea036103e9576001600160a01b0360043516600090815268a20d6e21d0e525531360205260409020546103e990600160801b900463ffffffff16610d53565b8063e2c79281036104155768a20d6e21d0e52553085461041590600160801b900463ffffffff16610d53565b8063c87b56dd0361044e57602060405101604052600061043c61043760043590565b610f99565b90506020810360208152815160600181f35b8063b7a94eb803610463576104636001610d53565b6040517f3c10b94e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3480156104a157600080fd5b506104aa610fe2565b6040516104b79190612b7e565b60405180910390f35b3480156104cc57600080fd5b506104e06104db366004612bc8565b611074565b60405190151581526020016104b7565b3480156104fc57600080fd5b50610505600581565b60405163ffffffff90911681526020016104b7565b34801561052657600080fd5b5068a20d6e21d0e525530854600160a01b90046bffffffffffffffffffffffff165b6040519081526020016104b7565b34801561056257600080fd5b506104e0610571366004612bf2565b61108a565b6101ec611111565b34801561058a57600080fd5b506101ec610599366004612c4a565b611161565b3480156105aa57600080fd5b506104e06105b9366004612c7d565b6111b7565b3480156105ca57600080fd5b506104e06105d9366004612c98565b611204565b3480156105ea57600080fd5b50604051601281526020016104b7565b34801561060657600080fd5b5061050561138881565b34801561061c57600080fd5b506101ec611218565b34801561063157600080fd5b5068a20d6e21d0e5255309546001600160a01b03165b6040516001600160a01b0390911681526020016104b7565b6101ec61122b565b34801561067357600080fd5b506101ec610682366004612cba565b611267565b34801561069357600080fd5b506105486106a2366004612c7d565b6001600160a01b0316600090815268a20d6e21d0e52553136020526040902054600160a01b90046bffffffffffffffffffffffff1690565b6101ec611281565b6101ec6106f0366004612d2c565b611293565b34801561070157600080fd5b50638b78c6d81954610647565b34801561071a57600080fd5b5060045461073a90600160601b90046bffffffffffffffffffffffff1681565b6040516bffffffffffffffffffffffff90911681526020016104b7565b34801561076357600080fd5b506004546104e090600160e01b900460ff1681565b34801561078457600080fd5b506104aa611525565b6101ec61079b366004612dab565b611534565b3480156107ac57600080fd5b5060045461050590600160c01b900463ffffffff1681565b3480156107d057600080fd5b506104e06107df366004612bc8565b611728565b3480156107f057600080fd5b5060045461073a906bffffffffffffffffffffffff1681565b34801561081557600080fd5b50610548610824366004612dc4565b602890815260149190915268a20d6e21d0e525530f60009081526048812091525490565b34801561085457600080fd5b506101ec611735565b6101ec61086b366004612c7d565b611779565b6101ec61087e366004612c7d565b6117b9565b34801561088f57600080fd5b5061054861089e366004612c7d565b63389a75e1600c908152600091909152602090205490565b6001600160a01b0383166108dd57604051633a954ecd60e21b815260040160405180910390fd5b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b03166109195760405163040739bf60e41b815260040160405180910390fd5b600a81016002820160006109638361093f640100000000891089025b6000190160011b90565b60008160031c8360601b0180546007841660051b1c63ffffffff1691505092915050565b63ffffffff1681526020810191909152604001600020546001600160a01b038781169116146109be576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160a01b0316836001600160a01b031614610a38576109e18684610d5d565b610a3857826001600160a01b03166109f885610f34565b6001600160a01b031614610a38576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038681166000908152600b84016020526040808220928816825290208154670de0b6b3a7640000906008860190600160a01b90046bffffffffffffffffffffffff1680831115610abb576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84546bffffffffffffffffffffffff918490038216600160a01b9081026001600160a01b039283161787558554818104841686019093160291161783556005860160601b600889901c015460ff89161c60011615610b59576005860160601b600889901c018054600160ff8b161b1916905560008881526004870160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b6001600160a01b038a166000908152602082905260408120855460001963ffffffff600160801b80840482169290920180821690920263ffffffff60801b19909316929092178855600381901c631fffffff16606084901b015492939260059190911b60e0161c1690506000610bd9886000198d01600190811b0161093f565b606084901b631fffffff600383901c1601805460e0600584901b1681811c861863ffffffff16901b1890559050610c478860001963ffffffff851601600190811b01838160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b5050835463ffffffff60801b198116600160801b9182900463ffffffff8181166001810182169094029290921787556001600160a01b038d16600090815260208690526040902060601b631fffffff600383901c1601805460e060059390931b9290921682811c8e1890931690921b1890559050610d0e868a610cca878e6117e0565b84600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b50816000528860601b60601c8a60601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050505050565b8060005260206000f35b6028818152601483905268a20d6e21d0e525530b60009081526048812091525415155b92915050565b6000610d91826118ad565b610dc7576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610d80825b600068a20d6e21d0e525530868a20d6e21d0e525530a82610e0268a20d6e21d0e525531261093f64010000000088108802610935565b63ffffffff1681526020810191909152604001600020546001600160a01b03169392505050565b600068a20d6e21d0e525530868a20d6e21d0e525530a82610e5f68a20d6e21d0e525531261093f64010000000089108902610935565b63ffffffff1681526020810191909152604001600020546001600160a01b03908116925083168214610ecb57610e958284610d5d565b610ecb576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008481526004820160205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387169081179091556005820160601b600886901c018054600160ff881690811b1991909116921515901b919091179055509392505050565b6000610f3f826118ad565b610f75576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600090815268a20d6e21d0e525530c60205260409020546001600160a01b031690565b606060028054610fa890612dee565b159050610fdd576002610fba836118ca565b604051602001610fcb929190612e28565b60405160208183030381529060405290505b919050565b606060008054610ff190612dee565b80601f016020809104026020016040519081016040528092919081815260200182805461101d90612dee565b801561106a5780601f1061103f5761010080835404028352916020019161106a565b820191906000526020600020905b81548152906001019060200180831161104d57829003601f168201915b5050505050905090565b600061108133848461190e565b50600192915050565b336028908152601484905268a20d6e21d0e525530f60009081526048812091819052815490919060001981146110fa57808411156110f4576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83810382555b611105868686611970565b50600195945050505050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b61116961238e565b600480546bffffffffffffffffffffffff928316600160601b027fffffffffffffffff0000000000000000000000000000000000000000000000009091169290931691909117919091179055565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604081208054600160581b90046001166111f157823b5b9392505050565b54600160581b9004600216151592915050565b600061121033836123a9565b506001919050565b61122061238e565b6112293361242f565b565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b61126f61238e565b600261127c828483612f33565b505050565b61128961238e565b611229600061244b565b600454600160e01b900460ff166112d6576040517fbaf13b3f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600454600160601b90046bffffffffffffffffffffffff1683346112fa828461300a565b14611330576040517ebfc92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815268a20d6e21d0e5255313602052604081205486916affffffffffffffffffffff909116906113648383613021565b905060058111156113a1576040517f201dc6f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815268a20d6e21d0e52553136020526040902080546affffffffffffffffffffff19166affffffffffffffffffffff831617905560045488906000906113f9908390600160c01b900463ffffffff16613021565b9050611388811115611437576040517f7be9badb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600480547fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff16600160c01b63ffffffff8416021790556040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b1660208201526000906034016040516020818303038152906040528051906020012090506114c78a8a60035484612489565b6114fd576040517f09bde33900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61151833611513670de0b6b3a76400008e61300a565b6124c3565b5050505050505050505050565b606060018054610ff190612dee565b600454600160e01b900460ff16611577576040517fbaf13b3f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6004546bffffffffffffffffffffffff168134611594828461300a565b146115ca576040517ebfc92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815268a20d6e21d0e5255313602052604081205484916affffffffffffffffffffff909116906115fe8383613021565b9050600581111561163b576040517f201dc6f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815268a20d6e21d0e52553136020526040902080546affffffffffffffffffffff19166affffffffffffffffffffff83161790556004548690600090611693908390600160c01b900463ffffffff16613021565b90506113888111156116d1576040517f7be9badb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600480547fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff16600160c01b63ffffffff84160217905561171e33670de0b6b3a7640000611513908b61300a565b5050505050505050565b6000611081338484611970565b61173d61238e565b600480547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff8116600160e01b9182900460ff1615909102179055565b61178161238e565b63389a75e1600c52806000526020600c2080544211156117a957636f5e88186000526004601cfd5b600090556117b68161244b565b50565b6117c161238e565b8060601b6117d757637448fbae6000526004601cfd5b6117b68161244b565b8154600160601b900463ffffffff1668a20d6e21d0e5255308816118a65780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000008116600163ffffffff92831601918216908117835585547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff16600160601b820217865560008181526002840160205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387161790559092506118a657600080fd5b5092915050565b6000806118b983610dcc565b6001600160a01b0316141592915050565b60606080604051019050602081016040526000815280600019835b928101926030600a8206018453600a9004806118e5575050819003601f19909101908152919050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b6001600160a01b03821661199757604051633a954ecd60e21b815260040160405180910390fd5b6001600160a01b038316600090815268a20d6e21d0e52553136020526040812068a20d6e21d0e5255308916119cb85612944565b60018401549091506001600160a01b03166119f95760405163040739bf60e41b815260040160405180910390fd5b611a5b60405180610140016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600063ffffffff16815260200160008152602001600063ffffffff1681525090565b825463ffffffff600160801b808304821660408501528454041660608301526bffffffffffffffffffffffff600160a01b9091041680861115611aca576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83546bffffffffffffffffffffffff91879003828116600160a01b9081026001600160a01b03938416178755855481810485168a0194851690910292169190911784556040830151909190611b4090611b28670de0b6b3a764000090565b8481611b3657611b36613034565b0480821191030290565b83528354600160581b9004600216611b9b57876001600160a01b0316896001600160a01b031603611b7957825160408401510360608401525b611b95670de0b6b3a76400008204846060015180821191030290565b60208401525b5050611ba5600190565b15611e3d576000611bd78260400151611bcc84600001518560200151808218908211021890565b808218908211021890565b905080611be45750611e3d565b8151819003825260208201805182900390526001600160a01b0380881690891603611c19576060820180519091019052611e3d565b6000611c80828a8a6040805180820182526000815260606020808301828152845163144027d381526001600160a01b03978816928101929092529490951685840152848101526080840185815260059590951b840160a09081019092529390915201815290565b6001600160a01b03808b166000908152600889016020526040808220928c168252902091925090611cb1868b6117e0565b63ffffffff1660e08601526060850151938401935b6040860180516000190190819052600381901c606085901b015460009160051b60e0161c63ffffffff16606084901b600384901c01805460e0600586901b1681811c63ffffffff948516908118909416901b1890559050611d6e8a600a01828960e0015185600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b84518181526020018552600881901c60058b0160601b015460ff82161c60011615611dd95760058a0160601b600882901c018054600160ff84161b19169055600081815260048b0160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b50848160010191508103611cc65760608601819052865463ffffffff808316600160801b90810263ffffffff60801b19938416178a5560408901518b5492160291161788556001890154611e379085906001600160a01b03166129a7565b50505050505b80516020820151855463ffffffff600160801b80830482168401859003608087018190529091160263ffffffff60801b19909116178655600a860191600091611e8691016129dc565b8654600160601b900463ffffffff1661012085015283519091501561208b57606089901b6001176020828101919091526001600160a01b038a166000908152600888019091526040808220908501518551810360a08701819052885463ffffffff909116600160801b0263ffffffff60801b199091161788556101208601515b60001991909101600381901c606084901b0154909190600090600584901b60e0161c63ffffffff1663ffffffff166000198101600281901c60608a901b01805460069290921b60c01682811c67ffffffffffffffff16901b909118905590508551602080880151600884901b178252018652600115611f9a5760068b0160601b600882901c018054600160ff84161b191690555b8415611fd45760098b0160601b631fffffff600384901c1601805460e0600585901b1681811c841863ffffffff16901b1890556001909101905b600881901c60058c0160601b015460ff82161c600116156120355760058b0160601b600882901c018054600160ff84161b19169055600081815260048c0160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b508660a001518203611f065783156120865763ffffffff811661012088018190528a547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff16600160601b909102178a555b505050505b60208301511561232757606088901b60208201526001600160a01b038816600090815260088701602052604090206120c3858a6117e0565b63ffffffff1660e08501526000670de0b6b3a76400008854600160a01b90046bffffffffffffffffffffffff16816120fd576120fd613034565b89549190049150640100000000900463ffffffff1681811180159091021761010086015260608501516020860151810160c08701819052875463ffffffff60801b1916600160801b63ffffffff928316021788558954680100000000000000009004165b600087610120015163ffffffff168263ffffffff16146121b15760098b0160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050612210565b506101008701515b6121ca87600019830160011b61093f565b63ffffffff16156121fc576121f56121e98c6006018360010187612a23565b85811180159091021790565b90506121b9565b600181018481118015909102176101008901525b600881901c60068c0160601b018054600160ff84161b8019909116179055600383901c606086901b018054600585901b60e01681811c841863ffffffff16901b1890556122a787828a60e0015186806001019750600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8551602080880151600884901b178252018652508660c00151820361216157895461010088015163ffffffff908116640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff919093166801000000000000000002166bffffffffffffffff0000000019909116171789555050505b6040810151511561234b57600186015461234b9082906001600160a01b0316612b1e565b5050846000528560601b60601c8760601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050565b638b78c6d819543314611229576382b429006000526004601cfd5b60006123b483612944565b8054909150600160581b90046002161515821515146123f757805460ff600160581b8083048216600218909116026bff0000000000000000000000199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b60003860003847855af16117b65763b12d13eb6000526004601cfd5b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b600083156124bb578360051b8501855b803580851160051b948552602094851852604060002093018181106124995750505b501492915050565b6001600160a01b0382166124ea57604051633a954ecd60e21b815260040160405180910390fd5b60006124f583612944565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b03166125345760405163040739bf60e41b815260040160405180910390fd5b60408051608081018252600080825260208201819052918101829052606081019190915282546bffffffffffffffffffffffff600160a01b80830482168701918216026001600160a01b03909216919091178455670de0b6b3a7640000810460408301525081546001600160a01b038116600160a01b918290046bffffffffffffffffffffffff9081168701908116909202178355600090816125ee606083901c670de0b6b3a7640000840463fffffffe10171515151590565b905086821081171561262c576040517fe5cfe95700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508454670de0b6b3a76400009091049150600160581b9004600216612907576001600160a01b03861660009081526008840160205260408082208654918501519092600a870192600160801b900463ffffffff169161269190838103908410026129dc565b90508060400151516000146129025760608a901b602082015260408082015151885463ffffffff600160801b80830482169093018116830263ffffffff60801b19928316178b55928901518b54931690910291161788556126f2888b6117e0565b63ffffffff90811660608801528754600160601b810482166020890152640100000000810482168781118015909102178852680100000000000000009004165b6000876020015163ffffffff168263ffffffff1614612781576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff1690506127d8565b5086515b61279685600019830160011b61093f565b63ffffffff16156127c8576127c16127b58a600601836001018a612a23565b88811180159091021790565b9050612785565b6001810187811180159091021788525b600881901c60068a0160601b018054600160ff84161b8019909116179055600384901c606087901b018054600586901b60e01681811c841863ffffffff16901b18905561286f85828a6060015187806001019850600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8251602080850151600884901b1782520183525086604001518303612732578651885463ffffffff83811668010000000000000000027fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff9190931664010000000002166bffffffffffffffff00000000199091161717885560018801546129009083906001600160a01b0316612b1e565b505b505050505b60008581526001600160a01b038716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a3505050505050565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604090208054600160581b9004600116610fdd5780546bff00000000000000000000001916600160581b60ff933b1515600202600117939093169290920291909117815590565b6020820151805160051b60840160808203915060208282601c85016000875af16001835114166129d657600082fd5b50505050565b612a0060405180606001604052806000815260200160008152602001606081525090565b604051828152806020018360051b81016040528183604001528083525050919050565b6000801990508360601b8360081c81018054198560ff161c8560ff161b80612a78578460081c83015b6001830192508254199150808311821715612a4c5780831115612a765760ff86191691821b90911c905b505b8015612b145782820360081b7e1f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405821960010183166101e07a1412563212c14164235266736f7425221143267a4524367526767760fc7b2aaaaaaaba69a69a6db6db6db2cb2cb2ce739ce73def7bdeffffffff840260f81c161b60f71c1690811c63d76453e004601f169190911a1717858111878210176000031793505b5050509392505050565b60408201516040810363263c69d68152602080820152815160051b604401915060208183601c84016000875af16001825114166129d657600081fd5b60005b83811015612b75578181015183820152602001612b5d565b50506000910152565b6020815260008251806020840152612b9d816040850160208701612b5a565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114610fdd57600080fd5b60008060408385031215612bdb57600080fd5b612be483612bb1565b946020939093013593505050565b600080600060608486031215612c0757600080fd5b612c1084612bb1565b9250612c1e60208501612bb1565b9150604084013590509250925092565b80356bffffffffffffffffffffffff81168114610fdd57600080fd5b60008060408385031215612c5d57600080fd5b612c6683612c2e565b9150612c7460208401612c2e565b90509250929050565b600060208284031215612c8f57600080fd5b6111ea82612bb1565b600060208284031215612caa57600080fd5b813580151581146111ea57600080fd5b60008060208385031215612ccd57600080fd5b823567ffffffffffffffff80821115612ce557600080fd5b818501915085601f830112612cf957600080fd5b813581811115612d0857600080fd5b866020828501011115612d1a57600080fd5b60209290920196919550909350505050565b600080600060408486031215612d4157600080fd5b83359250602084013567ffffffffffffffff80821115612d6057600080fd5b818601915086601f830112612d7457600080fd5b813581811115612d8357600080fd5b8760208260051b8501011115612d9857600080fd5b6020830194508093505050509250925092565b600060208284031215612dbd57600080fd5b5035919050565b60008060408385031215612dd757600080fd5b612de083612bb1565b9150612c7460208401612bb1565b600181811c90821680612e0257607f821691505b602082108103612e2257634e487b7160e01b600052602260045260246000fd5b50919050565b6000808454612e3681612dee565b60018281168015612e4e5760018114612e8157612eb0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450612eb0565b8860005260208060002060005b85811015612ea75781548a820152908401908201612e8e565b50505082870194505b505050508351612ec4818360208801612b5a565b01949350505050565b634e487b7160e01b600052604160045260246000fd5b601f82111561127c576000816000526020600020601f850160051c81016020861015612f0c5750805b601f850160051c820191505b81811015612f2b57828155600101612f18565b505050505050565b67ffffffffffffffff831115612f4b57612f4b612ecd565b612f5f83612f598354612dee565b83612ee3565b6000601f841160018114612f935760008515612f7b5750838201355b600019600387901b1c1916600186901b178355612fed565b600083815260209020601f19861690835b82811015612fc45786850135825560209485019460019092019101612fa4565b5086821015612fe15760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610d8057610d80612ff4565b80820180821115610d8057610d80612ff4565b634e487b7160e01b600052601260045260246000fdfea2646970667358221220eb975a7239ee2d8920aecec0cfce4f859d335037e0489e24c0323f24cb835d5964736f6c634300081900336080604052348015600f57600080fd5b50604051610ea1380380610ea1833981016040819052602c916058565b683602298b8c10b0123180546001600160a01b0319166001600160a01b03929092169190911790556086565b600060208284031215606957600080fd5b81516001600160a01b0381168114607f57600080fd5b9392505050565b610e0c806100956000396000f3fe60806040526004361061012d5760003560e01c80636cef16e6116100a557806397e5311c11610074578063b88d4fde11610059578063b88d4fde146105c1578063c87b56dd146105d4578063e985e9c5146105f45761013f565b806397e5311c1461058c578063a22cb465146105a15761013f565b80636cef16e61461051c57806370a08231146105315780638da5cb5b1461055157806395d89b41146105775761013f565b806318160ddd116100fc57806324359879116100e157806324359879146104c957806342842e0e146104e95780636352211e146104fc5761013f565b806318160ddd1461049357806323b872dd146104b65761013f565b806301ffc9a7146103d457806306fdde0314610426578063081812fc14610448578063095ea7b3146104805761013f565b3661013f57341561013d57600080fd5b005b683602298b8c10b0123060003560e01c63263c69d681900361020e5781546001600160a01b0316331461019e576040517f363cb31200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600435602401602081033560051b81015b8082146102015781358060601c816001168260a01b60a81c811583028284027fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a45050508160200191506101af565b5050600160005260206000f35b8063144027d3036102bd5781546001600160a01b0316331461025c576040517f363cb31200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600435602435604435602401602081033560051b81015b8082146102ae57813583857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a4816020019150610273565b50505050600160005260206000f35b80630f4599e5036103a25760018201546001600160a01b03161561032c5760018201546001600160a01b03166004356001600160a01b03161461032c576040517fc59ec47a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81546001600160a01b03161561036e576040517fbf656a4600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317825560016000908152602090f35b6040517f3c10b94e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3480156103e057600080fd5b506104116103ef366004610b60565b6301ffc9a760e09190911c9081146380ac58cd821417635b5e139f9091141790565b60405190151581526020015b60405180910390f35b34801561043257600080fd5b5061043b610614565b60405161041d9190610ba9565b34801561045457600080fd5b50610468610463366004610c16565b61062a565b6040516001600160a01b03909116815260200161041d565b61013d61048e366004610c4b565b610642565b34801561049f57600080fd5b506104a86106c8565b60405190815260200161041d565b61013d6104c4366004610c75565b6106da565b3480156104d557600080fd5b506104686104e4366004610c16565b610769565b61013d6104f7366004610c75565b61077b565b34801561050857600080fd5b50610468610517366004610c16565b6107ad565b34801561052857600080fd5b506104116107bf565b34801561053d57600080fd5b506104a861054c366004610cb1565b610892565b34801561055d57600080fd5b50683602298b8c10b01232546001600160a01b0316610468565b34801561058357600080fd5b5061043b6108ad565b34801561059857600080fd5b506104686108be565b3480156105ad57600080fd5b5061013d6105bc366004610ccc565b61090c565b61013d6105cf366004610d08565b61098f565b3480156105e057600080fd5b5061043b6105ef366004610c16565b6109ea565b34801561060057600080fd5b5061041161060f366004610da3565b6109fa565b60606106256306fdde036000610a26565b905090565b600061063c63081812fc836000610a8c565b92915050565b600061064c6108be565b90508260601b60601c925060405163d10b6e0c600052836020528260405233606052602060006064601c34865af1601f3d111661068c573d6000823e3d81fd5b806040525060006060528183600c5160601c7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600038a4505050565b600061062563e2c79281600080610a8c565b60006106e46108be565b90508360601b60601c93508260601b60601c925060405163e5eb36c881528460208201528360408201528260608201523360808201526020816084601c840134865af160018251141661073a573d6000823e3d81fd5b508183857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a450505050565b600061063c6324359879836000610a8c565b6107868383836106da565b813b156107a8576107a883838360405180602001604052806000815250610ad4565b505050565b600061063c636352211e836000610a8c565b60008060006107cc6108be565b9050638da5cb5b600052602060006004601c845afa600c51683602298b8c10b0123254601f3d119290921660609190911c029250683602298b8c10b01230906001600160a01b039081169084168114610887576002820180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691821790925560405190918316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35b600194505050505090565b600061063c63f5b100ea836001600160a01b03166000610a8c565b60606106256395d89b416000610a26565b683602298b8c10b01230546001600160a01b031680610909576040517f5b2a47ae00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b90565b60006109166108be565b90508260601b60601c925060405163813500fc6000528360205282151560405233606052602060006064601c34865af16001600051141661095a573d6000823e3d81fd5b83337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206040a36040525050600060605250565b61099a8585856106da565b833b156109e3576109e385858585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610ad492505050565b5050505050565b606061063c63c87b56dd83610a26565b6000610a1d63e985e9c5846001600160a01b0316846001600160a01b0316610a8c565b15159392505050565b60606000610a326108be565b9050604051915083600052826020526000806024601c845afa610a58573d6000833e3d82fd5b60206000803e6020600051833e8151602060005101602084013e815160208301016000815260208101604052505092915050565b600080610a976108be565b9050604051856000528460205283604052602060006044601c855afa601f3d1116610ac5573d6000823e3d81fd5b60405250506000519392505050565b60405163150b7a028082523360208301528560601b60601c604083015283606083015260808083015282518060a08401528015610b1b578060c08401826020870160045afa505b60208360a48301601c860160008a5af1610b3e573d15610b3e573d6000843e3d83fd5b508060e01b825114610b585763d1a57ed66000526004601cfd5b505050505050565b600060208284031215610b7257600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610ba257600080fd5b9392505050565b60006020808352835180602085015260005b81811015610bd757858101830151858201604001528201610bbb565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b600060208284031215610c2857600080fd5b5035919050565b80356001600160a01b0381168114610c4657600080fd5b919050565b60008060408385031215610c5e57600080fd5b610c6783610c2f565b946020939093013593505050565b600080600060608486031215610c8a57600080fd5b610c9384610c2f565b9250610ca160208501610c2f565b9150604084013590509250925092565b600060208284031215610cc357600080fd5b610ba282610c2f565b60008060408385031215610cdf57600080fd5b610ce883610c2f565b915060208301358015158114610cfd57600080fd5b809150509250929050565b600080600080600060808688031215610d2057600080fd5b610d2986610c2f565b9450610d3760208701610c2f565b935060408601359250606086013567ffffffffffffffff80821115610d5b57600080fd5b818801915088601f830112610d6f57600080fd5b813581811115610d7e57600080fd5b896020828501011115610d9057600080fd5b9699959850939650602001949392505050565b60008060408385031215610db657600080fd5b610dbf83610c2f565b9150610dcd60208401610c2f565b9050925092905056fea2646970667358221220abfdbd4f65aae35e4082870df5d855d74739c3551476f95b56478fb7badbf2a264736f6c63430008190033", + "deployedBytecode": "0x6080604052600436106101dc5760003560e01c806370a0823111610102578063a2309ff811610095578063ec0d755711610064578063ec0d755714610848578063f04e283e1461085d578063f2fde38b14610870578063fee81cf414610883576101ee565b8063a2309ff8146107a0578063a9059cbb146107c4578063a945bf80146107e4578063dd62ed3e14610809576101ee565b806390967a52116100d157806390967a521461070e578063957aa58c1461075757806395d89b4114610778578063a0712d681461078d576101ee565b806370a0823114610687578063715018a6146106da5780637bc9200e146106e25780638da5cb5b146106f5576101ee565b8063274e430b1161017a5780633ccfd60b116101495780633ccfd60b146106105780634ef41efc1461062557806354d1f13d1461065f57806355f804b314610667576101ee565b8063274e430b1461059e5780632a6a935d146105be578063313ce567146105de57806332cb6b0c146105fa576101ee565b806318160ddd116101b657806318160ddd1461051a57806323b872dd146105565780632569296214610576578063272afea91461057e576101ee565b806306fdde0314610495578063095ea7b3146104c05780630f2cdd6c146104f0576101ee565b366101ee5734156101ec57600080fd5b005b68a20d6e21d0e525530860003560e01c63e5eb36c88190036102555760018201546001600160a01b031633146102375760405163ce5a776b60e01b815260040160405180910390fd5b61024b6004356024356044356064356108b6565b6102556001610d53565b8063813500fc036102c15760018201546001600160a01b0316331461028d5760405163ce5a776b60e01b815260040160405180910390fd5b600435602890815260443560145268a20d6e21d0e525530b6000908152604881209152602435151590556102c16001610d53565b8063e985e9c5036102eb5760006102dc600435602435610d5d565b90506102e9811515610d53565b505b80636352211e0361031257610312610304600435610d86565b6001600160a01b0316610d53565b8063243598790361032b5761032b610304600435610dcc565b8063d10b6e0c0361038c5760018201546001600160a01b031633146103635760405163ce5a776b60e01b815260040160405180910390fd5b6000610376600435602435604435610e29565b905061038a816001600160a01b0316610d53565b505b8063081812fc036103a5576103a5610304600435610f34565b8063f5b100ea036103e9576001600160a01b0360043516600090815268a20d6e21d0e525531360205260409020546103e990600160801b900463ffffffff16610d53565b8063e2c79281036104155768a20d6e21d0e52553085461041590600160801b900463ffffffff16610d53565b8063c87b56dd0361044e57602060405101604052600061043c61043760043590565b610f99565b90506020810360208152815160600181f35b8063b7a94eb803610463576104636001610d53565b6040517f3c10b94e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3480156104a157600080fd5b506104aa610fe2565b6040516104b79190612b7e565b60405180910390f35b3480156104cc57600080fd5b506104e06104db366004612bc8565b611074565b60405190151581526020016104b7565b3480156104fc57600080fd5b50610505600581565b60405163ffffffff90911681526020016104b7565b34801561052657600080fd5b5068a20d6e21d0e525530854600160a01b90046bffffffffffffffffffffffff165b6040519081526020016104b7565b34801561056257600080fd5b506104e0610571366004612bf2565b61108a565b6101ec611111565b34801561058a57600080fd5b506101ec610599366004612c4a565b611161565b3480156105aa57600080fd5b506104e06105b9366004612c7d565b6111b7565b3480156105ca57600080fd5b506104e06105d9366004612c98565b611204565b3480156105ea57600080fd5b50604051601281526020016104b7565b34801561060657600080fd5b5061050561138881565b34801561061c57600080fd5b506101ec611218565b34801561063157600080fd5b5068a20d6e21d0e5255309546001600160a01b03165b6040516001600160a01b0390911681526020016104b7565b6101ec61122b565b34801561067357600080fd5b506101ec610682366004612cba565b611267565b34801561069357600080fd5b506105486106a2366004612c7d565b6001600160a01b0316600090815268a20d6e21d0e52553136020526040902054600160a01b90046bffffffffffffffffffffffff1690565b6101ec611281565b6101ec6106f0366004612d2c565b611293565b34801561070157600080fd5b50638b78c6d81954610647565b34801561071a57600080fd5b5060045461073a90600160601b90046bffffffffffffffffffffffff1681565b6040516bffffffffffffffffffffffff90911681526020016104b7565b34801561076357600080fd5b506004546104e090600160e01b900460ff1681565b34801561078457600080fd5b506104aa611525565b6101ec61079b366004612dab565b611534565b3480156107ac57600080fd5b5060045461050590600160c01b900463ffffffff1681565b3480156107d057600080fd5b506104e06107df366004612bc8565b611728565b3480156107f057600080fd5b5060045461073a906bffffffffffffffffffffffff1681565b34801561081557600080fd5b50610548610824366004612dc4565b602890815260149190915268a20d6e21d0e525530f60009081526048812091525490565b34801561085457600080fd5b506101ec611735565b6101ec61086b366004612c7d565b611779565b6101ec61087e366004612c7d565b6117b9565b34801561088f57600080fd5b5061054861089e366004612c7d565b63389a75e1600c908152600091909152602090205490565b6001600160a01b0383166108dd57604051633a954ecd60e21b815260040160405180910390fd5b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b03166109195760405163040739bf60e41b815260040160405180910390fd5b600a81016002820160006109638361093f640100000000891089025b6000190160011b90565b60008160031c8360601b0180546007841660051b1c63ffffffff1691505092915050565b63ffffffff1681526020810191909152604001600020546001600160a01b038781169116146109be576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160a01b0316836001600160a01b031614610a38576109e18684610d5d565b610a3857826001600160a01b03166109f885610f34565b6001600160a01b031614610a38576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038681166000908152600b84016020526040808220928816825290208154670de0b6b3a7640000906008860190600160a01b90046bffffffffffffffffffffffff1680831115610abb576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84546bffffffffffffffffffffffff918490038216600160a01b9081026001600160a01b039283161787558554818104841686019093160291161783556005860160601b600889901c015460ff89161c60011615610b59576005860160601b600889901c018054600160ff8b161b1916905560008881526004870160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b6001600160a01b038a166000908152602082905260408120855460001963ffffffff600160801b80840482169290920180821690920263ffffffff60801b19909316929092178855600381901c631fffffff16606084901b015492939260059190911b60e0161c1690506000610bd9886000198d01600190811b0161093f565b606084901b631fffffff600383901c1601805460e0600584901b1681811c861863ffffffff16901b1890559050610c478860001963ffffffff851601600190811b01838160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b5050835463ffffffff60801b198116600160801b9182900463ffffffff8181166001810182169094029290921787556001600160a01b038d16600090815260208690526040902060601b631fffffff600383901c1601805460e060059390931b9290921682811c8e1890931690921b1890559050610d0e868a610cca878e6117e0565b84600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b50816000528860601b60601c8a60601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050505050565b8060005260206000f35b6028818152601483905268a20d6e21d0e525530b60009081526048812091525415155b92915050565b6000610d91826118ad565b610dc7576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610d80825b600068a20d6e21d0e525530868a20d6e21d0e525530a82610e0268a20d6e21d0e525531261093f64010000000088108802610935565b63ffffffff1681526020810191909152604001600020546001600160a01b03169392505050565b600068a20d6e21d0e525530868a20d6e21d0e525530a82610e5f68a20d6e21d0e525531261093f64010000000089108902610935565b63ffffffff1681526020810191909152604001600020546001600160a01b03908116925083168214610ecb57610e958284610d5d565b610ecb576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008481526004820160205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387169081179091556005820160601b600886901c018054600160ff881690811b1991909116921515901b919091179055509392505050565b6000610f3f826118ad565b610f75576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600090815268a20d6e21d0e525530c60205260409020546001600160a01b031690565b606060028054610fa890612dee565b159050610fdd576002610fba836118ca565b604051602001610fcb929190612e28565b60405160208183030381529060405290505b919050565b606060008054610ff190612dee565b80601f016020809104026020016040519081016040528092919081815260200182805461101d90612dee565b801561106a5780601f1061103f5761010080835404028352916020019161106a565b820191906000526020600020905b81548152906001019060200180831161104d57829003601f168201915b5050505050905090565b600061108133848461190e565b50600192915050565b336028908152601484905268a20d6e21d0e525530f60009081526048812091819052815490919060001981146110fa57808411156110f4576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83810382555b611105868686611970565b50600195945050505050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b61116961238e565b600480546bffffffffffffffffffffffff928316600160601b027fffffffffffffffff0000000000000000000000000000000000000000000000009091169290931691909117919091179055565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604081208054600160581b90046001166111f157823b5b9392505050565b54600160581b9004600216151592915050565b600061121033836123a9565b506001919050565b61122061238e565b6112293361242f565b565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b61126f61238e565b600261127c828483612f33565b505050565b61128961238e565b611229600061244b565b600454600160e01b900460ff166112d6576040517fbaf13b3f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600454600160601b90046bffffffffffffffffffffffff1683346112fa828461300a565b14611330576040517ebfc92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815268a20d6e21d0e5255313602052604081205486916affffffffffffffffffffff909116906113648383613021565b905060058111156113a1576040517f201dc6f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815268a20d6e21d0e52553136020526040902080546affffffffffffffffffffff19166affffffffffffffffffffff831617905560045488906000906113f9908390600160c01b900463ffffffff16613021565b9050611388811115611437576040517f7be9badb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600480547fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff16600160c01b63ffffffff8416021790556040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b1660208201526000906034016040516020818303038152906040528051906020012090506114c78a8a60035484612489565b6114fd576040517f09bde33900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61151833611513670de0b6b3a76400008e61300a565b6124c3565b5050505050505050505050565b606060018054610ff190612dee565b600454600160e01b900460ff16611577576040517fbaf13b3f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6004546bffffffffffffffffffffffff168134611594828461300a565b146115ca576040517ebfc92100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815268a20d6e21d0e5255313602052604081205484916affffffffffffffffffffff909116906115fe8383613021565b9050600581111561163b576040517f201dc6f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b33600090815268a20d6e21d0e52553136020526040902080546affffffffffffffffffffff19166affffffffffffffffffffff83161790556004548690600090611693908390600160c01b900463ffffffff16613021565b90506113888111156116d1576040517f7be9badb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600480547fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff16600160c01b63ffffffff84160217905561171e33670de0b6b3a7640000611513908b61300a565b5050505050505050565b6000611081338484611970565b61173d61238e565b600480547fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff8116600160e01b9182900460ff1615909102179055565b61178161238e565b63389a75e1600c52806000526020600c2080544211156117a957636f5e88186000526004601cfd5b600090556117b68161244b565b50565b6117c161238e565b8060601b6117d757637448fbae6000526004601cfd5b6117b68161244b565b8154600160601b900463ffffffff1668a20d6e21d0e5255308816118a65780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000008116600163ffffffff92831601918216908117835585547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff16600160601b820217865560008181526002840160205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387161790559092506118a657600080fd5b5092915050565b6000806118b983610dcc565b6001600160a01b0316141592915050565b60606080604051019050602081016040526000815280600019835b928101926030600a8206018453600a9004806118e5575050819003601f19909101908152919050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b6001600160a01b03821661199757604051633a954ecd60e21b815260040160405180910390fd5b6001600160a01b038316600090815268a20d6e21d0e52553136020526040812068a20d6e21d0e5255308916119cb85612944565b60018401549091506001600160a01b03166119f95760405163040739bf60e41b815260040160405180910390fd5b611a5b60405180610140016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600063ffffffff16815260200160008152602001600063ffffffff1681525090565b825463ffffffff600160801b808304821660408501528454041660608301526bffffffffffffffffffffffff600160a01b9091041680861115611aca576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83546bffffffffffffffffffffffff91879003828116600160a01b9081026001600160a01b03938416178755855481810485168a0194851690910292169190911784556040830151909190611b4090611b28670de0b6b3a764000090565b8481611b3657611b36613034565b0480821191030290565b83528354600160581b9004600216611b9b57876001600160a01b0316896001600160a01b031603611b7957825160408401510360608401525b611b95670de0b6b3a76400008204846060015180821191030290565b60208401525b5050611ba5600190565b15611e3d576000611bd78260400151611bcc84600001518560200151808218908211021890565b808218908211021890565b905080611be45750611e3d565b8151819003825260208201805182900390526001600160a01b0380881690891603611c19576060820180519091019052611e3d565b6000611c80828a8a6040805180820182526000815260606020808301828152845163144027d381526001600160a01b03978816928101929092529490951685840152848101526080840185815260059590951b840160a09081019092529390915201815290565b6001600160a01b03808b166000908152600889016020526040808220928c168252902091925090611cb1868b6117e0565b63ffffffff1660e08601526060850151938401935b6040860180516000190190819052600381901c606085901b015460009160051b60e0161c63ffffffff16606084901b600384901c01805460e0600586901b1681811c63ffffffff948516908118909416901b1890559050611d6e8a600a01828960e0015185600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b84518181526020018552600881901c60058b0160601b015460ff82161c60011615611dd95760058a0160601b600882901c018054600160ff84161b19169055600081815260048b0160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b50848160010191508103611cc65760608601819052865463ffffffff808316600160801b90810263ffffffff60801b19938416178a5560408901518b5492160291161788556001890154611e379085906001600160a01b03166129a7565b50505050505b80516020820151855463ffffffff600160801b80830482168401859003608087018190529091160263ffffffff60801b19909116178655600a860191600091611e8691016129dc565b8654600160601b900463ffffffff1661012085015283519091501561208b57606089901b6001176020828101919091526001600160a01b038a166000908152600888019091526040808220908501518551810360a08701819052885463ffffffff909116600160801b0263ffffffff60801b199091161788556101208601515b60001991909101600381901c606084901b0154909190600090600584901b60e0161c63ffffffff1663ffffffff166000198101600281901c60608a901b01805460069290921b60c01682811c67ffffffffffffffff16901b909118905590508551602080880151600884901b178252018652600115611f9a5760068b0160601b600882901c018054600160ff84161b191690555b8415611fd45760098b0160601b631fffffff600384901c1601805460e0600585901b1681811c841863ffffffff16901b1890556001909101905b600881901c60058c0160601b015460ff82161c600116156120355760058b0160601b600882901c018054600160ff84161b19169055600081815260048c0160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b508660a001518203611f065783156120865763ffffffff811661012088018190528a547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff16600160601b909102178a555b505050505b60208301511561232757606088901b60208201526001600160a01b038816600090815260088701602052604090206120c3858a6117e0565b63ffffffff1660e08501526000670de0b6b3a76400008854600160a01b90046bffffffffffffffffffffffff16816120fd576120fd613034565b89549190049150640100000000900463ffffffff1681811180159091021761010086015260608501516020860151810160c08701819052875463ffffffff60801b1916600160801b63ffffffff928316021788558954680100000000000000009004165b600087610120015163ffffffff168263ffffffff16146121b15760098b0160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050612210565b506101008701515b6121ca87600019830160011b61093f565b63ffffffff16156121fc576121f56121e98c6006018360010187612a23565b85811180159091021790565b90506121b9565b600181018481118015909102176101008901525b600881901c60068c0160601b018054600160ff84161b8019909116179055600383901c606086901b018054600585901b60e01681811c841863ffffffff16901b1890556122a787828a60e0015186806001019750600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8551602080880151600884901b178252018652508660c00151820361216157895461010088015163ffffffff908116640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff919093166801000000000000000002166bffffffffffffffff0000000019909116171789555050505b6040810151511561234b57600186015461234b9082906001600160a01b0316612b1e565b5050846000528560601b60601c8760601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050565b638b78c6d819543314611229576382b429006000526004601cfd5b60006123b483612944565b8054909150600160581b90046002161515821515146123f757805460ff600160581b8083048216600218909116026bff0000000000000000000000199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b60003860003847855af16117b65763b12d13eb6000526004601cfd5b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b600083156124bb578360051b8501855b803580851160051b948552602094851852604060002093018181106124995750505b501492915050565b6001600160a01b0382166124ea57604051633a954ecd60e21b815260040160405180910390fd5b60006124f583612944565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b03166125345760405163040739bf60e41b815260040160405180910390fd5b60408051608081018252600080825260208201819052918101829052606081019190915282546bffffffffffffffffffffffff600160a01b80830482168701918216026001600160a01b03909216919091178455670de0b6b3a7640000810460408301525081546001600160a01b038116600160a01b918290046bffffffffffffffffffffffff9081168701908116909202178355600090816125ee606083901c670de0b6b3a7640000840463fffffffe10171515151590565b905086821081171561262c576040517fe5cfe95700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508454670de0b6b3a76400009091049150600160581b9004600216612907576001600160a01b03861660009081526008840160205260408082208654918501519092600a870192600160801b900463ffffffff169161269190838103908410026129dc565b90508060400151516000146129025760608a901b602082015260408082015151885463ffffffff600160801b80830482169093018116830263ffffffff60801b19928316178b55928901518b54931690910291161788556126f2888b6117e0565b63ffffffff90811660608801528754600160601b810482166020890152640100000000810482168781118015909102178852680100000000000000009004165b6000876020015163ffffffff168263ffffffff1614612781576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff1690506127d8565b5086515b61279685600019830160011b61093f565b63ffffffff16156127c8576127c16127b58a600601836001018a612a23565b88811180159091021790565b9050612785565b6001810187811180159091021788525b600881901c60068a0160601b018054600160ff84161b8019909116179055600384901c606087901b018054600586901b60e01681811c841863ffffffff16901b18905561286f85828a6060015187806001019850600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8251602080850151600884901b1782520183525086604001518303612732578651885463ffffffff83811668010000000000000000027fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff9190931664010000000002166bffffffffffffffff00000000199091161717885560018801546129009083906001600160a01b0316612b1e565b505b505050505b60008581526001600160a01b038716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a3505050505050565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604090208054600160581b9004600116610fdd5780546bff00000000000000000000001916600160581b60ff933b1515600202600117939093169290920291909117815590565b6020820151805160051b60840160808203915060208282601c85016000875af16001835114166129d657600082fd5b50505050565b612a0060405180606001604052806000815260200160008152602001606081525090565b604051828152806020018360051b81016040528183604001528083525050919050565b6000801990508360601b8360081c81018054198560ff161c8560ff161b80612a78578460081c83015b6001830192508254199150808311821715612a4c5780831115612a765760ff86191691821b90911c905b505b8015612b145782820360081b7e1f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405821960010183166101e07a1412563212c14164235266736f7425221143267a4524367526767760fc7b2aaaaaaaba69a69a6db6db6db2cb2cb2ce739ce73def7bdeffffffff840260f81c161b60f71c1690811c63d76453e004601f169190911a1717858111878210176000031793505b5050509392505050565b60408201516040810363263c69d68152602080820152815160051b604401915060208183601c84016000875af16001825114166129d657600081fd5b60005b83811015612b75578181015183820152602001612b5d565b50506000910152565b6020815260008251806020840152612b9d816040850160208701612b5a565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114610fdd57600080fd5b60008060408385031215612bdb57600080fd5b612be483612bb1565b946020939093013593505050565b600080600060608486031215612c0757600080fd5b612c1084612bb1565b9250612c1e60208501612bb1565b9150604084013590509250925092565b80356bffffffffffffffffffffffff81168114610fdd57600080fd5b60008060408385031215612c5d57600080fd5b612c6683612c2e565b9150612c7460208401612c2e565b90509250929050565b600060208284031215612c8f57600080fd5b6111ea82612bb1565b600060208284031215612caa57600080fd5b813580151581146111ea57600080fd5b60008060208385031215612ccd57600080fd5b823567ffffffffffffffff80821115612ce557600080fd5b818501915085601f830112612cf957600080fd5b813581811115612d0857600080fd5b866020828501011115612d1a57600080fd5b60209290920196919550909350505050565b600080600060408486031215612d4157600080fd5b83359250602084013567ffffffffffffffff80821115612d6057600080fd5b818601915086601f830112612d7457600080fd5b813581811115612d8357600080fd5b8760208260051b8501011115612d9857600080fd5b6020830194508093505050509250925092565b600060208284031215612dbd57600080fd5b5035919050565b60008060408385031215612dd757600080fd5b612de083612bb1565b9150612c7460208401612bb1565b600181811c90821680612e0257607f821691505b602082108103612e2257634e487b7160e01b600052602260045260246000fd5b50919050565b6000808454612e3681612dee565b60018281168015612e4e5760018114612e8157612eb0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450612eb0565b8860005260208060002060005b85811015612ea75781548a820152908401908201612e8e565b50505082870194505b505050508351612ec4818360208801612b5a565b01949350505050565b634e487b7160e01b600052604160045260246000fd5b601f82111561127c576000816000526020600020601f850160051c81016020861015612f0c5750805b601f850160051c820191505b81811015612f2b57828155600101612f18565b505050505050565b67ffffffffffffffff831115612f4b57612f4b612ecd565b612f5f83612f598354612dee565b83612ee3565b6000601f841160018114612f935760008515612f7b5750838201355b600019600387901b1c1916600186901b178355612fed565b600083815260209020601f19861690835b82811015612fc45786850135825560209485019460019092019101612fa4565b5086821015612fe15760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610d8057610d80612ff4565b80820180821115610d8057610d80612ff4565b634e487b7160e01b600052601260045260246000fdfea2646970667358221220eb975a7239ee2d8920aecec0cfce4f859d335037e0489e24c0323f24cb835d5964736f6c63430008190033", + "devdoc": { + "errors": { + "AlreadyInitialized()": [ + { + "details": "Cannot double-initialize." + } + ], + "ApprovalCallerNotOwnerNorApproved()": [ + { + "details": "Thrown when setting an NFT token approval and the caller is not the owner or an approved operator." + } + ], + "DNAlreadyInitialized()": [ + { + "details": "Thrown when attempting to double-initialize the contract." + } + ], + "DNNotInitialized()": [ + { + "details": "The function can only be called after the contract has been initialized." + } + ], + "FnSelectorNotRecognized()": [ + { + "details": "The function selector is not recognized." + } + ], + "InsufficientAllowance()": [ + { + "details": "Thrown when a spender attempts to transfer tokens with an insufficient allowance." + } + ], + "InsufficientBalance()": [ + { + "details": "Thrown when attempting to transfer or burn more tokens than sender's balance." + } + ], + "InvalidUnit()": [ + { + "details": "The unit must be greater than zero and less than `2**96`." + } + ], + "LinkMirrorContractFailed()": [ + { + "details": "Thrown when the link call to the mirror contract reverts." + } + ], + "MirrorAddressIsZero()": [ + { + "details": "Thrown when the mirror address provided for initialization is the zero address." + } + ], + "NewOwnerIsZeroAddress()": [ + { + "details": "The `newOwner` cannot be the zero address." + } + ], + "NoHandoverRequest()": [ + { + "details": "The `pendingOwner` does not have a valid handover request." + } + ], + "SenderNotMirror()": [ + { + "details": "Thrown when the caller for a fallback NFT function is not the mirror contract." + } + ], + "TokenDoesNotExist()": [ + { + "details": "Thrown when checking the owner or approved address for a non-existent NFT." + } + ], + "TotalSupplyOverflow()": [ + { + "details": "Thrown when minting an amount of tokens that would overflow the max tokens." + } + ], + "TransferCallerNotOwnerNorApproved()": [ + { + "details": "Thrown when transferring an NFT and the caller is not the owner or an approved operator." + } + ], + "TransferFromIncorrectOwner()": [ + { + "details": "Thrown when transferring an NFT and the from address is not the current owner." + } + ], + "TransferToZeroAddress()": [ + { + "details": "Thrown when attempting to transfer tokens to the zero address." + } + ], + "Unauthorized()": [ + { + "details": "The caller is not authorized to call the function." + } + ] + }, + "events": { + "Approval(address,address,uint256)": { + "details": "Emitted when `amount` tokens is approved by `owner` to be used by `spender`." + }, + "OwnershipHandoverCanceled(address)": { + "details": "The ownership handover to `pendingOwner` has been canceled." + }, + "OwnershipHandoverRequested(address)": { + "details": "An ownership handover to `pendingOwner` has been requested." + }, + "OwnershipTransferred(address,address)": { + "details": "The ownership is transferred from `oldOwner` to `newOwner`. This event is intentionally kept the same as OpenZeppelin's Ownable to be compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173), despite it not being as lightweight as a single argument event." + }, + "SkipNFTSet(address,bool)": { + "details": "Emitted when `owner` sets their skipNFT flag to `status`." + }, + "Transfer(address,address,uint256)": { + "details": "Emitted when `amount` tokens is transferred from `from` to `to`." + } + }, + "kind": "dev", + "methods": { + "allowance(address,address)": { + "details": "Returns the amount of tokens that `spender` can spend on behalf of `owner`." + }, + "approve(address,uint256)": { + "details": "Sets `amount` as the allowance of `spender` over the caller's tokens. Emits a {Approval} event." + }, + "balanceOf(address)": { + "details": "Returns the amount of tokens owned by `owner`." + }, + "cancelOwnershipHandover()": { + "details": "Cancels the two-step ownership handover to the caller, if any." + }, + "completeOwnershipHandover(address)": { + "details": "Allows the owner to complete the two-step ownership handover to `pendingOwner`. Reverts if there is no existing ownership handover requested by `pendingOwner`." + }, + "decimals()": { + "details": "Returns the decimals places of the token. Defaults to 18. Does not affect DN404's internal calculations. Will only affect the frontend UI on most protocols." + }, + "getSkipNFT(address)": { + "details": "Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs. Returns false otherwise." + }, + "mirrorERC721()": { + "details": "Returns the address of the mirror NFT contract." + }, + "name()": { + "details": "Returns the name of the token." + }, + "owner()": { + "details": "Returns the owner of the contract." + }, + "ownershipHandoverExpiresAt(address)": { + "details": "Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`." + }, + "renounceOwnership()": { + "details": "Allows the owner to renounce their ownership." + }, + "requestOwnershipHandover()": { + "details": "Request a two-step ownership handover to the caller. The request will automatically expire in 48 hours (172800 seconds) by default." + }, + "setSkipNFT(bool)": { + "details": "Sets the caller's skipNFT flag to `skipNFT`. Returns true. Emits a {SkipNFTSet} event." + }, + "symbol()": { + "details": "Returns the symbol of the token." + }, + "totalSupply()": { + "details": "Returns the amount of tokens in existence." + }, + "transfer(address,uint256)": { + "details": "Transfer `amount` tokens from the caller to `to`. Will burn sender NFTs if balance after transfer is less than the amount required to support the current NFT balance. Will mint NFTs to `to` if the recipient's new balance supports additional NFTs ***AND*** the `to` address's skipNFT flag is set to false. Requirements: - `from` must at least have `amount`. Emits a {Transfer} event." + }, + "transferFrom(address,address,uint256)": { + "details": "Transfers `amount` tokens from `from` to `to`. Note: Does not update the allowance if it is the maximum uint256 value. Will burn sender NFTs if balance after transfer is less than the amount required to support the current NFT balance. Will mint NFTs to `to` if the recipient's new balance supports additional NFTs ***AND*** the `to` address's skipNFT flag is set to false. Requirements: - `from` must at least have `amount`. - The caller must have at least `amount` of allowance to transfer the tokens of `from`. Emits a {Transfer} event." + }, + "transferOwnership(address)": { + "details": "Allows the owner to transfer the ownership to `newOwner`." + } + }, + "title": "NFTMintDN404", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "notice": "Sample DN404 contract that demonstrates the owner selling NFTs rather than the fungible token. The underlying call still mints ERC20 tokens, but to the end user it'll appear as a standard NFT mint. Each address is limited to MAX_PER_WALLET total mints.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 20, + "contract": "@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol:NFTMintDN404", + "label": "_name", + "offset": 0, + "slot": "0", + "type": "t_string_storage" + }, + { + "astId": 22, + "contract": "@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol:NFTMintDN404", + "label": "_symbol", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 24, + "contract": "@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol:NFTMintDN404", + "label": "_baseURI", + "offset": 0, + "slot": "2", + "type": "t_string_storage" + }, + { + "astId": 26, + "contract": "@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol:NFTMintDN404", + "label": "_allowlistRoot", + "offset": 0, + "slot": "3", + "type": "t_bytes32" + }, + { + "astId": 28, + "contract": "@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol:NFTMintDN404", + "label": "publicPrice", + "offset": 0, + "slot": "4", + "type": "t_uint96" + }, + { + "astId": 30, + "contract": "@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol:NFTMintDN404", + "label": "allowlistPrice", + "offset": 12, + "slot": "4", + "type": "t_uint96" + }, + { + "astId": 32, + "contract": "@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol:NFTMintDN404", + "label": "totalMinted", + "offset": 24, + "slot": "4", + "type": "t_uint32" + }, + { + "astId": 34, + "contract": "@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol:NFTMintDN404", + "label": "live", + "offset": 28, + "slot": "4", + "type": "t_bool" + } + ], + "types": { + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_uint32": { + "encoding": "inplace", + "label": "uint32", + "numberOfBytes": "4" + }, + "t_uint96": { + "encoding": "inplace", + "label": "uint96", + "numberOfBytes": "12" + } + } + } +} \ No newline at end of file diff --git a/packages/deploy/deployments/amoy/TSBSimpleDN404.json b/packages/deploy/deployments/amoy/TSBSimpleDN404.json new file mode 100644 index 0000000000..9bfff9119b --- /dev/null +++ b/packages/deploy/deployments/amoy/TSBSimpleDN404.json @@ -0,0 +1,894 @@ +{ + "address": "0x3dB6D51D8de507615f643C27B6351F3bFeB8880C", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "name_", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol_", + "type": "string" + }, + { + "internalType": "uint96", + "name": "initialTokenSupply", + "type": "uint96" + }, + { + "internalType": "address", + "name": "initialSupplyOwner", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AlreadyInitialized", + "type": "error" + }, + { + "inputs": [], + "name": "ApprovalCallerNotOwnerNorApproved", + "type": "error" + }, + { + "inputs": [], + "name": "DNAlreadyInitialized", + "type": "error" + }, + { + "inputs": [], + "name": "DNNotInitialized", + "type": "error" + }, + { + "inputs": [], + "name": "FnSelectorNotRecognized", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientAllowance", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidUnit", + "type": "error" + }, + { + "inputs": [], + "name": "LinkMirrorContractFailed", + "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": "owner", + "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": [ + { + "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": "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": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "getSkipNFT", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "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": "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": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "requestOwnershipHandover", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "baseURI_", + "type": "string" + } + ], + "name": "setBaseURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "skipNFT", + "type": "bool" + } + ], + "name": "setSkipNFT", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "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": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xa87c2a7f80c5cb9c008d99557b326cfcb531e8f4d01d353519d5cc691935cc47", + "receipt": { + "to": null, + "from": "0x5F890c9522dCE5670d741D4277BFCC2d9cA8Af02", + "contractAddress": "0x3dB6D51D8de507615f643C27B6351F3bFeB8880C", + "transactionIndex": 3, + "gasUsed": "3324408", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000002000000008400000000000000000000008000000000000000000000400000000000000000000000000008000020800001000000000000000100001000000000000000020000000000020000000800000000000000000080000010000000400000000000000000004000000000000000000000000000000000000000204000200000000000000000000000000000000000000000000000000000000000004000000002000000000001010000000000000000000020000000108000000020000000000000000000000000000000008000000000000000000000000000100000", + "blockHash": "0xf26bcfc5afe4047d862ba59f489b42b49d1e1d67bd27adb5a200a17648ea071c", + "transactionHash": "0xa87c2a7f80c5cb9c008d99557b326cfcb531e8f4d01d353519d5cc691935cc47", + "logs": [ + { + "transactionIndex": 3, + "blockNumber": 6324162, + "transactionHash": "0xa87c2a7f80c5cb9c008d99557b326cfcb531e8f4d01d353519d5cc691935cc47", + "address": "0x3dB6D51D8de507615f643C27B6351F3bFeB8880C", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000005f890c9522dce5670d741d4277bfcc2d9ca8af02" + ], + "data": "0x", + "logIndex": 6, + "blockHash": "0xf26bcfc5afe4047d862ba59f489b42b49d1e1d67bd27adb5a200a17648ea071c" + }, + { + "transactionIndex": 3, + "blockNumber": 6324162, + "transactionHash": "0xa87c2a7f80c5cb9c008d99557b326cfcb531e8f4d01d353519d5cc691935cc47", + "address": "0x3dB6D51D8de507615f643C27B6351F3bFeB8880C", + "topics": [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000049c4d4c94829b9c44052c5f5cb164fc612181165" + ], + "data": "0x00000000000000000000000000000000000000000000010f0cf064dd59200000", + "logIndex": 7, + "blockHash": "0xf26bcfc5afe4047d862ba59f489b42b49d1e1d67bd27adb5a200a17648ea071c" + }, + { + "transactionIndex": 3, + "blockNumber": 6324162, + "transactionHash": "0xa87c2a7f80c5cb9c008d99557b326cfcb531e8f4d01d353519d5cc691935cc47", + "address": "0x3dB6D51D8de507615f643C27B6351F3bFeB8880C", + "topics": [ + "0xb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d6420393", + "0x00000000000000000000000049c4d4c94829b9c44052c5f5cb164fc612181165" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 8, + "blockHash": "0xf26bcfc5afe4047d862ba59f489b42b49d1e1d67bd27adb5a200a17648ea071c" + }, + { + "transactionIndex": 3, + "blockNumber": 6324162, + "transactionHash": "0xa87c2a7f80c5cb9c008d99557b326cfcb531e8f4d01d353519d5cc691935cc47", + "address": "0x0000000000000000000000000000000000001010", + "topics": [ + "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", + "0x0000000000000000000000000000000000000000000000000000000000001010", + "0x0000000000000000000000005f890c9522dce5670d741d4277bfcc2d9ca8af02", + "0x0000000000000000000000004ad84f7014b7b44f723f284a85b1662337971439" + ], + "data": "0x000000000000000000000000000000000000000000000000016251f1a1daa000000000000000000000000000000000000000000000000003668f3f674f75e67900000000000000000000000000000000000000000000008fa611395e6a187c66000000000000000000000000000000000000000000000003652ced75ad9b467900000000000000000000000000000000000000000000008fa7738b500bf31c66", + "logIndex": 9, + "blockHash": "0xf26bcfc5afe4047d862ba59f489b42b49d1e1d67bd27adb5a200a17648ea071c" + } + ], + "blockNumber": 6324162, + "cumulativeGasUsed": "3467764", + "status": 1, + "byzantium": true + }, + "args": [ + "Simples", + "SIMP", + "5000000000000000000000", + "0x49c4D4C94829B9c44052C5f5Cb164Fc612181165" + ], + "numDeployments": 1, + "solcInputHash": "efe1133fb66c7fcb6c05f983751390cd", + "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"},{\"internalType\":\"uint96\",\"name\":\"initialTokenSupply\",\"type\":\"uint96\"},{\"internalType\":\"address\",\"name\":\"initialSupplyOwner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AlreadyInitialized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ApprovalCallerNotOwnerNorApproved\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DNAlreadyInitialized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"DNNotInitialized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FnSelectorNotRecognized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InsufficientAllowance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidUnit\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"LinkMirrorContractFailed\",\"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\":\"owner\",\"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\":[{\"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\":\"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\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"getSkipNFT\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"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\":\"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\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"requestOwnershipHandover\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"baseURI_\",\"type\":\"string\"}],\"name\":\"setBaseURI\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bool\",\"name\":\"skipNFT\",\"type\":\"bool\"}],\"name\":\"setSkipNFT\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"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\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"errors\":{\"AlreadyInitialized()\":[{\"details\":\"Cannot double-initialize.\"}],\"ApprovalCallerNotOwnerNorApproved()\":[{\"details\":\"Thrown when setting an NFT token approval and the caller is not the owner or an approved operator.\"}],\"DNAlreadyInitialized()\":[{\"details\":\"Thrown when attempting to double-initialize the contract.\"}],\"DNNotInitialized()\":[{\"details\":\"The function can only be called after the contract has been initialized.\"}],\"FnSelectorNotRecognized()\":[{\"details\":\"The function selector is not recognized.\"}],\"InsufficientAllowance()\":[{\"details\":\"Thrown when a spender attempts to transfer tokens with an insufficient allowance.\"}],\"InsufficientBalance()\":[{\"details\":\"Thrown when attempting to transfer or burn more tokens than sender's balance.\"}],\"InvalidUnit()\":[{\"details\":\"The unit must be greater than zero and less than `2**96`.\"}],\"LinkMirrorContractFailed()\":[{\"details\":\"Thrown when the link call to the mirror contract reverts.\"}],\"MirrorAddressIsZero()\":[{\"details\":\"Thrown when the mirror address provided for initialization is the zero address.\"}],\"NewOwnerIsZeroAddress()\":[{\"details\":\"The `newOwner` cannot be the zero address.\"}],\"NoHandoverRequest()\":[{\"details\":\"The `pendingOwner` does not have a valid handover request.\"}],\"SenderNotMirror()\":[{\"details\":\"Thrown when the caller for a fallback NFT function is not the mirror contract.\"}],\"TokenDoesNotExist()\":[{\"details\":\"Thrown when checking the owner or approved address for a non-existent NFT.\"}],\"TotalSupplyOverflow()\":[{\"details\":\"Thrown when minting an amount of tokens that would overflow the max tokens.\"}],\"TransferCallerNotOwnerNorApproved()\":[{\"details\":\"Thrown when transferring an NFT and the caller is not the owner or an approved operator.\"}],\"TransferFromIncorrectOwner()\":[{\"details\":\"Thrown when transferring an NFT and the from address is not the current owner.\"}],\"TransferToZeroAddress()\":[{\"details\":\"Thrown when attempting to transfer tokens to the zero address.\"}],\"Unauthorized()\":[{\"details\":\"The caller is not authorized to call the function.\"}]},\"events\":{\"Approval(address,address,uint256)\":{\"details\":\"Emitted when `amount` tokens is approved by `owner` to be used by `spender`.\"},\"OwnershipHandoverCanceled(address)\":{\"details\":\"The ownership handover to `pendingOwner` has been canceled.\"},\"OwnershipHandoverRequested(address)\":{\"details\":\"An ownership handover to `pendingOwner` has been requested.\"},\"OwnershipTransferred(address,address)\":{\"details\":\"The ownership is transferred from `oldOwner` to `newOwner`. This event is intentionally kept the same as OpenZeppelin's Ownable to be compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173), despite it not being as lightweight as a single argument event.\"},\"SkipNFTSet(address,bool)\":{\"details\":\"Emitted when `owner` sets their skipNFT flag to `status`.\"},\"Transfer(address,address,uint256)\":{\"details\":\"Emitted when `amount` tokens is transferred from `from` to `to`.\"}},\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"Returns the amount of tokens that `spender` can spend on behalf of `owner`.\"},\"approve(address,uint256)\":{\"details\":\"Sets `amount` as the allowance of `spender` over the caller's tokens. Emits a {Approval} event.\"},\"balanceOf(address)\":{\"details\":\"Returns the amount of tokens owned by `owner`.\"},\"cancelOwnershipHandover()\":{\"details\":\"Cancels the two-step ownership handover to the caller, if any.\"},\"completeOwnershipHandover(address)\":{\"details\":\"Allows the owner to complete the two-step ownership handover to `pendingOwner`. Reverts if there is no existing ownership handover requested by `pendingOwner`.\"},\"decimals()\":{\"details\":\"Returns the decimals places of the token. Defaults to 18. Does not affect DN404's internal calculations. Will only affect the frontend UI on most protocols.\"},\"getSkipNFT(address)\":{\"details\":\"Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs. Returns false otherwise.\"},\"mirrorERC721()\":{\"details\":\"Returns the address of the mirror NFT contract.\"},\"name()\":{\"details\":\"Returns the name of the token.\"},\"owner()\":{\"details\":\"Returns the owner of the contract.\"},\"ownershipHandoverExpiresAt(address)\":{\"details\":\"Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.\"},\"renounceOwnership()\":{\"details\":\"Allows the owner to renounce their ownership.\"},\"requestOwnershipHandover()\":{\"details\":\"Request a two-step ownership handover to the caller. The request will automatically expire in 48 hours (172800 seconds) by default.\"},\"setSkipNFT(bool)\":{\"details\":\"Sets the caller's skipNFT flag to `skipNFT`. Returns true. Emits a {SkipNFTSet} event.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token.\"},\"totalSupply()\":{\"details\":\"Returns the amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"details\":\"Transfer `amount` tokens from the caller to `to`. Will burn sender NFTs if balance after transfer is less than the amount required to support the current NFT balance. Will mint NFTs to `to` if the recipient's new balance supports additional NFTs ***AND*** the `to` address's skipNFT flag is set to false. Requirements: - `from` must at least have `amount`. Emits a {Transfer} event.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"Transfers `amount` tokens from `from` to `to`. Note: Does not update the allowance if it is the maximum uint256 value. Will burn sender NFTs if balance after transfer is less than the amount required to support the current NFT balance. Will mint NFTs to `to` if the recipient's new balance supports additional NFTs ***AND*** the `to` address's skipNFT flag is set to false. Requirements: - `from` must at least have `amount`. - The caller must have at least `amount` of allowance to transfer the tokens of `from`. Emits a {Transfer} event.\"},\"transferOwnership(address)\":{\"details\":\"Allows the owner to transfer the ownership to `newOwner`.\"}},\"title\":\"SimpleDN404\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"Sample DN404 contract that demonstrates the owner selling fungible tokens. When a user has at least one base unit (10^18) amount of tokens, they will automatically receive an NFT. NFTs are minted as an address accumulates each base unit amount of tokens.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"@sandbox-smart-contracts/dn404/contracts/SimpleDN404.sol\":\"SimpleDN404\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":2000},\"remappings\":[]},\"sources\":{\"@sandbox-smart-contracts/dn404/contracts/SimpleDN404.sol\":{\"content\":\"//SPDX-License-Identifier: MIT\\npragma solidity 0.8.25;\\n\\nimport {DN404} from \\\"dn404/src/DN404.sol\\\";\\nimport {DN404Mirror} from \\\"dn404/src/DN404Mirror.sol\\\";\\nimport {Ownable} from \\\"solady/src/auth/Ownable.sol\\\";\\nimport {LibString} from \\\"solady/src/utils/LibString.sol\\\";\\nimport {SafeTransferLib} from \\\"solady/src/utils/SafeTransferLib.sol\\\";\\n\\n/**\\n * @title SimpleDN404\\n * @notice Sample DN404 contract that demonstrates the owner selling fungible tokens.\\n * When a user has at least one base unit (10^18) amount of tokens, they will automatically receive an NFT.\\n * NFTs are minted as an address accumulates each base unit amount of tokens.\\n */\\ncontract SimpleDN404 is DN404, Ownable {\\n string private _name;\\n string private _symbol;\\n string private _baseURI;\\n\\n constructor(string memory name_, string memory symbol_, uint96 initialTokenSupply, address initialSupplyOwner) {\\n _initializeOwner(msg.sender);\\n\\n _name = name_;\\n _symbol = symbol_;\\n\\n address mirror = address(new DN404Mirror(msg.sender));\\n _initializeDN404(initialTokenSupply, initialSupplyOwner, mirror);\\n }\\n\\n function name() public view override returns (string memory) {\\n return _name;\\n }\\n\\n function symbol() public view override returns (string memory) {\\n return _symbol;\\n }\\n\\n function _tokenURI(uint256 tokenId) internal view override returns (string memory result) {\\n if (bytes(_baseURI).length != 0) {\\n result = string(abi.encodePacked(_baseURI, LibString.toString(tokenId)));\\n }\\n }\\n\\n // This allows the owner of the contract to mint more tokens.\\n function mint(address to, uint256 amount) public onlyOwner {\\n _mint(to, amount);\\n }\\n\\n function setBaseURI(string calldata baseURI_) public onlyOwner {\\n _baseURI = baseURI_;\\n }\\n\\n function withdraw() public onlyOwner {\\n SafeTransferLib.safeTransferAllETH(msg.sender);\\n }\\n}\\n\",\"keccak256\":\"0xa56f1035ab25ec0bf84faad841ba913a4867e7aad9c1c06287e57706f1ef6b0b\",\"license\":\"MIT\"},\"dn404/src/DN404.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @title DN404\\n/// @notice DN404 is a hybrid ERC20 and ERC721 implementation that mints\\n/// and burns NFTs based on an account's ERC20 token balance.\\n///\\n/// @author vectorized.eth (@optimizoor)\\n/// @author Quit (@0xQuit)\\n/// @author Michael Amadi (@AmadiMichaels)\\n/// @author cygaar (@0xCygaar)\\n/// @author Thomas (@0xjustadev)\\n/// @author Harrison (@PopPunkOnChain)\\n///\\n/// @dev Note:\\n/// - The ERC721 data is stored in this base DN404 contract, however a\\n/// DN404Mirror contract ***MUST*** be deployed and linked during\\n/// initialization.\\nabstract contract DN404 {\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* EVENTS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Emitted when `amount` tokens is transferred from `from` to `to`.\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n /// @dev Emitted when `amount` tokens is approved by `owner` to be used by `spender`.\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /// @dev Emitted when `owner` sets their skipNFT flag to `status`.\\n event SkipNFTSet(address indexed owner, bool status);\\n\\n /// @dev `keccak256(bytes(\\\"Transfer(address,address,uint256)\\\"))`.\\n uint256 private constant _TRANSFER_EVENT_SIGNATURE =\\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\\n\\n /// @dev `keccak256(bytes(\\\"Approval(address,address,uint256)\\\"))`.\\n uint256 private constant _APPROVAL_EVENT_SIGNATURE =\\n 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;\\n\\n /// @dev `keccak256(bytes(\\\"SkipNFTSet(address,bool)\\\"))`.\\n uint256 private constant _SKIP_NFT_SET_EVENT_SIGNATURE =\\n 0xb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d6420393;\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CUSTOM ERRORS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Thrown when attempting to double-initialize the contract.\\n error DNAlreadyInitialized();\\n\\n /// @dev The function can only be called after the contract has been initialized.\\n error DNNotInitialized();\\n\\n /// @dev Thrown when attempting to transfer or burn more tokens than sender's balance.\\n error InsufficientBalance();\\n\\n /// @dev Thrown when a spender attempts to transfer tokens with an insufficient allowance.\\n error InsufficientAllowance();\\n\\n /// @dev Thrown when minting an amount of tokens that would overflow the max tokens.\\n error TotalSupplyOverflow();\\n\\n /// @dev The unit must be greater than zero and less than `2**96`.\\n error InvalidUnit();\\n\\n /// @dev Thrown when the caller for a fallback NFT function is not the mirror contract.\\n error SenderNotMirror();\\n\\n /// @dev Thrown when attempting to transfer tokens to the zero address.\\n error TransferToZeroAddress();\\n\\n /// @dev Thrown when the mirror address provided for initialization is the zero address.\\n error MirrorAddressIsZero();\\n\\n /// @dev Thrown when the link call to the mirror contract reverts.\\n error LinkMirrorContractFailed();\\n\\n /// @dev Thrown when setting an NFT token approval\\n /// and the caller is not the owner or an approved operator.\\n error ApprovalCallerNotOwnerNorApproved();\\n\\n /// @dev Thrown when transferring an NFT\\n /// and the caller is not the owner or an approved operator.\\n error TransferCallerNotOwnerNorApproved();\\n\\n /// @dev Thrown when transferring an NFT and the from address is not the current owner.\\n error TransferFromIncorrectOwner();\\n\\n /// @dev Thrown when checking the owner or approved address for a non-existent NFT.\\n error TokenDoesNotExist();\\n\\n /// @dev The function selector is not recognized.\\n error FnSelectorNotRecognized();\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CONSTANTS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev The flag to denote that the address data is initialized.\\n uint8 internal constant _ADDRESS_DATA_INITIALIZED_FLAG = 1 << 0;\\n\\n /// @dev The flag to denote that the address should skip NFTs.\\n uint8 internal constant _ADDRESS_DATA_SKIP_NFT_FLAG = 1 << 1;\\n\\n /// @dev The flag to denote that the address has overridden the default Permit2 allowance.\\n uint8 internal constant _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG = 1 << 2;\\n\\n /// @dev The canonical Permit2 address.\\n /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.\\n /// To enable, override `_givePermit2DefaultInfiniteAllowance()`.\\n /// [Github](https://github.com/Uniswap/permit2)\\n /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)\\n address internal constant _PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* STORAGE */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Struct containing an address's token data and settings.\\n struct AddressData {\\n // Auxiliary data.\\n uint88 aux;\\n // Flags for `initialized` and `skipNFT`.\\n uint8 flags;\\n // The alias for the address. Zero means absence of an alias.\\n uint32 addressAlias;\\n // The number of NFT tokens.\\n uint32 ownedLength;\\n // The token balance in wei.\\n uint96 balance;\\n }\\n\\n /// @dev A uint32 map in storage.\\n struct Uint32Map {\\n uint256 spacer;\\n }\\n\\n /// @dev A bitmap in storage.\\n struct Bitmap {\\n uint256 spacer;\\n }\\n\\n /// @dev A struct to wrap a uint256 in storage.\\n struct Uint256Ref {\\n uint256 value;\\n }\\n\\n /// @dev A mapping of an address pair to a Uint256Ref.\\n struct AddressPairToUint256RefMap {\\n uint256 spacer;\\n }\\n\\n /// @dev Struct containing the base token contract storage.\\n struct DN404Storage {\\n // Current number of address aliases assigned.\\n uint32 numAliases;\\n // Next NFT ID to assign for a mint.\\n uint32 nextTokenId;\\n // The head of the burned pool.\\n uint32 burnedPoolHead;\\n // The tail of the burned pool.\\n uint32 burnedPoolTail;\\n // Total number of NFTs in existence.\\n uint32 totalNFTSupply;\\n // Total supply of tokens.\\n uint96 totalSupply;\\n // Address of the NFT mirror contract.\\n address mirrorERC721;\\n // Mapping of a user alias number to their address.\\n mapping(uint32 => address) aliasToAddress;\\n // Mapping of user operator approvals for NFTs.\\n AddressPairToUint256RefMap operatorApprovals;\\n // Mapping of NFT approvals to approved operators.\\n mapping(uint256 => address) nftApprovals;\\n // Bitmap of whether an non-zero NFT approval may exist.\\n Bitmap mayHaveNFTApproval;\\n // Bitmap of whether a NFT ID exists. Ignored if `_useExistsLookup()` returns false.\\n Bitmap exists;\\n // Mapping of user allowances for ERC20 spenders.\\n AddressPairToUint256RefMap allowance;\\n // Mapping of NFT IDs owned by an address.\\n mapping(address => Uint32Map) owned;\\n // The pool of burned NFT IDs.\\n Uint32Map burnedPool;\\n // Even indices: owner aliases. Odd indices: owned indices.\\n Uint32Map oo;\\n // Mapping of user account AddressData.\\n mapping(address => AddressData) addressData;\\n }\\n\\n /// @dev Returns a storage pointer for DN404Storage.\\n function _getDN404Storage() internal pure virtual returns (DN404Storage storage $) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // `uint72(bytes9(keccak256(\\\"DN404_STORAGE\\\")))`.\\n $.slot := 0xa20d6e21d0e5255308 // Truncate to 9 bytes to reduce bytecode size.\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INITIALIZER */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Initializes the DN404 contract with an\\n /// `initialTokenSupply`, `initialTokenOwner` and `mirror` NFT contract address.\\n function _initializeDN404(\\n uint256 initialTokenSupply,\\n address initialSupplyOwner,\\n address mirror\\n ) internal virtual {\\n DN404Storage storage $ = _getDN404Storage();\\n\\n unchecked {\\n if (_unit() - 1 >= 2 ** 96 - 1) revert InvalidUnit();\\n }\\n if ($.mirrorERC721 != address(0)) revert DNAlreadyInitialized();\\n if (mirror == address(0)) revert MirrorAddressIsZero();\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Make the call to link the mirror contract.\\n mstore(0x00, 0x0f4599e5) // `linkMirrorContract(address)`.\\n mstore(0x20, caller())\\n if iszero(and(eq(mload(0x00), 1), call(gas(), mirror, 0, 0x1c, 0x24, 0x00, 0x20))) {\\n mstore(0x00, 0xd125259c) // `LinkMirrorContractFailed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n\\n $.nextTokenId = 1;\\n $.mirrorERC721 = mirror;\\n\\n if (initialTokenSupply != 0) {\\n if (initialSupplyOwner == address(0)) revert TransferToZeroAddress();\\n if (_totalSupplyOverflows(initialTokenSupply)) revert TotalSupplyOverflow();\\n\\n $.totalSupply = uint96(initialTokenSupply);\\n AddressData storage initialOwnerAddressData = _addressData(initialSupplyOwner);\\n initialOwnerAddressData.balance = uint96(initialTokenSupply);\\n\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, initialTokenSupply)\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, initialSupplyOwner)))\\n }\\n\\n _setSkipNFT(initialSupplyOwner, true);\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* BASE UNIT FUNCTION TO OVERRIDE */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Amount of token balance that is equal to one NFT.\\n function _unit() internal view virtual returns (uint256) {\\n return 10 ** 18;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* METADATA FUNCTIONS TO OVERRIDE */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the name of the token.\\n function name() public view virtual returns (string memory);\\n\\n /// @dev Returns the symbol of the token.\\n function symbol() public view virtual returns (string memory);\\n\\n /// @dev Returns the Uniform Resource Identifier (URI) for token `id`.\\n function _tokenURI(uint256 id) internal view virtual returns (string memory);\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CONFIGURABLES */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns if direct NFT transfers should be used during ERC20 transfers\\n /// whenever possible, instead of burning and re-minting.\\n function _useDirectTransfersIfPossible() internal view virtual returns (bool) {\\n return true;\\n }\\n\\n /// @dev Returns if burns should be added to the burn pool.\\n /// This returns false by default, which means the NFT IDs are re-minted in a cycle.\\n function _addToBurnedPool(uint256 totalNFTSupplyAfterBurn, uint256 totalSupplyAfterBurn)\\n internal\\n view\\n virtual\\n returns (bool)\\n {\\n // Silence unused variable compiler warning.\\n totalSupplyAfterBurn = totalNFTSupplyAfterBurn;\\n return false;\\n }\\n\\n /// @dev Returns whether to use the exists bitmap for more efficient\\n /// scanning of an empty token ID slot.\\n /// Recommended for collections that do not use the burn pool,\\n /// and are expected to have nearly all possible NFTs materialized.\\n ///\\n /// Note: The returned value must be constant after initialization.\\n function _useExistsLookup() internal view virtual returns (bool) {\\n return true;\\n }\\n\\n /// @dev Hook that is called after any NFT token transfers, including minting and burning.\\n function _afterNFTTransfer(address from, address to, uint256 id) internal virtual {}\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* ERC20 OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the decimals places of the token. Defaults to 18.\\n /// Does not affect DN404's internal calculations.\\n /// Will only affect the frontend UI on most protocols.\\n function decimals() public view virtual returns (uint8) {\\n return 18;\\n }\\n\\n /// @dev Returns the amount of tokens in existence.\\n function totalSupply() public view virtual returns (uint256) {\\n return uint256(_getDN404Storage().totalSupply);\\n }\\n\\n /// @dev Returns the amount of tokens owned by `owner`.\\n function balanceOf(address owner) public view virtual returns (uint256) {\\n return _getDN404Storage().addressData[owner].balance;\\n }\\n\\n /// @dev Returns the amount of tokens that `spender` can spend on behalf of `owner`.\\n function allowance(address owner, address spender) public view returns (uint256) {\\n if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {\\n uint8 flags = _getDN404Storage().addressData[owner].flags;\\n if (_isZero(flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG)) return type(uint256).max;\\n }\\n return _ref(_getDN404Storage().allowance, owner, spender).value;\\n }\\n\\n /// @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n ///\\n /// Emits a {Approval} event.\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @dev Transfer `amount` tokens from the caller to `to`.\\n ///\\n /// Will burn sender NFTs if balance after transfer is less than\\n /// the amount required to support the current NFT balance.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is\\n /// set to false.\\n ///\\n /// Requirements:\\n /// - `from` must at least have `amount`.\\n ///\\n /// Emits a {Transfer} event.\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n _transfer(msg.sender, to, amount);\\n return true;\\n }\\n\\n /// @dev Transfers `amount` tokens from `from` to `to`.\\n ///\\n /// Note: Does not update the allowance if it is the maximum uint256 value.\\n ///\\n /// Will burn sender NFTs if balance after transfer is less than\\n /// the amount required to support the current NFT balance.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is\\n /// set to false.\\n ///\\n /// Requirements:\\n /// - `from` must at least have `amount`.\\n /// - The caller must have at least `amount` of allowance to transfer the tokens of `from`.\\n ///\\n /// Emits a {Transfer} event.\\n function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) {\\n Uint256Ref storage a = _ref(_getDN404Storage().allowance, from, msg.sender);\\n\\n uint256 allowed = _givePermit2DefaultInfiniteAllowance() && msg.sender == _PERMIT2\\n && _isZero(_getDN404Storage().addressData[from].flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG)\\n ? type(uint256).max\\n : a.value;\\n\\n if (allowed != type(uint256).max) {\\n if (amount > allowed) revert InsufficientAllowance();\\n unchecked {\\n a.value = allowed - amount;\\n }\\n }\\n _transfer(from, to, amount);\\n return true;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* PERMIT2 */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Whether Permit2 has infinite allowances by default for all owners.\\n /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.\\n /// To enable, override this function to return true.\\n function _givePermit2DefaultInfiniteAllowance() internal view virtual returns (bool) {\\n return false;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL MINT FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Mints `amount` tokens to `to`, increasing the total supply.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.\\n ///\\n /// Emits a {Transfer} event.\\n function _mint(address to, uint256 amount) internal virtual {\\n if (to == address(0)) revert TransferToZeroAddress();\\n\\n AddressData storage toAddressData = _addressData(to);\\n DN404Storage storage $ = _getDN404Storage();\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n _DNMintTemps memory t;\\n unchecked {\\n uint256 toBalance = uint256(toAddressData.balance) + amount;\\n toAddressData.balance = uint96(toBalance);\\n t.toEnd = toBalance / _unit();\\n }\\n uint256 maxId;\\n unchecked {\\n uint256 totalSupply_ = uint256($.totalSupply) + amount;\\n $.totalSupply = uint96(totalSupply_);\\n uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));\\n if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();\\n maxId = totalSupply_ / _unit();\\n }\\n unchecked {\\n if (_isZero(toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG)) {\\n Uint32Map storage toOwned = $.owned[to];\\n Uint32Map storage oo = $.oo;\\n uint256 toIndex = toAddressData.ownedLength;\\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));\\n\\n if (packedLogs.logs.length != 0) {\\n _packedLogsSet(packedLogs, to, 0);\\n $.totalNFTSupply += uint32(packedLogs.logs.length);\\n toAddressData.ownedLength = uint32(t.toEnd);\\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\\n uint32 burnedPoolHead = $.burnedPoolHead;\\n t.burnedPoolTail = $.burnedPoolTail;\\n t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);\\n // Mint loop.\\n do {\\n uint256 id;\\n if (burnedPoolHead != t.burnedPoolTail) {\\n id = _get($.burnedPool, burnedPoolHead++);\\n } else {\\n id = t.nextTokenId;\\n while (_get(oo, _ownershipIndex(id)) != 0) {\\n id = _useExistsLookup()\\n ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId), maxId)\\n : _wrapNFTId(id + 1, maxId);\\n }\\n t.nextTokenId = _wrapNFTId(id + 1, maxId);\\n }\\n if (_useExistsLookup()) _set($.exists, id, true);\\n _set(toOwned, toIndex, uint32(id));\\n _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));\\n _packedLogsAppend(packedLogs, id);\\n _afterNFTTransfer(address(0), to, id);\\n } while (toIndex != t.toEnd);\\n\\n $.nextTokenId = uint32(t.nextTokenId);\\n $.burnedPoolHead = burnedPoolHead;\\n _packedLogsSend(packedLogs, $.mirrorERC721);\\n }\\n }\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, amount)\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))\\n }\\n }\\n\\n /// @dev Mints `amount` tokens to `to`, increasing the total supply.\\n /// This variant mints NFT tokens starting from ID `preTotalSupply / _unit() + 1`.\\n /// This variant will not touch the `burnedPool` and `nextTokenId`.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.\\n ///\\n /// Emits a {Transfer} event.\\n function _mintNext(address to, uint256 amount) internal virtual {\\n if (to == address(0)) revert TransferToZeroAddress();\\n\\n AddressData storage toAddressData = _addressData(to);\\n DN404Storage storage $ = _getDN404Storage();\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n _DNMintTemps memory t;\\n unchecked {\\n uint256 toBalance = uint256(toAddressData.balance) + amount;\\n toAddressData.balance = uint96(toBalance);\\n t.toEnd = toBalance / _unit();\\n }\\n uint256 startId;\\n uint256 maxId;\\n unchecked {\\n uint256 preTotalSupply = uint256($.totalSupply);\\n startId = preTotalSupply / _unit() + 1;\\n uint256 totalSupply_ = uint256(preTotalSupply) + amount;\\n $.totalSupply = uint96(totalSupply_);\\n uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));\\n if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();\\n maxId = totalSupply_ / _unit();\\n }\\n unchecked {\\n if (_isZero(toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG)) {\\n Uint32Map storage toOwned = $.owned[to];\\n Uint32Map storage oo = $.oo;\\n uint256 toIndex = toAddressData.ownedLength;\\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));\\n\\n if (packedLogs.logs.length != 0) {\\n _packedLogsSet(packedLogs, to, 0);\\n $.totalNFTSupply += uint32(packedLogs.logs.length);\\n toAddressData.ownedLength = uint32(t.toEnd);\\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\\n // Mint loop.\\n do {\\n uint256 id = startId;\\n while (_get(oo, _ownershipIndex(id)) != 0) {\\n id = _useExistsLookup()\\n ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId), maxId)\\n : _wrapNFTId(id + 1, maxId);\\n }\\n startId = _wrapNFTId(id + 1, maxId);\\n if (_useExistsLookup()) _set($.exists, id, true);\\n _set(toOwned, toIndex, uint32(id));\\n _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));\\n _packedLogsAppend(packedLogs, id);\\n _afterNFTTransfer(address(0), to, id);\\n } while (toIndex != t.toEnd);\\n\\n _packedLogsSend(packedLogs, $.mirrorERC721);\\n }\\n }\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, amount)\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL BURN FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Burns `amount` tokens from `from`, reducing the total supply.\\n ///\\n /// Will burn sender NFTs if balance after transfer is less than\\n /// the amount required to support the current NFT balance.\\n ///\\n /// Emits a {Transfer} event.\\n function _burn(address from, uint256 amount) internal virtual {\\n DN404Storage storage $ = _getDN404Storage();\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n AddressData storage fromAddressData = $.addressData[from];\\n uint256 fromBalance = fromAddressData.balance;\\n if (amount > fromBalance) revert InsufficientBalance();\\n\\n unchecked {\\n fromAddressData.balance = uint96(fromBalance -= amount);\\n uint256 totalSupply_ = uint256($.totalSupply) - amount;\\n $.totalSupply = uint96(totalSupply_);\\n\\n Uint32Map storage fromOwned = $.owned[from];\\n uint256 fromIndex = fromAddressData.ownedLength;\\n uint256 numNFTBurns = _zeroFloorSub(fromIndex, fromBalance / _unit());\\n\\n if (numNFTBurns != 0) {\\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(numNFTBurns);\\n _packedLogsSet(packedLogs, from, 1);\\n bool addToBurnedPool;\\n {\\n uint256 totalNFTSupply = uint256($.totalNFTSupply) - numNFTBurns;\\n $.totalNFTSupply = uint32(totalNFTSupply);\\n addToBurnedPool = _addToBurnedPool(totalNFTSupply, totalSupply_);\\n }\\n\\n Uint32Map storage oo = $.oo;\\n uint256 fromEnd = fromIndex - numNFTBurns;\\n fromAddressData.ownedLength = uint32(fromEnd);\\n uint32 burnedPoolTail = $.burnedPoolTail;\\n // Burn loop.\\n do {\\n uint256 id = _get(fromOwned, --fromIndex);\\n _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);\\n _packedLogsAppend(packedLogs, id);\\n if (_useExistsLookup()) _set($.exists, id, false);\\n if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));\\n if (_get($.mayHaveNFTApproval, id)) {\\n _set($.mayHaveNFTApproval, id, false);\\n delete $.nftApprovals[id];\\n }\\n _afterNFTTransfer(from, address(0), id);\\n } while (fromIndex != fromEnd);\\n\\n if (addToBurnedPool) $.burnedPoolTail = burnedPoolTail;\\n _packedLogsSend(packedLogs, $.mirrorERC721);\\n }\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, amount)\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), 0)\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL TRANSFER FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Moves `amount` of tokens from `from` to `to`.\\n ///\\n /// Will burn sender NFTs if balance after transfer is less than\\n /// the amount required to support the current NFT balance.\\n ///\\n /// Will mint NFTs to `to` if the recipient's new balance supports\\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is\\n /// set to false.\\n ///\\n /// Emits a {Transfer} event.\\n function _transfer(address from, address to, uint256 amount) internal virtual {\\n if (to == address(0)) revert TransferToZeroAddress();\\n\\n DN404Storage storage $ = _getDN404Storage();\\n AddressData storage fromAddressData = $.addressData[from];\\n AddressData storage toAddressData = _addressData(to);\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n _DNTransferTemps memory t;\\n t.fromOwnedLength = fromAddressData.ownedLength;\\n t.toOwnedLength = toAddressData.ownedLength;\\n\\n unchecked {\\n {\\n uint256 fromBalance = fromAddressData.balance;\\n if (amount > fromBalance) revert InsufficientBalance();\\n fromAddressData.balance = uint96(fromBalance -= amount);\\n\\n uint256 toBalance = uint256(toAddressData.balance) + amount;\\n toAddressData.balance = uint96(toBalance);\\n t.numNFTBurns = _zeroFloorSub(t.fromOwnedLength, fromBalance / _unit());\\n\\n if (_isZero(toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG)) {\\n if (from == to) t.toOwnedLength = t.fromOwnedLength - t.numNFTBurns;\\n t.numNFTMints = _zeroFloorSub(toBalance / _unit(), t.toOwnedLength);\\n }\\n }\\n\\n while (_useDirectTransfersIfPossible()) {\\n uint256 n = _min(t.fromOwnedLength, _min(t.numNFTBurns, t.numNFTMints));\\n if (_isZero(n)) break;\\n t.numNFTBurns -= n;\\n t.numNFTMints -= n;\\n if (from == to) {\\n t.toOwnedLength += n;\\n break;\\n }\\n _DNDirectLogs memory directLogs = _directLogsMalloc(n, from, to);\\n Uint32Map storage fromOwned = $.owned[from];\\n Uint32Map storage toOwned = $.owned[to];\\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\\n uint256 toIndex = t.toOwnedLength;\\n n = toIndex + n;\\n // Direct transfer loop.\\n do {\\n uint256 id = _get(fromOwned, --t.fromOwnedLength);\\n _set(toOwned, toIndex, uint32(id));\\n _setOwnerAliasAndOwnedIndex($.oo, id, t.toAlias, uint32(toIndex));\\n _directLogsAppend(directLogs, id);\\n if (_get($.mayHaveNFTApproval, id)) {\\n _set($.mayHaveNFTApproval, id, false);\\n delete $.nftApprovals[id];\\n }\\n _afterNFTTransfer(from, to, id);\\n } while (++toIndex != n);\\n\\n toAddressData.ownedLength = uint32(t.toOwnedLength = toIndex);\\n fromAddressData.ownedLength = uint32(t.fromOwnedLength);\\n _directLogsSend(directLogs, $.mirrorERC721);\\n break;\\n }\\n\\n t.totalNFTSupply = uint256($.totalNFTSupply) + t.numNFTMints - t.numNFTBurns;\\n $.totalNFTSupply = uint32(t.totalNFTSupply);\\n\\n Uint32Map storage oo = $.oo;\\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(t.numNFTBurns + t.numNFTMints);\\n\\n t.burnedPoolTail = $.burnedPoolTail;\\n if (t.numNFTBurns != 0) {\\n _packedLogsSet(packedLogs, from, 1);\\n bool addToBurnedPool = _addToBurnedPool(t.totalNFTSupply, $.totalSupply);\\n Uint32Map storage fromOwned = $.owned[from];\\n uint256 fromIndex = t.fromOwnedLength;\\n fromAddressData.ownedLength = uint32(t.fromEnd = fromIndex - t.numNFTBurns);\\n uint32 burnedPoolTail = t.burnedPoolTail;\\n // Burn loop.\\n do {\\n uint256 id = _get(fromOwned, --fromIndex);\\n _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);\\n _packedLogsAppend(packedLogs, id);\\n if (_useExistsLookup()) _set($.exists, id, false);\\n if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));\\n if (_get($.mayHaveNFTApproval, id)) {\\n _set($.mayHaveNFTApproval, id, false);\\n delete $.nftApprovals[id];\\n }\\n _afterNFTTransfer(from, address(0), id);\\n } while (fromIndex != t.fromEnd);\\n\\n if (addToBurnedPool) $.burnedPoolTail = (t.burnedPoolTail = burnedPoolTail);\\n }\\n\\n if (t.numNFTMints != 0) {\\n _packedLogsSet(packedLogs, to, 0);\\n Uint32Map storage toOwned = $.owned[to];\\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\\n uint256 maxId = $.totalSupply / _unit();\\n t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);\\n uint256 toIndex = t.toOwnedLength;\\n toAddressData.ownedLength = uint32(t.toEnd = toIndex + t.numNFTMints);\\n uint32 burnedPoolHead = $.burnedPoolHead;\\n // Mint loop.\\n do {\\n uint256 id;\\n if (burnedPoolHead != t.burnedPoolTail) {\\n id = _get($.burnedPool, burnedPoolHead++);\\n } else {\\n id = t.nextTokenId;\\n while (_get(oo, _ownershipIndex(id)) != 0) {\\n id = _useExistsLookup()\\n ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId), maxId)\\n : _wrapNFTId(id + 1, maxId);\\n }\\n t.nextTokenId = _wrapNFTId(id + 1, maxId);\\n }\\n if (_useExistsLookup()) _set($.exists, id, true);\\n _set(toOwned, toIndex, uint32(id));\\n _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));\\n _packedLogsAppend(packedLogs, id);\\n _afterNFTTransfer(address(0), to, id);\\n } while (toIndex != t.toEnd);\\n\\n $.burnedPoolHead = burnedPoolHead;\\n $.nextTokenId = uint32(t.nextTokenId);\\n }\\n\\n if (packedLogs.logs.length != 0) _packedLogsSend(packedLogs, $.mirrorERC721);\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, amount)\\n // forgefmt: disable-next-item\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))\\n }\\n }\\n\\n /// @dev Transfers token `id` from `from` to `to`.\\n /// Also emits an ERC721 {Transfer} event on the `mirrorERC721`.\\n ///\\n /// Requirements:\\n ///\\n /// - Call must originate from the mirror contract.\\n /// - Token `id` must exist.\\n /// - `from` must be the owner of the token.\\n /// - `to` cannot be the zero address.\\n /// `msgSender` must be the owner of the token, or be approved to manage the token.\\n ///\\n /// Emits a {Transfer} event.\\n function _initiateTransferFromNFT(address from, address to, uint256 id, address msgSender)\\n internal\\n virtual\\n {\\n _transferFromNFT(from, to, id, msgSender);\\n // Emit ERC721 {Transfer} event.\\n _DNDirectLogs memory directLogs = _directLogsMalloc(1, from, to);\\n _directLogsAppend(directLogs, id);\\n _directLogsSend(directLogs, _getDN404Storage().mirrorERC721);\\n }\\n\\n /// @dev Transfers token `id` from `from` to `to`.\\n ///\\n /// Requirements:\\n ///\\n /// - Call must originate from the mirror contract.\\n /// - Token `id` must exist.\\n /// - `from` must be the owner of the token.\\n /// - `to` cannot be the zero address.\\n /// `msgSender` must be the owner of the token, or be approved to manage the token.\\n ///\\n /// Emits a {Transfer} event.\\n function _transferFromNFT(address from, address to, uint256 id, address msgSender)\\n internal\\n virtual\\n {\\n if (to == address(0)) revert TransferToZeroAddress();\\n\\n DN404Storage storage $ = _getDN404Storage();\\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\\n\\n Uint32Map storage oo = $.oo;\\n\\n if (from != $.aliasToAddress[_get(oo, _ownershipIndex(_restrictNFTId(id)))]) {\\n revert TransferFromIncorrectOwner();\\n }\\n\\n if (msgSender != from) {\\n if (!_isApprovedForAll(from, msgSender)) {\\n if (_getApproved(id) != msgSender) {\\n revert TransferCallerNotOwnerNorApproved();\\n }\\n }\\n }\\n\\n AddressData storage fromAddressData = $.addressData[from];\\n AddressData storage toAddressData = $.addressData[to];\\n\\n uint256 unit = _unit();\\n mapping(address => Uint32Map) storage owned = $.owned;\\n\\n unchecked {\\n uint256 fromBalance = fromAddressData.balance;\\n if (unit > fromBalance) revert InsufficientBalance();\\n fromAddressData.balance = uint96(fromBalance - unit);\\n toAddressData.balance += uint96(unit);\\n }\\n if (_get($.mayHaveNFTApproval, id)) {\\n _set($.mayHaveNFTApproval, id, false);\\n delete $.nftApprovals[id];\\n }\\n unchecked {\\n Uint32Map storage fromOwned = owned[from];\\n uint32 updatedId = _get(fromOwned, --fromAddressData.ownedLength);\\n uint32 i = _get(oo, _ownedIndex(id));\\n _set(fromOwned, i, updatedId);\\n _set(oo, _ownedIndex(updatedId), i);\\n }\\n unchecked {\\n uint32 n = toAddressData.ownedLength++;\\n _set(owned[to], n, uint32(id));\\n _setOwnerAliasAndOwnedIndex(oo, id, _registerAndResolveAlias(toAddressData, to), n);\\n }\\n _afterNFTTransfer(from, to, id);\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Transfer} event.\\n mstore(0x00, unit)\\n // forgefmt: disable-next-item\\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL APPROVE FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Sets `amount` as the allowance of `spender` over the tokens of `owner`.\\n ///\\n /// Emits a {Approval} event.\\n function _approve(address owner, address spender, uint256 amount) internal virtual {\\n if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {\\n _getDN404Storage().addressData[owner].flags |= _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG;\\n }\\n _ref(_getDN404Storage().allowance, owner, spender).value = amount;\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Emit the {Approval} event.\\n mstore(0x00, amount)\\n // forgefmt: disable-next-item\\n log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, shr(96, shl(96, owner)), shr(96, shl(96, spender)))\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* DATA HITCHHIKING FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the auxiliary data for `owner`.\\n /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.\\n /// Auxiliary data can be set for any address, even if it does not have any tokens.\\n function _getAux(address owner) internal view virtual returns (uint88) {\\n return _getDN404Storage().addressData[owner].aux;\\n }\\n\\n /// @dev Set the auxiliary data for `owner` to `value`.\\n /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.\\n /// Auxiliary data can be set for any address, even if it does not have any tokens.\\n function _setAux(address owner, uint88 value) internal virtual {\\n _getDN404Storage().addressData[owner].aux = value;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* SKIP NFT FUNCTIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs.\\n /// Returns false otherwise.\\n function getSkipNFT(address owner) public view virtual returns (bool) {\\n AddressData storage d = _getDN404Storage().addressData[owner];\\n if (_isZero(d.flags & _ADDRESS_DATA_INITIALIZED_FLAG)) return _hasCode(owner);\\n return d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0;\\n }\\n\\n /// @dev Sets the caller's skipNFT flag to `skipNFT`. Returns true.\\n ///\\n /// Emits a {SkipNFTSet} event.\\n function setSkipNFT(bool skipNFT) public virtual returns (bool) {\\n _setSkipNFT(msg.sender, skipNFT);\\n return true;\\n }\\n\\n /// @dev Internal function to set account `owner` skipNFT flag to `state`\\n ///\\n /// Initializes account `owner` AddressData if it is not currently initialized.\\n ///\\n /// Emits a {SkipNFTSet} event.\\n function _setSkipNFT(address owner, bool state) internal virtual {\\n AddressData storage d = _addressData(owner);\\n if ((d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0) != state) {\\n d.flags ^= _ADDRESS_DATA_SKIP_NFT_FLAG;\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, iszero(iszero(state)))\\n log2(0x00, 0x20, _SKIP_NFT_SET_EVENT_SIGNATURE, shr(96, shl(96, owner)))\\n }\\n }\\n\\n /// @dev Returns a storage data pointer for account `owner` AddressData\\n ///\\n /// Initializes account `owner` AddressData if it is not currently initialized.\\n function _addressData(address owner) internal virtual returns (AddressData storage d) {\\n d = _getDN404Storage().addressData[owner];\\n unchecked {\\n if (_isZero(d.flags & _ADDRESS_DATA_INITIALIZED_FLAG)) {\\n uint256 skipNFT = _toUint(_hasCode(owner)) * _ADDRESS_DATA_SKIP_NFT_FLAG;\\n d.flags = uint8(skipNFT | _ADDRESS_DATA_INITIALIZED_FLAG);\\n }\\n }\\n }\\n\\n /// @dev Returns the `addressAlias` of account `to`.\\n ///\\n /// Assigns and registers the next alias if `to` alias was not previously registered.\\n function _registerAndResolveAlias(AddressData storage toAddressData, address to)\\n internal\\n virtual\\n returns (uint32 addressAlias)\\n {\\n DN404Storage storage $ = _getDN404Storage();\\n addressAlias = toAddressData.addressAlias;\\n if (_isZero(addressAlias)) {\\n unchecked {\\n addressAlias = ++$.numAliases;\\n }\\n toAddressData.addressAlias = addressAlias;\\n $.aliasToAddress[addressAlias] = to;\\n if (_isZero(addressAlias)) revert(); // Overflow.\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* MIRROR OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the address of the mirror NFT contract.\\n function mirrorERC721() public view virtual returns (address) {\\n return _getDN404Storage().mirrorERC721;\\n }\\n\\n /// @dev Returns the total NFT supply.\\n function _totalNFTSupply() internal view virtual returns (uint256) {\\n return _getDN404Storage().totalNFTSupply;\\n }\\n\\n /// @dev Returns `owner` NFT balance.\\n function _balanceOfNFT(address owner) internal view virtual returns (uint256) {\\n return _getDN404Storage().addressData[owner].ownedLength;\\n }\\n\\n /// @dev Returns the owner of token `id`.\\n /// Returns the zero address instead of reverting if the token does not exist.\\n function _ownerAt(uint256 id) internal view virtual returns (address) {\\n DN404Storage storage $ = _getDN404Storage();\\n return $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];\\n }\\n\\n /// @dev Returns the owner of token `id`.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n function _ownerOf(uint256 id) internal view virtual returns (address) {\\n if (!_exists(id)) revert TokenDoesNotExist();\\n return _ownerAt(id);\\n }\\n\\n /// @dev Returns whether `operator` is approved to manage the NFT tokens of `owner`.\\n function _isApprovedForAll(address owner, address operator)\\n internal\\n view\\n virtual\\n returns (bool)\\n {\\n return !_isZero(_ref(_getDN404Storage().operatorApprovals, owner, operator).value);\\n }\\n\\n /// @dev Returns if token `id` exists.\\n function _exists(uint256 id) internal view virtual returns (bool) {\\n return _ownerAt(id) != address(0);\\n }\\n\\n /// @dev Returns the account approved to manage token `id`.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n function _getApproved(uint256 id) internal view virtual returns (address) {\\n if (!_exists(id)) revert TokenDoesNotExist();\\n return _getDN404Storage().nftApprovals[id];\\n }\\n\\n /// @dev Sets `spender` as the approved account to manage token `id`, using `msgSender`.\\n ///\\n /// Requirements:\\n /// - `msgSender` must be the owner or an approved operator for the token owner.\\n function _approveNFT(address spender, uint256 id, address msgSender)\\n internal\\n virtual\\n returns (address owner)\\n {\\n DN404Storage storage $ = _getDN404Storage();\\n\\n owner = $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];\\n\\n if (msgSender != owner) {\\n if (!_isApprovedForAll(owner, msgSender)) {\\n revert ApprovalCallerNotOwnerNorApproved();\\n }\\n }\\n\\n $.nftApprovals[id] = spender;\\n _set($.mayHaveNFTApproval, id, spender != address(0));\\n }\\n\\n /// @dev Approve or remove the `operator` as an operator for `msgSender`,\\n /// without authorization checks.\\n function _setApprovalForAll(address operator, bool approved, address msgSender)\\n internal\\n virtual\\n {\\n _ref(_getDN404Storage().operatorApprovals, msgSender, operator).value = _toUint(approved);\\n }\\n\\n /// @dev Returns the NFT IDs of `owner` in the range `[begin..end)` (exclusive of `end`).\\n /// `begin` and `end` are indices in the owner's token ID array, not the entire token range.\\n /// Optimized for smaller bytecode size, as this function is intended for off-chain calling.\\n function _ownedIds(address owner, uint256 begin, uint256 end)\\n internal\\n view\\n virtual\\n returns (uint256[] memory ids)\\n {\\n DN404Storage storage $ = _getDN404Storage();\\n Uint32Map storage owned = $.owned[owner];\\n end = _min($.addressData[owner].ownedLength, end);\\n /// @solidity memory-safe-assembly\\n assembly {\\n ids := mload(0x40)\\n let i := begin\\n for {} lt(i, end) { i := add(i, 1) } {\\n let s := add(shl(96, owned.slot), shr(3, i)) // Storage slot.\\n let id := and(0xffffffff, shr(shl(5, and(i, 7)), sload(s)))\\n mstore(add(add(ids, 0x20), shl(5, sub(i, begin))), id) // Append to.\\n }\\n mstore(ids, sub(i, begin)) // Store the length.\\n mstore(0x40, add(add(ids, 0x20), shl(5, sub(i, begin)))) // Allocate memory.\\n }\\n }\\n\\n /// @dev Fallback modifier to dispatch calls from the mirror NFT contract\\n /// to internal functions in this contract.\\n modifier dn404Fallback() virtual {\\n DN404Storage storage $ = _getDN404Storage();\\n\\n uint256 fnSelector = _calldataload(0x00) >> 224;\\n\\n // `transferFromNFT(address,address,uint256,address)`.\\n if (fnSelector == 0xe5eb36c8) {\\n if (msg.sender != $.mirrorERC721) revert SenderNotMirror();\\n _transferFromNFT(\\n address(uint160(_calldataload(0x04))), // `from`.\\n address(uint160(_calldataload(0x24))), // `to`.\\n _calldataload(0x44), // `id`.\\n address(uint160(_calldataload(0x64))) // `msgSender`.\\n );\\n _return(1);\\n }\\n // `setApprovalForAll(address,bool,address)`.\\n if (fnSelector == 0x813500fc) {\\n if (msg.sender != $.mirrorERC721) revert SenderNotMirror();\\n _setApprovalForAll(\\n address(uint160(_calldataload(0x04))), // `spender`.\\n _calldataload(0x24) != 0, // `status`.\\n address(uint160(_calldataload(0x44))) // `msgSender`.\\n );\\n _return(1);\\n }\\n // `isApprovedForAll(address,address)`.\\n if (fnSelector == 0xe985e9c5) {\\n bool result = _isApprovedForAll(\\n address(uint160(_calldataload(0x04))), // `owner`.\\n address(uint160(_calldataload(0x24))) // `operator`.\\n );\\n _return(_toUint(result));\\n }\\n // `ownerOf(uint256)`.\\n if (fnSelector == 0x6352211e) {\\n _return(uint160(_ownerOf(_calldataload(0x04))));\\n }\\n // `ownerAt(uint256)`.\\n if (fnSelector == 0x24359879) {\\n _return(uint160(_ownerAt(_calldataload(0x04))));\\n }\\n // `approveNFT(address,uint256,address)`.\\n if (fnSelector == 0xd10b6e0c) {\\n if (msg.sender != $.mirrorERC721) revert SenderNotMirror();\\n address owner = _approveNFT(\\n address(uint160(_calldataload(0x04))), // `spender`.\\n _calldataload(0x24), // `id`.\\n address(uint160(_calldataload(0x44))) // `msgSender`.\\n );\\n _return(uint160(owner));\\n }\\n // `getApproved(uint256)`.\\n if (fnSelector == 0x081812fc) {\\n _return(uint160(_getApproved(_calldataload(0x04))));\\n }\\n // `balanceOfNFT(address)`.\\n if (fnSelector == 0xf5b100ea) {\\n _return(_balanceOfNFT(address(uint160(_calldataload(0x04)))));\\n }\\n // `totalNFTSupply()`.\\n if (fnSelector == 0xe2c79281) {\\n _return(_totalNFTSupply());\\n }\\n // `tokenURI(uint256)`.\\n if (fnSelector == 0xc87b56dd) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x40, add(mload(0x40), 0x20))\\n }\\n string memory uri = _tokenURI(_calldataload(0x04));\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Memory safe, as we've advanced the free memory pointer by a word.\\n let o := sub(uri, 0x20)\\n mstore(o, 0x20) // Store the offset of `uri`.\\n return(o, add(0x60, mload(uri)))\\n }\\n }\\n // `implementsDN404()`.\\n if (fnSelector == 0xb7a94eb8) {\\n _return(1);\\n }\\n _;\\n }\\n\\n /// @dev Fallback function for calls from mirror NFT contract.\\n /// Override this if you need to implement your custom\\n /// fallback with utilities like Solady's `LibZip.cdFallback()`.\\n /// And always remember to always wrap the fallback with `dn404Fallback`.\\n fallback() external payable virtual dn404Fallback {\\n revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.\\n }\\n\\n /// @dev This is to silence the compiler warning.\\n /// Override and remove the revert if you want your contract to receive ETH via receive.\\n receive() external payable virtual {\\n if (msg.value != 0) revert();\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* INTERNAL / PRIVATE HELPERS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns `(i - 1) << 1`.\\n function _ownershipIndex(uint256 i) internal pure returns (uint256) {\\n unchecked {\\n return (i - 1) << 1; // Minus 1 as token IDs start from 1.\\n }\\n }\\n\\n /// @dev Returns `((i - 1) << 1) + 1`.\\n function _ownedIndex(uint256 i) internal pure returns (uint256) {\\n unchecked {\\n return ((i - 1) << 1) + 1; // Minus 1 as token IDs start from 1.\\n }\\n }\\n\\n /// @dev Returns the uint32 value at `index` in `map`.\\n function _get(Uint32Map storage map, uint256 index) internal view returns (uint32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.\\n result := and(0xffffffff, shr(shl(5, and(index, 7)), sload(s)))\\n }\\n }\\n\\n /// @dev Updates the uint32 value at `index` in `map`.\\n function _set(Uint32Map storage map, uint256 index, uint32 value) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.\\n let o := shl(5, and(index, 7)) // Storage slot offset (bits).\\n let v := sload(s) // Storage slot value.\\n sstore(s, xor(v, shl(o, and(0xffffffff, xor(value, shr(o, v))))))\\n }\\n }\\n\\n /// @dev Sets the owner alias and the owned index together.\\n function _setOwnerAliasAndOwnedIndex(\\n Uint32Map storage map,\\n uint256 id,\\n uint32 ownership,\\n uint32 ownedIndex\\n ) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let i := sub(id, 1) // Index of the uint64 combined value.\\n let s := add(shl(96, map.slot), shr(2, i)) // Storage slot.\\n let v := sload(s) // Storage slot value.\\n let o := shl(6, and(i, 3)) // Storage slot offset (bits).\\n let combined := or(shl(32, ownedIndex), and(0xffffffff, ownership))\\n sstore(s, xor(v, shl(o, and(0xffffffffffffffff, xor(shr(o, v), combined)))))\\n }\\n }\\n\\n /// @dev Returns the boolean value of the bit at `index` in `bitmap`.\\n function _get(Bitmap storage bitmap, uint256 index) internal view returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.\\n result := and(1, shr(and(0xff, index), sload(s)))\\n }\\n }\\n\\n /// @dev Updates the bit at `index` in `bitmap` to `value`.\\n function _set(Bitmap storage bitmap, uint256 index, bool value) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.\\n let o := and(0xff, index) // Storage slot offset (bits).\\n sstore(s, or(and(sload(s), not(shl(o, 1))), shl(o, iszero(iszero(value)))))\\n }\\n }\\n\\n /// @dev Returns the index of the least significant unset bit in `[begin..upTo]`.\\n /// If no set bit is found, returns `type(uint256).max`.\\n function _findFirstUnset(Bitmap storage bitmap, uint256 begin, uint256 upTo)\\n internal\\n view\\n returns (uint256 unsetBitIndex)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n unsetBitIndex := not(0) // Initialize to `type(uint256).max`.\\n let s := shl(96, bitmap.slot) // Storage offset of the bitmap.\\n let bucket := add(s, shr(8, begin))\\n let negBits := shl(and(0xff, begin), shr(and(0xff, begin), not(sload(bucket))))\\n if iszero(negBits) {\\n let lastBucket := add(s, shr(8, upTo))\\n for {} 1 {} {\\n bucket := add(bucket, 1)\\n negBits := not(sload(bucket))\\n if or(negBits, gt(bucket, lastBucket)) { break }\\n }\\n if gt(bucket, lastBucket) {\\n negBits := shr(and(0xff, not(upTo)), shl(and(0xff, not(upTo)), negBits))\\n }\\n }\\n if negBits {\\n // Find-first-set routine.\\n // From: https://github.com/vectorized/solady/blob/main/src/utils/LibBit.sol\\n let b := and(negBits, add(not(negBits), 1)) // Isolate the least significant bit.\\n // For the upper 3 bits of the result, use a De Bruijn-like lookup.\\n // Credit to adhusson: https://blog.adhusson.com/cheap-find-first-set-evm/\\n // forgefmt: disable-next-item\\n let r := shl(5, shr(252, shl(shl(2, shr(250, mul(b,\\n 0x2aaaaaaaba69a69a6db6db6db2cb2cb2ce739ce73def7bdeffffffff))),\\n 0x1412563212c14164235266736f7425221143267a45243675267677)))\\n // For the lower 5 bits of the result, use a De Bruijn lookup.\\n // forgefmt: disable-next-item\\n r := or(r, byte(and(div(0xd76453e0, shr(r, b)), 0x1f),\\n 0x001f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405))\\n r := or(shl(8, sub(bucket, s)), r)\\n unsetBitIndex := or(r, sub(0, or(gt(r, upTo), lt(r, begin))))\\n }\\n }\\n }\\n\\n /// @dev Returns a storage reference to the value at (`a0`, `a1`) in `map`.\\n function _ref(AddressPairToUint256RefMap storage map, address a0, address a1)\\n internal\\n pure\\n returns (Uint256Ref storage ref)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x28, a1)\\n mstore(0x14, a0)\\n mstore(0x00, map.slot)\\n ref.slot := keccak256(0x00, 0x48)\\n // Clear the part of the free memory pointer that was overwritten.\\n mstore(0x28, 0x00)\\n }\\n }\\n\\n /// @dev Wraps the NFT ID.\\n function _wrapNFTId(uint256 id, uint256 maxId) internal pure returns (uint256 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := or(mul(iszero(gt(id, maxId)), id), gt(id, maxId))\\n }\\n }\\n\\n /// @dev Returns `id > type(uint32).max ? 0 : id`.\\n function _restrictNFTId(uint256 id) internal pure returns (uint256 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := mul(id, lt(id, 0x100000000))\\n }\\n }\\n\\n /// @dev Returns whether `amount` is a valid `totalSupply`.\\n function _totalSupplyOverflows(uint256 amount) internal view returns (bool result) {\\n uint256 unit = _unit();\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := iszero(iszero(or(shr(96, amount), lt(0xfffffffe, div(amount, unit)))))\\n }\\n }\\n\\n /// @dev Returns `max(0, x - y)`.\\n function _zeroFloorSub(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n z := mul(gt(x, y), sub(x, y))\\n }\\n }\\n\\n /// @dev Returns `x < y ? x : y`.\\n function _min(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n z := xor(x, mul(xor(x, y), lt(y, x)))\\n }\\n }\\n\\n /// @dev Returns `b ? 1 : 0`.\\n function _toUint(bool b) internal pure returns (uint256 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := iszero(iszero(b))\\n }\\n }\\n\\n /// @dev Returns `b == 0`. This is because solc is sometimes dumb.\\n function _isZero(uint256 x) internal pure returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := iszero(x)\\n }\\n }\\n\\n /// @dev Struct containing direct transfer log data for {Transfer} events to be\\n /// emitted by the mirror NFT contract.\\n struct _DNDirectLogs {\\n uint256 offset;\\n uint256[] logs;\\n }\\n\\n /// @dev Initiates memory allocation for direct logs with `n` log items.\\n function _directLogsMalloc(uint256 n, address from, address to)\\n private\\n pure\\n returns (_DNDirectLogs memory p)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40)\\n mstore(m, 0x144027d3) // `logDirectTransfer(address,address,uint256[])`.\\n mstore(add(m, 0x20), shr(96, shl(96, from)))\\n mstore(add(m, 0x40), shr(96, shl(96, to)))\\n mstore(add(m, 0x60), 0x60) // Offset of `logs` in the calldata to send.\\n // Skip 4 words: `fnSelector`, `from`, `to`, `calldataLogsOffset`.\\n let logs := add(0x80, m)\\n mstore(logs, n) // Store the length.\\n let offset := add(0x20, logs) // Skip the word for `p.logs.length`.\\n mstore(0x40, add(offset, shl(5, n))) // Allocate memory.\\n mstore(add(0x20, p), logs) // Set `p.logs`.\\n mstore(p, offset) // Set `p.offset`.\\n }\\n }\\n\\n /// @dev Adds a direct log item to `p` with token `id`.\\n function _directLogsAppend(_DNDirectLogs memory p, uint256 id) private pure {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let offset := mload(p)\\n mstore(offset, id)\\n mstore(p, add(offset, 0x20))\\n }\\n }\\n\\n /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.\\n function _directLogsSend(_DNDirectLogs memory p, address mirror) private {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let logs := mload(add(p, 0x20))\\n let n := add(0x84, shl(5, mload(logs))) // Length of calldata to send.\\n let o := sub(logs, 0x80) // Start of calldata to send.\\n if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {\\n revert(o, 0x00)\\n }\\n }\\n }\\n\\n /// @dev Struct containing packed log data for {Transfer} events to be\\n /// emitted by the mirror NFT contract.\\n struct _DNPackedLogs {\\n uint256 offset;\\n uint256 addressAndBit;\\n uint256[] logs;\\n }\\n\\n /// @dev Initiates memory allocation for packed logs with `n` log items.\\n function _packedLogsMalloc(uint256 n) private pure returns (_DNPackedLogs memory p) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Note that `p` implicitly allocates and advances the free memory pointer by\\n // 3 words, which we can safely mutate in `_packedLogsSend`.\\n let logs := mload(0x40)\\n mstore(logs, n) // Store the length.\\n let offset := add(0x20, logs) // Skip the word for `p.logs.length`.\\n mstore(0x40, add(offset, shl(5, n))) // Allocate memory.\\n mstore(add(0x40, p), logs) // Set `p.logs`.\\n mstore(p, offset) // Set `p.offset`.\\n }\\n }\\n\\n /// @dev Set the current address and the burn bit.\\n function _packedLogsSet(_DNPackedLogs memory p, address a, uint256 burnBit) private pure {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(add(p, 0x20), or(shl(96, a), burnBit)) // Set `p.addressAndBit`.\\n }\\n }\\n\\n /// @dev Adds a packed log item to `p` with token `id`.\\n function _packedLogsAppend(_DNPackedLogs memory p, uint256 id) private pure {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let offset := mload(p)\\n mstore(offset, or(mload(add(p, 0x20)), shl(8, id))) // `p.addressAndBit | (id << 8)`.\\n mstore(p, add(offset, 0x20))\\n }\\n }\\n\\n /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.\\n function _packedLogsSend(_DNPackedLogs memory p, address mirror) private {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let logs := mload(add(p, 0x40))\\n let o := sub(logs, 0x40) // Start of calldata to send.\\n mstore(o, 0x263c69d6) // `logTransfer(uint256[])`.\\n mstore(add(o, 0x20), 0x20) // Offset of `logs` in the calldata to send.\\n let n := add(0x44, shl(5, mload(logs))) // Length of calldata to send.\\n if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {\\n revert(o, 0x00)\\n }\\n }\\n }\\n\\n /// @dev Struct of temporary variables for transfers.\\n struct _DNTransferTemps {\\n uint256 numNFTBurns;\\n uint256 numNFTMints;\\n uint256 fromOwnedLength;\\n uint256 toOwnedLength;\\n uint256 totalNFTSupply;\\n uint256 fromEnd;\\n uint256 toEnd;\\n uint32 toAlias;\\n uint256 nextTokenId;\\n uint32 burnedPoolTail;\\n }\\n\\n /// @dev Struct of temporary variables for mints.\\n struct _DNMintTemps {\\n uint256 nextTokenId;\\n uint32 burnedPoolTail;\\n uint256 toEnd;\\n uint32 toAlias;\\n }\\n\\n /// @dev Returns if `a` has bytecode of non-zero length.\\n function _hasCode(address a) private view returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := extcodesize(a) // Can handle dirty upper bits.\\n }\\n }\\n\\n /// @dev Returns the calldata value at `offset`.\\n function _calldataload(uint256 offset) private pure returns (uint256 value) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n value := calldataload(offset)\\n }\\n }\\n\\n /// @dev Executes a return opcode to return `x` and end the current call frame.\\n function _return(uint256 x) private pure {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, x)\\n return(0x00, 0x20)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2d80b1d76a7b1bf630fd12b4ea357b4770cc8f447b3be2bcbe73823a43d3b042\",\"license\":\"MIT\"},\"dn404/src/DN404Mirror.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @title DN404Mirror\\n/// @notice DN404Mirror provides an interface for interacting with the\\n/// NFT tokens in a DN404 implementation.\\n///\\n/// @author vectorized.eth (@optimizoor)\\n/// @author Quit (@0xQuit)\\n/// @author Michael Amadi (@AmadiMichaels)\\n/// @author cygaar (@0xCygaar)\\n/// @author Thomas (@0xjustadev)\\n/// @author Harrison (@PopPunkOnChain)\\n///\\n/// @dev Note:\\n/// - The ERC721 data is stored in the base DN404 contract.\\ncontract DN404Mirror {\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* EVENTS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Emitted when token `id` is transferred from `from` to `to`.\\n event Transfer(address indexed from, address indexed to, uint256 indexed id);\\n\\n /// @dev Emitted when `owner` enables `account` to manage the `id` token.\\n event Approval(address indexed owner, address indexed account, uint256 indexed id);\\n\\n /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.\\n event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);\\n\\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\\n /// This is for marketplace signaling purposes. This contract has a `pullOwner()`\\n /// function that will sync the owner from the base contract.\\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\\n\\n /// @dev `keccak256(bytes(\\\"Transfer(address,address,uint256)\\\"))`.\\n uint256 private constant _TRANSFER_EVENT_SIGNATURE =\\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\\n\\n /// @dev `keccak256(bytes(\\\"Approval(address,address,uint256)\\\"))`.\\n uint256 private constant _APPROVAL_EVENT_SIGNATURE =\\n 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;\\n\\n /// @dev `keccak256(bytes(\\\"ApprovalForAll(address,address,bool)\\\"))`.\\n uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =\\n 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CUSTOM ERRORS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Thrown when a call for an NFT function did not originate\\n /// from the base DN404 contract.\\n error SenderNotBase();\\n\\n /// @dev Thrown when a call for an NFT function did not originate from the deployer.\\n error SenderNotDeployer();\\n\\n /// @dev Thrown when transferring an NFT to a contract address that\\n /// does not implement ERC721Receiver.\\n error TransferToNonERC721ReceiverImplementer();\\n\\n /// @dev Thrown when linking to the DN404 base contract and the\\n /// DN404 supportsInterface check fails or the call reverts.\\n error CannotLink();\\n\\n /// @dev Thrown when a linkMirrorContract call is received and the\\n /// NFT mirror contract has already been linked to a DN404 base contract.\\n error AlreadyLinked();\\n\\n /// @dev Thrown when retrieving the base DN404 address when a link has not\\n /// been established.\\n error NotLinked();\\n\\n /// @dev The function selector is not recognized.\\n error FnSelectorNotRecognized();\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* STORAGE */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Struct contain the NFT mirror contract storage.\\n struct DN404NFTStorage {\\n // Address of the ERC20 base contract.\\n address baseERC20;\\n // The deployer, if provided. If non-zero, the initialization of the\\n // ERC20 <-> ERC721 link can only be done be the deployer via the ERC20 base contract.\\n address deployer;\\n // The owner of the ERC20 base contract. For marketplace signaling.\\n address owner;\\n }\\n\\n /// @dev Returns a storage pointer for DN404NFTStorage.\\n function _getDN404NFTStorage() internal pure virtual returns (DN404NFTStorage storage $) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // `uint72(bytes9(keccak256(\\\"DN404_MIRROR_STORAGE\\\")))`.\\n $.slot := 0x3602298b8c10b01230 // Truncate to 9 bytes to reduce bytecode size.\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* CONSTRUCTOR */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n constructor(address deployer) {\\n // For non-proxies, we will store the deployer so that only the deployer can\\n // link the base contract.\\n _getDN404NFTStorage().deployer = deployer;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* ERC721 OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the token collection name from the base DN404 contract.\\n function name() public view virtual returns (string memory) {\\n return _readString(0x06fdde03, 0); // `name()`.\\n }\\n\\n /// @dev Returns the token collection symbol from the base DN404 contract.\\n function symbol() public view virtual returns (string memory) {\\n return _readString(0x95d89b41, 0); // `symbol()`.\\n }\\n\\n /// @dev Returns the Uniform Resource Identifier (URI) for token `id` from\\n /// the base DN404 contract.\\n function tokenURI(uint256 id) public view virtual returns (string memory) {\\n return _readString(0xc87b56dd, id); // `tokenURI(uint256)`.\\n }\\n\\n /// @dev Returns the total NFT supply from the base DN404 contract.\\n function totalSupply() public view virtual returns (uint256) {\\n return _readWord(0xe2c79281, 0, 0); // `totalNFTSupply()`.\\n }\\n\\n /// @dev Returns the number of NFT tokens owned by `nftOwner` from the base DN404 contract.\\n ///\\n /// Requirements:\\n /// - `nftOwner` must not be the zero address.\\n function balanceOf(address nftOwner) public view virtual returns (uint256) {\\n return _readWord(0xf5b100ea, uint160(nftOwner), 0); // `balanceOfNFT(address)`.\\n }\\n\\n /// @dev Returns the owner of token `id` from the base DN404 contract.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n function ownerOf(uint256 id) public view virtual returns (address) {\\n return address(uint160(_readWord(0x6352211e, id, 0))); // `ownerOf(uint256)`.\\n }\\n\\n /// @dev Returns the owner of token `id` from the base DN404 contract.\\n /// Returns `address(0)` instead of reverting if the token does not exist.\\n function ownerAt(uint256 id) public view virtual returns (address) {\\n return address(uint160(_readWord(0x24359879, id, 0))); // `ownerAt(uint256)`.\\n }\\n\\n /// @dev Sets `spender` as the approved account to manage token `id` in\\n /// the base DN404 contract.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n /// - The caller must be the owner of the token,\\n /// or an approved operator for the token owner.\\n ///\\n /// Emits an {Approval} event.\\n function approve(address spender, uint256 id) public payable virtual {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n spender := shr(96, shl(96, spender))\\n let m := mload(0x40)\\n mstore(0x00, 0xd10b6e0c) // `approveNFT(address,uint256,address)`.\\n mstore(0x20, spender)\\n mstore(0x40, id)\\n mstore(0x60, caller())\\n if iszero(\\n and( // Arguments of `and` are evaluated last to first.\\n gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.\\n call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)\\n )\\n ) {\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n mstore(0x40, m) // Restore the free memory pointer.\\n mstore(0x60, 0) // Restore the zero pointer.\\n // Emit the {Approval} event.\\n log4(codesize(), 0x00, _APPROVAL_EVENT_SIGNATURE, shr(96, mload(0x0c)), spender, id)\\n }\\n }\\n\\n /// @dev Returns the account approved to manage token `id` from\\n /// the base DN404 contract.\\n ///\\n /// Requirements:\\n /// - Token `id` must exist.\\n function getApproved(uint256 id) public view virtual returns (address) {\\n return address(uint160(_readWord(0x081812fc, id, 0))); // `getApproved(uint256)`.\\n }\\n\\n /// @dev Sets whether `operator` is approved to manage the tokens of the caller in\\n /// the base DN404 contract.\\n ///\\n /// Emits an {ApprovalForAll} event.\\n function setApprovalForAll(address operator, bool approved) public virtual {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n operator := shr(96, shl(96, operator))\\n let m := mload(0x40)\\n mstore(0x00, 0x813500fc) // `setApprovalForAll(address,bool,address)`.\\n mstore(0x20, operator)\\n mstore(0x40, iszero(iszero(approved)))\\n mstore(0x60, caller())\\n if iszero(\\n and( // Arguments of `and` are evaluated last to first.\\n eq(mload(0x00), 1), // The call must return 1.\\n call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)\\n )\\n ) {\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n // Emit the {ApprovalForAll} event.\\n // The `approved` value is already at 0x40.\\n log3(0x40, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), operator)\\n mstore(0x40, m) // Restore the free memory pointer.\\n mstore(0x60, 0) // Restore the zero pointer.\\n }\\n }\\n\\n /// @dev Returns whether `operator` is approved to manage the tokens of `nftOwner` from\\n /// the base DN404 contract.\\n function isApprovedForAll(address nftOwner, address operator)\\n public\\n view\\n virtual\\n returns (bool)\\n {\\n // `isApprovedForAll(address,address)`.\\n return _readWord(0xe985e9c5, uint160(nftOwner), uint160(operator)) != 0;\\n }\\n\\n /// @dev Transfers token `id` from `from` to `to`.\\n ///\\n /// Requirements:\\n ///\\n /// - Token `id` must exist.\\n /// - `from` must be the owner of the token.\\n /// - `to` cannot be the zero address.\\n /// - The caller must be the owner of the token, or be approved to manage the token.\\n ///\\n /// Emits a {Transfer} event.\\n function transferFrom(address from, address to, uint256 id) public payable virtual {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n from := shr(96, shl(96, from))\\n to := shr(96, shl(96, to))\\n let m := mload(0x40)\\n mstore(m, 0xe5eb36c8) // `transferFromNFT(address,address,uint256,address)`.\\n mstore(add(m, 0x20), from)\\n mstore(add(m, 0x40), to)\\n mstore(add(m, 0x60), id)\\n mstore(add(m, 0x80), caller())\\n if iszero(\\n and( // Arguments of `and` are evaluated last to first.\\n eq(mload(m), 1), // The call must return 1.\\n call(gas(), base, callvalue(), add(m, 0x1c), 0x84, m, 0x20)\\n )\\n ) {\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n // Emit the {Transfer} event.\\n log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id)\\n }\\n }\\n\\n /// @dev Equivalent to `safeTransferFrom(from, to, id, \\\"\\\")`.\\n function safeTransferFrom(address from, address to, uint256 id) public payable virtual {\\n transferFrom(from, to, id);\\n if (_hasCode(to)) _checkOnERC721Received(from, to, id, \\\"\\\");\\n }\\n\\n /// @dev Transfers token `id` from `from` to `to`.\\n ///\\n /// Requirements:\\n ///\\n /// - Token `id` must exist.\\n /// - `from` must be the owner of the token.\\n /// - `to` cannot be the zero address.\\n /// - The caller must be the owner of the token, or be approved to manage the token.\\n /// - If `to` refers to a smart contract, it must implement\\n /// {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n ///\\n /// Emits a {Transfer} event.\\n function safeTransferFrom(address from, address to, uint256 id, bytes calldata data)\\n public\\n payable\\n virtual\\n {\\n transferFrom(from, to, id);\\n if (_hasCode(to)) _checkOnERC721Received(from, to, id, data);\\n }\\n\\n /// @dev Returns true if this contract implements the interface defined by `interfaceId`.\\n /// See: https://eips.ethereum.org/EIPS/eip-165\\n /// This function call must use less than 30000 gas.\\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let s := shr(224, interfaceId)\\n // ERC165: 0x01ffc9a7, ERC721: 0x80ac58cd, ERC721Metadata: 0x5b5e139f.\\n result := or(or(eq(s, 0x01ffc9a7), eq(s, 0x80ac58cd)), eq(s, 0x5b5e139f))\\n }\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* OWNER SYNCING OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the `owner` of the contract, for marketplace signaling purposes.\\n function owner() public view virtual returns (address) {\\n return _getDN404NFTStorage().owner;\\n }\\n\\n /// @dev Permissionless function to pull the owner from the base DN404 contract\\n /// if it implements ownable, for marketplace signaling purposes.\\n function pullOwner() public virtual returns (bool) {\\n address newOwner;\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, 0x8da5cb5b) // `owner()`.\\n let success := staticcall(gas(), base, 0x1c, 0x04, 0x00, 0x20)\\n newOwner := mul(shr(96, mload(0x0c)), and(gt(returndatasize(), 0x1f), success))\\n }\\n DN404NFTStorage storage $ = _getDN404NFTStorage();\\n address oldOwner = $.owner;\\n if (oldOwner != newOwner) {\\n $.owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n return true;\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* MIRROR OPERATIONS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Returns the address of the base DN404 contract.\\n function baseERC20() public view virtual returns (address base) {\\n base = _getDN404NFTStorage().baseERC20;\\n if (base == address(0)) revert NotLinked();\\n }\\n\\n /// @dev Fallback modifier to execute calls from the base DN404 contract.\\n modifier dn404NFTFallback() virtual {\\n DN404NFTStorage storage $ = _getDN404NFTStorage();\\n\\n uint256 fnSelector = _calldataload(0x00) >> 224;\\n\\n // `logTransfer(uint256[])`.\\n if (fnSelector == 0x263c69d6) {\\n if (msg.sender != $.baseERC20) revert SenderNotBase();\\n /// @solidity memory-safe-assembly\\n assembly {\\n let o := add(0x24, calldataload(0x04)) // Packed logs offset.\\n let end := add(o, shl(5, calldataload(sub(o, 0x20))))\\n for {} iszero(eq(o, end)) { o := add(0x20, o) } {\\n let d := calldataload(o) // Entry in the packed logs.\\n let a := shr(96, d) // The address.\\n let b := and(1, d) // Whether it is a burn.\\n log4(\\n codesize(),\\n 0x00,\\n _TRANSFER_EVENT_SIGNATURE,\\n mul(a, b), // `from`.\\n mul(a, iszero(b)), // `to`.\\n shr(168, shl(160, d)) // `id`.\\n )\\n }\\n mstore(0x00, 0x01)\\n return(0x00, 0x20)\\n }\\n }\\n // `logDirectTransfer(address,address,uint256[])`.\\n if (fnSelector == 0x144027d3) {\\n if (msg.sender != $.baseERC20) revert SenderNotBase();\\n /// @solidity memory-safe-assembly\\n assembly {\\n let from := calldataload(0x04)\\n let to := calldataload(0x24)\\n let o := add(0x24, calldataload(0x44)) // Direct logs offset.\\n let end := add(o, shl(5, calldataload(sub(o, 0x20))))\\n for {} iszero(eq(o, end)) { o := add(0x20, o) } {\\n log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, calldataload(o))\\n }\\n mstore(0x00, 0x01)\\n return(0x00, 0x20)\\n }\\n }\\n // `linkMirrorContract(address)`.\\n if (fnSelector == 0x0f4599e5) {\\n if ($.deployer != address(0)) {\\n if (address(uint160(_calldataload(0x04))) != $.deployer) {\\n revert SenderNotDeployer();\\n }\\n }\\n if ($.baseERC20 != address(0)) revert AlreadyLinked();\\n $.baseERC20 = msg.sender;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, 0x01)\\n return(0x00, 0x20)\\n }\\n }\\n _;\\n }\\n\\n /// @dev Fallback function for calls from base DN404 contract.\\n /// Override this if you need to implement your custom\\n /// fallback with utilities like Solady's `LibZip.cdFallback()`.\\n /// And always remember to always wrap the fallback with `dn404NFTFallback`.\\n fallback() external payable virtual dn404NFTFallback {\\n revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.\\n }\\n\\n /// @dev This is to silence the compiler warning.\\n /// Override and remove the revert if you want your contract to receive ETH via receive.\\n receive() external payable virtual {\\n if (msg.value != 0) revert();\\n }\\n\\n /*\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-\\u00ab-*/\\n /* PRIVATE HELPERS */\\n /*-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb-\\u00bb*/\\n\\n /// @dev Helper to read a string from the base DN404 contract.\\n function _readString(uint256 fnSelector, uint256 arg0)\\n private\\n view\\n returns (string memory result)\\n {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := mload(0x40)\\n mstore(0x00, fnSelector)\\n mstore(0x20, arg0)\\n if iszero(staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x00)) {\\n returndatacopy(result, 0x00, returndatasize())\\n revert(result, returndatasize())\\n }\\n returndatacopy(0x00, 0x00, 0x20) // Copy the offset of the string in returndata.\\n returndatacopy(result, mload(0x00), 0x20) // Copy the length of the string.\\n returndatacopy(add(result, 0x20), add(mload(0x00), 0x20), mload(result)) // Copy the string.\\n let end := add(add(result, 0x20), mload(result))\\n mstore(end, 0) // Zeroize the word after the string.\\n mstore(0x40, add(end, 0x20)) // Allocate memory.\\n }\\n }\\n\\n /// @dev Helper to read a word from the base DN404 contract.\\n function _readWord(uint256 fnSelector, uint256 arg0, uint256 arg1)\\n private\\n view\\n returns (uint256 result)\\n {\\n address base = baseERC20();\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40)\\n mstore(0x00, fnSelector)\\n mstore(0x20, arg0)\\n mstore(0x40, arg1)\\n if iszero(\\n and( // Arguments of `and` are evaluated last to first.\\n gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.\\n staticcall(gas(), base, 0x1c, 0x44, 0x00, 0x20)\\n )\\n ) {\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n mstore(0x40, m) // Restore the free memory pointer.\\n result := mload(0x00)\\n }\\n }\\n\\n /// @dev Returns the calldata value at `offset`.\\n function _calldataload(uint256 offset) private pure returns (uint256 value) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n value := calldataload(offset)\\n }\\n }\\n\\n /// @dev Returns if `a` has bytecode of non-zero length.\\n function _hasCode(address a) private view returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := extcodesize(a) // Can handle dirty upper bits.\\n }\\n }\\n\\n /// @dev Perform a call to invoke {IERC721Receiver-onERC721Received} on `to`.\\n /// Reverts if the target does not support the function correctly.\\n function _checkOnERC721Received(address from, address to, uint256 id, bytes memory data)\\n private\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Prepare the calldata.\\n let m := mload(0x40)\\n let onERC721ReceivedSelector := 0x150b7a02\\n mstore(m, onERC721ReceivedSelector)\\n mstore(add(m, 0x20), caller()) // The `operator`, which is always `msg.sender`.\\n mstore(add(m, 0x40), shr(96, shl(96, from)))\\n mstore(add(m, 0x60), id)\\n mstore(add(m, 0x80), 0x80)\\n let n := mload(data)\\n mstore(add(m, 0xa0), n)\\n if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xc0), n)) }\\n // Revert if the call reverts.\\n if iszero(call(gas(), to, 0, add(m, 0x1c), add(n, 0xa4), m, 0x20)) {\\n if returndatasize() {\\n // Bubble up the revert if the call reverts.\\n returndatacopy(m, 0x00, returndatasize())\\n revert(m, returndatasize())\\n }\\n }\\n // Load the returndata and compare it.\\n if iszero(eq(mload(m), shl(224, onERC721ReceivedSelector))) {\\n mstore(0x00, 0xd1a57ed6) // `TransferToNonERC721ReceiverImplementer()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe733b0633f67e2dae563882ff76b9aa429ffd98b0c008c29e1635b82614b513b\",\"license\":\"MIT\"},\"solady/src/auth/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @notice Simple single owner authorization mixin.\\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)\\n///\\n/// @dev Note:\\n/// This implementation does NOT auto-initialize the owner to `msg.sender`.\\n/// You MUST call the `_initializeOwner` in the constructor / initializer.\\n///\\n/// While the ownable portion follows\\n/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,\\n/// the nomenclature for the 2-step ownership handover may be unique to this codebase.\\nabstract contract Ownable {\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CUSTOM ERRORS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The caller is not authorized to call the function.\\n error Unauthorized();\\n\\n /// @dev The `newOwner` cannot be the zero address.\\n error NewOwnerIsZeroAddress();\\n\\n /// @dev The `pendingOwner` does not have a valid handover request.\\n error NoHandoverRequest();\\n\\n /// @dev Cannot double-initialize.\\n error AlreadyInitialized();\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* EVENTS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\\n /// This event is intentionally kept the same as OpenZeppelin's Ownable to be\\n /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),\\n /// despite it not being as lightweight as a single argument event.\\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\\n\\n /// @dev An ownership handover to `pendingOwner` has been requested.\\n event OwnershipHandoverRequested(address indexed pendingOwner);\\n\\n /// @dev The ownership handover to `pendingOwner` has been canceled.\\n event OwnershipHandoverCanceled(address indexed pendingOwner);\\n\\n /// @dev `keccak256(bytes(\\\"OwnershipTransferred(address,address)\\\"))`.\\n uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =\\n 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;\\n\\n /// @dev `keccak256(bytes(\\\"OwnershipHandoverRequested(address)\\\"))`.\\n uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =\\n 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;\\n\\n /// @dev `keccak256(bytes(\\\"OwnershipHandoverCanceled(address)\\\"))`.\\n uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =\\n 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* STORAGE */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The owner slot is given by:\\n /// `bytes32(~uint256(uint32(bytes4(keccak256(\\\"_OWNER_SLOT_NOT\\\")))))`.\\n /// It is intentionally chosen to be a high value\\n /// to avoid collision with lower slots.\\n /// The choice of manual storage layout is to enable compatibility\\n /// with both regular and upgradeable contracts.\\n bytes32 internal constant _OWNER_SLOT =\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927;\\n\\n /// The ownership handover slot of `newOwner` is given by:\\n /// ```\\n /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))\\n /// let handoverSlot := keccak256(0x00, 0x20)\\n /// ```\\n /// It stores the expiry timestamp of the two-step ownership handover.\\n uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* INTERNAL FUNCTIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Override to return true to make `_initializeOwner` prevent double-initialization.\\n function _guardInitializeOwner() internal pure virtual returns (bool guard) {}\\n\\n /// @dev Initializes the owner directly without authorization guard.\\n /// This function must be called upon initialization,\\n /// regardless of whether the contract is upgradeable or not.\\n /// This is to enable generalization to both regular and upgradeable contracts,\\n /// and to save gas in case the initial owner is not the caller.\\n /// For performance reasons, this function will not check if there\\n /// is an existing owner.\\n function _initializeOwner(address newOwner) internal virtual {\\n if (_guardInitializeOwner()) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ownerSlot := _OWNER_SLOT\\n if sload(ownerSlot) {\\n mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`.\\n revert(0x1c, 0x04)\\n }\\n // Clean the upper 96 bits.\\n newOwner := shr(96, shl(96, newOwner))\\n // Store the new value.\\n sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))\\n // Emit the {OwnershipTransferred} event.\\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\\n }\\n } else {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Clean the upper 96 bits.\\n newOwner := shr(96, shl(96, newOwner))\\n // Store the new value.\\n sstore(_OWNER_SLOT, newOwner)\\n // Emit the {OwnershipTransferred} event.\\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\\n }\\n }\\n }\\n\\n /// @dev Sets the owner directly without authorization guard.\\n function _setOwner(address newOwner) internal virtual {\\n if (_guardInitializeOwner()) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ownerSlot := _OWNER_SLOT\\n // Clean the upper 96 bits.\\n newOwner := shr(96, shl(96, newOwner))\\n // Emit the {OwnershipTransferred} event.\\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\\n // Store the new value.\\n sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))\\n }\\n } else {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ownerSlot := _OWNER_SLOT\\n // Clean the upper 96 bits.\\n newOwner := shr(96, shl(96, newOwner))\\n // Emit the {OwnershipTransferred} event.\\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\\n // Store the new value.\\n sstore(ownerSlot, newOwner)\\n }\\n }\\n }\\n\\n /// @dev Throws if the sender is not the owner.\\n function _checkOwner() internal view virtual {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // If the caller is not the stored owner, revert.\\n if iszero(eq(caller(), sload(_OWNER_SLOT))) {\\n mstore(0x00, 0x82b42900) // `Unauthorized()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n\\n /// @dev Returns how long a two-step ownership handover is valid for in seconds.\\n /// Override to return a different value if needed.\\n /// Made internal to conserve bytecode. Wrap it in a public function if needed.\\n function _ownershipHandoverValidFor() internal view virtual returns (uint64) {\\n return 48 * 3600;\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* PUBLIC UPDATE FUNCTIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Allows the owner to transfer the ownership to `newOwner`.\\n function transferOwnership(address newOwner) public payable virtual onlyOwner {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if iszero(shl(96, newOwner)) {\\n mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n _setOwner(newOwner);\\n }\\n\\n /// @dev Allows the owner to renounce their ownership.\\n function renounceOwnership() public payable virtual onlyOwner {\\n _setOwner(address(0));\\n }\\n\\n /// @dev Request a two-step ownership handover to the caller.\\n /// The request will automatically expire in 48 hours (172800 seconds) by default.\\n function requestOwnershipHandover() public payable virtual {\\n unchecked {\\n uint256 expires = block.timestamp + _ownershipHandoverValidFor();\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Compute and set the handover slot to `expires`.\\n mstore(0x0c, _HANDOVER_SLOT_SEED)\\n mstore(0x00, caller())\\n sstore(keccak256(0x0c, 0x20), expires)\\n // Emit the {OwnershipHandoverRequested} event.\\n log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())\\n }\\n }\\n }\\n\\n /// @dev Cancels the two-step ownership handover to the caller, if any.\\n function cancelOwnershipHandover() public payable virtual {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Compute and set the handover slot to 0.\\n mstore(0x0c, _HANDOVER_SLOT_SEED)\\n mstore(0x00, caller())\\n sstore(keccak256(0x0c, 0x20), 0)\\n // Emit the {OwnershipHandoverCanceled} event.\\n log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())\\n }\\n }\\n\\n /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.\\n /// Reverts if there is no existing ownership handover requested by `pendingOwner`.\\n function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Compute and set the handover slot to 0.\\n mstore(0x0c, _HANDOVER_SLOT_SEED)\\n mstore(0x00, pendingOwner)\\n let handoverSlot := keccak256(0x0c, 0x20)\\n // If the handover does not exist, or has expired.\\n if gt(timestamp(), sload(handoverSlot)) {\\n mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.\\n revert(0x1c, 0x04)\\n }\\n // Set the handover slot to 0.\\n sstore(handoverSlot, 0)\\n }\\n _setOwner(pendingOwner);\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* PUBLIC READ FUNCTIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns the owner of the contract.\\n function owner() public view virtual returns (address result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := sload(_OWNER_SLOT)\\n }\\n }\\n\\n /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.\\n function ownershipHandoverExpiresAt(address pendingOwner)\\n public\\n view\\n virtual\\n returns (uint256 result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Compute the handover slot.\\n mstore(0x0c, _HANDOVER_SLOT_SEED)\\n mstore(0x00, pendingOwner)\\n // Load the handover slot.\\n result := sload(keccak256(0x0c, 0x20))\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* MODIFIERS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Marks a function as only callable by the owner.\\n modifier onlyOwner() virtual {\\n _checkOwner();\\n _;\\n }\\n}\\n\",\"keccak256\":\"0xc208cdd9de02bbf4b5edad18b88e23a2be7ff56d2287d5649329dc7cda64b9a3\",\"license\":\"MIT\"},\"solady/src/utils/LibString.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @notice Library for converting numbers into strings and other string operations.\\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibString.sol)\\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol)\\n///\\n/// @dev Note:\\n/// For performance and bytecode compactness, most of the string operations are restricted to\\n/// byte strings (7-bit ASCII), except where otherwise specified.\\n/// Usage of byte string operations on charsets with runes spanning two or more bytes\\n/// can lead to undefined behavior.\\nlibrary LibString {\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CUSTOM ERRORS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The length of the output is too small to contain all the hex digits.\\n error HexLengthInsufficient();\\n\\n /// @dev The length of the string is more than 32 bytes.\\n error TooBigForSmallString();\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CONSTANTS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The constant returned when the `search` is not found in the string.\\n uint256 internal constant NOT_FOUND = type(uint256).max;\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* DECIMAL OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns the base 10 decimal representation of `value`.\\n function toString(uint256 value) internal pure returns (string memory str) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // The maximum value of a uint256 contains 78 digits (1 byte per digit), but\\n // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.\\n // We will need 1 word for the trailing zeros padding, 1 word for the length,\\n // and 3 words for a maximum of 78 digits.\\n str := add(mload(0x40), 0x80)\\n // Update the free memory pointer to allocate.\\n mstore(0x40, add(str, 0x20))\\n // Zeroize the slot after the string.\\n mstore(str, 0)\\n\\n // Cache the end of the memory to calculate the length later.\\n let end := str\\n\\n let w := not(0) // Tsk.\\n // We write the string from rightmost digit to leftmost digit.\\n // The following is essentially a do-while loop that also handles the zero case.\\n for { let temp := value } 1 {} {\\n str := add(str, w) // `sub(str, 1)`.\\n // Write the character to the pointer.\\n // The ASCII index of the '0' character is 48.\\n mstore8(str, add(48, mod(temp, 10)))\\n // Keep dividing `temp` until zero.\\n temp := div(temp, 10)\\n if iszero(temp) { break }\\n }\\n\\n let length := sub(end, str)\\n // Move the pointer 32 bytes leftwards to make room for the length.\\n str := sub(str, 0x20)\\n // Store the length.\\n mstore(str, length)\\n }\\n }\\n\\n /// @dev Returns the base 10 decimal representation of `value`.\\n function toString(int256 value) internal pure returns (string memory str) {\\n if (value >= 0) {\\n return toString(uint256(value));\\n }\\n unchecked {\\n str = toString(~uint256(value) + 1);\\n }\\n /// @solidity memory-safe-assembly\\n assembly {\\n // We still have some spare memory space on the left,\\n // as we have allocated 3 words (96 bytes) for up to 78 digits.\\n let length := mload(str) // Load the string length.\\n mstore(str, 0x2d) // Store the '-' character.\\n str := sub(str, 1) // Move back the string pointer by a byte.\\n mstore(str, add(length, 1)) // Update the string length.\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* HEXADECIMAL OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns the hexadecimal representation of `value`,\\n /// left-padded to an input length of `length` bytes.\\n /// The output is prefixed with \\\"0x\\\" encoded using 2 hexadecimal digits per byte,\\n /// giving a total length of `length * 2 + 2` bytes.\\n /// Reverts if `length` is too small for the output to contain all the digits.\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value, length);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(str, 0x3078) // Write the \\\"0x\\\" prefix.\\n str := sub(str, 2) // Move the pointer.\\n mstore(str, strLength) // Write the length.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`,\\n /// left-padded to an input length of `length` bytes.\\n /// The output is prefixed with \\\"0x\\\" encoded using 2 hexadecimal digits per byte,\\n /// giving a total length of `length * 2` bytes.\\n /// Reverts if `length` is too small for the output to contain all the digits.\\n function toHexStringNoPrefix(uint256 value, uint256 length)\\n internal\\n pure\\n returns (string memory str)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // We need 0x20 bytes for the trailing zeros padding, `length * 2` bytes\\n // for the digits, 0x02 bytes for the prefix, and 0x20 bytes for the length.\\n // We add 0x20 to the total and round down to a multiple of 0x20.\\n // (0x20 + 0x20 + 0x02 + 0x20) = 0x62.\\n str := add(mload(0x40), and(add(shl(1, length), 0x42), not(0x1f)))\\n // Allocate the memory.\\n mstore(0x40, add(str, 0x20))\\n // Zeroize the slot after the string.\\n mstore(str, 0)\\n\\n // Cache the end to calculate the length later.\\n let end := str\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n mstore(0x0f, 0x30313233343536373839616263646566)\\n\\n let start := sub(str, add(length, length))\\n let w := not(1) // Tsk.\\n let temp := value\\n // We write the string from rightmost digit to leftmost digit.\\n // The following is essentially a do-while loop that also handles the zero case.\\n for {} 1 {} {\\n str := add(str, w) // `sub(str, 2)`.\\n mstore8(add(str, 1), mload(and(temp, 15)))\\n mstore8(str, mload(and(shr(4, temp), 15)))\\n temp := shr(8, temp)\\n if iszero(xor(str, start)) { break }\\n }\\n\\n if temp {\\n mstore(0x00, 0x2194895a) // `HexLengthInsufficient()`.\\n revert(0x1c, 0x04)\\n }\\n\\n // Compute the string's length.\\n let strLength := sub(end, str)\\n // Move the pointer and write the length.\\n str := sub(str, 0x20)\\n mstore(str, strLength)\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is prefixed with \\\"0x\\\" and encoded using 2 hexadecimal digits per byte.\\n /// As address are 20 bytes long, the output will left-padded to have\\n /// a length of `20 * 2 + 2` bytes.\\n function toHexString(uint256 value) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(str, 0x3078) // Write the \\\"0x\\\" prefix.\\n str := sub(str, 2) // Move the pointer.\\n mstore(str, strLength) // Write the length.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is prefixed with \\\"0x\\\".\\n /// The output excludes leading \\\"0\\\" from the `toHexString` output.\\n /// `0x00: \\\"0x0\\\", 0x01: \\\"0x1\\\", 0x12: \\\"0x12\\\", 0x123: \\\"0x123\\\"`.\\n function toMinimalHexString(uint256 value) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present.\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(add(str, o), 0x3078) // Write the \\\"0x\\\" prefix, accounting for leading zero.\\n str := sub(add(str, o), 2) // Move the pointer, accounting for leading zero.\\n mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output excludes leading \\\"0\\\" from the `toHexStringNoPrefix` output.\\n /// `0x00: \\\"0\\\", 0x01: \\\"1\\\", 0x12: \\\"12\\\", 0x123: \\\"123\\\"`.\\n function toMinimalHexStringNoPrefix(uint256 value) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present.\\n let strLength := mload(str) // Get the length.\\n str := add(str, o) // Move the pointer, accounting for leading zero.\\n mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is encoded using 2 hexadecimal digits per byte.\\n /// As address are 20 bytes long, the output will left-padded to have\\n /// a length of `20 * 2` bytes.\\n function toHexStringNoPrefix(uint256 value) internal pure returns (string memory str) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,\\n // 0x02 bytes for the prefix, and 0x40 bytes for the digits.\\n // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x40) is 0xa0.\\n str := add(mload(0x40), 0x80)\\n // Allocate the memory.\\n mstore(0x40, add(str, 0x20))\\n // Zeroize the slot after the string.\\n mstore(str, 0)\\n\\n // Cache the end to calculate the length later.\\n let end := str\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n mstore(0x0f, 0x30313233343536373839616263646566)\\n\\n let w := not(1) // Tsk.\\n // We write the string from rightmost digit to leftmost digit.\\n // The following is essentially a do-while loop that also handles the zero case.\\n for { let temp := value } 1 {} {\\n str := add(str, w) // `sub(str, 2)`.\\n mstore8(add(str, 1), mload(and(temp, 15)))\\n mstore8(str, mload(and(shr(4, temp), 15)))\\n temp := shr(8, temp)\\n if iszero(temp) { break }\\n }\\n\\n // Compute the string's length.\\n let strLength := sub(end, str)\\n // Move the pointer and write the length.\\n str := sub(str, 0x20)\\n mstore(str, strLength)\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is prefixed with \\\"0x\\\", encoded using 2 hexadecimal digits per byte,\\n /// and the alphabets are capitalized conditionally according to\\n /// https://eips.ethereum.org/EIPS/eip-55\\n function toHexStringChecksummed(address value) internal pure returns (string memory str) {\\n str = toHexString(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...`\\n let o := add(str, 0x22)\\n let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... `\\n let t := shl(240, 136) // `0b10001000 << 240`\\n for { let i := 0 } 1 {} {\\n mstore(add(i, i), mul(t, byte(i, hashed)))\\n i := add(i, 1)\\n if eq(i, 20) { break }\\n }\\n mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask)))))\\n o := add(o, 0x20)\\n mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask)))))\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is prefixed with \\\"0x\\\" and encoded using 2 hexadecimal digits per byte.\\n function toHexString(address value) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(value);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(str, 0x3078) // Write the \\\"0x\\\" prefix.\\n str := sub(str, 2) // Move the pointer.\\n mstore(str, strLength) // Write the length.\\n }\\n }\\n\\n /// @dev Returns the hexadecimal representation of `value`.\\n /// The output is encoded using 2 hexadecimal digits per byte.\\n function toHexStringNoPrefix(address value) internal pure returns (string memory str) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n str := mload(0x40)\\n\\n // Allocate the memory.\\n // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,\\n // 0x02 bytes for the prefix, and 0x28 bytes for the digits.\\n // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80.\\n mstore(0x40, add(str, 0x80))\\n\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n mstore(0x0f, 0x30313233343536373839616263646566)\\n\\n str := add(str, 2)\\n mstore(str, 40)\\n\\n let o := add(str, 0x20)\\n mstore(add(o, 40), 0)\\n\\n value := shl(96, value)\\n\\n // We write the string from rightmost digit to leftmost digit.\\n // The following is essentially a do-while loop that also handles the zero case.\\n for { let i := 0 } 1 {} {\\n let p := add(o, add(i, i))\\n let temp := byte(i, value)\\n mstore8(add(p, 1), mload(and(temp, 15)))\\n mstore8(p, mload(shr(4, temp)))\\n i := add(i, 1)\\n if eq(i, 20) { break }\\n }\\n }\\n }\\n\\n /// @dev Returns the hex encoded string from the raw bytes.\\n /// The output is encoded using 2 hexadecimal digits per byte.\\n function toHexString(bytes memory raw) internal pure returns (string memory str) {\\n str = toHexStringNoPrefix(raw);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let strLength := add(mload(str), 2) // Compute the length.\\n mstore(str, 0x3078) // Write the \\\"0x\\\" prefix.\\n str := sub(str, 2) // Move the pointer.\\n mstore(str, strLength) // Write the length.\\n }\\n }\\n\\n /// @dev Returns the hex encoded string from the raw bytes.\\n /// The output is encoded using 2 hexadecimal digits per byte.\\n function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let length := mload(raw)\\n str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix.\\n mstore(str, add(length, length)) // Store the length of the output.\\n\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n mstore(0x0f, 0x30313233343536373839616263646566)\\n\\n let o := add(str, 0x20)\\n let end := add(raw, length)\\n\\n for {} iszero(eq(raw, end)) {} {\\n raw := add(raw, 1)\\n mstore8(add(o, 1), mload(and(mload(raw), 15)))\\n mstore8(o, mload(and(shr(4, mload(raw)), 15)))\\n o := add(o, 2)\\n }\\n mstore(o, 0) // Zeroize the slot after the string.\\n mstore(0x40, add(o, 0x20)) // Allocate the memory.\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* RUNE STRING OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Returns the number of UTF characters in the string.\\n function runeCount(string memory s) internal pure returns (uint256 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if mload(s) {\\n mstore(0x00, div(not(0), 255))\\n mstore(0x20, 0x0202020202020202020202020202020202020202020202020303030304040506)\\n let o := add(s, 0x20)\\n let end := add(o, mload(s))\\n for { result := 1 } 1 { result := add(result, 1) } {\\n o := add(o, byte(0, mload(shr(250, mload(o)))))\\n if iszero(lt(o, end)) { break }\\n }\\n }\\n }\\n }\\n\\n /// @dev Returns if this string is a 7-bit ASCII string.\\n /// (i.e. all characters codes are in [0..127])\\n function is7BitASCII(string memory s) internal pure returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let mask := shl(7, div(not(0), 255))\\n result := 1\\n let n := mload(s)\\n if n {\\n let o := add(s, 0x20)\\n let end := add(o, n)\\n let last := mload(end)\\n mstore(end, 0)\\n for {} 1 {} {\\n if and(mask, mload(o)) {\\n result := 0\\n break\\n }\\n o := add(o, 0x20)\\n if iszero(lt(o, end)) { break }\\n }\\n mstore(end, last)\\n }\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* BYTE STRING OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n // For performance and bytecode compactness, byte string operations are restricted\\n // to 7-bit ASCII strings. All offsets are byte offsets, not UTF character offsets.\\n // Usage of byte string operations on charsets with runes spanning two or more bytes\\n // can lead to undefined behavior.\\n\\n /// @dev Returns `subject` all occurrences of `search` replaced with `replacement`.\\n function replace(string memory subject, string memory search, string memory replacement)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let subjectLength := mload(subject)\\n let searchLength := mload(search)\\n let replacementLength := mload(replacement)\\n\\n subject := add(subject, 0x20)\\n search := add(search, 0x20)\\n replacement := add(replacement, 0x20)\\n result := add(mload(0x40), 0x20)\\n\\n let subjectEnd := add(subject, subjectLength)\\n if iszero(gt(searchLength, subjectLength)) {\\n let subjectSearchEnd := add(sub(subjectEnd, searchLength), 1)\\n let h := 0\\n if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) }\\n let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\\n let s := mload(search)\\n for {} 1 {} {\\n let t := mload(subject)\\n // Whether the first `searchLength % 32` bytes of\\n // `subject` and `search` matches.\\n if iszero(shr(m, xor(t, s))) {\\n if h {\\n if iszero(eq(keccak256(subject, searchLength), h)) {\\n mstore(result, t)\\n result := add(result, 1)\\n subject := add(subject, 1)\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n continue\\n }\\n }\\n // Copy the `replacement` one word at a time.\\n for { let o := 0 } 1 {} {\\n mstore(add(result, o), mload(add(replacement, o)))\\n o := add(o, 0x20)\\n if iszero(lt(o, replacementLength)) { break }\\n }\\n result := add(result, replacementLength)\\n subject := add(subject, searchLength)\\n if searchLength {\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n continue\\n }\\n }\\n mstore(result, t)\\n result := add(result, 1)\\n subject := add(subject, 1)\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n }\\n }\\n\\n let resultRemainder := result\\n result := add(mload(0x40), 0x20)\\n let k := add(sub(resultRemainder, result), sub(subjectEnd, subject))\\n // Copy the rest of the string one word at a time.\\n for {} lt(subject, subjectEnd) {} {\\n mstore(resultRemainder, mload(subject))\\n resultRemainder := add(resultRemainder, 0x20)\\n subject := add(subject, 0x20)\\n }\\n result := sub(result, 0x20)\\n let last := add(add(result, 0x20), k) // Zeroize the slot after the string.\\n mstore(last, 0)\\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\\n mstore(result, k) // Store the length.\\n }\\n }\\n\\n /// @dev Returns the byte index of the first location of `search` in `subject`,\\n /// searching from left to right, starting from `from`.\\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\\n function indexOf(string memory subject, string memory search, uint256 from)\\n internal\\n pure\\n returns (uint256 result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n for { let subjectLength := mload(subject) } 1 {} {\\n if iszero(mload(search)) {\\n if iszero(gt(from, subjectLength)) {\\n result := from\\n break\\n }\\n result := subjectLength\\n break\\n }\\n let searchLength := mload(search)\\n let subjectStart := add(subject, 0x20)\\n\\n result := not(0) // Initialize to `NOT_FOUND`.\\n\\n subject := add(subjectStart, from)\\n let end := add(sub(add(subjectStart, subjectLength), searchLength), 1)\\n\\n let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\\n let s := mload(add(search, 0x20))\\n\\n if iszero(and(lt(subject, end), lt(from, subjectLength))) { break }\\n\\n if iszero(lt(searchLength, 0x20)) {\\n for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} {\\n if iszero(shr(m, xor(mload(subject), s))) {\\n if eq(keccak256(subject, searchLength), h) {\\n result := sub(subject, subjectStart)\\n break\\n }\\n }\\n subject := add(subject, 1)\\n if iszero(lt(subject, end)) { break }\\n }\\n break\\n }\\n for {} 1 {} {\\n if iszero(shr(m, xor(mload(subject), s))) {\\n result := sub(subject, subjectStart)\\n break\\n }\\n subject := add(subject, 1)\\n if iszero(lt(subject, end)) { break }\\n }\\n break\\n }\\n }\\n }\\n\\n /// @dev Returns the byte index of the first location of `search` in `subject`,\\n /// searching from left to right.\\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\\n function indexOf(string memory subject, string memory search)\\n internal\\n pure\\n returns (uint256 result)\\n {\\n result = indexOf(subject, search, 0);\\n }\\n\\n /// @dev Returns the byte index of the first location of `search` in `subject`,\\n /// searching from right to left, starting from `from`.\\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\\n function lastIndexOf(string memory subject, string memory search, uint256 from)\\n internal\\n pure\\n returns (uint256 result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n for {} 1 {} {\\n result := not(0) // Initialize to `NOT_FOUND`.\\n let searchLength := mload(search)\\n if gt(searchLength, mload(subject)) { break }\\n let w := result\\n\\n let fromMax := sub(mload(subject), searchLength)\\n if iszero(gt(fromMax, from)) { from := fromMax }\\n\\n let end := add(add(subject, 0x20), w)\\n subject := add(add(subject, 0x20), from)\\n if iszero(gt(subject, end)) { break }\\n // As this function is not too often used,\\n // we shall simply use keccak256 for smaller bytecode size.\\n for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} {\\n if eq(keccak256(subject, searchLength), h) {\\n result := sub(subject, add(end, 1))\\n break\\n }\\n subject := add(subject, w) // `sub(subject, 1)`.\\n if iszero(gt(subject, end)) { break }\\n }\\n break\\n }\\n }\\n }\\n\\n /// @dev Returns the byte index of the first location of `search` in `subject`,\\n /// searching from right to left.\\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\\n function lastIndexOf(string memory subject, string memory search)\\n internal\\n pure\\n returns (uint256 result)\\n {\\n result = lastIndexOf(subject, search, uint256(int256(-1)));\\n }\\n\\n /// @dev Returns true if `search` is found in `subject`, false otherwise.\\n function contains(string memory subject, string memory search) internal pure returns (bool) {\\n return indexOf(subject, search) != NOT_FOUND;\\n }\\n\\n /// @dev Returns whether `subject` starts with `search`.\\n function startsWith(string memory subject, string memory search)\\n internal\\n pure\\n returns (bool result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let searchLength := mload(search)\\n // Just using keccak256 directly is actually cheaper.\\n // forgefmt: disable-next-item\\n result := and(\\n iszero(gt(searchLength, mload(subject))),\\n eq(\\n keccak256(add(subject, 0x20), searchLength),\\n keccak256(add(search, 0x20), searchLength)\\n )\\n )\\n }\\n }\\n\\n /// @dev Returns whether `subject` ends with `search`.\\n function endsWith(string memory subject, string memory search)\\n internal\\n pure\\n returns (bool result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let searchLength := mload(search)\\n let subjectLength := mload(subject)\\n // Whether `search` is not longer than `subject`.\\n let withinRange := iszero(gt(searchLength, subjectLength))\\n // Just using keccak256 directly is actually cheaper.\\n // forgefmt: disable-next-item\\n result := and(\\n withinRange,\\n eq(\\n keccak256(\\n // `subject + 0x20 + max(subjectLength - searchLength, 0)`.\\n add(add(subject, 0x20), mul(withinRange, sub(subjectLength, searchLength))),\\n searchLength\\n ),\\n keccak256(add(search, 0x20), searchLength)\\n )\\n )\\n }\\n }\\n\\n /// @dev Returns `subject` repeated `times`.\\n function repeat(string memory subject, uint256 times)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let subjectLength := mload(subject)\\n if iszero(or(iszero(times), iszero(subjectLength))) {\\n subject := add(subject, 0x20)\\n result := mload(0x40)\\n let output := add(result, 0x20)\\n for {} 1 {} {\\n // Copy the `subject` one word at a time.\\n for { let o := 0 } 1 {} {\\n mstore(add(output, o), mload(add(subject, o)))\\n o := add(o, 0x20)\\n if iszero(lt(o, subjectLength)) { break }\\n }\\n output := add(output, subjectLength)\\n times := sub(times, 1)\\n if iszero(times) { break }\\n }\\n mstore(output, 0) // Zeroize the slot after the string.\\n let resultLength := sub(output, add(result, 0x20))\\n mstore(result, resultLength) // Store the length.\\n // Allocate the memory.\\n mstore(0x40, add(result, add(resultLength, 0x20)))\\n }\\n }\\n }\\n\\n /// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).\\n /// `start` and `end` are byte offsets.\\n function slice(string memory subject, uint256 start, uint256 end)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let subjectLength := mload(subject)\\n if iszero(gt(subjectLength, end)) { end := subjectLength }\\n if iszero(gt(subjectLength, start)) { start := subjectLength }\\n if lt(start, end) {\\n result := mload(0x40)\\n let resultLength := sub(end, start)\\n mstore(result, resultLength)\\n subject := add(subject, start)\\n let w := not(0x1f)\\n // Copy the `subject` one word at a time, backwards.\\n for { let o := and(add(resultLength, 0x1f), w) } 1 {} {\\n mstore(add(result, o), mload(add(subject, o)))\\n o := add(o, w) // `sub(o, 0x20)`.\\n if iszero(o) { break }\\n }\\n // Zeroize the slot after the string.\\n mstore(add(add(result, 0x20), resultLength), 0)\\n // Allocate memory for the length and the bytes,\\n // rounded up to a multiple of 32.\\n mstore(0x40, add(result, and(add(resultLength, 0x3f), w)))\\n }\\n }\\n }\\n\\n /// @dev Returns a copy of `subject` sliced from `start` to the end of the string.\\n /// `start` is a byte offset.\\n function slice(string memory subject, uint256 start)\\n internal\\n pure\\n returns (string memory result)\\n {\\n result = slice(subject, start, uint256(int256(-1)));\\n }\\n\\n /// @dev Returns all the indices of `search` in `subject`.\\n /// The indices are byte offsets.\\n function indicesOf(string memory subject, string memory search)\\n internal\\n pure\\n returns (uint256[] memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let subjectLength := mload(subject)\\n let searchLength := mload(search)\\n\\n if iszero(gt(searchLength, subjectLength)) {\\n subject := add(subject, 0x20)\\n search := add(search, 0x20)\\n result := add(mload(0x40), 0x20)\\n\\n let subjectStart := subject\\n let subjectSearchEnd := add(sub(add(subject, subjectLength), searchLength), 1)\\n let h := 0\\n if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) }\\n let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\\n let s := mload(search)\\n for {} 1 {} {\\n let t := mload(subject)\\n // Whether the first `searchLength % 32` bytes of\\n // `subject` and `search` matches.\\n if iszero(shr(m, xor(t, s))) {\\n if h {\\n if iszero(eq(keccak256(subject, searchLength), h)) {\\n subject := add(subject, 1)\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n continue\\n }\\n }\\n // Append to `result`.\\n mstore(result, sub(subject, subjectStart))\\n result := add(result, 0x20)\\n // Advance `subject` by `searchLength`.\\n subject := add(subject, searchLength)\\n if searchLength {\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n continue\\n }\\n }\\n subject := add(subject, 1)\\n if iszero(lt(subject, subjectSearchEnd)) { break }\\n }\\n let resultEnd := result\\n // Assign `result` to the free memory pointer.\\n result := mload(0x40)\\n // Store the length of `result`.\\n mstore(result, shr(5, sub(resultEnd, add(result, 0x20))))\\n // Allocate memory for result.\\n // We allocate one more word, so this array can be recycled for {split}.\\n mstore(0x40, add(resultEnd, 0x20))\\n }\\n }\\n }\\n\\n /// @dev Returns a arrays of strings based on the `delimiter` inside of the `subject` string.\\n function split(string memory subject, string memory delimiter)\\n internal\\n pure\\n returns (string[] memory result)\\n {\\n uint256[] memory indices = indicesOf(subject, delimiter);\\n /// @solidity memory-safe-assembly\\n assembly {\\n let w := not(0x1f)\\n let indexPtr := add(indices, 0x20)\\n let indicesEnd := add(indexPtr, shl(5, add(mload(indices), 1)))\\n mstore(add(indicesEnd, w), mload(subject))\\n mstore(indices, add(mload(indices), 1))\\n let prevIndex := 0\\n for {} 1 {} {\\n let index := mload(indexPtr)\\n mstore(indexPtr, 0x60)\\n if iszero(eq(index, prevIndex)) {\\n let element := mload(0x40)\\n let elementLength := sub(index, prevIndex)\\n mstore(element, elementLength)\\n // Copy the `subject` one word at a time, backwards.\\n for { let o := and(add(elementLength, 0x1f), w) } 1 {} {\\n mstore(add(element, o), mload(add(add(subject, prevIndex), o)))\\n o := add(o, w) // `sub(o, 0x20)`.\\n if iszero(o) { break }\\n }\\n // Zeroize the slot after the string.\\n mstore(add(add(element, 0x20), elementLength), 0)\\n // Allocate memory for the length and the bytes,\\n // rounded up to a multiple of 32.\\n mstore(0x40, add(element, and(add(elementLength, 0x3f), w)))\\n // Store the `element` into the array.\\n mstore(indexPtr, element)\\n }\\n prevIndex := add(index, mload(delimiter))\\n indexPtr := add(indexPtr, 0x20)\\n if iszero(lt(indexPtr, indicesEnd)) { break }\\n }\\n result := indices\\n if iszero(mload(delimiter)) {\\n result := add(indices, 0x20)\\n mstore(result, sub(mload(indices), 2))\\n }\\n }\\n }\\n\\n /// @dev Returns a concatenated string of `a` and `b`.\\n /// Cheaper than `string.concat()` and does not de-align the free memory pointer.\\n function concat(string memory a, string memory b)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let w := not(0x1f)\\n result := mload(0x40)\\n let aLength := mload(a)\\n // Copy `a` one word at a time, backwards.\\n for { let o := and(add(aLength, 0x20), w) } 1 {} {\\n mstore(add(result, o), mload(add(a, o)))\\n o := add(o, w) // `sub(o, 0x20)`.\\n if iszero(o) { break }\\n }\\n let bLength := mload(b)\\n let output := add(result, aLength)\\n // Copy `b` one word at a time, backwards.\\n for { let o := and(add(bLength, 0x20), w) } 1 {} {\\n mstore(add(output, o), mload(add(b, o)))\\n o := add(o, w) // `sub(o, 0x20)`.\\n if iszero(o) { break }\\n }\\n let totalLength := add(aLength, bLength)\\n let last := add(add(result, 0x20), totalLength)\\n // Zeroize the slot after the string.\\n mstore(last, 0)\\n // Stores the length.\\n mstore(result, totalLength)\\n // Allocate memory for the length and the bytes,\\n // rounded up to a multiple of 32.\\n mstore(0x40, and(add(last, 0x1f), w))\\n }\\n }\\n\\n /// @dev Returns a copy of the string in either lowercase or UPPERCASE.\\n /// WARNING! This function is only compatible with 7-bit ASCII strings.\\n function toCase(string memory subject, bool toUpper)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let length := mload(subject)\\n if length {\\n result := add(mload(0x40), 0x20)\\n subject := add(subject, 1)\\n let flags := shl(add(70, shl(5, toUpper)), 0x3ffffff)\\n let w := not(0)\\n for { let o := length } 1 {} {\\n o := add(o, w)\\n let b := and(0xff, mload(add(subject, o)))\\n mstore8(add(result, o), xor(b, and(shr(b, flags), 0x20)))\\n if iszero(o) { break }\\n }\\n result := mload(0x40)\\n mstore(result, length) // Store the length.\\n let last := add(add(result, 0x20), length)\\n mstore(last, 0) // Zeroize the slot after the string.\\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\\n }\\n }\\n }\\n\\n /// @dev Returns a string from a small bytes32 string.\\n /// `s` must be null-terminated, or behavior will be undefined.\\n function fromSmallString(bytes32 s) internal pure returns (string memory result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := mload(0x40)\\n let n := 0\\n for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\\\\0'.\\n mstore(result, n)\\n let o := add(result, 0x20)\\n mstore(o, s)\\n mstore(add(o, n), 0)\\n mstore(0x40, add(result, 0x40))\\n }\\n }\\n\\n /// @dev Returns the small string, with all bytes after the first null byte zeroized.\\n function normalizeSmallString(bytes32 s) internal pure returns (bytes32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n for {} byte(result, s) { result := add(result, 1) } {} // Scan for '\\\\0'.\\n mstore(0x00, s)\\n mstore(result, 0x00)\\n result := mload(0x00)\\n }\\n }\\n\\n /// @dev Returns the string as a normalized null-terminated small string.\\n function toSmallString(string memory s) internal pure returns (bytes32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := mload(s)\\n if iszero(lt(result, 33)) {\\n mstore(0x00, 0xec92f9a3) // `TooBigForSmallString()`.\\n revert(0x1c, 0x04)\\n }\\n result := shl(shl(3, sub(32, result)), mload(add(s, result)))\\n }\\n }\\n\\n /// @dev Returns a lowercased copy of the string.\\n /// WARNING! This function is only compatible with 7-bit ASCII strings.\\n function lower(string memory subject) internal pure returns (string memory result) {\\n result = toCase(subject, false);\\n }\\n\\n /// @dev Returns an UPPERCASED copy of the string.\\n /// WARNING! This function is only compatible with 7-bit ASCII strings.\\n function upper(string memory subject) internal pure returns (string memory result) {\\n result = toCase(subject, true);\\n }\\n\\n /// @dev Escapes the string to be used within HTML tags.\\n function escapeHTML(string memory s) internal pure returns (string memory result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let end := add(s, mload(s))\\n result := add(mload(0x40), 0x20)\\n // Store the bytes of the packed offsets and strides into the scratch space.\\n // `packed = (stride << 5) | offset`. Max offset is 20. Max stride is 6.\\n mstore(0x1f, 0x900094)\\n mstore(0x08, 0xc0000000a6ab)\\n // Store \\\""&'<>\\\" into the scratch space.\\n mstore(0x00, shl(64, 0x2671756f743b26616d703b262333393b266c743b2667743b))\\n for {} iszero(eq(s, end)) {} {\\n s := add(s, 1)\\n let c := and(mload(s), 0xff)\\n // Not in `[\\\"\\\\\\\"\\\",\\\"'\\\",\\\"&\\\",\\\"<\\\",\\\">\\\"]`.\\n if iszero(and(shl(c, 1), 0x500000c400000000)) {\\n mstore8(result, c)\\n result := add(result, 1)\\n continue\\n }\\n let t := shr(248, mload(c))\\n mstore(result, mload(and(t, 0x1f)))\\n result := add(result, shr(5, t))\\n }\\n let last := result\\n mstore(last, 0) // Zeroize the slot after the string.\\n result := mload(0x40)\\n mstore(result, sub(last, add(result, 0x20))) // Store the length.\\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\\n }\\n }\\n\\n /// @dev Escapes the string to be used within double-quotes in a JSON.\\n /// If `addDoubleQuotes` is true, the result will be enclosed in double-quotes.\\n function escapeJSON(string memory s, bool addDoubleQuotes)\\n internal\\n pure\\n returns (string memory result)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let end := add(s, mload(s))\\n result := add(mload(0x40), 0x20)\\n if addDoubleQuotes {\\n mstore8(result, 34)\\n result := add(1, result)\\n }\\n // Store \\\"\\\\\\\\u0000\\\" in scratch space.\\n // Store \\\"0123456789abcdef\\\" in scratch space.\\n // Also, store `{0x08:\\\"b\\\", 0x09:\\\"t\\\", 0x0a:\\\"n\\\", 0x0c:\\\"f\\\", 0x0d:\\\"r\\\"}`.\\n // into the scratch space.\\n mstore(0x15, 0x5c75303030303031323334353637383961626364656662746e006672)\\n // Bitmask for detecting `[\\\"\\\\\\\"\\\",\\\"\\\\\\\\\\\"]`.\\n let e := or(shl(0x22, 1), shl(0x5c, 1))\\n for {} iszero(eq(s, end)) {} {\\n s := add(s, 1)\\n let c := and(mload(s), 0xff)\\n if iszero(lt(c, 0x20)) {\\n if iszero(and(shl(c, 1), e)) {\\n // Not in `[\\\"\\\\\\\"\\\",\\\"\\\\\\\\\\\"]`.\\n mstore8(result, c)\\n result := add(result, 1)\\n continue\\n }\\n mstore8(result, 0x5c) // \\\"\\\\\\\\\\\".\\n mstore8(add(result, 1), c)\\n result := add(result, 2)\\n continue\\n }\\n if iszero(and(shl(c, 1), 0x3700)) {\\n // Not in `[\\\"\\\\b\\\",\\\"\\\\t\\\",\\\"\\\\n\\\",\\\"\\\\f\\\",\\\"\\\\d\\\"]`.\\n mstore8(0x1d, mload(shr(4, c))) // Hex value.\\n mstore8(0x1e, mload(and(c, 15))) // Hex value.\\n mstore(result, mload(0x19)) // \\\"\\\\\\\\u00XX\\\".\\n result := add(result, 6)\\n continue\\n }\\n mstore8(result, 0x5c) // \\\"\\\\\\\\\\\".\\n mstore8(add(result, 1), mload(add(c, 8)))\\n result := add(result, 2)\\n }\\n if addDoubleQuotes {\\n mstore8(result, 34)\\n result := add(1, result)\\n }\\n let last := result\\n mstore(last, 0) // Zeroize the slot after the string.\\n result := mload(0x40)\\n mstore(result, sub(last, add(result, 0x20))) // Store the length.\\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\\n }\\n }\\n\\n /// @dev Escapes the string to be used within double-quotes in a JSON.\\n function escapeJSON(string memory s) internal pure returns (string memory result) {\\n result = escapeJSON(s, false);\\n }\\n\\n /// @dev Returns whether `a` equals `b`.\\n function eq(string memory a, string memory b) internal pure returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n result := eq(keccak256(add(a, 0x20), mload(a)), keccak256(add(b, 0x20), mload(b)))\\n }\\n }\\n\\n /// @dev Returns whether `a` equals `b`, where `b` is a null-terminated small string.\\n function eqs(string memory a, bytes32 b) internal pure returns (bool result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // These should be evaluated on compile time, as far as possible.\\n let m := not(shl(7, div(not(iszero(b)), 255))) // `0x7f7f ...`.\\n let x := not(or(m, or(b, add(m, and(b, m)))))\\n let r := shl(7, iszero(iszero(shr(128, x))))\\n r := or(r, shl(6, iszero(iszero(shr(64, shr(r, x))))))\\n r := or(r, shl(5, lt(0xffffffff, shr(r, x))))\\n r := or(r, shl(4, lt(0xffff, shr(r, x))))\\n r := or(r, shl(3, lt(0xff, shr(r, x))))\\n // forgefmt: disable-next-item\\n result := gt(eq(mload(a), add(iszero(x), xor(31, shr(3, r)))),\\n xor(shr(add(8, r), b), shr(add(8, r), mload(add(a, 0x20)))))\\n }\\n }\\n\\n /// @dev Packs a single string with its length into a single word.\\n /// Returns `bytes32(0)` if the length is zero or greater than 31.\\n function packOne(string memory a) internal pure returns (bytes32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // We don't need to zero right pad the string,\\n // since this is our own custom non-standard packing scheme.\\n result :=\\n mul(\\n // Load the length and the bytes.\\n mload(add(a, 0x1f)),\\n // `length != 0 && length < 32`. Abuses underflow.\\n // Assumes that the length is valid and within the block gas limit.\\n lt(sub(mload(a), 1), 0x1f)\\n )\\n }\\n }\\n\\n /// @dev Unpacks a string packed using {packOne}.\\n /// Returns the empty string if `packed` is `bytes32(0)`.\\n /// If `packed` is not an output of {packOne}, the output behavior is undefined.\\n function unpackOne(bytes32 packed) internal pure returns (string memory result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Grab the free memory pointer.\\n result := mload(0x40)\\n // Allocate 2 words (1 for the length, 1 for the bytes).\\n mstore(0x40, add(result, 0x40))\\n // Zeroize the length slot.\\n mstore(result, 0)\\n // Store the length and bytes.\\n mstore(add(result, 0x1f), packed)\\n // Right pad with zeroes.\\n mstore(add(add(result, 0x20), mload(result)), 0)\\n }\\n }\\n\\n /// @dev Packs two strings with their lengths into a single word.\\n /// Returns `bytes32(0)` if combined length is zero or greater than 30.\\n function packTwo(string memory a, string memory b) internal pure returns (bytes32 result) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let aLength := mload(a)\\n // We don't need to zero right pad the strings,\\n // since this is our own custom non-standard packing scheme.\\n result :=\\n mul(\\n // Load the length and the bytes of `a` and `b`.\\n or(\\n shl(shl(3, sub(0x1f, aLength)), mload(add(a, aLength))),\\n mload(sub(add(b, 0x1e), aLength))\\n ),\\n // `totalLength != 0 && totalLength < 31`. Abuses underflow.\\n // Assumes that the lengths are valid and within the block gas limit.\\n lt(sub(add(aLength, mload(b)), 1), 0x1e)\\n )\\n }\\n }\\n\\n /// @dev Unpacks strings packed using {packTwo}.\\n /// Returns the empty strings if `packed` is `bytes32(0)`.\\n /// If `packed` is not an output of {packTwo}, the output behavior is undefined.\\n function unpackTwo(bytes32 packed)\\n internal\\n pure\\n returns (string memory resultA, string memory resultB)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Grab the free memory pointer.\\n resultA := mload(0x40)\\n resultB := add(resultA, 0x40)\\n // Allocate 2 words for each string (1 for the length, 1 for the byte). Total 4 words.\\n mstore(0x40, add(resultB, 0x40))\\n // Zeroize the length slots.\\n mstore(resultA, 0)\\n mstore(resultB, 0)\\n // Store the lengths and bytes.\\n mstore(add(resultA, 0x1f), packed)\\n mstore(add(resultB, 0x1f), mload(add(add(resultA, 0x20), mload(resultA))))\\n // Right pad with zeroes.\\n mstore(add(add(resultA, 0x20), mload(resultA)), 0)\\n mstore(add(add(resultB, 0x20), mload(resultB)), 0)\\n }\\n }\\n\\n /// @dev Directly returns `a` without copying.\\n function directReturn(string memory a) internal pure {\\n assembly {\\n // Assumes that the string does not start from the scratch space.\\n let retStart := sub(a, 0x20)\\n let retSize := add(mload(a), 0x40)\\n // Right pad with zeroes. Just in case the string is produced\\n // by a method that doesn't zero right pad.\\n mstore(add(retStart, retSize), 0)\\n // Store the return offset.\\n mstore(retStart, 0x20)\\n // End the transaction, returning the string.\\n return(retStart, retSize)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x4fc555fe1ceb29162b143ce1564ac936099071c853065efc289f6c30c712f125\",\"license\":\"MIT\"},\"solady/src/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)\\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @author Permit2 operations from (https://github.com/Uniswap/permit2/blob/main/src/libraries/Permit2Lib.sol)\\n///\\n/// @dev Note:\\n/// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection.\\n/// - For ERC20s, this implementation won't check that a token has code,\\n/// responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CUSTOM ERRORS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev The ETH transfer has failed.\\n error ETHTransferFailed();\\n\\n /// @dev The ERC20 `transferFrom` has failed.\\n error TransferFromFailed();\\n\\n /// @dev The ERC20 `transfer` has failed.\\n error TransferFailed();\\n\\n /// @dev The ERC20 `approve` has failed.\\n error ApproveFailed();\\n\\n /// @dev The Permit2 operation has failed.\\n error Permit2Failed();\\n\\n /// @dev The Permit2 amount must be less than `2**160 - 1`.\\n error Permit2AmountOverflow();\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* CONSTANTS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes.\\n uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300;\\n\\n /// @dev Suggested gas stipend for contract receiving ETH to perform a few\\n /// storage reads and writes, but low enough to prevent griefing.\\n uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000;\\n\\n /// @dev The unique EIP-712 domain domain separator for the DAI token contract.\\n bytes32 internal constant DAI_DOMAIN_SEPARATOR =\\n 0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;\\n\\n /// @dev The address for the WETH9 contract on Ethereum mainnet.\\n address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\\n\\n /// @dev The canonical Permit2 address.\\n /// [Github](https://github.com/Uniswap/permit2)\\n /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)\\n address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* ETH OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants.\\n //\\n // The regular variants:\\n // - Forwards all remaining gas to the target.\\n // - Reverts if the target reverts.\\n // - Reverts if the current contract has insufficient balance.\\n //\\n // The force variants:\\n // - Forwards with an optional gas stipend\\n // (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases).\\n // - If the target reverts, or if the gas stipend is exhausted,\\n // creates a temporary contract to force send the ETH via `SELFDESTRUCT`.\\n // Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758.\\n // - Reverts if the current contract has insufficient balance.\\n //\\n // The try variants:\\n // - Forwards with a mandatory gas stipend.\\n // - Instead of reverting, returns whether the transfer succeeded.\\n\\n /// @dev Sends `amount` (in wei) ETH to `to`.\\n function safeTransferETH(address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n\\n /// @dev Sends all the ETH in the current contract to `to`.\\n function safeTransferAllETH(address to) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // Transfer all the ETH and check if it succeeded or not.\\n if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n\\n /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`.\\n function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if lt(selfbalance(), amount) {\\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, to) // Store the address in scratch space.\\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\\n if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\\n }\\n }\\n }\\n\\n /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`.\\n function forceSafeTransferAllETH(address to, uint256 gasStipend) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, to) // Store the address in scratch space.\\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\\n if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\\n }\\n }\\n }\\n\\n /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`.\\n function forceSafeTransferETH(address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n if lt(selfbalance(), amount) {\\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, to) // Store the address in scratch space.\\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\\n if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\\n }\\n }\\n }\\n\\n /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`.\\n function forceSafeTransferAllETH(address to) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n // forgefmt: disable-next-item\\n if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\\n mstore(0x00, to) // Store the address in scratch space.\\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\\n if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\\n }\\n }\\n }\\n\\n /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`.\\n function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend)\\n internal\\n returns (bool success)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)\\n }\\n }\\n\\n /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`.\\n function trySafeTransferAllETH(address to, uint256 gasStipend)\\n internal\\n returns (bool success)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)\\n }\\n }\\n\\n /*\\u00b4:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0\\u2022.*\\u2022\\u00b4.*:\\u02da.\\u00b0*.\\u02da\\u2022\\u00b4.\\u00b0:\\u00b0\\u2022.\\u00b0+.*\\u2022\\u00b4.*:*/\\n /* ERC20 OPERATIONS */\\n /*.\\u2022\\u00b0:\\u00b0.\\u00b4+\\u02da.*\\u00b0.\\u02da:*.\\u00b4\\u2022*.+\\u00b0.\\u2022\\u00b0:\\u00b4*.\\u00b4\\u2022*.\\u2022\\u00b0.\\u2022\\u00b0:\\u00b0.\\u00b4:\\u2022\\u02da\\u00b0.*\\u00b0.\\u02da:*.\\u00b4+\\u00b0.\\u2022*/\\n\\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\\n /// Reverts upon failure.\\n ///\\n /// The `from` account must have at least `amount` approved for\\n /// the current contract to manage.\\n function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40) // Cache the free memory pointer.\\n mstore(0x60, amount) // Store the `amount` argument.\\n mstore(0x40, to) // Store the `to` argument.\\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\\n mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.\\n // Perform the transfer, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, m) // Restore the free memory pointer.\\n }\\n }\\n\\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\\n ///\\n /// The `from` account must have at least `amount` approved for the current contract to manage.\\n function trySafeTransferFrom(address token, address from, address to, uint256 amount)\\n internal\\n returns (bool success)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40) // Cache the free memory pointer.\\n mstore(0x60, amount) // Store the `amount` argument.\\n mstore(0x40, to) // Store the `to` argument.\\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\\n mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.\\n success :=\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\\n )\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, m) // Restore the free memory pointer.\\n }\\n }\\n\\n /// @dev Sends all of ERC20 `token` from `from` to `to`.\\n /// Reverts upon failure.\\n ///\\n /// The `from` account must have their entire balance approved for the current contract to manage.\\n function safeTransferAllFrom(address token, address from, address to)\\n internal\\n returns (uint256 amount)\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40) // Cache the free memory pointer.\\n mstore(0x40, to) // Store the `to` argument.\\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\\n mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`.\\n // Read the balance, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\\n staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`.\\n amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it.\\n // Perform the transfer, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, m) // Restore the free memory pointer.\\n }\\n }\\n\\n /// @dev Sends `amount` of ERC20 `token` from the current contract to `to`.\\n /// Reverts upon failure.\\n function safeTransfer(address token, address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x14, to) // Store the `to` argument.\\n mstore(0x34, amount) // Store the `amount` argument.\\n mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\\n // Perform the transfer, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\\n }\\n }\\n\\n /// @dev Sends all of ERC20 `token` from the current contract to `to`.\\n /// Reverts upon failure.\\n function safeTransferAll(address token, address to) internal returns (uint256 amount) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`.\\n mstore(0x20, address()) // Store the address of the current contract.\\n // Read the balance, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\\n staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x14, to) // Store the `to` argument.\\n amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it.\\n mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\\n // Perform the transfer, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\\n }\\n }\\n\\n /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.\\n /// Reverts upon failure.\\n function safeApprove(address token, address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x14, to) // Store the `to` argument.\\n mstore(0x34, amount) // Store the `amount` argument.\\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\\n // Perform the approval, reverting upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.\\n revert(0x1c, 0x04)\\n }\\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\\n }\\n }\\n\\n /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.\\n /// If the initial attempt to approve fails, attempts to reset the approved amount to zero,\\n /// then retries the approval again (some tokens, e.g. USDT, requires this).\\n /// Reverts upon failure.\\n function safeApproveWithRetry(address token, address to, uint256 amount) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x14, to) // Store the `to` argument.\\n mstore(0x34, amount) // Store the `amount` argument.\\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\\n // Perform the approval, retrying upon failure.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x34, 0) // Store 0 for the `amount`.\\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\\n pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval.\\n mstore(0x34, amount) // Store back the original `amount`.\\n // Retry the approval, reverting upon failure.\\n if iszero(\\n and(\\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\\n )\\n ) {\\n mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\\n }\\n }\\n\\n /// @dev Returns the amount of ERC20 `token` owned by `account`.\\n /// Returns zero if the `token` does not exist.\\n function balanceOf(address token, address account) internal view returns (uint256 amount) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x14, account) // Store the `account` argument.\\n mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`.\\n amount :=\\n mul( // The arguments of `mul` are evaluated from right to left.\\n mload(0x20),\\n and( // The arguments of `and` are evaluated from right to left.\\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\\n staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)\\n )\\n )\\n }\\n }\\n\\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\\n /// If the initial attempt fails, try to use Permit2 to transfer the token.\\n /// Reverts upon failure.\\n ///\\n /// The `from` account must have at least `amount` approved for the current contract to manage.\\n function safeTransferFrom2(address token, address from, address to, uint256 amount) internal {\\n if (!trySafeTransferFrom(token, from, to, amount)) {\\n permit2TransferFrom(token, from, to, amount);\\n }\\n }\\n\\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2.\\n /// Reverts upon failure.\\n function permit2TransferFrom(address token, address from, address to, uint256 amount)\\n internal\\n {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40)\\n mstore(add(m, 0x74), shr(96, shl(96, token)))\\n mstore(add(m, 0x54), amount)\\n mstore(add(m, 0x34), to)\\n mstore(add(m, 0x20), shl(96, from))\\n // `transferFrom(address,address,uint160,address)`.\\n mstore(m, 0x36c78516000000000000000000000000)\\n let p := PERMIT2\\n let exists := eq(chainid(), 1)\\n if iszero(exists) { exists := iszero(iszero(extcodesize(p))) }\\n if iszero(and(call(gas(), p, 0, add(m, 0x10), 0x84, codesize(), 0x00), exists)) {\\n mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`.\\n revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04)\\n }\\n }\\n }\\n\\n /// @dev Permit a user to spend a given amount of\\n /// another user's tokens via native EIP-2612 permit if possible, falling\\n /// back to Permit2 if native permit fails or is not implemented on the token.\\n function permit2(\\n address token,\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n bool success;\\n /// @solidity memory-safe-assembly\\n assembly {\\n for {} shl(96, xor(token, WETH9)) {} {\\n mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`.\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word.\\n // Gas stipend to limit gas burn for tokens that don't refund gas when\\n // an non-existing function is called. 5K should be enough for a SLOAD.\\n staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20)\\n )\\n ) { break }\\n // After here, we can be sure that token is a contract.\\n let m := mload(0x40)\\n mstore(add(m, 0x34), spender)\\n mstore(add(m, 0x20), shl(96, owner))\\n mstore(add(m, 0x74), deadline)\\n if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) {\\n mstore(0x14, owner)\\n mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`.\\n mstore(add(m, 0x94), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20))\\n mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`.\\n // `nonces` is already at `add(m, 0x54)`.\\n // `1` is already stored at `add(m, 0x94)`.\\n mstore(add(m, 0xb4), and(0xff, v))\\n mstore(add(m, 0xd4), r)\\n mstore(add(m, 0xf4), s)\\n success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00)\\n break\\n }\\n mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`.\\n mstore(add(m, 0x54), amount)\\n mstore(add(m, 0x94), and(0xff, v))\\n mstore(add(m, 0xb4), r)\\n mstore(add(m, 0xd4), s)\\n success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00)\\n break\\n }\\n }\\n if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s);\\n }\\n\\n /// @dev Simple permit on the Permit2 contract.\\n function simplePermit2(\\n address token,\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let m := mload(0x40)\\n mstore(m, 0x927da105) // `allowance(address,address,address)`.\\n {\\n let addressMask := shr(96, not(0))\\n mstore(add(m, 0x20), and(addressMask, owner))\\n mstore(add(m, 0x40), and(addressMask, token))\\n mstore(add(m, 0x60), and(addressMask, spender))\\n mstore(add(m, 0xc0), and(addressMask, spender))\\n }\\n let p := mul(PERMIT2, iszero(shr(160, amount)))\\n if iszero(\\n and( // The arguments of `and` are evaluated from right to left.\\n gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`.\\n staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60)\\n )\\n ) {\\n mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`.\\n revert(add(0x18, shl(2, iszero(p))), 0x04)\\n }\\n mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant).\\n // `owner` is already `add(m, 0x20)`.\\n // `token` is already at `add(m, 0x40)`.\\n mstore(add(m, 0x60), amount)\\n mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`.\\n // `nonce` is already at `add(m, 0xa0)`.\\n // `spender` is already at `add(m, 0xc0)`.\\n mstore(add(m, 0xe0), deadline)\\n mstore(add(m, 0x100), 0x100) // `signature` offset.\\n mstore(add(m, 0x120), 0x41) // `signature` length.\\n mstore(add(m, 0x140), r)\\n mstore(add(m, 0x160), s)\\n mstore(add(m, 0x180), shl(248, v))\\n if iszero(call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00)) {\\n mstore(0x00, 0x6b836e6b) // `Permit2Failed()`.\\n revert(0x1c, 0x04)\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x583f47701d9b47bb3ef80fcabbbd62fbb58a01733b7a57e19658b4b02468883a\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50604051613db7380380613db783398101604081905261002f91610460565b610038336100ae565b6000610044858261058e565b506001610051848261058e565b5060003360405161006190610395565b6001600160a01b039091168152602001604051809103906000f08015801561008d573d6000803e3d6000fd5b5090506100a46001600160601b03841683836100ea565b505050505061064d565b6001600160a01b0316638b78c6d8198190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b03161561012757604051633ab534b960e21b815260040160405180910390fd5b6001600160a01b03821661014e576040516339a84a7b60e01b815260040160405180910390fd5b630f4599e560005233602052602060006024601c6000865af1600160005114166101805763d125259c6000526004601cfd5b805463ffffffff60201b19166401000000001781556001810180546001600160a01b0384166001600160a01b0319909116179055831561029c576001600160a01b0383166101e157604051633a954ecd60e21b815260040160405180910390fd5b606084901c670de0b6b3a7640000850463fffffffe1017156102165760405163e5cfe95760e01b815260040160405180910390fd5b80546001600160a01b0316600160a01b6001600160601b03861602178155600061023f846102a2565b80546001600160601b038716600160a01b026001600160a01b0391821617825560008781529192508516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a361029a846001610307565b505b50505050565b6001600160a01b038116600090815268a20d6e21d0e52553136020526040902080546b010000000000000000000000900460011661030257805460ff60581b19166b01000000000000000000000060ff843b151560020260011716021781555b919050565b6000610312836102a2565b80549091506b010000000000000000000000900460021615158215151461035d57805460ff6b01000000000000000000000080830482166002189091160260ff60581b199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b610ea180612f1683390190565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126103c957600080fd5b81516001600160401b03808211156103e3576103e36103a2565b604051601f8301601f19908116603f0116810190828211818310171561040b5761040b6103a2565b816040528381526020925086602085880101111561042857600080fd5b600091505b8382101561044a578582018301518183018401529082019061042d565b6000602085830101528094505050505092915050565b6000806000806080858703121561047657600080fd5b84516001600160401b038082111561048d57600080fd5b610499888389016103b8565b955060208701519150808211156104af57600080fd5b506104bc878288016103b8565b604087015190945090506001600160601b03811681146104db57600080fd5b60608601519092506001600160a01b03811681146104f857600080fd5b939692955090935050565b600181811c9082168061051757607f821691505b60208210810361053757634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610589576000816000526020600020601f850160051c810160208610156105665750805b601f850160051c820191505b8181101561058557828155600101610572565b5050505b505050565b81516001600160401b038111156105a7576105a76103a2565b6105bb816105b58454610503565b8461053d565b602080601f8311600181146105f057600084156105d85750858301515b600019600386901b1c1916600185901b178555610585565b600085815260208120601f198616915b8281101561061f57888601518255948401946001909101908401610600565b508582101561063d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6128ba8061065c6000396000f3fe6080604052600436106101795760003560e01c806354d1f13d116100cb57806395d89b411161007f578063f04e283e11610059578063f04e283e146106cc578063f2fde38b146106df578063fee81cf4146106f25761018b565b806395d89b4114610658578063a9059cbb1461066d578063dd62ed3e1461068d5761018b565b806370a08231116100b057806370a08231146105e4578063715018a6146106375780638da5cb5b1461063f5761018b565b806354d1f13d146105bc57806355f804b3146105c45761018b565b8063274e430b1161012d5780633ccfd60b116101075780633ccfd60b1461054d57806340c10f19146105625780634ef41efc146105825761018b565b8063274e430b146104f15780632a6a935d14610511578063313ce567146105315761018b565b806318160ddd1161015e57806318160ddd1461048d57806323b872dd146104c957806325692962146104e95761018b565b806306fdde0314610432578063095ea7b31461045d5761018b565b3661018b57341561018957600080fd5b005b68a20d6e21d0e525530860003560e01c63e5eb36c88190036101f25760018201546001600160a01b031633146101d45760405163ce5a776b60e01b815260040160405180910390fd5b6101e8600435602435604435606435610725565b6101f26001610bc2565b8063813500fc0361025e5760018201546001600160a01b0316331461022a5760405163ce5a776b60e01b815260040160405180910390fd5b600435602890815260443560145268a20d6e21d0e525530b60009081526048812091526024351515905561025e6001610bc2565b8063e985e9c503610288576000610279600435602435610bcc565b9050610286811515610bc2565b505b80636352211e036102af576102af6102a1600435610bf5565b6001600160a01b0316610bc2565b806324359879036102c8576102c86102a1600435610c3b565b8063d10b6e0c036103295760018201546001600160a01b031633146103005760405163ce5a776b60e01b815260040160405180910390fd5b6000610313600435602435604435610c98565b9050610327816001600160a01b0316610bc2565b505b8063081812fc03610342576103426102a1600435610da3565b8063f5b100ea03610386576001600160a01b0360043516600090815268a20d6e21d0e5255313602052604090205461038690600160801b900463ffffffff16610bc2565b8063e2c79281036103b25768a20d6e21d0e5255308546103b290600160801b900463ffffffff16610bc2565b8063c87b56dd036103eb5760206040510160405260006103d96103d460043590565b610e08565b90506020810360208152815160600181f35b8063b7a94eb803610400576104006001610bc2565b6040517f3c10b94e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b34801561043e57600080fd5b50610447610e51565b60405161045491906124d6565b60405180910390f35b34801561046957600080fd5b5061047d610478366004612520565b610ee3565b6040519015158152602001610454565b34801561049957600080fd5b5068a20d6e21d0e525530854600160a01b90046bffffffffffffffffffffffff165b604051908152602001610454565b3480156104d557600080fd5b5061047d6104e436600461254a565b610ef9565b610189610f80565b3480156104fd57600080fd5b5061047d61050c366004612586565b610fd0565b34801561051d57600080fd5b5061047d61052c3660046125a1565b61101d565b34801561053d57600080fd5b5060405160128152602001610454565b34801561055957600080fd5b50610189611031565b34801561056e57600080fd5b5061018961057d366004612520565b611044565b34801561058e57600080fd5b5068a20d6e21d0e5255309546001600160a01b03165b6040516001600160a01b039091168152602001610454565b61018961105a565b3480156105d057600080fd5b506101896105df3660046125c3565b611096565b3480156105f057600080fd5b506104bb6105ff366004612586565b6001600160a01b0316600090815268a20d6e21d0e52553136020526040902054600160a01b90046bffffffffffffffffffffffff1690565b6101896110b0565b34801561064b57600080fd5b50638b78c6d819546105a4565b34801561066457600080fd5b506104476110c2565b34801561067957600080fd5b5061047d610688366004612520565b6110d1565b34801561069957600080fd5b506104bb6106a8366004612635565b602890815260149190915268a20d6e21d0e525530f60009081526048812091525490565b6101896106da366004612586565b6110de565b6101896106ed366004612586565b61111e565b3480156106fe57600080fd5b506104bb61070d366004612586565b63389a75e1600c908152600091909152602090205490565b6001600160a01b03831661074c57604051633a954ecd60e21b815260040160405180910390fd5b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b03166107885760405163040739bf60e41b815260040160405180910390fd5b600a81016002820160006107d2836107ae640100000000891089025b6000190160011b90565b60008160031c8360601b0180546007841660051b1c63ffffffff1691505092915050565b63ffffffff1681526020810191909152604001600020546001600160a01b0387811691161461082d576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160a01b0316836001600160a01b0316146108a7576108508684610bcc565b6108a757826001600160a01b031661086785610da3565b6001600160a01b0316146108a7576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038681166000908152600b84016020526040808220928816825290208154670de0b6b3a7640000906008860190600160a01b90046bffffffffffffffffffffffff168083111561092a576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84546bffffffffffffffffffffffff918490038216600160a01b9081026001600160a01b039283161787558554818104841686019093160291161783556005860160601b600889901c015460ff89161c600116156109c8576005860160601b600889901c018054600160ff8b161b1916905560008881526004870160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b6001600160a01b038a166000908152602082905260408120855460001963ffffffff600160801b80840482169290920180821690920263ffffffff60801b19909316929092178855600381901c631fffffff16606084901b015492939260059190911b60e0161c1690506000610a48886000198d01600190811b016107ae565b606084901b631fffffff600383901c1601805460e0600584901b1681811c861863ffffffff16901b1890559050610ab68860001963ffffffff851601600190811b01838160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b5050835463ffffffff60801b198116600160801b9182900463ffffffff8181166001810182169094029290921787556001600160a01b038d16600090815260208690526040902060601b631fffffff600383901c1601805460e060059390931b9290921682811c8e1890931690921b1890559050610b7d868a610b39878e611145565b84600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b50816000528860601b60601c8a60601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050505050565b8060005260206000f35b6028818152601483905268a20d6e21d0e525530b60009081526048812091525415155b92915050565b6000610c0082611224565b610c36576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bef825b600068a20d6e21d0e525530868a20d6e21d0e525530a82610c7168a20d6e21d0e52553126107ae640100000000881088026107a4565b63ffffffff1681526020810191909152604001600020546001600160a01b03169392505050565b600068a20d6e21d0e525530868a20d6e21d0e525530a82610cce68a20d6e21d0e52553126107ae640100000000891089026107a4565b63ffffffff1681526020810191909152604001600020546001600160a01b03908116925083168214610d3a57610d048284610bcc565b610d3a576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008481526004820160205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387169081179091556005820160601b600886901c018054600160ff881690811b1991909116921515901b919091179055509392505050565b6000610dae82611224565b610de4576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600090815268a20d6e21d0e525530c60205260409020546001600160a01b031690565b606060028054610e1790612668565b159050610e4c576002610e2983611241565b604051602001610e3a9291906126a2565b60405160208183030381529060405290505b919050565b606060008054610e6090612668565b80601f0160208091040260200160405190810160405280929190818152602001828054610e8c90612668565b8015610ed95780601f10610eae57610100808354040283529160200191610ed9565b820191906000526020600020905b815481529060010190602001808311610ebc57829003601f168201915b5050505050905090565b6000610ef0338484611285565b50600192915050565b336028908152601484905268a20d6e21d0e525530f6000908152604881209181905281549091906000198114610f695780841115610f63576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83810382555b610f748686866112e7565b50600195945050505050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604081208054600160581b900460011661100a57823b5b9392505050565b54600160581b9004600216151592915050565b60006110293383611d17565b506001919050565b611039611d9d565b61104233611db8565b565b61104c611d9d565b6110568282611dd4565b5050565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b61109e611d9d565b60026110ab8284836127ad565b505050565b6110b8611d9d565b611042600061225e565b606060018054610e6090612668565b6000610ef03384846112e7565b6110e6611d9d565b63389a75e1600c52806000526020600c20805442111561110e57636f5e88186000526004601cfd5b6000905561111b8161225e565b50565b611126611d9d565b8060601b61113c57637448fbae6000526004601cfd5b61111b8161225e565b81546c01000000000000000000000000900463ffffffff1668a20d6e21d0e52553088161121d5780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000008116600163ffffffff92831601918216908117835585547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c01000000000000000000000000820217865560008181526002840160205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03871617905590925061121d57600080fd5b5092915050565b60008061123083610c3b565b6001600160a01b0316141592915050565b60606080604051019050602081016040526000815280600019835b928101926030600a8206018453600a90048061125c575050819003601f19909101908152919050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b6001600160a01b03821661130e57604051633a954ecd60e21b815260040160405180910390fd5b6001600160a01b038316600090815268a20d6e21d0e52553136020526040812068a20d6e21d0e5255308916113428561229c565b60018401549091506001600160a01b03166113705760405163040739bf60e41b815260040160405180910390fd5b6113d260405180610140016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600063ffffffff16815260200160008152602001600063ffffffff1681525090565b825463ffffffff600160801b808304821660408501528454041660608301526bffffffffffffffffffffffff600160a01b9091041680861115611441576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83546bffffffffffffffffffffffff91879003828116600160a01b9081026001600160a01b03938416178755855481810485168a01948516909102921691909117845560408301519091906114b79061149f670de0b6b3a764000090565b84816114ad576114ad61286e565b0480821191030290565b83528354600160581b900460021661151257876001600160a01b0316896001600160a01b0316036114f057825160408401510360608401525b61150c670de0b6b3a76400008204846060015180821191030290565b60208401525b505061151c600190565b156117b457600061154e826040015161154384600001518560200151808218908211021890565b808218908211021890565b90508061155b57506117b4565b8151819003825260208201805182900390526001600160a01b03808816908916036115905760608201805190910190526117b4565b60006115f7828a8a6040805180820182526000815260606020808301828152845163144027d381526001600160a01b03978816928101929092529490951685840152848101526080840185815260059590951b840160a09081019092529390915201815290565b6001600160a01b03808b166000908152600889016020526040808220928c168252902091925090611628868b611145565b63ffffffff1660e08601526060850151938401935b6040860180516000190190819052600381901c606085901b015460009160051b60e0161c63ffffffff16606084901b600384901c01805460e0600586901b1681811c63ffffffff948516908118909416901b18905590506116e58a600a01828960e0015185600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b84518181526020018552600881901c60058b0160601b015460ff82161c600116156117505760058a0160601b600882901c018054600160ff84161b19169055600081815260048b0160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b5084816001019150810361163d5760608601819052865463ffffffff808316600160801b90810263ffffffff60801b19938416178a5560408901518b54921602911617885560018901546117ae9085906001600160a01b03166122ff565b50505050505b80516020820151855463ffffffff600160801b80830482168401859003608087018190529091160263ffffffff60801b19909116178655600a8601916000916117fd9101612334565b86546c01000000000000000000000000900463ffffffff16610120850152835190915015611a1457606089901b6001176020828101919091526001600160a01b038a166000908152600888019091526040808220908501518551810360a08701819052885463ffffffff909116600160801b0263ffffffff60801b199091161788556101208601515b60001991909101600381901c606084901b0154909190600090600584901b60e0161c63ffffffff1663ffffffff166000198101600281901c60608a901b01805460069290921b60c01682811c67ffffffffffffffff16901b909118905590508551602080880151600884901b17825201865260011561191a5760068b0160601b600882901c018054600160ff84161b191690555b84156119545760098b0160601b631fffffff600384901c1601805460e0600585901b1681811c841863ffffffff16901b1890556001909101905b600881901c60058c0160601b015460ff82161c600116156119b55760058b0160601b600882901c018054600160ff84161b19169055600081815260048c0160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b508660a001518203611886578315611a0f5763ffffffff811661012088018190528a547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c01000000000000000000000000909102178a555b505050505b602083015115611cb057606088901b60208201526001600160a01b03881660009081526008870160205260409020611a4c858a611145565b63ffffffff1660e08501526000670de0b6b3a76400008854600160a01b90046bffffffffffffffffffffffff1681611a8657611a8661286e565b89549190049150640100000000900463ffffffff1681811180159091021761010086015260608501516020860151810160c08701819052875463ffffffff60801b1916600160801b63ffffffff928316021788558954680100000000000000009004165b600087610120015163ffffffff168263ffffffff1614611b3a5760098b0160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050611b99565b506101008701515b611b5387600019830160011b6107ae565b63ffffffff1615611b8557611b7e611b728c600601836001018761237b565b85811180159091021790565b9050611b42565b600181018481118015909102176101008901525b600881901c60068c0160601b018054600160ff84161b8019909116179055600383901c606086901b018054600585901b60e01681811c841863ffffffff16901b189055611c3087828a60e0015186806001019750600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8551602080880151600884901b178252018652508660c001518203611aea57895461010088015163ffffffff908116640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff919093166801000000000000000002166bffffffffffffffff0000000019909116171789555050505b60408101515115611cd4576001860154611cd49082906001600160a01b0316612476565b5050846000528560601b60601c8760601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050565b6000611d228361229c565b8054909150600160581b9004600216151582151514611d6557805460ff600160581b8083048216600218909116026bff0000000000000000000000199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b638b78c6d819543314611042576382b429006000526004601cfd5b60003860003847855af161111b5763b12d13eb6000526004601cfd5b6001600160a01b038216611dfb57604051633a954ecd60e21b815260040160405180910390fd5b6000611e068361229c565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b0316611e455760405163040739bf60e41b815260040160405180910390fd5b60408051608081018252600080825260208201819052918101829052606081019190915282546bffffffffffffffffffffffff600160a01b80830482168701918216026001600160a01b03909216919091178455670de0b6b3a7640000810460408301525081546001600160a01b038116600160a01b918290046bffffffffffffffffffffffff908116870190811690920217835560009081611eff606083901c670de0b6b3a7640000840463fffffffe10171515151590565b9050868210811715611f3d576040517fe5cfe95700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508454670de0b6b3a76400009091049150600160581b9004600216612221576001600160a01b03861660009081526008840160205260408082208654918501519092600a870192600160801b900463ffffffff1691611fa29083810390841002612334565b905080604001515160001461221c5760608a901b602082015260408082015151885463ffffffff600160801b80830482169093018116830263ffffffff60801b19928316178b55928901518b5493169091029116178855612003888b611145565b63ffffffff908116606088015287546c01000000000000000000000000810482166020890152640100000000810482168781118015909102178852680100000000000000009004165b6000876020015163ffffffff168263ffffffff161461209b576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff1690506120f2565b5086515b6120b085600019830160011b6107ae565b63ffffffff16156120e2576120db6120cf8a600601836001018a61237b565b88811180159091021790565b905061209f565b6001810187811180159091021788525b600881901c60068a0160601b018054600160ff84161b8019909116179055600384901c606087901b018054600586901b60e01681811c841863ffffffff16901b18905561218985828a6060015187806001019850600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8251602080850151600884901b178252018352508660400151830361204c578651885463ffffffff83811668010000000000000000027fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff9190931664010000000002166bffffffffffffffff000000001990911617178855600188015461221a9083906001600160a01b0316612476565b505b505050505b60008581526001600160a01b038716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a3505050505050565b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604090208054600160581b9004600116610e4c5780546bff00000000000000000000001916600160581b60ff933b1515600202600117939093169290920291909117815590565b6020820151805160051b60840160808203915060208282601c85016000875af160018351141661232e57600082fd5b50505050565b61235860405180606001604052806000815260200160008152602001606081525090565b604051828152806020018360051b81016040528183604001528083525050919050565b6000801990508360601b8360081c81018054198560ff161c8560ff161b806123d0578460081c83015b60018301925082541991508083118217156123a457808311156123ce5760ff86191691821b90911c905b505b801561246c5782820360081b7e1f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405821960010183166101e07a1412563212c14164235266736f7425221143267a4524367526767760fc7b2aaaaaaaba69a69a6db6db6db2cb2cb2ce739ce73def7bdeffffffff840260f81c161b60f71c1690811c63d76453e004601f169190911a1717858111878210176000031793505b5050509392505050565b60408201516040810363263c69d68152602080820152815160051b604401915060208183601c84016000875af160018251141661232e57600081fd5b60005b838110156124cd5781810151838201526020016124b5565b50506000910152565b60208152600082518060208401526124f58160408501602087016124b2565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114610e4c57600080fd5b6000806040838503121561253357600080fd5b61253c83612509565b946020939093013593505050565b60008060006060848603121561255f57600080fd5b61256884612509565b925061257660208501612509565b9150604084013590509250925092565b60006020828403121561259857600080fd5b61100382612509565b6000602082840312156125b357600080fd5b8135801515811461100357600080fd5b600080602083850312156125d657600080fd5b823567ffffffffffffffff808211156125ee57600080fd5b818501915085601f83011261260257600080fd5b81358181111561261157600080fd5b86602082850101111561262357600080fd5b60209290920196919550909350505050565b6000806040838503121561264857600080fd5b61265183612509565b915061265f60208401612509565b90509250929050565b600181811c9082168061267c57607f821691505b60208210810361269c57634e487b7160e01b600052602260045260246000fd5b50919050565b60008084546126b081612668565b600182811680156126c857600181146126fb5761272a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008416875282151583028701945061272a565b8860005260208060002060005b858110156127215781548a820152908401908201612708565b50505082870194505b50505050835161273e8183602088016124b2565b01949350505050565b634e487b7160e01b600052604160045260246000fd5b601f8211156110ab576000816000526020600020601f850160051c810160208610156127865750805b601f850160051c820191505b818110156127a557828155600101612792565b505050505050565b67ffffffffffffffff8311156127c5576127c5612747565b6127d9836127d38354612668565b8361275d565b6000601f84116001811461280d57600085156127f55750838201355b600019600387901b1c1916600186901b178355612867565b600083815260209020601f19861690835b8281101561283e578685013582556020948501946001909201910161281e565b508682101561285b5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b634e487b7160e01b600052601260045260246000fdfea26469706673582212207ae5e05fd866b7d0bc52310edcae4f8a7dd62c70624f0e7e8df8292e71250b5b64736f6c634300081900336080604052348015600f57600080fd5b50604051610ea1380380610ea1833981016040819052602c916058565b683602298b8c10b0123180546001600160a01b0319166001600160a01b03929092169190911790556086565b600060208284031215606957600080fd5b81516001600160a01b0381168114607f57600080fd5b9392505050565b610e0c806100956000396000f3fe60806040526004361061012d5760003560e01c80636cef16e6116100a557806397e5311c11610074578063b88d4fde11610059578063b88d4fde146105c1578063c87b56dd146105d4578063e985e9c5146105f45761013f565b806397e5311c1461058c578063a22cb465146105a15761013f565b80636cef16e61461051c57806370a08231146105315780638da5cb5b1461055157806395d89b41146105775761013f565b806318160ddd116100fc57806324359879116100e157806324359879146104c957806342842e0e146104e95780636352211e146104fc5761013f565b806318160ddd1461049357806323b872dd146104b65761013f565b806301ffc9a7146103d457806306fdde0314610426578063081812fc14610448578063095ea7b3146104805761013f565b3661013f57341561013d57600080fd5b005b683602298b8c10b0123060003560e01c63263c69d681900361020e5781546001600160a01b0316331461019e576040517f363cb31200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600435602401602081033560051b81015b8082146102015781358060601c816001168260a01b60a81c811583028284027fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a45050508160200191506101af565b5050600160005260206000f35b8063144027d3036102bd5781546001600160a01b0316331461025c576040517f363cb31200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600435602435604435602401602081033560051b81015b8082146102ae57813583857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a4816020019150610273565b50505050600160005260206000f35b80630f4599e5036103a25760018201546001600160a01b03161561032c5760018201546001600160a01b03166004356001600160a01b03161461032c576040517fc59ec47a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81546001600160a01b03161561036e576040517fbf656a4600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317825560016000908152602090f35b6040517f3c10b94e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3480156103e057600080fd5b506104116103ef366004610b60565b6301ffc9a760e09190911c9081146380ac58cd821417635b5e139f9091141790565b60405190151581526020015b60405180910390f35b34801561043257600080fd5b5061043b610614565b60405161041d9190610ba9565b34801561045457600080fd5b50610468610463366004610c16565b61062a565b6040516001600160a01b03909116815260200161041d565b61013d61048e366004610c4b565b610642565b34801561049f57600080fd5b506104a86106c8565b60405190815260200161041d565b61013d6104c4366004610c75565b6106da565b3480156104d557600080fd5b506104686104e4366004610c16565b610769565b61013d6104f7366004610c75565b61077b565b34801561050857600080fd5b50610468610517366004610c16565b6107ad565b34801561052857600080fd5b506104116107bf565b34801561053d57600080fd5b506104a861054c366004610cb1565b610892565b34801561055d57600080fd5b50683602298b8c10b01232546001600160a01b0316610468565b34801561058357600080fd5b5061043b6108ad565b34801561059857600080fd5b506104686108be565b3480156105ad57600080fd5b5061013d6105bc366004610ccc565b61090c565b61013d6105cf366004610d08565b61098f565b3480156105e057600080fd5b5061043b6105ef366004610c16565b6109ea565b34801561060057600080fd5b5061041161060f366004610da3565b6109fa565b60606106256306fdde036000610a26565b905090565b600061063c63081812fc836000610a8c565b92915050565b600061064c6108be565b90508260601b60601c925060405163d10b6e0c600052836020528260405233606052602060006064601c34865af1601f3d111661068c573d6000823e3d81fd5b806040525060006060528183600c5160601c7f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600038a4505050565b600061062563e2c79281600080610a8c565b60006106e46108be565b90508360601b60601c93508260601b60601c925060405163e5eb36c881528460208201528360408201528260608201523360808201526020816084601c840134865af160018251141661073a573d6000823e3d81fd5b508183857fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600038a450505050565b600061063c6324359879836000610a8c565b6107868383836106da565b813b156107a8576107a883838360405180602001604052806000815250610ad4565b505050565b600061063c636352211e836000610a8c565b60008060006107cc6108be565b9050638da5cb5b600052602060006004601c845afa600c51683602298b8c10b0123254601f3d119290921660609190911c029250683602298b8c10b01230906001600160a01b039081169084168114610887576002820180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691821790925560405190918316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35b600194505050505090565b600061063c63f5b100ea836001600160a01b03166000610a8c565b60606106256395d89b416000610a26565b683602298b8c10b01230546001600160a01b031680610909576040517f5b2a47ae00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b90565b60006109166108be565b90508260601b60601c925060405163813500fc6000528360205282151560405233606052602060006064601c34865af16001600051141661095a573d6000823e3d81fd5b83337f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160206040a36040525050600060605250565b61099a8585856106da565b833b156109e3576109e385858585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610ad492505050565b5050505050565b606061063c63c87b56dd83610a26565b6000610a1d63e985e9c5846001600160a01b0316846001600160a01b0316610a8c565b15159392505050565b60606000610a326108be565b9050604051915083600052826020526000806024601c845afa610a58573d6000833e3d82fd5b60206000803e6020600051833e8151602060005101602084013e815160208301016000815260208101604052505092915050565b600080610a976108be565b9050604051856000528460205283604052602060006044601c855afa601f3d1116610ac5573d6000823e3d81fd5b60405250506000519392505050565b60405163150b7a028082523360208301528560601b60601c604083015283606083015260808083015282518060a08401528015610b1b578060c08401826020870160045afa505b60208360a48301601c860160008a5af1610b3e573d15610b3e573d6000843e3d83fd5b508060e01b825114610b585763d1a57ed66000526004601cfd5b505050505050565b600060208284031215610b7257600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610ba257600080fd5b9392505050565b60006020808352835180602085015260005b81811015610bd757858101830151858201604001528201610bbb565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b600060208284031215610c2857600080fd5b5035919050565b80356001600160a01b0381168114610c4657600080fd5b919050565b60008060408385031215610c5e57600080fd5b610c6783610c2f565b946020939093013593505050565b600080600060608486031215610c8a57600080fd5b610c9384610c2f565b9250610ca160208501610c2f565b9150604084013590509250925092565b600060208284031215610cc357600080fd5b610ba282610c2f565b60008060408385031215610cdf57600080fd5b610ce883610c2f565b915060208301358015158114610cfd57600080fd5b809150509250929050565b600080600080600060808688031215610d2057600080fd5b610d2986610c2f565b9450610d3760208701610c2f565b935060408601359250606086013567ffffffffffffffff80821115610d5b57600080fd5b818801915088601f830112610d6f57600080fd5b813581811115610d7e57600080fd5b896020828501011115610d9057600080fd5b9699959850939650602001949392505050565b60008060408385031215610db657600080fd5b610dbf83610c2f565b9150610dcd60208401610c2f565b9050925092905056fea2646970667358221220abfdbd4f65aae35e4082870df5d855d74739c3551476f95b56478fb7badbf2a264736f6c63430008190033", + "deployedBytecode": "0x6080604052600436106101795760003560e01c806354d1f13d116100cb57806395d89b411161007f578063f04e283e11610059578063f04e283e146106cc578063f2fde38b146106df578063fee81cf4146106f25761018b565b806395d89b4114610658578063a9059cbb1461066d578063dd62ed3e1461068d5761018b565b806370a08231116100b057806370a08231146105e4578063715018a6146106375780638da5cb5b1461063f5761018b565b806354d1f13d146105bc57806355f804b3146105c45761018b565b8063274e430b1161012d5780633ccfd60b116101075780633ccfd60b1461054d57806340c10f19146105625780634ef41efc146105825761018b565b8063274e430b146104f15780632a6a935d14610511578063313ce567146105315761018b565b806318160ddd1161015e57806318160ddd1461048d57806323b872dd146104c957806325692962146104e95761018b565b806306fdde0314610432578063095ea7b31461045d5761018b565b3661018b57341561018957600080fd5b005b68a20d6e21d0e525530860003560e01c63e5eb36c88190036101f25760018201546001600160a01b031633146101d45760405163ce5a776b60e01b815260040160405180910390fd5b6101e8600435602435604435606435610725565b6101f26001610bc2565b8063813500fc0361025e5760018201546001600160a01b0316331461022a5760405163ce5a776b60e01b815260040160405180910390fd5b600435602890815260443560145268a20d6e21d0e525530b60009081526048812091526024351515905561025e6001610bc2565b8063e985e9c503610288576000610279600435602435610bcc565b9050610286811515610bc2565b505b80636352211e036102af576102af6102a1600435610bf5565b6001600160a01b0316610bc2565b806324359879036102c8576102c86102a1600435610c3b565b8063d10b6e0c036103295760018201546001600160a01b031633146103005760405163ce5a776b60e01b815260040160405180910390fd5b6000610313600435602435604435610c98565b9050610327816001600160a01b0316610bc2565b505b8063081812fc03610342576103426102a1600435610da3565b8063f5b100ea03610386576001600160a01b0360043516600090815268a20d6e21d0e5255313602052604090205461038690600160801b900463ffffffff16610bc2565b8063e2c79281036103b25768a20d6e21d0e5255308546103b290600160801b900463ffffffff16610bc2565b8063c87b56dd036103eb5760206040510160405260006103d96103d460043590565b610e08565b90506020810360208152815160600181f35b8063b7a94eb803610400576104006001610bc2565b6040517f3c10b94e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b34801561043e57600080fd5b50610447610e51565b60405161045491906124d6565b60405180910390f35b34801561046957600080fd5b5061047d610478366004612520565b610ee3565b6040519015158152602001610454565b34801561049957600080fd5b5068a20d6e21d0e525530854600160a01b90046bffffffffffffffffffffffff165b604051908152602001610454565b3480156104d557600080fd5b5061047d6104e436600461254a565b610ef9565b610189610f80565b3480156104fd57600080fd5b5061047d61050c366004612586565b610fd0565b34801561051d57600080fd5b5061047d61052c3660046125a1565b61101d565b34801561053d57600080fd5b5060405160128152602001610454565b34801561055957600080fd5b50610189611031565b34801561056e57600080fd5b5061018961057d366004612520565b611044565b34801561058e57600080fd5b5068a20d6e21d0e5255309546001600160a01b03165b6040516001600160a01b039091168152602001610454565b61018961105a565b3480156105d057600080fd5b506101896105df3660046125c3565b611096565b3480156105f057600080fd5b506104bb6105ff366004612586565b6001600160a01b0316600090815268a20d6e21d0e52553136020526040902054600160a01b90046bffffffffffffffffffffffff1690565b6101896110b0565b34801561064b57600080fd5b50638b78c6d819546105a4565b34801561066457600080fd5b506104476110c2565b34801561067957600080fd5b5061047d610688366004612520565b6110d1565b34801561069957600080fd5b506104bb6106a8366004612635565b602890815260149190915268a20d6e21d0e525530f60009081526048812091525490565b6101896106da366004612586565b6110de565b6101896106ed366004612586565b61111e565b3480156106fe57600080fd5b506104bb61070d366004612586565b63389a75e1600c908152600091909152602090205490565b6001600160a01b03831661074c57604051633a954ecd60e21b815260040160405180910390fd5b68a20d6e21d0e52553095468a20d6e21d0e5255308906001600160a01b03166107885760405163040739bf60e41b815260040160405180910390fd5b600a81016002820160006107d2836107ae640100000000891089025b6000190160011b90565b60008160031c8360601b0180546007841660051b1c63ffffffff1691505092915050565b63ffffffff1681526020810191909152604001600020546001600160a01b0387811691161461082d576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160a01b0316836001600160a01b0316146108a7576108508684610bcc565b6108a757826001600160a01b031661086785610da3565b6001600160a01b0316146108a7576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038681166000908152600b84016020526040808220928816825290208154670de0b6b3a7640000906008860190600160a01b90046bffffffffffffffffffffffff168083111561092a576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84546bffffffffffffffffffffffff918490038216600160a01b9081026001600160a01b039283161787558554818104841686019093160291161783556005860160601b600889901c015460ff89161c600116156109c8576005860160601b600889901c018054600160ff8b161b1916905560008881526004870160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b6001600160a01b038a166000908152602082905260408120855460001963ffffffff600160801b80840482169290920180821690920263ffffffff60801b19909316929092178855600381901c631fffffff16606084901b015492939260059190911b60e0161c1690506000610a48886000198d01600190811b016107ae565b606084901b631fffffff600383901c1601805460e0600584901b1681811c861863ffffffff16901b1890559050610ab68860001963ffffffff851601600190811b01838160031c8360601b016007831660051b815480821c841863ffffffff16821b81188355505050505050565b5050835463ffffffff60801b198116600160801b9182900463ffffffff8181166001810182169094029290921787556001600160a01b038d16600090815260208690526040902060601b631fffffff600383901c1601805460e060059390931b9290921682811c8e1890931690921b1890559050610b7d868a610b39878e611145565b84600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b50816000528860601b60601c8a60601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050505050565b8060005260206000f35b6028818152601483905268a20d6e21d0e525530b60009081526048812091525415155b92915050565b6000610c0082611224565b610c36576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bef825b600068a20d6e21d0e525530868a20d6e21d0e525530a82610c7168a20d6e21d0e52553126107ae640100000000881088026107a4565b63ffffffff1681526020810191909152604001600020546001600160a01b03169392505050565b600068a20d6e21d0e525530868a20d6e21d0e525530a82610cce68a20d6e21d0e52553126107ae640100000000891089026107a4565b63ffffffff1681526020810191909152604001600020546001600160a01b03908116925083168214610d3a57610d048284610bcc565b610d3a576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008481526004820160205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387169081179091556005820160601b600886901c018054600160ff881690811b1991909116921515901b919091179055509392505050565b6000610dae82611224565b610de4576040517fceea21b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50600090815268a20d6e21d0e525530c60205260409020546001600160a01b031690565b606060028054610e1790612668565b159050610e4c576002610e2983611241565b604051602001610e3a9291906126a2565b60405160208183030381529060405290505b919050565b606060008054610e6090612668565b80601f0160208091040260200160405190810160405280929190818152602001828054610e8c90612668565b8015610ed95780601f10610eae57610100808354040283529160200191610ed9565b820191906000526020600020905b815481529060010190602001808311610ebc57829003601f168201915b5050505050905090565b6000610ef0338484611285565b50600192915050565b336028908152601484905268a20d6e21d0e525530f6000908152604881209181905281549091906000198114610f695780841115610f63576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83810382555b610f748686866112e7565b50600195945050505050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604081208054600160581b900460011661100a57823b5b9392505050565b54600160581b9004600216151592915050565b60006110293383611d17565b506001919050565b611039611d9d565b61104233611db8565b565b61104c611d9d565b6110568282611dd4565b5050565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b61109e611d9d565b60026110ab8284836127ad565b505050565b6110b8611d9d565b611042600061225e565b606060018054610e6090612668565b6000610ef03384846112e7565b6110e6611d9d565b63389a75e1600c52806000526020600c20805442111561110e57636f5e88186000526004601cfd5b6000905561111b8161225e565b50565b611126611d9d565b8060601b61113c57637448fbae6000526004601cfd5b61111b8161225e565b81546c01000000000000000000000000900463ffffffff1668a20d6e21d0e52553088161121d5780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000008116600163ffffffff92831601918216908117835585547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c01000000000000000000000000820217865560008181526002840160205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03871617905590925061121d57600080fd5b5092915050565b60008061123083610c3b565b6001600160a01b0316141592915050565b60606080604051019050602081016040526000815280600019835b928101926030600a8206018453600a90048061125c575050819003601f19909101908152919050565b6028828152601484905268a20d6e21d0e525530f600090815260488120915281905560008181526001600160a01b0380841691908516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590602090a3505050565b6001600160a01b03821661130e57604051633a954ecd60e21b815260040160405180910390fd5b6001600160a01b038316600090815268a20d6e21d0e52553136020526040812068a20d6e21d0e5255308916113428561229c565b60018401549091506001600160a01b03166113705760405163040739bf60e41b815260040160405180910390fd5b6113d260405180610140016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600063ffffffff16815260200160008152602001600063ffffffff1681525090565b825463ffffffff600160801b808304821660408501528454041660608301526bffffffffffffffffffffffff600160a01b9091041680861115611441576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83546bffffffffffffffffffffffff91879003828116600160a01b9081026001600160a01b03938416178755855481810485168a01948516909102921691909117845560408301519091906114b79061149f670de0b6b3a764000090565b84816114ad576114ad61286e565b0480821191030290565b83528354600160581b900460021661151257876001600160a01b0316896001600160a01b0316036114f057825160408401510360608401525b61150c670de0b6b3a76400008204846060015180821191030290565b60208401525b505061151c600190565b156117b457600061154e826040015161154384600001518560200151808218908211021890565b808218908211021890565b90508061155b57506117b4565b8151819003825260208201805182900390526001600160a01b03808816908916036115905760608201805190910190526117b4565b60006115f7828a8a6040805180820182526000815260606020808301828152845163144027d381526001600160a01b03978816928101929092529490951685840152848101526080840185815260059590951b840160a09081019092529390915201815290565b6001600160a01b03808b166000908152600889016020526040808220928c168252902091925090611628868b611145565b63ffffffff1660e08601526060850151938401935b6040860180516000190190819052600381901c606085901b015460009160051b60e0161c63ffffffff16606084901b600384901c01805460e0600586901b1681811c63ffffffff948516908118909416901b18905590506116e58a600a01828960e0015185600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b84518181526020018552600881901c60058b0160601b015460ff82161c600116156117505760058a0160601b600882901c018054600160ff84161b19169055600081815260048b0160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b5084816001019150810361163d5760608601819052865463ffffffff808316600160801b90810263ffffffff60801b19938416178a5560408901518b54921602911617885560018901546117ae9085906001600160a01b03166122ff565b50505050505b80516020820151855463ffffffff600160801b80830482168401859003608087018190529091160263ffffffff60801b19909116178655600a8601916000916117fd9101612334565b86546c01000000000000000000000000900463ffffffff16610120850152835190915015611a1457606089901b6001176020828101919091526001600160a01b038a166000908152600888019091526040808220908501518551810360a08701819052885463ffffffff909116600160801b0263ffffffff60801b199091161788556101208601515b60001991909101600381901c606084901b0154909190600090600584901b60e0161c63ffffffff1663ffffffff166000198101600281901c60608a901b01805460069290921b60c01682811c67ffffffffffffffff16901b909118905590508551602080880151600884901b17825201865260011561191a5760068b0160601b600882901c018054600160ff84161b191690555b84156119545760098b0160601b631fffffff600384901c1601805460e0600585901b1681811c841863ffffffff16901b1890556001909101905b600881901c60058c0160601b015460ff82161c600116156119b55760058b0160601b600882901c018054600160ff84161b19169055600081815260048c0160205260409020805473ffffffffffffffffffffffffffffffffffffffff191690555b508660a001518203611886578315611a0f5763ffffffff811661012088018190528a547fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c01000000000000000000000000909102178a555b505050505b602083015115611cb057606088901b60208201526001600160a01b03881660009081526008870160205260409020611a4c858a611145565b63ffffffff1660e08501526000670de0b6b3a76400008854600160a01b90046bffffffffffffffffffffffff1681611a8657611a8661286e565b89549190049150640100000000900463ffffffff1681811180159091021761010086015260608501516020860151810160c08701819052875463ffffffff60801b1916600160801b63ffffffff928316021788558954680100000000000000009004165b600087610120015163ffffffff168263ffffffff1614611b3a5760098b0160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff169050611b99565b506101008701515b611b5387600019830160011b6107ae565b63ffffffff1615611b8557611b7e611b728c600601836001018761237b565b85811180159091021790565b9050611b42565b600181018481118015909102176101008901525b600881901c60068c0160601b018054600160ff84161b8019909116179055600383901c606086901b018054600585901b60e01681811c841863ffffffff16901b189055611c3087828a60e0015186806001019750600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8551602080880151600884901b178252018652508660c001518203611aea57895461010088015163ffffffff908116640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff919093166801000000000000000002166bffffffffffffffff0000000019909116171789555050505b60408101515115611cd4576001860154611cd49082906001600160a01b0316612476565b5050846000528560601b60601c8760601b60601c7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a350505050505050565b6000611d228361229c565b8054909150600160581b9004600216151582151514611d6557805460ff600160581b8083048216600218909116026bff0000000000000000000000199091161781555b8115156000528260601b60601c7fb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d642039360206000a2505050565b638b78c6d819543314611042576382b429006000526004601cfd5b60003860003847855af161111b5763b12d13eb6000526004601cfd5b6001600160a01b038216611dfb57604051633a954ecd60e21b815260040160405180910390fd5b6000611e068361229c565b68a20d6e21d0e52553095490915068a20d6e21d0e5255308906001600160a01b0316611e455760405163040739bf60e41b815260040160405180910390fd5b60408051608081018252600080825260208201819052918101829052606081019190915282546bffffffffffffffffffffffff600160a01b80830482168701918216026001600160a01b03909216919091178455670de0b6b3a7640000810460408301525081546001600160a01b038116600160a01b918290046bffffffffffffffffffffffff908116870190811690920217835560009081611eff606083901c670de0b6b3a7640000840463fffffffe10171515151590565b9050868210811715611f3d576040517fe5cfe95700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b508454670de0b6b3a76400009091049150600160581b9004600216612221576001600160a01b03861660009081526008840160205260408082208654918501519092600a870192600160801b900463ffffffff1691611fa29083810390841002612334565b905080604001515160001461221c5760608a901b602082015260408082015151885463ffffffff600160801b80830482169093018116830263ffffffff60801b19928316178b55928901518b5493169091029116178855612003888b611145565b63ffffffff908116606088015287546c01000000000000000000000000810482166020890152640100000000810482168781118015909102178852680100000000000000009004165b6000876020015163ffffffff168263ffffffff161461209b576009890160601b631fffffff600384901c160154600183019260e060059190911b161c63ffffffff1663ffffffff1690506120f2565b5086515b6120b085600019830160011b6107ae565b63ffffffff16156120e2576120db6120cf8a600601836001018a61237b565b88811180159091021790565b905061209f565b6001810187811180159091021788525b600881901c60068a0160601b018054600160ff84161b8019909116179055600384901c606087901b018054600586901b60e01681811c841863ffffffff16901b18905561218985828a6060015187806001019850600183038060021c8560601b0180546003831660061b92508463ffffffff168460201b178082851c1867ffffffffffffffff16841b821883555050505050505050565b8251602080850151600884901b178252018352508660400151830361204c578651885463ffffffff83811668010000000000000000027fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff9190931664010000000002166bffffffffffffffff000000001990911617178855600188015461221a9083906001600160a01b0316612476565b505b505050505b60008581526001600160a01b038716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082a3505050505050565b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b6001600160a01b038116600090815268a20d6e21d0e5255313602052604090208054600160581b9004600116610e4c5780546bff00000000000000000000001916600160581b60ff933b1515600202600117939093169290920291909117815590565b6020820151805160051b60840160808203915060208282601c85016000875af160018351141661232e57600082fd5b50505050565b61235860405180606001604052806000815260200160008152602001606081525090565b604051828152806020018360051b81016040528183604001528083525050919050565b6000801990508360601b8360081c81018054198560ff161c8560ff161b806123d0578460081c83015b60018301925082541991508083118217156123a457808311156123ce5760ff86191691821b90911c905b505b801561246c5782820360081b7e1f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405821960010183166101e07a1412563212c14164235266736f7425221143267a4524367526767760fc7b2aaaaaaaba69a69a6db6db6db2cb2cb2ce739ce73def7bdeffffffff840260f81c161b60f71c1690811c63d76453e004601f169190911a1717858111878210176000031793505b5050509392505050565b60408201516040810363263c69d68152602080820152815160051b604401915060208183601c84016000875af160018251141661232e57600081fd5b60005b838110156124cd5781810151838201526020016124b5565b50506000910152565b60208152600082518060208401526124f58160408501602087016124b2565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114610e4c57600080fd5b6000806040838503121561253357600080fd5b61253c83612509565b946020939093013593505050565b60008060006060848603121561255f57600080fd5b61256884612509565b925061257660208501612509565b9150604084013590509250925092565b60006020828403121561259857600080fd5b61100382612509565b6000602082840312156125b357600080fd5b8135801515811461100357600080fd5b600080602083850312156125d657600080fd5b823567ffffffffffffffff808211156125ee57600080fd5b818501915085601f83011261260257600080fd5b81358181111561261157600080fd5b86602082850101111561262357600080fd5b60209290920196919550909350505050565b6000806040838503121561264857600080fd5b61265183612509565b915061265f60208401612509565b90509250929050565b600181811c9082168061267c57607f821691505b60208210810361269c57634e487b7160e01b600052602260045260246000fd5b50919050565b60008084546126b081612668565b600182811680156126c857600181146126fb5761272a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008416875282151583028701945061272a565b8860005260208060002060005b858110156127215781548a820152908401908201612708565b50505082870194505b50505050835161273e8183602088016124b2565b01949350505050565b634e487b7160e01b600052604160045260246000fd5b601f8211156110ab576000816000526020600020601f850160051c810160208610156127865750805b601f850160051c820191505b818110156127a557828155600101612792565b505050505050565b67ffffffffffffffff8311156127c5576127c5612747565b6127d9836127d38354612668565b8361275d565b6000601f84116001811461280d57600085156127f55750838201355b600019600387901b1c1916600186901b178355612867565b600083815260209020601f19861690835b8281101561283e578685013582556020948501946001909201910161281e565b508682101561285b5760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b634e487b7160e01b600052601260045260246000fdfea26469706673582212207ae5e05fd866b7d0bc52310edcae4f8a7dd62c70624f0e7e8df8292e71250b5b64736f6c63430008190033", + "devdoc": { + "errors": { + "AlreadyInitialized()": [ + { + "details": "Cannot double-initialize." + } + ], + "ApprovalCallerNotOwnerNorApproved()": [ + { + "details": "Thrown when setting an NFT token approval and the caller is not the owner or an approved operator." + } + ], + "DNAlreadyInitialized()": [ + { + "details": "Thrown when attempting to double-initialize the contract." + } + ], + "DNNotInitialized()": [ + { + "details": "The function can only be called after the contract has been initialized." + } + ], + "FnSelectorNotRecognized()": [ + { + "details": "The function selector is not recognized." + } + ], + "InsufficientAllowance()": [ + { + "details": "Thrown when a spender attempts to transfer tokens with an insufficient allowance." + } + ], + "InsufficientBalance()": [ + { + "details": "Thrown when attempting to transfer or burn more tokens than sender's balance." + } + ], + "InvalidUnit()": [ + { + "details": "The unit must be greater than zero and less than `2**96`." + } + ], + "LinkMirrorContractFailed()": [ + { + "details": "Thrown when the link call to the mirror contract reverts." + } + ], + "MirrorAddressIsZero()": [ + { + "details": "Thrown when the mirror address provided for initialization is the zero address." + } + ], + "NewOwnerIsZeroAddress()": [ + { + "details": "The `newOwner` cannot be the zero address." + } + ], + "NoHandoverRequest()": [ + { + "details": "The `pendingOwner` does not have a valid handover request." + } + ], + "SenderNotMirror()": [ + { + "details": "Thrown when the caller for a fallback NFT function is not the mirror contract." + } + ], + "TokenDoesNotExist()": [ + { + "details": "Thrown when checking the owner or approved address for a non-existent NFT." + } + ], + "TotalSupplyOverflow()": [ + { + "details": "Thrown when minting an amount of tokens that would overflow the max tokens." + } + ], + "TransferCallerNotOwnerNorApproved()": [ + { + "details": "Thrown when transferring an NFT and the caller is not the owner or an approved operator." + } + ], + "TransferFromIncorrectOwner()": [ + { + "details": "Thrown when transferring an NFT and the from address is not the current owner." + } + ], + "TransferToZeroAddress()": [ + { + "details": "Thrown when attempting to transfer tokens to the zero address." + } + ], + "Unauthorized()": [ + { + "details": "The caller is not authorized to call the function." + } + ] + }, + "events": { + "Approval(address,address,uint256)": { + "details": "Emitted when `amount` tokens is approved by `owner` to be used by `spender`." + }, + "OwnershipHandoverCanceled(address)": { + "details": "The ownership handover to `pendingOwner` has been canceled." + }, + "OwnershipHandoverRequested(address)": { + "details": "An ownership handover to `pendingOwner` has been requested." + }, + "OwnershipTransferred(address,address)": { + "details": "The ownership is transferred from `oldOwner` to `newOwner`. This event is intentionally kept the same as OpenZeppelin's Ownable to be compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173), despite it not being as lightweight as a single argument event." + }, + "SkipNFTSet(address,bool)": { + "details": "Emitted when `owner` sets their skipNFT flag to `status`." + }, + "Transfer(address,address,uint256)": { + "details": "Emitted when `amount` tokens is transferred from `from` to `to`." + } + }, + "kind": "dev", + "methods": { + "allowance(address,address)": { + "details": "Returns the amount of tokens that `spender` can spend on behalf of `owner`." + }, + "approve(address,uint256)": { + "details": "Sets `amount` as the allowance of `spender` over the caller's tokens. Emits a {Approval} event." + }, + "balanceOf(address)": { + "details": "Returns the amount of tokens owned by `owner`." + }, + "cancelOwnershipHandover()": { + "details": "Cancels the two-step ownership handover to the caller, if any." + }, + "completeOwnershipHandover(address)": { + "details": "Allows the owner to complete the two-step ownership handover to `pendingOwner`. Reverts if there is no existing ownership handover requested by `pendingOwner`." + }, + "decimals()": { + "details": "Returns the decimals places of the token. Defaults to 18. Does not affect DN404's internal calculations. Will only affect the frontend UI on most protocols." + }, + "getSkipNFT(address)": { + "details": "Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs. Returns false otherwise." + }, + "mirrorERC721()": { + "details": "Returns the address of the mirror NFT contract." + }, + "name()": { + "details": "Returns the name of the token." + }, + "owner()": { + "details": "Returns the owner of the contract." + }, + "ownershipHandoverExpiresAt(address)": { + "details": "Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`." + }, + "renounceOwnership()": { + "details": "Allows the owner to renounce their ownership." + }, + "requestOwnershipHandover()": { + "details": "Request a two-step ownership handover to the caller. The request will automatically expire in 48 hours (172800 seconds) by default." + }, + "setSkipNFT(bool)": { + "details": "Sets the caller's skipNFT flag to `skipNFT`. Returns true. Emits a {SkipNFTSet} event." + }, + "symbol()": { + "details": "Returns the symbol of the token." + }, + "totalSupply()": { + "details": "Returns the amount of tokens in existence." + }, + "transfer(address,uint256)": { + "details": "Transfer `amount` tokens from the caller to `to`. Will burn sender NFTs if balance after transfer is less than the amount required to support the current NFT balance. Will mint NFTs to `to` if the recipient's new balance supports additional NFTs ***AND*** the `to` address's skipNFT flag is set to false. Requirements: - `from` must at least have `amount`. Emits a {Transfer} event." + }, + "transferFrom(address,address,uint256)": { + "details": "Transfers `amount` tokens from `from` to `to`. Note: Does not update the allowance if it is the maximum uint256 value. Will burn sender NFTs if balance after transfer is less than the amount required to support the current NFT balance. Will mint NFTs to `to` if the recipient's new balance supports additional NFTs ***AND*** the `to` address's skipNFT flag is set to false. Requirements: - `from` must at least have `amount`. - The caller must have at least `amount` of allowance to transfer the tokens of `from`. Emits a {Transfer} event." + }, + "transferOwnership(address)": { + "details": "Allows the owner to transfer the ownership to `newOwner`." + } + }, + "title": "SimpleDN404", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "notice": "Sample DN404 contract that demonstrates the owner selling fungible tokens. When a user has at least one base unit (10^18) amount of tokens, they will automatically receive an NFT. NFTs are minted as an address accumulates each base unit amount of tokens.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 410, + "contract": "@sandbox-smart-contracts/dn404/contracts/SimpleDN404.sol:SimpleDN404", + "label": "_name", + "offset": 0, + "slot": "0", + "type": "t_string_storage" + }, + { + "astId": 412, + "contract": "@sandbox-smart-contracts/dn404/contracts/SimpleDN404.sol:SimpleDN404", + "label": "_symbol", + "offset": 0, + "slot": "1", + "type": "t_string_storage" + }, + { + "astId": 414, + "contract": "@sandbox-smart-contracts/dn404/contracts/SimpleDN404.sol:SimpleDN404", + "label": "_baseURI", + "offset": 0, + "slot": "2", + "type": "t_string_storage" + } + ], + "types": { + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/packages/deploy/deployments/amoy/solcInputs/efe1133fb66c7fcb6c05f983751390cd.json b/packages/deploy/deployments/amoy/solcInputs/efe1133fb66c7fcb6c05f983751390cd.json new file mode 100644 index 0000000000..92bcc25c12 --- /dev/null +++ b/packages/deploy/deployments/amoy/solcInputs/efe1133fb66c7fcb6c05f983751390cd.json @@ -0,0 +1,57 @@ +{ + "language": "Solidity", + "sources": { + "@sandbox-smart-contracts/dn404/contracts/NFTMintDN404.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity 0.8.25;\n\nimport {DN404} from \"dn404/src/DN404.sol\";\nimport {DN404Mirror} from \"dn404/src/DN404Mirror.sol\";\nimport {Ownable} from \"solady/src/auth/Ownable.sol\";\nimport {LibString} from \"solady/src/utils/LibString.sol\";\nimport {SafeTransferLib} from \"solady/src/utils/SafeTransferLib.sol\";\nimport {MerkleProofLib} from \"solady/src/utils/MerkleProofLib.sol\";\n\n/**\n * @title NFTMintDN404\n * @notice Sample DN404 contract that demonstrates the owner selling NFTs rather than the fungible token.\n * The underlying call still mints ERC20 tokens, but to the end user it'll appear as a standard NFT mint.\n * Each address is limited to MAX_PER_WALLET total mints.\n */\ncontract NFTMintDN404 is DN404, Ownable {\n string private _name;\n string private _symbol;\n string private _baseURI;\n bytes32 private _allowlistRoot;\n uint96 public publicPrice; // uint96 is sufficient to represent all ETH in existence.\n uint96 public allowlistPrice; // uint96 is sufficient to represent all ETH in existence.\n uint32 public totalMinted; // DN404 only supports up to `2**32 - 2` tokens.\n bool public live;\n\n uint32 public constant MAX_PER_WALLET = 5;\n uint32 public constant MAX_SUPPLY = 5000;\n\n error InvalidProof();\n error InvalidMint();\n error InvalidPrice();\n error TotalSupplyReached();\n error NotLive();\n\n constructor(\n string memory name_,\n string memory symbol_,\n bytes32 allowlistRoot_,\n uint96 publicPrice_,\n uint96 allowlistPrice_,\n uint96 initialTokenSupply,\n address initialSupplyOwner\n ) {\n _initializeOwner(msg.sender);\n\n _name = name_;\n _symbol = symbol_;\n _allowlistRoot = allowlistRoot_;\n publicPrice = publicPrice_;\n allowlistPrice = allowlistPrice_;\n\n address mirror = address(new DN404Mirror(msg.sender));\n _initializeDN404(initialTokenSupply, initialSupplyOwner, mirror);\n }\n\n modifier onlyLive() {\n if (!live) {\n revert NotLive();\n }\n _;\n }\n\n modifier checkPrice(uint256 price, uint256 nftAmount) {\n if (price * nftAmount != msg.value) {\n revert InvalidPrice();\n }\n _;\n }\n\n modifier checkAndUpdateTotalMinted(uint256 nftAmount) {\n uint256 newTotalMinted = uint256(totalMinted) + nftAmount;\n if (newTotalMinted > MAX_SUPPLY) {\n revert TotalSupplyReached();\n }\n totalMinted = uint32(newTotalMinted);\n _;\n }\n\n modifier checkAndUpdateBuyerMintCount(uint256 nftAmount) {\n uint256 currentMintCount = _getAux(msg.sender);\n uint256 newMintCount = currentMintCount + nftAmount;\n if (newMintCount > MAX_PER_WALLET) {\n revert InvalidMint();\n }\n _setAux(msg.sender, uint88(newMintCount));\n _;\n }\n\n function mint(\n uint256 nftAmount\n )\n public\n payable\n onlyLive\n checkPrice(publicPrice, nftAmount)\n checkAndUpdateBuyerMintCount(nftAmount)\n checkAndUpdateTotalMinted(nftAmount)\n {\n _mint(msg.sender, nftAmount * _unit());\n }\n\n function allowlistMint(\n uint256 nftAmount,\n bytes32[] calldata proof\n )\n public\n payable\n onlyLive\n checkPrice(allowlistPrice, nftAmount)\n checkAndUpdateBuyerMintCount(nftAmount)\n checkAndUpdateTotalMinted(nftAmount)\n {\n bytes32 leaf = keccak256(abi.encodePacked(msg.sender));\n if (!MerkleProofLib.verifyCalldata(proof, _allowlistRoot, leaf)) {\n revert InvalidProof();\n }\n _mint(msg.sender, nftAmount * _unit());\n }\n\n function setBaseURI(string calldata baseURI_) public onlyOwner {\n _baseURI = baseURI_;\n }\n\n function setPrices(uint96 publicPrice_, uint96 allowlistPrice_) public onlyOwner {\n publicPrice = publicPrice_;\n allowlistPrice = allowlistPrice_;\n }\n\n function toggleLive() public onlyOwner {\n live = !live;\n }\n\n function withdraw() public onlyOwner {\n SafeTransferLib.safeTransferAllETH(msg.sender);\n }\n\n function name() public view override returns (string memory) {\n return _name;\n }\n\n function symbol() public view override returns (string memory) {\n return _symbol;\n }\n\n function _tokenURI(uint256 tokenId) internal view override returns (string memory result) {\n if (bytes(_baseURI).length != 0) {\n result = string(abi.encodePacked(_baseURI, LibString.toString(tokenId)));\n }\n }\n}\n" + }, + "@sandbox-smart-contracts/dn404/contracts/SimpleDN404.sol": { + "content": "//SPDX-License-Identifier: MIT\npragma solidity 0.8.25;\n\nimport {DN404} from \"dn404/src/DN404.sol\";\nimport {DN404Mirror} from \"dn404/src/DN404Mirror.sol\";\nimport {Ownable} from \"solady/src/auth/Ownable.sol\";\nimport {LibString} from \"solady/src/utils/LibString.sol\";\nimport {SafeTransferLib} from \"solady/src/utils/SafeTransferLib.sol\";\n\n/**\n * @title SimpleDN404\n * @notice Sample DN404 contract that demonstrates the owner selling fungible tokens.\n * When a user has at least one base unit (10^18) amount of tokens, they will automatically receive an NFT.\n * NFTs are minted as an address accumulates each base unit amount of tokens.\n */\ncontract SimpleDN404 is DN404, Ownable {\n string private _name;\n string private _symbol;\n string private _baseURI;\n\n constructor(string memory name_, string memory symbol_, uint96 initialTokenSupply, address initialSupplyOwner) {\n _initializeOwner(msg.sender);\n\n _name = name_;\n _symbol = symbol_;\n\n address mirror = address(new DN404Mirror(msg.sender));\n _initializeDN404(initialTokenSupply, initialSupplyOwner, mirror);\n }\n\n function name() public view override returns (string memory) {\n return _name;\n }\n\n function symbol() public view override returns (string memory) {\n return _symbol;\n }\n\n function _tokenURI(uint256 tokenId) internal view override returns (string memory result) {\n if (bytes(_baseURI).length != 0) {\n result = string(abi.encodePacked(_baseURI, LibString.toString(tokenId)));\n }\n }\n\n // This allows the owner of the contract to mint more tokens.\n function mint(address to, uint256 amount) public onlyOwner {\n _mint(to, amount);\n }\n\n function setBaseURI(string calldata baseURI_) public onlyOwner {\n _baseURI = baseURI_;\n }\n\n function withdraw() public onlyOwner {\n SafeTransferLib.safeTransferAllETH(msg.sender);\n }\n}\n" + }, + "dn404/src/DN404.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @title DN404\n/// @notice DN404 is a hybrid ERC20 and ERC721 implementation that mints\n/// and burns NFTs based on an account's ERC20 token balance.\n///\n/// @author vectorized.eth (@optimizoor)\n/// @author Quit (@0xQuit)\n/// @author Michael Amadi (@AmadiMichaels)\n/// @author cygaar (@0xCygaar)\n/// @author Thomas (@0xjustadev)\n/// @author Harrison (@PopPunkOnChain)\n///\n/// @dev Note:\n/// - The ERC721 data is stored in this base DN404 contract, however a\n/// DN404Mirror contract ***MUST*** be deployed and linked during\n/// initialization.\nabstract contract DN404 {\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* EVENTS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Emitted when `amount` tokens is transferred from `from` to `to`.\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n /// @dev Emitted when `amount` tokens is approved by `owner` to be used by `spender`.\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /// @dev Emitted when `owner` sets their skipNFT flag to `status`.\n event SkipNFTSet(address indexed owner, bool status);\n\n /// @dev `keccak256(bytes(\"Transfer(address,address,uint256)\"))`.\n uint256 private constant _TRANSFER_EVENT_SIGNATURE =\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\n\n /// @dev `keccak256(bytes(\"Approval(address,address,uint256)\"))`.\n uint256 private constant _APPROVAL_EVENT_SIGNATURE =\n 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;\n\n /// @dev `keccak256(bytes(\"SkipNFTSet(address,bool)\"))`.\n uint256 private constant _SKIP_NFT_SET_EVENT_SIGNATURE =\n 0xb5a1de456fff688115a4f75380060c23c8532d14ff85f687cc871456d6420393;\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* CUSTOM ERRORS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Thrown when attempting to double-initialize the contract.\n error DNAlreadyInitialized();\n\n /// @dev The function can only be called after the contract has been initialized.\n error DNNotInitialized();\n\n /// @dev Thrown when attempting to transfer or burn more tokens than sender's balance.\n error InsufficientBalance();\n\n /// @dev Thrown when a spender attempts to transfer tokens with an insufficient allowance.\n error InsufficientAllowance();\n\n /// @dev Thrown when minting an amount of tokens that would overflow the max tokens.\n error TotalSupplyOverflow();\n\n /// @dev The unit must be greater than zero and less than `2**96`.\n error InvalidUnit();\n\n /// @dev Thrown when the caller for a fallback NFT function is not the mirror contract.\n error SenderNotMirror();\n\n /// @dev Thrown when attempting to transfer tokens to the zero address.\n error TransferToZeroAddress();\n\n /// @dev Thrown when the mirror address provided for initialization is the zero address.\n error MirrorAddressIsZero();\n\n /// @dev Thrown when the link call to the mirror contract reverts.\n error LinkMirrorContractFailed();\n\n /// @dev Thrown when setting an NFT token approval\n /// and the caller is not the owner or an approved operator.\n error ApprovalCallerNotOwnerNorApproved();\n\n /// @dev Thrown when transferring an NFT\n /// and the caller is not the owner or an approved operator.\n error TransferCallerNotOwnerNorApproved();\n\n /// @dev Thrown when transferring an NFT and the from address is not the current owner.\n error TransferFromIncorrectOwner();\n\n /// @dev Thrown when checking the owner or approved address for a non-existent NFT.\n error TokenDoesNotExist();\n\n /// @dev The function selector is not recognized.\n error FnSelectorNotRecognized();\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* CONSTANTS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev The flag to denote that the address data is initialized.\n uint8 internal constant _ADDRESS_DATA_INITIALIZED_FLAG = 1 << 0;\n\n /// @dev The flag to denote that the address should skip NFTs.\n uint8 internal constant _ADDRESS_DATA_SKIP_NFT_FLAG = 1 << 1;\n\n /// @dev The flag to denote that the address has overridden the default Permit2 allowance.\n uint8 internal constant _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG = 1 << 2;\n\n /// @dev The canonical Permit2 address.\n /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.\n /// To enable, override `_givePermit2DefaultInfiniteAllowance()`.\n /// [Github](https://github.com/Uniswap/permit2)\n /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)\n address internal constant _PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* STORAGE */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Struct containing an address's token data and settings.\n struct AddressData {\n // Auxiliary data.\n uint88 aux;\n // Flags for `initialized` and `skipNFT`.\n uint8 flags;\n // The alias for the address. Zero means absence of an alias.\n uint32 addressAlias;\n // The number of NFT tokens.\n uint32 ownedLength;\n // The token balance in wei.\n uint96 balance;\n }\n\n /// @dev A uint32 map in storage.\n struct Uint32Map {\n uint256 spacer;\n }\n\n /// @dev A bitmap in storage.\n struct Bitmap {\n uint256 spacer;\n }\n\n /// @dev A struct to wrap a uint256 in storage.\n struct Uint256Ref {\n uint256 value;\n }\n\n /// @dev A mapping of an address pair to a Uint256Ref.\n struct AddressPairToUint256RefMap {\n uint256 spacer;\n }\n\n /// @dev Struct containing the base token contract storage.\n struct DN404Storage {\n // Current number of address aliases assigned.\n uint32 numAliases;\n // Next NFT ID to assign for a mint.\n uint32 nextTokenId;\n // The head of the burned pool.\n uint32 burnedPoolHead;\n // The tail of the burned pool.\n uint32 burnedPoolTail;\n // Total number of NFTs in existence.\n uint32 totalNFTSupply;\n // Total supply of tokens.\n uint96 totalSupply;\n // Address of the NFT mirror contract.\n address mirrorERC721;\n // Mapping of a user alias number to their address.\n mapping(uint32 => address) aliasToAddress;\n // Mapping of user operator approvals for NFTs.\n AddressPairToUint256RefMap operatorApprovals;\n // Mapping of NFT approvals to approved operators.\n mapping(uint256 => address) nftApprovals;\n // Bitmap of whether an non-zero NFT approval may exist.\n Bitmap mayHaveNFTApproval;\n // Bitmap of whether a NFT ID exists. Ignored if `_useExistsLookup()` returns false.\n Bitmap exists;\n // Mapping of user allowances for ERC20 spenders.\n AddressPairToUint256RefMap allowance;\n // Mapping of NFT IDs owned by an address.\n mapping(address => Uint32Map) owned;\n // The pool of burned NFT IDs.\n Uint32Map burnedPool;\n // Even indices: owner aliases. Odd indices: owned indices.\n Uint32Map oo;\n // Mapping of user account AddressData.\n mapping(address => AddressData) addressData;\n }\n\n /// @dev Returns a storage pointer for DN404Storage.\n function _getDN404Storage() internal pure virtual returns (DN404Storage storage $) {\n /// @solidity memory-safe-assembly\n assembly {\n // `uint72(bytes9(keccak256(\"DN404_STORAGE\")))`.\n $.slot := 0xa20d6e21d0e5255308 // Truncate to 9 bytes to reduce bytecode size.\n }\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* INITIALIZER */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Initializes the DN404 contract with an\n /// `initialTokenSupply`, `initialTokenOwner` and `mirror` NFT contract address.\n function _initializeDN404(\n uint256 initialTokenSupply,\n address initialSupplyOwner,\n address mirror\n ) internal virtual {\n DN404Storage storage $ = _getDN404Storage();\n\n unchecked {\n if (_unit() - 1 >= 2 ** 96 - 1) revert InvalidUnit();\n }\n if ($.mirrorERC721 != address(0)) revert DNAlreadyInitialized();\n if (mirror == address(0)) revert MirrorAddressIsZero();\n\n /// @solidity memory-safe-assembly\n assembly {\n // Make the call to link the mirror contract.\n mstore(0x00, 0x0f4599e5) // `linkMirrorContract(address)`.\n mstore(0x20, caller())\n if iszero(and(eq(mload(0x00), 1), call(gas(), mirror, 0, 0x1c, 0x24, 0x00, 0x20))) {\n mstore(0x00, 0xd125259c) // `LinkMirrorContractFailed()`.\n revert(0x1c, 0x04)\n }\n }\n\n $.nextTokenId = 1;\n $.mirrorERC721 = mirror;\n\n if (initialTokenSupply != 0) {\n if (initialSupplyOwner == address(0)) revert TransferToZeroAddress();\n if (_totalSupplyOverflows(initialTokenSupply)) revert TotalSupplyOverflow();\n\n $.totalSupply = uint96(initialTokenSupply);\n AddressData storage initialOwnerAddressData = _addressData(initialSupplyOwner);\n initialOwnerAddressData.balance = uint96(initialTokenSupply);\n\n /// @solidity memory-safe-assembly\n assembly {\n // Emit the {Transfer} event.\n mstore(0x00, initialTokenSupply)\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, initialSupplyOwner)))\n }\n\n _setSkipNFT(initialSupplyOwner, true);\n }\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* BASE UNIT FUNCTION TO OVERRIDE */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Amount of token balance that is equal to one NFT.\n function _unit() internal view virtual returns (uint256) {\n return 10 ** 18;\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* METADATA FUNCTIONS TO OVERRIDE */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns the name of the token.\n function name() public view virtual returns (string memory);\n\n /// @dev Returns the symbol of the token.\n function symbol() public view virtual returns (string memory);\n\n /// @dev Returns the Uniform Resource Identifier (URI) for token `id`.\n function _tokenURI(uint256 id) internal view virtual returns (string memory);\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* CONFIGURABLES */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns if direct NFT transfers should be used during ERC20 transfers\n /// whenever possible, instead of burning and re-minting.\n function _useDirectTransfersIfPossible() internal view virtual returns (bool) {\n return true;\n }\n\n /// @dev Returns if burns should be added to the burn pool.\n /// This returns false by default, which means the NFT IDs are re-minted in a cycle.\n function _addToBurnedPool(uint256 totalNFTSupplyAfterBurn, uint256 totalSupplyAfterBurn)\n internal\n view\n virtual\n returns (bool)\n {\n // Silence unused variable compiler warning.\n totalSupplyAfterBurn = totalNFTSupplyAfterBurn;\n return false;\n }\n\n /// @dev Returns whether to use the exists bitmap for more efficient\n /// scanning of an empty token ID slot.\n /// Recommended for collections that do not use the burn pool,\n /// and are expected to have nearly all possible NFTs materialized.\n ///\n /// Note: The returned value must be constant after initialization.\n function _useExistsLookup() internal view virtual returns (bool) {\n return true;\n }\n\n /// @dev Hook that is called after any NFT token transfers, including minting and burning.\n function _afterNFTTransfer(address from, address to, uint256 id) internal virtual {}\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* ERC20 OPERATIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns the decimals places of the token. Defaults to 18.\n /// Does not affect DN404's internal calculations.\n /// Will only affect the frontend UI on most protocols.\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /// @dev Returns the amount of tokens in existence.\n function totalSupply() public view virtual returns (uint256) {\n return uint256(_getDN404Storage().totalSupply);\n }\n\n /// @dev Returns the amount of tokens owned by `owner`.\n function balanceOf(address owner) public view virtual returns (uint256) {\n return _getDN404Storage().addressData[owner].balance;\n }\n\n /// @dev Returns the amount of tokens that `spender` can spend on behalf of `owner`.\n function allowance(address owner, address spender) public view returns (uint256) {\n if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {\n uint8 flags = _getDN404Storage().addressData[owner].flags;\n if (_isZero(flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG)) return type(uint256).max;\n }\n return _ref(_getDN404Storage().allowance, owner, spender).value;\n }\n\n /// @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n ///\n /// Emits a {Approval} event.\n function approve(address spender, uint256 amount) public virtual returns (bool) {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n /// @dev Transfer `amount` tokens from the caller to `to`.\n ///\n /// Will burn sender NFTs if balance after transfer is less than\n /// the amount required to support the current NFT balance.\n ///\n /// Will mint NFTs to `to` if the recipient's new balance supports\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is\n /// set to false.\n ///\n /// Requirements:\n /// - `from` must at least have `amount`.\n ///\n /// Emits a {Transfer} event.\n function transfer(address to, uint256 amount) public virtual returns (bool) {\n _transfer(msg.sender, to, amount);\n return true;\n }\n\n /// @dev Transfers `amount` tokens from `from` to `to`.\n ///\n /// Note: Does not update the allowance if it is the maximum uint256 value.\n ///\n /// Will burn sender NFTs if balance after transfer is less than\n /// the amount required to support the current NFT balance.\n ///\n /// Will mint NFTs to `to` if the recipient's new balance supports\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is\n /// set to false.\n ///\n /// Requirements:\n /// - `from` must at least have `amount`.\n /// - The caller must have at least `amount` of allowance to transfer the tokens of `from`.\n ///\n /// Emits a {Transfer} event.\n function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) {\n Uint256Ref storage a = _ref(_getDN404Storage().allowance, from, msg.sender);\n\n uint256 allowed = _givePermit2DefaultInfiniteAllowance() && msg.sender == _PERMIT2\n && _isZero(_getDN404Storage().addressData[from].flags & _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG)\n ? type(uint256).max\n : a.value;\n\n if (allowed != type(uint256).max) {\n if (amount > allowed) revert InsufficientAllowance();\n unchecked {\n a.value = allowed - amount;\n }\n }\n _transfer(from, to, amount);\n return true;\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* PERMIT2 */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Whether Permit2 has infinite allowances by default for all owners.\n /// For signature-based allowance granting for single transaction ERC20 `transferFrom`.\n /// To enable, override this function to return true.\n function _givePermit2DefaultInfiniteAllowance() internal view virtual returns (bool) {\n return false;\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* INTERNAL MINT FUNCTIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Mints `amount` tokens to `to`, increasing the total supply.\n ///\n /// Will mint NFTs to `to` if the recipient's new balance supports\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.\n ///\n /// Emits a {Transfer} event.\n function _mint(address to, uint256 amount) internal virtual {\n if (to == address(0)) revert TransferToZeroAddress();\n\n AddressData storage toAddressData = _addressData(to);\n DN404Storage storage $ = _getDN404Storage();\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\n\n _DNMintTemps memory t;\n unchecked {\n uint256 toBalance = uint256(toAddressData.balance) + amount;\n toAddressData.balance = uint96(toBalance);\n t.toEnd = toBalance / _unit();\n }\n uint256 maxId;\n unchecked {\n uint256 totalSupply_ = uint256($.totalSupply) + amount;\n $.totalSupply = uint96(totalSupply_);\n uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));\n if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();\n maxId = totalSupply_ / _unit();\n }\n unchecked {\n if (_isZero(toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG)) {\n Uint32Map storage toOwned = $.owned[to];\n Uint32Map storage oo = $.oo;\n uint256 toIndex = toAddressData.ownedLength;\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));\n\n if (packedLogs.logs.length != 0) {\n _packedLogsSet(packedLogs, to, 0);\n $.totalNFTSupply += uint32(packedLogs.logs.length);\n toAddressData.ownedLength = uint32(t.toEnd);\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\n uint32 burnedPoolHead = $.burnedPoolHead;\n t.burnedPoolTail = $.burnedPoolTail;\n t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);\n // Mint loop.\n do {\n uint256 id;\n if (burnedPoolHead != t.burnedPoolTail) {\n id = _get($.burnedPool, burnedPoolHead++);\n } else {\n id = t.nextTokenId;\n while (_get(oo, _ownershipIndex(id)) != 0) {\n id = _useExistsLookup()\n ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId), maxId)\n : _wrapNFTId(id + 1, maxId);\n }\n t.nextTokenId = _wrapNFTId(id + 1, maxId);\n }\n if (_useExistsLookup()) _set($.exists, id, true);\n _set(toOwned, toIndex, uint32(id));\n _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));\n _packedLogsAppend(packedLogs, id);\n _afterNFTTransfer(address(0), to, id);\n } while (toIndex != t.toEnd);\n\n $.nextTokenId = uint32(t.nextTokenId);\n $.burnedPoolHead = burnedPoolHead;\n _packedLogsSend(packedLogs, $.mirrorERC721);\n }\n }\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Emit the {Transfer} event.\n mstore(0x00, amount)\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))\n }\n }\n\n /// @dev Mints `amount` tokens to `to`, increasing the total supply.\n /// This variant mints NFT tokens starting from ID `preTotalSupply / _unit() + 1`.\n /// This variant will not touch the `burnedPool` and `nextTokenId`.\n ///\n /// Will mint NFTs to `to` if the recipient's new balance supports\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is set to false.\n ///\n /// Emits a {Transfer} event.\n function _mintNext(address to, uint256 amount) internal virtual {\n if (to == address(0)) revert TransferToZeroAddress();\n\n AddressData storage toAddressData = _addressData(to);\n DN404Storage storage $ = _getDN404Storage();\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\n\n _DNMintTemps memory t;\n unchecked {\n uint256 toBalance = uint256(toAddressData.balance) + amount;\n toAddressData.balance = uint96(toBalance);\n t.toEnd = toBalance / _unit();\n }\n uint256 startId;\n uint256 maxId;\n unchecked {\n uint256 preTotalSupply = uint256($.totalSupply);\n startId = preTotalSupply / _unit() + 1;\n uint256 totalSupply_ = uint256(preTotalSupply) + amount;\n $.totalSupply = uint96(totalSupply_);\n uint256 overflows = _toUint(_totalSupplyOverflows(totalSupply_));\n if (overflows | _toUint(totalSupply_ < amount) != 0) revert TotalSupplyOverflow();\n maxId = totalSupply_ / _unit();\n }\n unchecked {\n if (_isZero(toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG)) {\n Uint32Map storage toOwned = $.owned[to];\n Uint32Map storage oo = $.oo;\n uint256 toIndex = toAddressData.ownedLength;\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(_zeroFloorSub(t.toEnd, toIndex));\n\n if (packedLogs.logs.length != 0) {\n _packedLogsSet(packedLogs, to, 0);\n $.totalNFTSupply += uint32(packedLogs.logs.length);\n toAddressData.ownedLength = uint32(t.toEnd);\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\n // Mint loop.\n do {\n uint256 id = startId;\n while (_get(oo, _ownershipIndex(id)) != 0) {\n id = _useExistsLookup()\n ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId), maxId)\n : _wrapNFTId(id + 1, maxId);\n }\n startId = _wrapNFTId(id + 1, maxId);\n if (_useExistsLookup()) _set($.exists, id, true);\n _set(toOwned, toIndex, uint32(id));\n _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));\n _packedLogsAppend(packedLogs, id);\n _afterNFTTransfer(address(0), to, id);\n } while (toIndex != t.toEnd);\n\n _packedLogsSend(packedLogs, $.mirrorERC721);\n }\n }\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Emit the {Transfer} event.\n mstore(0x00, amount)\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, 0, shr(96, shl(96, to)))\n }\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* INTERNAL BURN FUNCTIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Burns `amount` tokens from `from`, reducing the total supply.\n ///\n /// Will burn sender NFTs if balance after transfer is less than\n /// the amount required to support the current NFT balance.\n ///\n /// Emits a {Transfer} event.\n function _burn(address from, uint256 amount) internal virtual {\n DN404Storage storage $ = _getDN404Storage();\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\n\n AddressData storage fromAddressData = $.addressData[from];\n uint256 fromBalance = fromAddressData.balance;\n if (amount > fromBalance) revert InsufficientBalance();\n\n unchecked {\n fromAddressData.balance = uint96(fromBalance -= amount);\n uint256 totalSupply_ = uint256($.totalSupply) - amount;\n $.totalSupply = uint96(totalSupply_);\n\n Uint32Map storage fromOwned = $.owned[from];\n uint256 fromIndex = fromAddressData.ownedLength;\n uint256 numNFTBurns = _zeroFloorSub(fromIndex, fromBalance / _unit());\n\n if (numNFTBurns != 0) {\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(numNFTBurns);\n _packedLogsSet(packedLogs, from, 1);\n bool addToBurnedPool;\n {\n uint256 totalNFTSupply = uint256($.totalNFTSupply) - numNFTBurns;\n $.totalNFTSupply = uint32(totalNFTSupply);\n addToBurnedPool = _addToBurnedPool(totalNFTSupply, totalSupply_);\n }\n\n Uint32Map storage oo = $.oo;\n uint256 fromEnd = fromIndex - numNFTBurns;\n fromAddressData.ownedLength = uint32(fromEnd);\n uint32 burnedPoolTail = $.burnedPoolTail;\n // Burn loop.\n do {\n uint256 id = _get(fromOwned, --fromIndex);\n _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);\n _packedLogsAppend(packedLogs, id);\n if (_useExistsLookup()) _set($.exists, id, false);\n if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));\n if (_get($.mayHaveNFTApproval, id)) {\n _set($.mayHaveNFTApproval, id, false);\n delete $.nftApprovals[id];\n }\n _afterNFTTransfer(from, address(0), id);\n } while (fromIndex != fromEnd);\n\n if (addToBurnedPool) $.burnedPoolTail = burnedPoolTail;\n _packedLogsSend(packedLogs, $.mirrorERC721);\n }\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Emit the {Transfer} event.\n mstore(0x00, amount)\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), 0)\n }\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* INTERNAL TRANSFER FUNCTIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Moves `amount` of tokens from `from` to `to`.\n ///\n /// Will burn sender NFTs if balance after transfer is less than\n /// the amount required to support the current NFT balance.\n ///\n /// Will mint NFTs to `to` if the recipient's new balance supports\n /// additional NFTs ***AND*** the `to` address's skipNFT flag is\n /// set to false.\n ///\n /// Emits a {Transfer} event.\n function _transfer(address from, address to, uint256 amount) internal virtual {\n if (to == address(0)) revert TransferToZeroAddress();\n\n DN404Storage storage $ = _getDN404Storage();\n AddressData storage fromAddressData = $.addressData[from];\n AddressData storage toAddressData = _addressData(to);\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\n\n _DNTransferTemps memory t;\n t.fromOwnedLength = fromAddressData.ownedLength;\n t.toOwnedLength = toAddressData.ownedLength;\n\n unchecked {\n {\n uint256 fromBalance = fromAddressData.balance;\n if (amount > fromBalance) revert InsufficientBalance();\n fromAddressData.balance = uint96(fromBalance -= amount);\n\n uint256 toBalance = uint256(toAddressData.balance) + amount;\n toAddressData.balance = uint96(toBalance);\n t.numNFTBurns = _zeroFloorSub(t.fromOwnedLength, fromBalance / _unit());\n\n if (_isZero(toAddressData.flags & _ADDRESS_DATA_SKIP_NFT_FLAG)) {\n if (from == to) t.toOwnedLength = t.fromOwnedLength - t.numNFTBurns;\n t.numNFTMints = _zeroFloorSub(toBalance / _unit(), t.toOwnedLength);\n }\n }\n\n while (_useDirectTransfersIfPossible()) {\n uint256 n = _min(t.fromOwnedLength, _min(t.numNFTBurns, t.numNFTMints));\n if (_isZero(n)) break;\n t.numNFTBurns -= n;\n t.numNFTMints -= n;\n if (from == to) {\n t.toOwnedLength += n;\n break;\n }\n _DNDirectLogs memory directLogs = _directLogsMalloc(n, from, to);\n Uint32Map storage fromOwned = $.owned[from];\n Uint32Map storage toOwned = $.owned[to];\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\n uint256 toIndex = t.toOwnedLength;\n n = toIndex + n;\n // Direct transfer loop.\n do {\n uint256 id = _get(fromOwned, --t.fromOwnedLength);\n _set(toOwned, toIndex, uint32(id));\n _setOwnerAliasAndOwnedIndex($.oo, id, t.toAlias, uint32(toIndex));\n _directLogsAppend(directLogs, id);\n if (_get($.mayHaveNFTApproval, id)) {\n _set($.mayHaveNFTApproval, id, false);\n delete $.nftApprovals[id];\n }\n _afterNFTTransfer(from, to, id);\n } while (++toIndex != n);\n\n toAddressData.ownedLength = uint32(t.toOwnedLength = toIndex);\n fromAddressData.ownedLength = uint32(t.fromOwnedLength);\n _directLogsSend(directLogs, $.mirrorERC721);\n break;\n }\n\n t.totalNFTSupply = uint256($.totalNFTSupply) + t.numNFTMints - t.numNFTBurns;\n $.totalNFTSupply = uint32(t.totalNFTSupply);\n\n Uint32Map storage oo = $.oo;\n _DNPackedLogs memory packedLogs = _packedLogsMalloc(t.numNFTBurns + t.numNFTMints);\n\n t.burnedPoolTail = $.burnedPoolTail;\n if (t.numNFTBurns != 0) {\n _packedLogsSet(packedLogs, from, 1);\n bool addToBurnedPool = _addToBurnedPool(t.totalNFTSupply, $.totalSupply);\n Uint32Map storage fromOwned = $.owned[from];\n uint256 fromIndex = t.fromOwnedLength;\n fromAddressData.ownedLength = uint32(t.fromEnd = fromIndex - t.numNFTBurns);\n uint32 burnedPoolTail = t.burnedPoolTail;\n // Burn loop.\n do {\n uint256 id = _get(fromOwned, --fromIndex);\n _setOwnerAliasAndOwnedIndex(oo, id, 0, 0);\n _packedLogsAppend(packedLogs, id);\n if (_useExistsLookup()) _set($.exists, id, false);\n if (addToBurnedPool) _set($.burnedPool, burnedPoolTail++, uint32(id));\n if (_get($.mayHaveNFTApproval, id)) {\n _set($.mayHaveNFTApproval, id, false);\n delete $.nftApprovals[id];\n }\n _afterNFTTransfer(from, address(0), id);\n } while (fromIndex != t.fromEnd);\n\n if (addToBurnedPool) $.burnedPoolTail = (t.burnedPoolTail = burnedPoolTail);\n }\n\n if (t.numNFTMints != 0) {\n _packedLogsSet(packedLogs, to, 0);\n Uint32Map storage toOwned = $.owned[to];\n t.toAlias = _registerAndResolveAlias(toAddressData, to);\n uint256 maxId = $.totalSupply / _unit();\n t.nextTokenId = _wrapNFTId($.nextTokenId, maxId);\n uint256 toIndex = t.toOwnedLength;\n toAddressData.ownedLength = uint32(t.toEnd = toIndex + t.numNFTMints);\n uint32 burnedPoolHead = $.burnedPoolHead;\n // Mint loop.\n do {\n uint256 id;\n if (burnedPoolHead != t.burnedPoolTail) {\n id = _get($.burnedPool, burnedPoolHead++);\n } else {\n id = t.nextTokenId;\n while (_get(oo, _ownershipIndex(id)) != 0) {\n id = _useExistsLookup()\n ? _wrapNFTId(_findFirstUnset($.exists, id + 1, maxId), maxId)\n : _wrapNFTId(id + 1, maxId);\n }\n t.nextTokenId = _wrapNFTId(id + 1, maxId);\n }\n if (_useExistsLookup()) _set($.exists, id, true);\n _set(toOwned, toIndex, uint32(id));\n _setOwnerAliasAndOwnedIndex(oo, id, t.toAlias, uint32(toIndex++));\n _packedLogsAppend(packedLogs, id);\n _afterNFTTransfer(address(0), to, id);\n } while (toIndex != t.toEnd);\n\n $.burnedPoolHead = burnedPoolHead;\n $.nextTokenId = uint32(t.nextTokenId);\n }\n\n if (packedLogs.logs.length != 0) _packedLogsSend(packedLogs, $.mirrorERC721);\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Emit the {Transfer} event.\n mstore(0x00, amount)\n // forgefmt: disable-next-item\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))\n }\n }\n\n /// @dev Transfers token `id` from `from` to `to`.\n /// Also emits an ERC721 {Transfer} event on the `mirrorERC721`.\n ///\n /// Requirements:\n ///\n /// - Call must originate from the mirror contract.\n /// - Token `id` must exist.\n /// - `from` must be the owner of the token.\n /// - `to` cannot be the zero address.\n /// `msgSender` must be the owner of the token, or be approved to manage the token.\n ///\n /// Emits a {Transfer} event.\n function _initiateTransferFromNFT(address from, address to, uint256 id, address msgSender)\n internal\n virtual\n {\n _transferFromNFT(from, to, id, msgSender);\n // Emit ERC721 {Transfer} event.\n _DNDirectLogs memory directLogs = _directLogsMalloc(1, from, to);\n _directLogsAppend(directLogs, id);\n _directLogsSend(directLogs, _getDN404Storage().mirrorERC721);\n }\n\n /// @dev Transfers token `id` from `from` to `to`.\n ///\n /// Requirements:\n ///\n /// - Call must originate from the mirror contract.\n /// - Token `id` must exist.\n /// - `from` must be the owner of the token.\n /// - `to` cannot be the zero address.\n /// `msgSender` must be the owner of the token, or be approved to manage the token.\n ///\n /// Emits a {Transfer} event.\n function _transferFromNFT(address from, address to, uint256 id, address msgSender)\n internal\n virtual\n {\n if (to == address(0)) revert TransferToZeroAddress();\n\n DN404Storage storage $ = _getDN404Storage();\n if ($.mirrorERC721 == address(0)) revert DNNotInitialized();\n\n Uint32Map storage oo = $.oo;\n\n if (from != $.aliasToAddress[_get(oo, _ownershipIndex(_restrictNFTId(id)))]) {\n revert TransferFromIncorrectOwner();\n }\n\n if (msgSender != from) {\n if (!_isApprovedForAll(from, msgSender)) {\n if (_getApproved(id) != msgSender) {\n revert TransferCallerNotOwnerNorApproved();\n }\n }\n }\n\n AddressData storage fromAddressData = $.addressData[from];\n AddressData storage toAddressData = $.addressData[to];\n\n uint256 unit = _unit();\n mapping(address => Uint32Map) storage owned = $.owned;\n\n unchecked {\n uint256 fromBalance = fromAddressData.balance;\n if (unit > fromBalance) revert InsufficientBalance();\n fromAddressData.balance = uint96(fromBalance - unit);\n toAddressData.balance += uint96(unit);\n }\n if (_get($.mayHaveNFTApproval, id)) {\n _set($.mayHaveNFTApproval, id, false);\n delete $.nftApprovals[id];\n }\n unchecked {\n Uint32Map storage fromOwned = owned[from];\n uint32 updatedId = _get(fromOwned, --fromAddressData.ownedLength);\n uint32 i = _get(oo, _ownedIndex(id));\n _set(fromOwned, i, updatedId);\n _set(oo, _ownedIndex(updatedId), i);\n }\n unchecked {\n uint32 n = toAddressData.ownedLength++;\n _set(owned[to], n, uint32(id));\n _setOwnerAliasAndOwnedIndex(oo, id, _registerAndResolveAlias(toAddressData, to), n);\n }\n _afterNFTTransfer(from, to, id);\n /// @solidity memory-safe-assembly\n assembly {\n // Emit the {Transfer} event.\n mstore(0x00, unit)\n // forgefmt: disable-next-item\n log3(0x00, 0x20, _TRANSFER_EVENT_SIGNATURE, shr(96, shl(96, from)), shr(96, shl(96, to)))\n }\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* INTERNAL APPROVE FUNCTIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Sets `amount` as the allowance of `spender` over the tokens of `owner`.\n ///\n /// Emits a {Approval} event.\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n if (_givePermit2DefaultInfiniteAllowance() && spender == _PERMIT2) {\n _getDN404Storage().addressData[owner].flags |= _ADDRESS_DATA_OVERRIDE_PERMIT2_FLAG;\n }\n _ref(_getDN404Storage().allowance, owner, spender).value = amount;\n /// @solidity memory-safe-assembly\n assembly {\n // Emit the {Approval} event.\n mstore(0x00, amount)\n // forgefmt: disable-next-item\n log3(0x00, 0x20, _APPROVAL_EVENT_SIGNATURE, shr(96, shl(96, owner)), shr(96, shl(96, spender)))\n }\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* DATA HITCHHIKING FUNCTIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns the auxiliary data for `owner`.\n /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.\n /// Auxiliary data can be set for any address, even if it does not have any tokens.\n function _getAux(address owner) internal view virtual returns (uint88) {\n return _getDN404Storage().addressData[owner].aux;\n }\n\n /// @dev Set the auxiliary data for `owner` to `value`.\n /// Minting, transferring, burning the tokens of `owner` will not change the auxiliary data.\n /// Auxiliary data can be set for any address, even if it does not have any tokens.\n function _setAux(address owner, uint88 value) internal virtual {\n _getDN404Storage().addressData[owner].aux = value;\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* SKIP NFT FUNCTIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns true if minting and transferring ERC20s to `owner` will skip minting NFTs.\n /// Returns false otherwise.\n function getSkipNFT(address owner) public view virtual returns (bool) {\n AddressData storage d = _getDN404Storage().addressData[owner];\n if (_isZero(d.flags & _ADDRESS_DATA_INITIALIZED_FLAG)) return _hasCode(owner);\n return d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0;\n }\n\n /// @dev Sets the caller's skipNFT flag to `skipNFT`. Returns true.\n ///\n /// Emits a {SkipNFTSet} event.\n function setSkipNFT(bool skipNFT) public virtual returns (bool) {\n _setSkipNFT(msg.sender, skipNFT);\n return true;\n }\n\n /// @dev Internal function to set account `owner` skipNFT flag to `state`\n ///\n /// Initializes account `owner` AddressData if it is not currently initialized.\n ///\n /// Emits a {SkipNFTSet} event.\n function _setSkipNFT(address owner, bool state) internal virtual {\n AddressData storage d = _addressData(owner);\n if ((d.flags & _ADDRESS_DATA_SKIP_NFT_FLAG != 0) != state) {\n d.flags ^= _ADDRESS_DATA_SKIP_NFT_FLAG;\n }\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, iszero(iszero(state)))\n log2(0x00, 0x20, _SKIP_NFT_SET_EVENT_SIGNATURE, shr(96, shl(96, owner)))\n }\n }\n\n /// @dev Returns a storage data pointer for account `owner` AddressData\n ///\n /// Initializes account `owner` AddressData if it is not currently initialized.\n function _addressData(address owner) internal virtual returns (AddressData storage d) {\n d = _getDN404Storage().addressData[owner];\n unchecked {\n if (_isZero(d.flags & _ADDRESS_DATA_INITIALIZED_FLAG)) {\n uint256 skipNFT = _toUint(_hasCode(owner)) * _ADDRESS_DATA_SKIP_NFT_FLAG;\n d.flags = uint8(skipNFT | _ADDRESS_DATA_INITIALIZED_FLAG);\n }\n }\n }\n\n /// @dev Returns the `addressAlias` of account `to`.\n ///\n /// Assigns and registers the next alias if `to` alias was not previously registered.\n function _registerAndResolveAlias(AddressData storage toAddressData, address to)\n internal\n virtual\n returns (uint32 addressAlias)\n {\n DN404Storage storage $ = _getDN404Storage();\n addressAlias = toAddressData.addressAlias;\n if (_isZero(addressAlias)) {\n unchecked {\n addressAlias = ++$.numAliases;\n }\n toAddressData.addressAlias = addressAlias;\n $.aliasToAddress[addressAlias] = to;\n if (_isZero(addressAlias)) revert(); // Overflow.\n }\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* MIRROR OPERATIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns the address of the mirror NFT contract.\n function mirrorERC721() public view virtual returns (address) {\n return _getDN404Storage().mirrorERC721;\n }\n\n /// @dev Returns the total NFT supply.\n function _totalNFTSupply() internal view virtual returns (uint256) {\n return _getDN404Storage().totalNFTSupply;\n }\n\n /// @dev Returns `owner` NFT balance.\n function _balanceOfNFT(address owner) internal view virtual returns (uint256) {\n return _getDN404Storage().addressData[owner].ownedLength;\n }\n\n /// @dev Returns the owner of token `id`.\n /// Returns the zero address instead of reverting if the token does not exist.\n function _ownerAt(uint256 id) internal view virtual returns (address) {\n DN404Storage storage $ = _getDN404Storage();\n return $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];\n }\n\n /// @dev Returns the owner of token `id`.\n ///\n /// Requirements:\n /// - Token `id` must exist.\n function _ownerOf(uint256 id) internal view virtual returns (address) {\n if (!_exists(id)) revert TokenDoesNotExist();\n return _ownerAt(id);\n }\n\n /// @dev Returns whether `operator` is approved to manage the NFT tokens of `owner`.\n function _isApprovedForAll(address owner, address operator)\n internal\n view\n virtual\n returns (bool)\n {\n return !_isZero(_ref(_getDN404Storage().operatorApprovals, owner, operator).value);\n }\n\n /// @dev Returns if token `id` exists.\n function _exists(uint256 id) internal view virtual returns (bool) {\n return _ownerAt(id) != address(0);\n }\n\n /// @dev Returns the account approved to manage token `id`.\n ///\n /// Requirements:\n /// - Token `id` must exist.\n function _getApproved(uint256 id) internal view virtual returns (address) {\n if (!_exists(id)) revert TokenDoesNotExist();\n return _getDN404Storage().nftApprovals[id];\n }\n\n /// @dev Sets `spender` as the approved account to manage token `id`, using `msgSender`.\n ///\n /// Requirements:\n /// - `msgSender` must be the owner or an approved operator for the token owner.\n function _approveNFT(address spender, uint256 id, address msgSender)\n internal\n virtual\n returns (address owner)\n {\n DN404Storage storage $ = _getDN404Storage();\n\n owner = $.aliasToAddress[_get($.oo, _ownershipIndex(_restrictNFTId(id)))];\n\n if (msgSender != owner) {\n if (!_isApprovedForAll(owner, msgSender)) {\n revert ApprovalCallerNotOwnerNorApproved();\n }\n }\n\n $.nftApprovals[id] = spender;\n _set($.mayHaveNFTApproval, id, spender != address(0));\n }\n\n /// @dev Approve or remove the `operator` as an operator for `msgSender`,\n /// without authorization checks.\n function _setApprovalForAll(address operator, bool approved, address msgSender)\n internal\n virtual\n {\n _ref(_getDN404Storage().operatorApprovals, msgSender, operator).value = _toUint(approved);\n }\n\n /// @dev Returns the NFT IDs of `owner` in the range `[begin..end)` (exclusive of `end`).\n /// `begin` and `end` are indices in the owner's token ID array, not the entire token range.\n /// Optimized for smaller bytecode size, as this function is intended for off-chain calling.\n function _ownedIds(address owner, uint256 begin, uint256 end)\n internal\n view\n virtual\n returns (uint256[] memory ids)\n {\n DN404Storage storage $ = _getDN404Storage();\n Uint32Map storage owned = $.owned[owner];\n end = _min($.addressData[owner].ownedLength, end);\n /// @solidity memory-safe-assembly\n assembly {\n ids := mload(0x40)\n let i := begin\n for {} lt(i, end) { i := add(i, 1) } {\n let s := add(shl(96, owned.slot), shr(3, i)) // Storage slot.\n let id := and(0xffffffff, shr(shl(5, and(i, 7)), sload(s)))\n mstore(add(add(ids, 0x20), shl(5, sub(i, begin))), id) // Append to.\n }\n mstore(ids, sub(i, begin)) // Store the length.\n mstore(0x40, add(add(ids, 0x20), shl(5, sub(i, begin)))) // Allocate memory.\n }\n }\n\n /// @dev Fallback modifier to dispatch calls from the mirror NFT contract\n /// to internal functions in this contract.\n modifier dn404Fallback() virtual {\n DN404Storage storage $ = _getDN404Storage();\n\n uint256 fnSelector = _calldataload(0x00) >> 224;\n\n // `transferFromNFT(address,address,uint256,address)`.\n if (fnSelector == 0xe5eb36c8) {\n if (msg.sender != $.mirrorERC721) revert SenderNotMirror();\n _transferFromNFT(\n address(uint160(_calldataload(0x04))), // `from`.\n address(uint160(_calldataload(0x24))), // `to`.\n _calldataload(0x44), // `id`.\n address(uint160(_calldataload(0x64))) // `msgSender`.\n );\n _return(1);\n }\n // `setApprovalForAll(address,bool,address)`.\n if (fnSelector == 0x813500fc) {\n if (msg.sender != $.mirrorERC721) revert SenderNotMirror();\n _setApprovalForAll(\n address(uint160(_calldataload(0x04))), // `spender`.\n _calldataload(0x24) != 0, // `status`.\n address(uint160(_calldataload(0x44))) // `msgSender`.\n );\n _return(1);\n }\n // `isApprovedForAll(address,address)`.\n if (fnSelector == 0xe985e9c5) {\n bool result = _isApprovedForAll(\n address(uint160(_calldataload(0x04))), // `owner`.\n address(uint160(_calldataload(0x24))) // `operator`.\n );\n _return(_toUint(result));\n }\n // `ownerOf(uint256)`.\n if (fnSelector == 0x6352211e) {\n _return(uint160(_ownerOf(_calldataload(0x04))));\n }\n // `ownerAt(uint256)`.\n if (fnSelector == 0x24359879) {\n _return(uint160(_ownerAt(_calldataload(0x04))));\n }\n // `approveNFT(address,uint256,address)`.\n if (fnSelector == 0xd10b6e0c) {\n if (msg.sender != $.mirrorERC721) revert SenderNotMirror();\n address owner = _approveNFT(\n address(uint160(_calldataload(0x04))), // `spender`.\n _calldataload(0x24), // `id`.\n address(uint160(_calldataload(0x44))) // `msgSender`.\n );\n _return(uint160(owner));\n }\n // `getApproved(uint256)`.\n if (fnSelector == 0x081812fc) {\n _return(uint160(_getApproved(_calldataload(0x04))));\n }\n // `balanceOfNFT(address)`.\n if (fnSelector == 0xf5b100ea) {\n _return(_balanceOfNFT(address(uint160(_calldataload(0x04)))));\n }\n // `totalNFTSupply()`.\n if (fnSelector == 0xe2c79281) {\n _return(_totalNFTSupply());\n }\n // `tokenURI(uint256)`.\n if (fnSelector == 0xc87b56dd) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x40, add(mload(0x40), 0x20))\n }\n string memory uri = _tokenURI(_calldataload(0x04));\n /// @solidity memory-safe-assembly\n assembly {\n // Memory safe, as we've advanced the free memory pointer by a word.\n let o := sub(uri, 0x20)\n mstore(o, 0x20) // Store the offset of `uri`.\n return(o, add(0x60, mload(uri)))\n }\n }\n // `implementsDN404()`.\n if (fnSelector == 0xb7a94eb8) {\n _return(1);\n }\n _;\n }\n\n /// @dev Fallback function for calls from mirror NFT contract.\n /// Override this if you need to implement your custom\n /// fallback with utilities like Solady's `LibZip.cdFallback()`.\n /// And always remember to always wrap the fallback with `dn404Fallback`.\n fallback() external payable virtual dn404Fallback {\n revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.\n }\n\n /// @dev This is to silence the compiler warning.\n /// Override and remove the revert if you want your contract to receive ETH via receive.\n receive() external payable virtual {\n if (msg.value != 0) revert();\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* INTERNAL / PRIVATE HELPERS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns `(i - 1) << 1`.\n function _ownershipIndex(uint256 i) internal pure returns (uint256) {\n unchecked {\n return (i - 1) << 1; // Minus 1 as token IDs start from 1.\n }\n }\n\n /// @dev Returns `((i - 1) << 1) + 1`.\n function _ownedIndex(uint256 i) internal pure returns (uint256) {\n unchecked {\n return ((i - 1) << 1) + 1; // Minus 1 as token IDs start from 1.\n }\n }\n\n /// @dev Returns the uint32 value at `index` in `map`.\n function _get(Uint32Map storage map, uint256 index) internal view returns (uint32 result) {\n /// @solidity memory-safe-assembly\n assembly {\n let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.\n result := and(0xffffffff, shr(shl(5, and(index, 7)), sload(s)))\n }\n }\n\n /// @dev Updates the uint32 value at `index` in `map`.\n function _set(Uint32Map storage map, uint256 index, uint32 value) internal {\n /// @solidity memory-safe-assembly\n assembly {\n let s := add(shl(96, map.slot), shr(3, index)) // Storage slot.\n let o := shl(5, and(index, 7)) // Storage slot offset (bits).\n let v := sload(s) // Storage slot value.\n sstore(s, xor(v, shl(o, and(0xffffffff, xor(value, shr(o, v))))))\n }\n }\n\n /// @dev Sets the owner alias and the owned index together.\n function _setOwnerAliasAndOwnedIndex(\n Uint32Map storage map,\n uint256 id,\n uint32 ownership,\n uint32 ownedIndex\n ) internal {\n /// @solidity memory-safe-assembly\n assembly {\n let i := sub(id, 1) // Index of the uint64 combined value.\n let s := add(shl(96, map.slot), shr(2, i)) // Storage slot.\n let v := sload(s) // Storage slot value.\n let o := shl(6, and(i, 3)) // Storage slot offset (bits).\n let combined := or(shl(32, ownedIndex), and(0xffffffff, ownership))\n sstore(s, xor(v, shl(o, and(0xffffffffffffffff, xor(shr(o, v), combined)))))\n }\n }\n\n /// @dev Returns the boolean value of the bit at `index` in `bitmap`.\n function _get(Bitmap storage bitmap, uint256 index) internal view returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.\n result := and(1, shr(and(0xff, index), sload(s)))\n }\n }\n\n /// @dev Updates the bit at `index` in `bitmap` to `value`.\n function _set(Bitmap storage bitmap, uint256 index, bool value) internal {\n /// @solidity memory-safe-assembly\n assembly {\n let s := add(shl(96, bitmap.slot), shr(8, index)) // Storage slot.\n let o := and(0xff, index) // Storage slot offset (bits).\n sstore(s, or(and(sload(s), not(shl(o, 1))), shl(o, iszero(iszero(value)))))\n }\n }\n\n /// @dev Returns the index of the least significant unset bit in `[begin..upTo]`.\n /// If no set bit is found, returns `type(uint256).max`.\n function _findFirstUnset(Bitmap storage bitmap, uint256 begin, uint256 upTo)\n internal\n view\n returns (uint256 unsetBitIndex)\n {\n /// @solidity memory-safe-assembly\n assembly {\n unsetBitIndex := not(0) // Initialize to `type(uint256).max`.\n let s := shl(96, bitmap.slot) // Storage offset of the bitmap.\n let bucket := add(s, shr(8, begin))\n let negBits := shl(and(0xff, begin), shr(and(0xff, begin), not(sload(bucket))))\n if iszero(negBits) {\n let lastBucket := add(s, shr(8, upTo))\n for {} 1 {} {\n bucket := add(bucket, 1)\n negBits := not(sload(bucket))\n if or(negBits, gt(bucket, lastBucket)) { break }\n }\n if gt(bucket, lastBucket) {\n negBits := shr(and(0xff, not(upTo)), shl(and(0xff, not(upTo)), negBits))\n }\n }\n if negBits {\n // Find-first-set routine.\n // From: https://github.com/vectorized/solady/blob/main/src/utils/LibBit.sol\n let b := and(negBits, add(not(negBits), 1)) // Isolate the least significant bit.\n // For the upper 3 bits of the result, use a De Bruijn-like lookup.\n // Credit to adhusson: https://blog.adhusson.com/cheap-find-first-set-evm/\n // forgefmt: disable-next-item\n let r := shl(5, shr(252, shl(shl(2, shr(250, mul(b,\n 0x2aaaaaaaba69a69a6db6db6db2cb2cb2ce739ce73def7bdeffffffff))),\n 0x1412563212c14164235266736f7425221143267a45243675267677)))\n // For the lower 5 bits of the result, use a De Bruijn lookup.\n // forgefmt: disable-next-item\n r := or(r, byte(and(div(0xd76453e0, shr(r, b)), 0x1f),\n 0x001f0d1e100c1d070f090b19131c1706010e11080a1a141802121b1503160405))\n r := or(shl(8, sub(bucket, s)), r)\n unsetBitIndex := or(r, sub(0, or(gt(r, upTo), lt(r, begin))))\n }\n }\n }\n\n /// @dev Returns a storage reference to the value at (`a0`, `a1`) in `map`.\n function _ref(AddressPairToUint256RefMap storage map, address a0, address a1)\n internal\n pure\n returns (Uint256Ref storage ref)\n {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x28, a1)\n mstore(0x14, a0)\n mstore(0x00, map.slot)\n ref.slot := keccak256(0x00, 0x48)\n // Clear the part of the free memory pointer that was overwritten.\n mstore(0x28, 0x00)\n }\n }\n\n /// @dev Wraps the NFT ID.\n function _wrapNFTId(uint256 id, uint256 maxId) internal pure returns (uint256 result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := or(mul(iszero(gt(id, maxId)), id), gt(id, maxId))\n }\n }\n\n /// @dev Returns `id > type(uint32).max ? 0 : id`.\n function _restrictNFTId(uint256 id) internal pure returns (uint256 result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := mul(id, lt(id, 0x100000000))\n }\n }\n\n /// @dev Returns whether `amount` is a valid `totalSupply`.\n function _totalSupplyOverflows(uint256 amount) internal view returns (bool result) {\n uint256 unit = _unit();\n /// @solidity memory-safe-assembly\n assembly {\n result := iszero(iszero(or(shr(96, amount), lt(0xfffffffe, div(amount, unit)))))\n }\n }\n\n /// @dev Returns `max(0, x - y)`.\n function _zeroFloorSub(uint256 x, uint256 y) internal pure returns (uint256 z) {\n /// @solidity memory-safe-assembly\n assembly {\n z := mul(gt(x, y), sub(x, y))\n }\n }\n\n /// @dev Returns `x < y ? x : y`.\n function _min(uint256 x, uint256 y) internal pure returns (uint256 z) {\n /// @solidity memory-safe-assembly\n assembly {\n z := xor(x, mul(xor(x, y), lt(y, x)))\n }\n }\n\n /// @dev Returns `b ? 1 : 0`.\n function _toUint(bool b) internal pure returns (uint256 result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := iszero(iszero(b))\n }\n }\n\n /// @dev Returns `b == 0`. This is because solc is sometimes dumb.\n function _isZero(uint256 x) internal pure returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := iszero(x)\n }\n }\n\n /// @dev Struct containing direct transfer log data for {Transfer} events to be\n /// emitted by the mirror NFT contract.\n struct _DNDirectLogs {\n uint256 offset;\n uint256[] logs;\n }\n\n /// @dev Initiates memory allocation for direct logs with `n` log items.\n function _directLogsMalloc(uint256 n, address from, address to)\n private\n pure\n returns (_DNDirectLogs memory p)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n mstore(m, 0x144027d3) // `logDirectTransfer(address,address,uint256[])`.\n mstore(add(m, 0x20), shr(96, shl(96, from)))\n mstore(add(m, 0x40), shr(96, shl(96, to)))\n mstore(add(m, 0x60), 0x60) // Offset of `logs` in the calldata to send.\n // Skip 4 words: `fnSelector`, `from`, `to`, `calldataLogsOffset`.\n let logs := add(0x80, m)\n mstore(logs, n) // Store the length.\n let offset := add(0x20, logs) // Skip the word for `p.logs.length`.\n mstore(0x40, add(offset, shl(5, n))) // Allocate memory.\n mstore(add(0x20, p), logs) // Set `p.logs`.\n mstore(p, offset) // Set `p.offset`.\n }\n }\n\n /// @dev Adds a direct log item to `p` with token `id`.\n function _directLogsAppend(_DNDirectLogs memory p, uint256 id) private pure {\n /// @solidity memory-safe-assembly\n assembly {\n let offset := mload(p)\n mstore(offset, id)\n mstore(p, add(offset, 0x20))\n }\n }\n\n /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.\n function _directLogsSend(_DNDirectLogs memory p, address mirror) private {\n /// @solidity memory-safe-assembly\n assembly {\n let logs := mload(add(p, 0x20))\n let n := add(0x84, shl(5, mload(logs))) // Length of calldata to send.\n let o := sub(logs, 0x80) // Start of calldata to send.\n if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {\n revert(o, 0x00)\n }\n }\n }\n\n /// @dev Struct containing packed log data for {Transfer} events to be\n /// emitted by the mirror NFT contract.\n struct _DNPackedLogs {\n uint256 offset;\n uint256 addressAndBit;\n uint256[] logs;\n }\n\n /// @dev Initiates memory allocation for packed logs with `n` log items.\n function _packedLogsMalloc(uint256 n) private pure returns (_DNPackedLogs memory p) {\n /// @solidity memory-safe-assembly\n assembly {\n // Note that `p` implicitly allocates and advances the free memory pointer by\n // 3 words, which we can safely mutate in `_packedLogsSend`.\n let logs := mload(0x40)\n mstore(logs, n) // Store the length.\n let offset := add(0x20, logs) // Skip the word for `p.logs.length`.\n mstore(0x40, add(offset, shl(5, n))) // Allocate memory.\n mstore(add(0x40, p), logs) // Set `p.logs`.\n mstore(p, offset) // Set `p.offset`.\n }\n }\n\n /// @dev Set the current address and the burn bit.\n function _packedLogsSet(_DNPackedLogs memory p, address a, uint256 burnBit) private pure {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(add(p, 0x20), or(shl(96, a), burnBit)) // Set `p.addressAndBit`.\n }\n }\n\n /// @dev Adds a packed log item to `p` with token `id`.\n function _packedLogsAppend(_DNPackedLogs memory p, uint256 id) private pure {\n /// @solidity memory-safe-assembly\n assembly {\n let offset := mload(p)\n mstore(offset, or(mload(add(p, 0x20)), shl(8, id))) // `p.addressAndBit | (id << 8)`.\n mstore(p, add(offset, 0x20))\n }\n }\n\n /// @dev Calls the `mirror` NFT contract to emit {Transfer} events for packed logs `p`.\n function _packedLogsSend(_DNPackedLogs memory p, address mirror) private {\n /// @solidity memory-safe-assembly\n assembly {\n let logs := mload(add(p, 0x40))\n let o := sub(logs, 0x40) // Start of calldata to send.\n mstore(o, 0x263c69d6) // `logTransfer(uint256[])`.\n mstore(add(o, 0x20), 0x20) // Offset of `logs` in the calldata to send.\n let n := add(0x44, shl(5, mload(logs))) // Length of calldata to send.\n if iszero(and(eq(mload(o), 1), call(gas(), mirror, 0, add(o, 0x1c), n, o, 0x20))) {\n revert(o, 0x00)\n }\n }\n }\n\n /// @dev Struct of temporary variables for transfers.\n struct _DNTransferTemps {\n uint256 numNFTBurns;\n uint256 numNFTMints;\n uint256 fromOwnedLength;\n uint256 toOwnedLength;\n uint256 totalNFTSupply;\n uint256 fromEnd;\n uint256 toEnd;\n uint32 toAlias;\n uint256 nextTokenId;\n uint32 burnedPoolTail;\n }\n\n /// @dev Struct of temporary variables for mints.\n struct _DNMintTemps {\n uint256 nextTokenId;\n uint32 burnedPoolTail;\n uint256 toEnd;\n uint32 toAlias;\n }\n\n /// @dev Returns if `a` has bytecode of non-zero length.\n function _hasCode(address a) private view returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := extcodesize(a) // Can handle dirty upper bits.\n }\n }\n\n /// @dev Returns the calldata value at `offset`.\n function _calldataload(uint256 offset) private pure returns (uint256 value) {\n /// @solidity memory-safe-assembly\n assembly {\n value := calldataload(offset)\n }\n }\n\n /// @dev Executes a return opcode to return `x` and end the current call frame.\n function _return(uint256 x) private pure {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, x)\n return(0x00, 0x20)\n }\n }\n}\n" + }, + "dn404/src/DN404Mirror.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @title DN404Mirror\n/// @notice DN404Mirror provides an interface for interacting with the\n/// NFT tokens in a DN404 implementation.\n///\n/// @author vectorized.eth (@optimizoor)\n/// @author Quit (@0xQuit)\n/// @author Michael Amadi (@AmadiMichaels)\n/// @author cygaar (@0xCygaar)\n/// @author Thomas (@0xjustadev)\n/// @author Harrison (@PopPunkOnChain)\n///\n/// @dev Note:\n/// - The ERC721 data is stored in the base DN404 contract.\ncontract DN404Mirror {\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* EVENTS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Emitted when token `id` is transferred from `from` to `to`.\n event Transfer(address indexed from, address indexed to, uint256 indexed id);\n\n /// @dev Emitted when `owner` enables `account` to manage the `id` token.\n event Approval(address indexed owner, address indexed account, uint256 indexed id);\n\n /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.\n event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);\n\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\n /// This is for marketplace signaling purposes. This contract has a `pullOwner()`\n /// function that will sync the owner from the base contract.\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\n\n /// @dev `keccak256(bytes(\"Transfer(address,address,uint256)\"))`.\n uint256 private constant _TRANSFER_EVENT_SIGNATURE =\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\n\n /// @dev `keccak256(bytes(\"Approval(address,address,uint256)\"))`.\n uint256 private constant _APPROVAL_EVENT_SIGNATURE =\n 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925;\n\n /// @dev `keccak256(bytes(\"ApprovalForAll(address,address,bool)\"))`.\n uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =\n 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* CUSTOM ERRORS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Thrown when a call for an NFT function did not originate\n /// from the base DN404 contract.\n error SenderNotBase();\n\n /// @dev Thrown when a call for an NFT function did not originate from the deployer.\n error SenderNotDeployer();\n\n /// @dev Thrown when transferring an NFT to a contract address that\n /// does not implement ERC721Receiver.\n error TransferToNonERC721ReceiverImplementer();\n\n /// @dev Thrown when linking to the DN404 base contract and the\n /// DN404 supportsInterface check fails or the call reverts.\n error CannotLink();\n\n /// @dev Thrown when a linkMirrorContract call is received and the\n /// NFT mirror contract has already been linked to a DN404 base contract.\n error AlreadyLinked();\n\n /// @dev Thrown when retrieving the base DN404 address when a link has not\n /// been established.\n error NotLinked();\n\n /// @dev The function selector is not recognized.\n error FnSelectorNotRecognized();\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* STORAGE */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Struct contain the NFT mirror contract storage.\n struct DN404NFTStorage {\n // Address of the ERC20 base contract.\n address baseERC20;\n // The deployer, if provided. If non-zero, the initialization of the\n // ERC20 <-> ERC721 link can only be done be the deployer via the ERC20 base contract.\n address deployer;\n // The owner of the ERC20 base contract. For marketplace signaling.\n address owner;\n }\n\n /// @dev Returns a storage pointer for DN404NFTStorage.\n function _getDN404NFTStorage() internal pure virtual returns (DN404NFTStorage storage $) {\n /// @solidity memory-safe-assembly\n assembly {\n // `uint72(bytes9(keccak256(\"DN404_MIRROR_STORAGE\")))`.\n $.slot := 0x3602298b8c10b01230 // Truncate to 9 bytes to reduce bytecode size.\n }\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* CONSTRUCTOR */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n constructor(address deployer) {\n // For non-proxies, we will store the deployer so that only the deployer can\n // link the base contract.\n _getDN404NFTStorage().deployer = deployer;\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* ERC721 OPERATIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns the token collection name from the base DN404 contract.\n function name() public view virtual returns (string memory) {\n return _readString(0x06fdde03, 0); // `name()`.\n }\n\n /// @dev Returns the token collection symbol from the base DN404 contract.\n function symbol() public view virtual returns (string memory) {\n return _readString(0x95d89b41, 0); // `symbol()`.\n }\n\n /// @dev Returns the Uniform Resource Identifier (URI) for token `id` from\n /// the base DN404 contract.\n function tokenURI(uint256 id) public view virtual returns (string memory) {\n return _readString(0xc87b56dd, id); // `tokenURI(uint256)`.\n }\n\n /// @dev Returns the total NFT supply from the base DN404 contract.\n function totalSupply() public view virtual returns (uint256) {\n return _readWord(0xe2c79281, 0, 0); // `totalNFTSupply()`.\n }\n\n /// @dev Returns the number of NFT tokens owned by `nftOwner` from the base DN404 contract.\n ///\n /// Requirements:\n /// - `nftOwner` must not be the zero address.\n function balanceOf(address nftOwner) public view virtual returns (uint256) {\n return _readWord(0xf5b100ea, uint160(nftOwner), 0); // `balanceOfNFT(address)`.\n }\n\n /// @dev Returns the owner of token `id` from the base DN404 contract.\n ///\n /// Requirements:\n /// - Token `id` must exist.\n function ownerOf(uint256 id) public view virtual returns (address) {\n return address(uint160(_readWord(0x6352211e, id, 0))); // `ownerOf(uint256)`.\n }\n\n /// @dev Returns the owner of token `id` from the base DN404 contract.\n /// Returns `address(0)` instead of reverting if the token does not exist.\n function ownerAt(uint256 id) public view virtual returns (address) {\n return address(uint160(_readWord(0x24359879, id, 0))); // `ownerAt(uint256)`.\n }\n\n /// @dev Sets `spender` as the approved account to manage token `id` in\n /// the base DN404 contract.\n ///\n /// Requirements:\n /// - Token `id` must exist.\n /// - The caller must be the owner of the token,\n /// or an approved operator for the token owner.\n ///\n /// Emits an {Approval} event.\n function approve(address spender, uint256 id) public payable virtual {\n address base = baseERC20();\n /// @solidity memory-safe-assembly\n assembly {\n spender := shr(96, shl(96, spender))\n let m := mload(0x40)\n mstore(0x00, 0xd10b6e0c) // `approveNFT(address,uint256,address)`.\n mstore(0x20, spender)\n mstore(0x40, id)\n mstore(0x60, caller())\n if iszero(\n and( // Arguments of `and` are evaluated last to first.\n gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.\n call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)\n )\n ) {\n returndatacopy(m, 0x00, returndatasize())\n revert(m, returndatasize())\n }\n mstore(0x40, m) // Restore the free memory pointer.\n mstore(0x60, 0) // Restore the zero pointer.\n // Emit the {Approval} event.\n log4(codesize(), 0x00, _APPROVAL_EVENT_SIGNATURE, shr(96, mload(0x0c)), spender, id)\n }\n }\n\n /// @dev Returns the account approved to manage token `id` from\n /// the base DN404 contract.\n ///\n /// Requirements:\n /// - Token `id` must exist.\n function getApproved(uint256 id) public view virtual returns (address) {\n return address(uint160(_readWord(0x081812fc, id, 0))); // `getApproved(uint256)`.\n }\n\n /// @dev Sets whether `operator` is approved to manage the tokens of the caller in\n /// the base DN404 contract.\n ///\n /// Emits an {ApprovalForAll} event.\n function setApprovalForAll(address operator, bool approved) public virtual {\n address base = baseERC20();\n /// @solidity memory-safe-assembly\n assembly {\n operator := shr(96, shl(96, operator))\n let m := mload(0x40)\n mstore(0x00, 0x813500fc) // `setApprovalForAll(address,bool,address)`.\n mstore(0x20, operator)\n mstore(0x40, iszero(iszero(approved)))\n mstore(0x60, caller())\n if iszero(\n and( // Arguments of `and` are evaluated last to first.\n eq(mload(0x00), 1), // The call must return 1.\n call(gas(), base, callvalue(), 0x1c, 0x64, 0x00, 0x20)\n )\n ) {\n returndatacopy(m, 0x00, returndatasize())\n revert(m, returndatasize())\n }\n // Emit the {ApprovalForAll} event.\n // The `approved` value is already at 0x40.\n log3(0x40, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), operator)\n mstore(0x40, m) // Restore the free memory pointer.\n mstore(0x60, 0) // Restore the zero pointer.\n }\n }\n\n /// @dev Returns whether `operator` is approved to manage the tokens of `nftOwner` from\n /// the base DN404 contract.\n function isApprovedForAll(address nftOwner, address operator)\n public\n view\n virtual\n returns (bool)\n {\n // `isApprovedForAll(address,address)`.\n return _readWord(0xe985e9c5, uint160(nftOwner), uint160(operator)) != 0;\n }\n\n /// @dev Transfers token `id` from `from` to `to`.\n ///\n /// Requirements:\n ///\n /// - Token `id` must exist.\n /// - `from` must be the owner of the token.\n /// - `to` cannot be the zero address.\n /// - The caller must be the owner of the token, or be approved to manage the token.\n ///\n /// Emits a {Transfer} event.\n function transferFrom(address from, address to, uint256 id) public payable virtual {\n address base = baseERC20();\n /// @solidity memory-safe-assembly\n assembly {\n from := shr(96, shl(96, from))\n to := shr(96, shl(96, to))\n let m := mload(0x40)\n mstore(m, 0xe5eb36c8) // `transferFromNFT(address,address,uint256,address)`.\n mstore(add(m, 0x20), from)\n mstore(add(m, 0x40), to)\n mstore(add(m, 0x60), id)\n mstore(add(m, 0x80), caller())\n if iszero(\n and( // Arguments of `and` are evaluated last to first.\n eq(mload(m), 1), // The call must return 1.\n call(gas(), base, callvalue(), add(m, 0x1c), 0x84, m, 0x20)\n )\n ) {\n returndatacopy(m, 0x00, returndatasize())\n revert(m, returndatasize())\n }\n // Emit the {Transfer} event.\n log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, id)\n }\n }\n\n /// @dev Equivalent to `safeTransferFrom(from, to, id, \"\")`.\n function safeTransferFrom(address from, address to, uint256 id) public payable virtual {\n transferFrom(from, to, id);\n if (_hasCode(to)) _checkOnERC721Received(from, to, id, \"\");\n }\n\n /// @dev Transfers token `id` from `from` to `to`.\n ///\n /// Requirements:\n ///\n /// - Token `id` must exist.\n /// - `from` must be the owner of the token.\n /// - `to` cannot be the zero address.\n /// - The caller must be the owner of the token, or be approved to manage the token.\n /// - If `to` refers to a smart contract, it must implement\n /// {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n ///\n /// Emits a {Transfer} event.\n function safeTransferFrom(address from, address to, uint256 id, bytes calldata data)\n public\n payable\n virtual\n {\n transferFrom(from, to, id);\n if (_hasCode(to)) _checkOnERC721Received(from, to, id, data);\n }\n\n /// @dev Returns true if this contract implements the interface defined by `interfaceId`.\n /// See: https://eips.ethereum.org/EIPS/eip-165\n /// This function call must use less than 30000 gas.\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n let s := shr(224, interfaceId)\n // ERC165: 0x01ffc9a7, ERC721: 0x80ac58cd, ERC721Metadata: 0x5b5e139f.\n result := or(or(eq(s, 0x01ffc9a7), eq(s, 0x80ac58cd)), eq(s, 0x5b5e139f))\n }\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* OWNER SYNCING OPERATIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns the `owner` of the contract, for marketplace signaling purposes.\n function owner() public view virtual returns (address) {\n return _getDN404NFTStorage().owner;\n }\n\n /// @dev Permissionless function to pull the owner from the base DN404 contract\n /// if it implements ownable, for marketplace signaling purposes.\n function pullOwner() public virtual returns (bool) {\n address newOwner;\n address base = baseERC20();\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, 0x8da5cb5b) // `owner()`.\n let success := staticcall(gas(), base, 0x1c, 0x04, 0x00, 0x20)\n newOwner := mul(shr(96, mload(0x0c)), and(gt(returndatasize(), 0x1f), success))\n }\n DN404NFTStorage storage $ = _getDN404NFTStorage();\n address oldOwner = $.owner;\n if (oldOwner != newOwner) {\n $.owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n return true;\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* MIRROR OPERATIONS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Returns the address of the base DN404 contract.\n function baseERC20() public view virtual returns (address base) {\n base = _getDN404NFTStorage().baseERC20;\n if (base == address(0)) revert NotLinked();\n }\n\n /// @dev Fallback modifier to execute calls from the base DN404 contract.\n modifier dn404NFTFallback() virtual {\n DN404NFTStorage storage $ = _getDN404NFTStorage();\n\n uint256 fnSelector = _calldataload(0x00) >> 224;\n\n // `logTransfer(uint256[])`.\n if (fnSelector == 0x263c69d6) {\n if (msg.sender != $.baseERC20) revert SenderNotBase();\n /// @solidity memory-safe-assembly\n assembly {\n let o := add(0x24, calldataload(0x04)) // Packed logs offset.\n let end := add(o, shl(5, calldataload(sub(o, 0x20))))\n for {} iszero(eq(o, end)) { o := add(0x20, o) } {\n let d := calldataload(o) // Entry in the packed logs.\n let a := shr(96, d) // The address.\n let b := and(1, d) // Whether it is a burn.\n log4(\n codesize(),\n 0x00,\n _TRANSFER_EVENT_SIGNATURE,\n mul(a, b), // `from`.\n mul(a, iszero(b)), // `to`.\n shr(168, shl(160, d)) // `id`.\n )\n }\n mstore(0x00, 0x01)\n return(0x00, 0x20)\n }\n }\n // `logDirectTransfer(address,address,uint256[])`.\n if (fnSelector == 0x144027d3) {\n if (msg.sender != $.baseERC20) revert SenderNotBase();\n /// @solidity memory-safe-assembly\n assembly {\n let from := calldataload(0x04)\n let to := calldataload(0x24)\n let o := add(0x24, calldataload(0x44)) // Direct logs offset.\n let end := add(o, shl(5, calldataload(sub(o, 0x20))))\n for {} iszero(eq(o, end)) { o := add(0x20, o) } {\n log4(codesize(), 0x00, _TRANSFER_EVENT_SIGNATURE, from, to, calldataload(o))\n }\n mstore(0x00, 0x01)\n return(0x00, 0x20)\n }\n }\n // `linkMirrorContract(address)`.\n if (fnSelector == 0x0f4599e5) {\n if ($.deployer != address(0)) {\n if (address(uint160(_calldataload(0x04))) != $.deployer) {\n revert SenderNotDeployer();\n }\n }\n if ($.baseERC20 != address(0)) revert AlreadyLinked();\n $.baseERC20 = msg.sender;\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, 0x01)\n return(0x00, 0x20)\n }\n }\n _;\n }\n\n /// @dev Fallback function for calls from base DN404 contract.\n /// Override this if you need to implement your custom\n /// fallback with utilities like Solady's `LibZip.cdFallback()`.\n /// And always remember to always wrap the fallback with `dn404NFTFallback`.\n fallback() external payable virtual dn404NFTFallback {\n revert FnSelectorNotRecognized(); // Not mandatory. Just for quality of life.\n }\n\n /// @dev This is to silence the compiler warning.\n /// Override and remove the revert if you want your contract to receive ETH via receive.\n receive() external payable virtual {\n if (msg.value != 0) revert();\n }\n\n /*«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-«-*/\n /* PRIVATE HELPERS */\n /*-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»-»*/\n\n /// @dev Helper to read a string from the base DN404 contract.\n function _readString(uint256 fnSelector, uint256 arg0)\n private\n view\n returns (string memory result)\n {\n address base = baseERC20();\n /// @solidity memory-safe-assembly\n assembly {\n result := mload(0x40)\n mstore(0x00, fnSelector)\n mstore(0x20, arg0)\n if iszero(staticcall(gas(), base, 0x1c, 0x24, 0x00, 0x00)) {\n returndatacopy(result, 0x00, returndatasize())\n revert(result, returndatasize())\n }\n returndatacopy(0x00, 0x00, 0x20) // Copy the offset of the string in returndata.\n returndatacopy(result, mload(0x00), 0x20) // Copy the length of the string.\n returndatacopy(add(result, 0x20), add(mload(0x00), 0x20), mload(result)) // Copy the string.\n let end := add(add(result, 0x20), mload(result))\n mstore(end, 0) // Zeroize the word after the string.\n mstore(0x40, add(end, 0x20)) // Allocate memory.\n }\n }\n\n /// @dev Helper to read a word from the base DN404 contract.\n function _readWord(uint256 fnSelector, uint256 arg0, uint256 arg1)\n private\n view\n returns (uint256 result)\n {\n address base = baseERC20();\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n mstore(0x00, fnSelector)\n mstore(0x20, arg0)\n mstore(0x40, arg1)\n if iszero(\n and( // Arguments of `and` are evaluated last to first.\n gt(returndatasize(), 0x1f), // The call must return at least 32 bytes.\n staticcall(gas(), base, 0x1c, 0x44, 0x00, 0x20)\n )\n ) {\n returndatacopy(m, 0x00, returndatasize())\n revert(m, returndatasize())\n }\n mstore(0x40, m) // Restore the free memory pointer.\n result := mload(0x00)\n }\n }\n\n /// @dev Returns the calldata value at `offset`.\n function _calldataload(uint256 offset) private pure returns (uint256 value) {\n /// @solidity memory-safe-assembly\n assembly {\n value := calldataload(offset)\n }\n }\n\n /// @dev Returns if `a` has bytecode of non-zero length.\n function _hasCode(address a) private view returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := extcodesize(a) // Can handle dirty upper bits.\n }\n }\n\n /// @dev Perform a call to invoke {IERC721Receiver-onERC721Received} on `to`.\n /// Reverts if the target does not support the function correctly.\n function _checkOnERC721Received(address from, address to, uint256 id, bytes memory data)\n private\n {\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the calldata.\n let m := mload(0x40)\n let onERC721ReceivedSelector := 0x150b7a02\n mstore(m, onERC721ReceivedSelector)\n mstore(add(m, 0x20), caller()) // The `operator`, which is always `msg.sender`.\n mstore(add(m, 0x40), shr(96, shl(96, from)))\n mstore(add(m, 0x60), id)\n mstore(add(m, 0x80), 0x80)\n let n := mload(data)\n mstore(add(m, 0xa0), n)\n if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xc0), n)) }\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), add(n, 0xa4), m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(m, 0x00, returndatasize())\n revert(m, returndatasize())\n }\n }\n // Load the returndata and compare it.\n if iszero(eq(mload(m), shl(224, onERC721ReceivedSelector))) {\n mstore(0x00, 0xd1a57ed6) // `TransferToNonERC721ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n}\n" + }, + "solady/src/auth/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple single owner authorization mixin.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)\n///\n/// @dev Note:\n/// This implementation does NOT auto-initialize the owner to `msg.sender`.\n/// You MUST call the `_initializeOwner` in the constructor / initializer.\n///\n/// While the ownable portion follows\n/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,\n/// the nomenclature for the 2-step ownership handover may be unique to this codebase.\nabstract contract Ownable {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The caller is not authorized to call the function.\n error Unauthorized();\n\n /// @dev The `newOwner` cannot be the zero address.\n error NewOwnerIsZeroAddress();\n\n /// @dev The `pendingOwner` does not have a valid handover request.\n error NoHandoverRequest();\n\n /// @dev Cannot double-initialize.\n error AlreadyInitialized();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EVENTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\n /// This event is intentionally kept the same as OpenZeppelin's Ownable to be\n /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),\n /// despite it not being as lightweight as a single argument event.\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\n\n /// @dev An ownership handover to `pendingOwner` has been requested.\n event OwnershipHandoverRequested(address indexed pendingOwner);\n\n /// @dev The ownership handover to `pendingOwner` has been canceled.\n event OwnershipHandoverCanceled(address indexed pendingOwner);\n\n /// @dev `keccak256(bytes(\"OwnershipTransferred(address,address)\"))`.\n uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =\n 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverRequested(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =\n 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverCanceled(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =\n 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The owner slot is given by:\n /// `bytes32(~uint256(uint32(bytes4(keccak256(\"_OWNER_SLOT_NOT\")))))`.\n /// It is intentionally chosen to be a high value\n /// to avoid collision with lower slots.\n /// The choice of manual storage layout is to enable compatibility\n /// with both regular and upgradeable contracts.\n bytes32 internal constant _OWNER_SLOT =\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927;\n\n /// The ownership handover slot of `newOwner` is given by:\n /// ```\n /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))\n /// let handoverSlot := keccak256(0x00, 0x20)\n /// ```\n /// It stores the expiry timestamp of the two-step ownership handover.\n uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Override to return true to make `_initializeOwner` prevent double-initialization.\n function _guardInitializeOwner() internal pure virtual returns (bool guard) {}\n\n /// @dev Initializes the owner directly without authorization guard.\n /// This function must be called upon initialization,\n /// regardless of whether the contract is upgradeable or not.\n /// This is to enable generalization to both regular and upgradeable contracts,\n /// and to save gas in case the initial owner is not the caller.\n /// For performance reasons, this function will not check if there\n /// is an existing owner.\n function _initializeOwner(address newOwner) internal virtual {\n if (_guardInitializeOwner()) {\n /// @solidity memory-safe-assembly\n assembly {\n let ownerSlot := _OWNER_SLOT\n if sload(ownerSlot) {\n mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`.\n revert(0x1c, 0x04)\n }\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Store the new value.\n sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\n }\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Store the new value.\n sstore(_OWNER_SLOT, newOwner)\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\n }\n }\n }\n\n /// @dev Sets the owner directly without authorization guard.\n function _setOwner(address newOwner) internal virtual {\n if (_guardInitializeOwner()) {\n /// @solidity memory-safe-assembly\n assembly {\n let ownerSlot := _OWNER_SLOT\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\n // Store the new value.\n sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner))))\n }\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n let ownerSlot := _OWNER_SLOT\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\n // Store the new value.\n sstore(ownerSlot, newOwner)\n }\n }\n }\n\n /// @dev Throws if the sender is not the owner.\n function _checkOwner() internal view virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // If the caller is not the stored owner, revert.\n if iszero(eq(caller(), sload(_OWNER_SLOT))) {\n mstore(0x00, 0x82b42900) // `Unauthorized()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Returns how long a two-step ownership handover is valid for in seconds.\n /// Override to return a different value if needed.\n /// Made internal to conserve bytecode. Wrap it in a public function if needed.\n function _ownershipHandoverValidFor() internal view virtual returns (uint64) {\n return 48 * 3600;\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC UPDATE FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Allows the owner to transfer the ownership to `newOwner`.\n function transferOwnership(address newOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(shl(96, newOwner)) {\n mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n }\n _setOwner(newOwner);\n }\n\n /// @dev Allows the owner to renounce their ownership.\n function renounceOwnership() public payable virtual onlyOwner {\n _setOwner(address(0));\n }\n\n /// @dev Request a two-step ownership handover to the caller.\n /// The request will automatically expire in 48 hours (172800 seconds) by default.\n function requestOwnershipHandover() public payable virtual {\n unchecked {\n uint256 expires = block.timestamp + _ownershipHandoverValidFor();\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to `expires`.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), expires)\n // Emit the {OwnershipHandoverRequested} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())\n }\n }\n }\n\n /// @dev Cancels the two-step ownership handover to the caller, if any.\n function cancelOwnershipHandover() public payable virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), 0)\n // Emit the {OwnershipHandoverCanceled} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())\n }\n }\n\n /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.\n /// Reverts if there is no existing ownership handover requested by `pendingOwner`.\n function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n let handoverSlot := keccak256(0x0c, 0x20)\n // If the handover does not exist, or has expired.\n if gt(timestamp(), sload(handoverSlot)) {\n mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.\n revert(0x1c, 0x04)\n }\n // Set the handover slot to 0.\n sstore(handoverSlot, 0)\n }\n _setOwner(pendingOwner);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC READ FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the owner of the contract.\n function owner() public view virtual returns (address result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := sload(_OWNER_SLOT)\n }\n }\n\n /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.\n function ownershipHandoverExpiresAt(address pendingOwner)\n public\n view\n virtual\n returns (uint256 result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute the handover slot.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n // Load the handover slot.\n result := sload(keccak256(0x0c, 0x20))\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* MODIFIERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Marks a function as only callable by the owner.\n modifier onlyOwner() virtual {\n _checkOwner();\n _;\n }\n}\n" + }, + "solady/src/utils/LibString.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Library for converting numbers into strings and other string operations.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibString.sol)\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol)\n///\n/// @dev Note:\n/// For performance and bytecode compactness, most of the string operations are restricted to\n/// byte strings (7-bit ASCII), except where otherwise specified.\n/// Usage of byte string operations on charsets with runes spanning two or more bytes\n/// can lead to undefined behavior.\nlibrary LibString {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The length of the output is too small to contain all the hex digits.\n error HexLengthInsufficient();\n\n /// @dev The length of the string is more than 32 bytes.\n error TooBigForSmallString();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CONSTANTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The constant returned when the `search` is not found in the string.\n uint256 internal constant NOT_FOUND = type(uint256).max;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* DECIMAL OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the base 10 decimal representation of `value`.\n function toString(uint256 value) internal pure returns (string memory str) {\n /// @solidity memory-safe-assembly\n assembly {\n // The maximum value of a uint256 contains 78 digits (1 byte per digit), but\n // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.\n // We will need 1 word for the trailing zeros padding, 1 word for the length,\n // and 3 words for a maximum of 78 digits.\n str := add(mload(0x40), 0x80)\n // Update the free memory pointer to allocate.\n mstore(0x40, add(str, 0x20))\n // Zeroize the slot after the string.\n mstore(str, 0)\n\n // Cache the end of the memory to calculate the length later.\n let end := str\n\n let w := not(0) // Tsk.\n // We write the string from rightmost digit to leftmost digit.\n // The following is essentially a do-while loop that also handles the zero case.\n for { let temp := value } 1 {} {\n str := add(str, w) // `sub(str, 1)`.\n // Write the character to the pointer.\n // The ASCII index of the '0' character is 48.\n mstore8(str, add(48, mod(temp, 10)))\n // Keep dividing `temp` until zero.\n temp := div(temp, 10)\n if iszero(temp) { break }\n }\n\n let length := sub(end, str)\n // Move the pointer 32 bytes leftwards to make room for the length.\n str := sub(str, 0x20)\n // Store the length.\n mstore(str, length)\n }\n }\n\n /// @dev Returns the base 10 decimal representation of `value`.\n function toString(int256 value) internal pure returns (string memory str) {\n if (value >= 0) {\n return toString(uint256(value));\n }\n unchecked {\n str = toString(~uint256(value) + 1);\n }\n /// @solidity memory-safe-assembly\n assembly {\n // We still have some spare memory space on the left,\n // as we have allocated 3 words (96 bytes) for up to 78 digits.\n let length := mload(str) // Load the string length.\n mstore(str, 0x2d) // Store the '-' character.\n str := sub(str, 1) // Move back the string pointer by a byte.\n mstore(str, add(length, 1)) // Update the string length.\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* HEXADECIMAL OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the hexadecimal representation of `value`,\n /// left-padded to an input length of `length` bytes.\n /// The output is prefixed with \"0x\" encoded using 2 hexadecimal digits per byte,\n /// giving a total length of `length * 2 + 2` bytes.\n /// Reverts if `length` is too small for the output to contain all the digits.\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory str) {\n str = toHexStringNoPrefix(value, length);\n /// @solidity memory-safe-assembly\n assembly {\n let strLength := add(mload(str), 2) // Compute the length.\n mstore(str, 0x3078) // Write the \"0x\" prefix.\n str := sub(str, 2) // Move the pointer.\n mstore(str, strLength) // Write the length.\n }\n }\n\n /// @dev Returns the hexadecimal representation of `value`,\n /// left-padded to an input length of `length` bytes.\n /// The output is prefixed with \"0x\" encoded using 2 hexadecimal digits per byte,\n /// giving a total length of `length * 2` bytes.\n /// Reverts if `length` is too small for the output to contain all the digits.\n function toHexStringNoPrefix(uint256 value, uint256 length)\n internal\n pure\n returns (string memory str)\n {\n /// @solidity memory-safe-assembly\n assembly {\n // We need 0x20 bytes for the trailing zeros padding, `length * 2` bytes\n // for the digits, 0x02 bytes for the prefix, and 0x20 bytes for the length.\n // We add 0x20 to the total and round down to a multiple of 0x20.\n // (0x20 + 0x20 + 0x02 + 0x20) = 0x62.\n str := add(mload(0x40), and(add(shl(1, length), 0x42), not(0x1f)))\n // Allocate the memory.\n mstore(0x40, add(str, 0x20))\n // Zeroize the slot after the string.\n mstore(str, 0)\n\n // Cache the end to calculate the length later.\n let end := str\n // Store \"0123456789abcdef\" in scratch space.\n mstore(0x0f, 0x30313233343536373839616263646566)\n\n let start := sub(str, add(length, length))\n let w := not(1) // Tsk.\n let temp := value\n // We write the string from rightmost digit to leftmost digit.\n // The following is essentially a do-while loop that also handles the zero case.\n for {} 1 {} {\n str := add(str, w) // `sub(str, 2)`.\n mstore8(add(str, 1), mload(and(temp, 15)))\n mstore8(str, mload(and(shr(4, temp), 15)))\n temp := shr(8, temp)\n if iszero(xor(str, start)) { break }\n }\n\n if temp {\n mstore(0x00, 0x2194895a) // `HexLengthInsufficient()`.\n revert(0x1c, 0x04)\n }\n\n // Compute the string's length.\n let strLength := sub(end, str)\n // Move the pointer and write the length.\n str := sub(str, 0x20)\n mstore(str, strLength)\n }\n }\n\n /// @dev Returns the hexadecimal representation of `value`.\n /// The output is prefixed with \"0x\" and encoded using 2 hexadecimal digits per byte.\n /// As address are 20 bytes long, the output will left-padded to have\n /// a length of `20 * 2 + 2` bytes.\n function toHexString(uint256 value) internal pure returns (string memory str) {\n str = toHexStringNoPrefix(value);\n /// @solidity memory-safe-assembly\n assembly {\n let strLength := add(mload(str), 2) // Compute the length.\n mstore(str, 0x3078) // Write the \"0x\" prefix.\n str := sub(str, 2) // Move the pointer.\n mstore(str, strLength) // Write the length.\n }\n }\n\n /// @dev Returns the hexadecimal representation of `value`.\n /// The output is prefixed with \"0x\".\n /// The output excludes leading \"0\" from the `toHexString` output.\n /// `0x00: \"0x0\", 0x01: \"0x1\", 0x12: \"0x12\", 0x123: \"0x123\"`.\n function toMinimalHexString(uint256 value) internal pure returns (string memory str) {\n str = toHexStringNoPrefix(value);\n /// @solidity memory-safe-assembly\n assembly {\n let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present.\n let strLength := add(mload(str), 2) // Compute the length.\n mstore(add(str, o), 0x3078) // Write the \"0x\" prefix, accounting for leading zero.\n str := sub(add(str, o), 2) // Move the pointer, accounting for leading zero.\n mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero.\n }\n }\n\n /// @dev Returns the hexadecimal representation of `value`.\n /// The output excludes leading \"0\" from the `toHexStringNoPrefix` output.\n /// `0x00: \"0\", 0x01: \"1\", 0x12: \"12\", 0x123: \"123\"`.\n function toMinimalHexStringNoPrefix(uint256 value) internal pure returns (string memory str) {\n str = toHexStringNoPrefix(value);\n /// @solidity memory-safe-assembly\n assembly {\n let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present.\n let strLength := mload(str) // Get the length.\n str := add(str, o) // Move the pointer, accounting for leading zero.\n mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero.\n }\n }\n\n /// @dev Returns the hexadecimal representation of `value`.\n /// The output is encoded using 2 hexadecimal digits per byte.\n /// As address are 20 bytes long, the output will left-padded to have\n /// a length of `20 * 2` bytes.\n function toHexStringNoPrefix(uint256 value) internal pure returns (string memory str) {\n /// @solidity memory-safe-assembly\n assembly {\n // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,\n // 0x02 bytes for the prefix, and 0x40 bytes for the digits.\n // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x40) is 0xa0.\n str := add(mload(0x40), 0x80)\n // Allocate the memory.\n mstore(0x40, add(str, 0x20))\n // Zeroize the slot after the string.\n mstore(str, 0)\n\n // Cache the end to calculate the length later.\n let end := str\n // Store \"0123456789abcdef\" in scratch space.\n mstore(0x0f, 0x30313233343536373839616263646566)\n\n let w := not(1) // Tsk.\n // We write the string from rightmost digit to leftmost digit.\n // The following is essentially a do-while loop that also handles the zero case.\n for { let temp := value } 1 {} {\n str := add(str, w) // `sub(str, 2)`.\n mstore8(add(str, 1), mload(and(temp, 15)))\n mstore8(str, mload(and(shr(4, temp), 15)))\n temp := shr(8, temp)\n if iszero(temp) { break }\n }\n\n // Compute the string's length.\n let strLength := sub(end, str)\n // Move the pointer and write the length.\n str := sub(str, 0x20)\n mstore(str, strLength)\n }\n }\n\n /// @dev Returns the hexadecimal representation of `value`.\n /// The output is prefixed with \"0x\", encoded using 2 hexadecimal digits per byte,\n /// and the alphabets are capitalized conditionally according to\n /// https://eips.ethereum.org/EIPS/eip-55\n function toHexStringChecksummed(address value) internal pure returns (string memory str) {\n str = toHexString(value);\n /// @solidity memory-safe-assembly\n assembly {\n let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...`\n let o := add(str, 0x22)\n let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... `\n let t := shl(240, 136) // `0b10001000 << 240`\n for { let i := 0 } 1 {} {\n mstore(add(i, i), mul(t, byte(i, hashed)))\n i := add(i, 1)\n if eq(i, 20) { break }\n }\n mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask)))))\n o := add(o, 0x20)\n mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask)))))\n }\n }\n\n /// @dev Returns the hexadecimal representation of `value`.\n /// The output is prefixed with \"0x\" and encoded using 2 hexadecimal digits per byte.\n function toHexString(address value) internal pure returns (string memory str) {\n str = toHexStringNoPrefix(value);\n /// @solidity memory-safe-assembly\n assembly {\n let strLength := add(mload(str), 2) // Compute the length.\n mstore(str, 0x3078) // Write the \"0x\" prefix.\n str := sub(str, 2) // Move the pointer.\n mstore(str, strLength) // Write the length.\n }\n }\n\n /// @dev Returns the hexadecimal representation of `value`.\n /// The output is encoded using 2 hexadecimal digits per byte.\n function toHexStringNoPrefix(address value) internal pure returns (string memory str) {\n /// @solidity memory-safe-assembly\n assembly {\n str := mload(0x40)\n\n // Allocate the memory.\n // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,\n // 0x02 bytes for the prefix, and 0x28 bytes for the digits.\n // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80.\n mstore(0x40, add(str, 0x80))\n\n // Store \"0123456789abcdef\" in scratch space.\n mstore(0x0f, 0x30313233343536373839616263646566)\n\n str := add(str, 2)\n mstore(str, 40)\n\n let o := add(str, 0x20)\n mstore(add(o, 40), 0)\n\n value := shl(96, value)\n\n // We write the string from rightmost digit to leftmost digit.\n // The following is essentially a do-while loop that also handles the zero case.\n for { let i := 0 } 1 {} {\n let p := add(o, add(i, i))\n let temp := byte(i, value)\n mstore8(add(p, 1), mload(and(temp, 15)))\n mstore8(p, mload(shr(4, temp)))\n i := add(i, 1)\n if eq(i, 20) { break }\n }\n }\n }\n\n /// @dev Returns the hex encoded string from the raw bytes.\n /// The output is encoded using 2 hexadecimal digits per byte.\n function toHexString(bytes memory raw) internal pure returns (string memory str) {\n str = toHexStringNoPrefix(raw);\n /// @solidity memory-safe-assembly\n assembly {\n let strLength := add(mload(str), 2) // Compute the length.\n mstore(str, 0x3078) // Write the \"0x\" prefix.\n str := sub(str, 2) // Move the pointer.\n mstore(str, strLength) // Write the length.\n }\n }\n\n /// @dev Returns the hex encoded string from the raw bytes.\n /// The output is encoded using 2 hexadecimal digits per byte.\n function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) {\n /// @solidity memory-safe-assembly\n assembly {\n let length := mload(raw)\n str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix.\n mstore(str, add(length, length)) // Store the length of the output.\n\n // Store \"0123456789abcdef\" in scratch space.\n mstore(0x0f, 0x30313233343536373839616263646566)\n\n let o := add(str, 0x20)\n let end := add(raw, length)\n\n for {} iszero(eq(raw, end)) {} {\n raw := add(raw, 1)\n mstore8(add(o, 1), mload(and(mload(raw), 15)))\n mstore8(o, mload(and(shr(4, mload(raw)), 15)))\n o := add(o, 2)\n }\n mstore(o, 0) // Zeroize the slot after the string.\n mstore(0x40, add(o, 0x20)) // Allocate the memory.\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* RUNE STRING OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the number of UTF characters in the string.\n function runeCount(string memory s) internal pure returns (uint256 result) {\n /// @solidity memory-safe-assembly\n assembly {\n if mload(s) {\n mstore(0x00, div(not(0), 255))\n mstore(0x20, 0x0202020202020202020202020202020202020202020202020303030304040506)\n let o := add(s, 0x20)\n let end := add(o, mload(s))\n for { result := 1 } 1 { result := add(result, 1) } {\n o := add(o, byte(0, mload(shr(250, mload(o)))))\n if iszero(lt(o, end)) { break }\n }\n }\n }\n }\n\n /// @dev Returns if this string is a 7-bit ASCII string.\n /// (i.e. all characters codes are in [0..127])\n function is7BitASCII(string memory s) internal pure returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n let mask := shl(7, div(not(0), 255))\n result := 1\n let n := mload(s)\n if n {\n let o := add(s, 0x20)\n let end := add(o, n)\n let last := mload(end)\n mstore(end, 0)\n for {} 1 {} {\n if and(mask, mload(o)) {\n result := 0\n break\n }\n o := add(o, 0x20)\n if iszero(lt(o, end)) { break }\n }\n mstore(end, last)\n }\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* BYTE STRING OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n // For performance and bytecode compactness, byte string operations are restricted\n // to 7-bit ASCII strings. All offsets are byte offsets, not UTF character offsets.\n // Usage of byte string operations on charsets with runes spanning two or more bytes\n // can lead to undefined behavior.\n\n /// @dev Returns `subject` all occurrences of `search` replaced with `replacement`.\n function replace(string memory subject, string memory search, string memory replacement)\n internal\n pure\n returns (string memory result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let subjectLength := mload(subject)\n let searchLength := mload(search)\n let replacementLength := mload(replacement)\n\n subject := add(subject, 0x20)\n search := add(search, 0x20)\n replacement := add(replacement, 0x20)\n result := add(mload(0x40), 0x20)\n\n let subjectEnd := add(subject, subjectLength)\n if iszero(gt(searchLength, subjectLength)) {\n let subjectSearchEnd := add(sub(subjectEnd, searchLength), 1)\n let h := 0\n if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) }\n let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\n let s := mload(search)\n for {} 1 {} {\n let t := mload(subject)\n // Whether the first `searchLength % 32` bytes of\n // `subject` and `search` matches.\n if iszero(shr(m, xor(t, s))) {\n if h {\n if iszero(eq(keccak256(subject, searchLength), h)) {\n mstore(result, t)\n result := add(result, 1)\n subject := add(subject, 1)\n if iszero(lt(subject, subjectSearchEnd)) { break }\n continue\n }\n }\n // Copy the `replacement` one word at a time.\n for { let o := 0 } 1 {} {\n mstore(add(result, o), mload(add(replacement, o)))\n o := add(o, 0x20)\n if iszero(lt(o, replacementLength)) { break }\n }\n result := add(result, replacementLength)\n subject := add(subject, searchLength)\n if searchLength {\n if iszero(lt(subject, subjectSearchEnd)) { break }\n continue\n }\n }\n mstore(result, t)\n result := add(result, 1)\n subject := add(subject, 1)\n if iszero(lt(subject, subjectSearchEnd)) { break }\n }\n }\n\n let resultRemainder := result\n result := add(mload(0x40), 0x20)\n let k := add(sub(resultRemainder, result), sub(subjectEnd, subject))\n // Copy the rest of the string one word at a time.\n for {} lt(subject, subjectEnd) {} {\n mstore(resultRemainder, mload(subject))\n resultRemainder := add(resultRemainder, 0x20)\n subject := add(subject, 0x20)\n }\n result := sub(result, 0x20)\n let last := add(add(result, 0x20), k) // Zeroize the slot after the string.\n mstore(last, 0)\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\n mstore(result, k) // Store the length.\n }\n }\n\n /// @dev Returns the byte index of the first location of `search` in `subject`,\n /// searching from left to right, starting from `from`.\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\n function indexOf(string memory subject, string memory search, uint256 from)\n internal\n pure\n returns (uint256 result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n for { let subjectLength := mload(subject) } 1 {} {\n if iszero(mload(search)) {\n if iszero(gt(from, subjectLength)) {\n result := from\n break\n }\n result := subjectLength\n break\n }\n let searchLength := mload(search)\n let subjectStart := add(subject, 0x20)\n\n result := not(0) // Initialize to `NOT_FOUND`.\n\n subject := add(subjectStart, from)\n let end := add(sub(add(subjectStart, subjectLength), searchLength), 1)\n\n let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\n let s := mload(add(search, 0x20))\n\n if iszero(and(lt(subject, end), lt(from, subjectLength))) { break }\n\n if iszero(lt(searchLength, 0x20)) {\n for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} {\n if iszero(shr(m, xor(mload(subject), s))) {\n if eq(keccak256(subject, searchLength), h) {\n result := sub(subject, subjectStart)\n break\n }\n }\n subject := add(subject, 1)\n if iszero(lt(subject, end)) { break }\n }\n break\n }\n for {} 1 {} {\n if iszero(shr(m, xor(mload(subject), s))) {\n result := sub(subject, subjectStart)\n break\n }\n subject := add(subject, 1)\n if iszero(lt(subject, end)) { break }\n }\n break\n }\n }\n }\n\n /// @dev Returns the byte index of the first location of `search` in `subject`,\n /// searching from left to right.\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\n function indexOf(string memory subject, string memory search)\n internal\n pure\n returns (uint256 result)\n {\n result = indexOf(subject, search, 0);\n }\n\n /// @dev Returns the byte index of the first location of `search` in `subject`,\n /// searching from right to left, starting from `from`.\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\n function lastIndexOf(string memory subject, string memory search, uint256 from)\n internal\n pure\n returns (uint256 result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n for {} 1 {} {\n result := not(0) // Initialize to `NOT_FOUND`.\n let searchLength := mload(search)\n if gt(searchLength, mload(subject)) { break }\n let w := result\n\n let fromMax := sub(mload(subject), searchLength)\n if iszero(gt(fromMax, from)) { from := fromMax }\n\n let end := add(add(subject, 0x20), w)\n subject := add(add(subject, 0x20), from)\n if iszero(gt(subject, end)) { break }\n // As this function is not too often used,\n // we shall simply use keccak256 for smaller bytecode size.\n for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} {\n if eq(keccak256(subject, searchLength), h) {\n result := sub(subject, add(end, 1))\n break\n }\n subject := add(subject, w) // `sub(subject, 1)`.\n if iszero(gt(subject, end)) { break }\n }\n break\n }\n }\n }\n\n /// @dev Returns the byte index of the first location of `search` in `subject`,\n /// searching from right to left.\n /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\n function lastIndexOf(string memory subject, string memory search)\n internal\n pure\n returns (uint256 result)\n {\n result = lastIndexOf(subject, search, uint256(int256(-1)));\n }\n\n /// @dev Returns true if `search` is found in `subject`, false otherwise.\n function contains(string memory subject, string memory search) internal pure returns (bool) {\n return indexOf(subject, search) != NOT_FOUND;\n }\n\n /// @dev Returns whether `subject` starts with `search`.\n function startsWith(string memory subject, string memory search)\n internal\n pure\n returns (bool result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let searchLength := mload(search)\n // Just using keccak256 directly is actually cheaper.\n // forgefmt: disable-next-item\n result := and(\n iszero(gt(searchLength, mload(subject))),\n eq(\n keccak256(add(subject, 0x20), searchLength),\n keccak256(add(search, 0x20), searchLength)\n )\n )\n }\n }\n\n /// @dev Returns whether `subject` ends with `search`.\n function endsWith(string memory subject, string memory search)\n internal\n pure\n returns (bool result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let searchLength := mload(search)\n let subjectLength := mload(subject)\n // Whether `search` is not longer than `subject`.\n let withinRange := iszero(gt(searchLength, subjectLength))\n // Just using keccak256 directly is actually cheaper.\n // forgefmt: disable-next-item\n result := and(\n withinRange,\n eq(\n keccak256(\n // `subject + 0x20 + max(subjectLength - searchLength, 0)`.\n add(add(subject, 0x20), mul(withinRange, sub(subjectLength, searchLength))),\n searchLength\n ),\n keccak256(add(search, 0x20), searchLength)\n )\n )\n }\n }\n\n /// @dev Returns `subject` repeated `times`.\n function repeat(string memory subject, uint256 times)\n internal\n pure\n returns (string memory result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let subjectLength := mload(subject)\n if iszero(or(iszero(times), iszero(subjectLength))) {\n subject := add(subject, 0x20)\n result := mload(0x40)\n let output := add(result, 0x20)\n for {} 1 {} {\n // Copy the `subject` one word at a time.\n for { let o := 0 } 1 {} {\n mstore(add(output, o), mload(add(subject, o)))\n o := add(o, 0x20)\n if iszero(lt(o, subjectLength)) { break }\n }\n output := add(output, subjectLength)\n times := sub(times, 1)\n if iszero(times) { break }\n }\n mstore(output, 0) // Zeroize the slot after the string.\n let resultLength := sub(output, add(result, 0x20))\n mstore(result, resultLength) // Store the length.\n // Allocate the memory.\n mstore(0x40, add(result, add(resultLength, 0x20)))\n }\n }\n }\n\n /// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).\n /// `start` and `end` are byte offsets.\n function slice(string memory subject, uint256 start, uint256 end)\n internal\n pure\n returns (string memory result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let subjectLength := mload(subject)\n if iszero(gt(subjectLength, end)) { end := subjectLength }\n if iszero(gt(subjectLength, start)) { start := subjectLength }\n if lt(start, end) {\n result := mload(0x40)\n let resultLength := sub(end, start)\n mstore(result, resultLength)\n subject := add(subject, start)\n let w := not(0x1f)\n // Copy the `subject` one word at a time, backwards.\n for { let o := and(add(resultLength, 0x1f), w) } 1 {} {\n mstore(add(result, o), mload(add(subject, o)))\n o := add(o, w) // `sub(o, 0x20)`.\n if iszero(o) { break }\n }\n // Zeroize the slot after the string.\n mstore(add(add(result, 0x20), resultLength), 0)\n // Allocate memory for the length and the bytes,\n // rounded up to a multiple of 32.\n mstore(0x40, add(result, and(add(resultLength, 0x3f), w)))\n }\n }\n }\n\n /// @dev Returns a copy of `subject` sliced from `start` to the end of the string.\n /// `start` is a byte offset.\n function slice(string memory subject, uint256 start)\n internal\n pure\n returns (string memory result)\n {\n result = slice(subject, start, uint256(int256(-1)));\n }\n\n /// @dev Returns all the indices of `search` in `subject`.\n /// The indices are byte offsets.\n function indicesOf(string memory subject, string memory search)\n internal\n pure\n returns (uint256[] memory result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let subjectLength := mload(subject)\n let searchLength := mload(search)\n\n if iszero(gt(searchLength, subjectLength)) {\n subject := add(subject, 0x20)\n search := add(search, 0x20)\n result := add(mload(0x40), 0x20)\n\n let subjectStart := subject\n let subjectSearchEnd := add(sub(add(subject, subjectLength), searchLength), 1)\n let h := 0\n if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) }\n let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\n let s := mload(search)\n for {} 1 {} {\n let t := mload(subject)\n // Whether the first `searchLength % 32` bytes of\n // `subject` and `search` matches.\n if iszero(shr(m, xor(t, s))) {\n if h {\n if iszero(eq(keccak256(subject, searchLength), h)) {\n subject := add(subject, 1)\n if iszero(lt(subject, subjectSearchEnd)) { break }\n continue\n }\n }\n // Append to `result`.\n mstore(result, sub(subject, subjectStart))\n result := add(result, 0x20)\n // Advance `subject` by `searchLength`.\n subject := add(subject, searchLength)\n if searchLength {\n if iszero(lt(subject, subjectSearchEnd)) { break }\n continue\n }\n }\n subject := add(subject, 1)\n if iszero(lt(subject, subjectSearchEnd)) { break }\n }\n let resultEnd := result\n // Assign `result` to the free memory pointer.\n result := mload(0x40)\n // Store the length of `result`.\n mstore(result, shr(5, sub(resultEnd, add(result, 0x20))))\n // Allocate memory for result.\n // We allocate one more word, so this array can be recycled for {split}.\n mstore(0x40, add(resultEnd, 0x20))\n }\n }\n }\n\n /// @dev Returns a arrays of strings based on the `delimiter` inside of the `subject` string.\n function split(string memory subject, string memory delimiter)\n internal\n pure\n returns (string[] memory result)\n {\n uint256[] memory indices = indicesOf(subject, delimiter);\n /// @solidity memory-safe-assembly\n assembly {\n let w := not(0x1f)\n let indexPtr := add(indices, 0x20)\n let indicesEnd := add(indexPtr, shl(5, add(mload(indices), 1)))\n mstore(add(indicesEnd, w), mload(subject))\n mstore(indices, add(mload(indices), 1))\n let prevIndex := 0\n for {} 1 {} {\n let index := mload(indexPtr)\n mstore(indexPtr, 0x60)\n if iszero(eq(index, prevIndex)) {\n let element := mload(0x40)\n let elementLength := sub(index, prevIndex)\n mstore(element, elementLength)\n // Copy the `subject` one word at a time, backwards.\n for { let o := and(add(elementLength, 0x1f), w) } 1 {} {\n mstore(add(element, o), mload(add(add(subject, prevIndex), o)))\n o := add(o, w) // `sub(o, 0x20)`.\n if iszero(o) { break }\n }\n // Zeroize the slot after the string.\n mstore(add(add(element, 0x20), elementLength), 0)\n // Allocate memory for the length and the bytes,\n // rounded up to a multiple of 32.\n mstore(0x40, add(element, and(add(elementLength, 0x3f), w)))\n // Store the `element` into the array.\n mstore(indexPtr, element)\n }\n prevIndex := add(index, mload(delimiter))\n indexPtr := add(indexPtr, 0x20)\n if iszero(lt(indexPtr, indicesEnd)) { break }\n }\n result := indices\n if iszero(mload(delimiter)) {\n result := add(indices, 0x20)\n mstore(result, sub(mload(indices), 2))\n }\n }\n }\n\n /// @dev Returns a concatenated string of `a` and `b`.\n /// Cheaper than `string.concat()` and does not de-align the free memory pointer.\n function concat(string memory a, string memory b)\n internal\n pure\n returns (string memory result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let w := not(0x1f)\n result := mload(0x40)\n let aLength := mload(a)\n // Copy `a` one word at a time, backwards.\n for { let o := and(add(aLength, 0x20), w) } 1 {} {\n mstore(add(result, o), mload(add(a, o)))\n o := add(o, w) // `sub(o, 0x20)`.\n if iszero(o) { break }\n }\n let bLength := mload(b)\n let output := add(result, aLength)\n // Copy `b` one word at a time, backwards.\n for { let o := and(add(bLength, 0x20), w) } 1 {} {\n mstore(add(output, o), mload(add(b, o)))\n o := add(o, w) // `sub(o, 0x20)`.\n if iszero(o) { break }\n }\n let totalLength := add(aLength, bLength)\n let last := add(add(result, 0x20), totalLength)\n // Zeroize the slot after the string.\n mstore(last, 0)\n // Stores the length.\n mstore(result, totalLength)\n // Allocate memory for the length and the bytes,\n // rounded up to a multiple of 32.\n mstore(0x40, and(add(last, 0x1f), w))\n }\n }\n\n /// @dev Returns a copy of the string in either lowercase or UPPERCASE.\n /// WARNING! This function is only compatible with 7-bit ASCII strings.\n function toCase(string memory subject, bool toUpper)\n internal\n pure\n returns (string memory result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let length := mload(subject)\n if length {\n result := add(mload(0x40), 0x20)\n subject := add(subject, 1)\n let flags := shl(add(70, shl(5, toUpper)), 0x3ffffff)\n let w := not(0)\n for { let o := length } 1 {} {\n o := add(o, w)\n let b := and(0xff, mload(add(subject, o)))\n mstore8(add(result, o), xor(b, and(shr(b, flags), 0x20)))\n if iszero(o) { break }\n }\n result := mload(0x40)\n mstore(result, length) // Store the length.\n let last := add(add(result, 0x20), length)\n mstore(last, 0) // Zeroize the slot after the string.\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\n }\n }\n }\n\n /// @dev Returns a string from a small bytes32 string.\n /// `s` must be null-terminated, or behavior will be undefined.\n function fromSmallString(bytes32 s) internal pure returns (string memory result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := mload(0x40)\n let n := 0\n for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\\0'.\n mstore(result, n)\n let o := add(result, 0x20)\n mstore(o, s)\n mstore(add(o, n), 0)\n mstore(0x40, add(result, 0x40))\n }\n }\n\n /// @dev Returns the small string, with all bytes after the first null byte zeroized.\n function normalizeSmallString(bytes32 s) internal pure returns (bytes32 result) {\n /// @solidity memory-safe-assembly\n assembly {\n for {} byte(result, s) { result := add(result, 1) } {} // Scan for '\\0'.\n mstore(0x00, s)\n mstore(result, 0x00)\n result := mload(0x00)\n }\n }\n\n /// @dev Returns the string as a normalized null-terminated small string.\n function toSmallString(string memory s) internal pure returns (bytes32 result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := mload(s)\n if iszero(lt(result, 33)) {\n mstore(0x00, 0xec92f9a3) // `TooBigForSmallString()`.\n revert(0x1c, 0x04)\n }\n result := shl(shl(3, sub(32, result)), mload(add(s, result)))\n }\n }\n\n /// @dev Returns a lowercased copy of the string.\n /// WARNING! This function is only compatible with 7-bit ASCII strings.\n function lower(string memory subject) internal pure returns (string memory result) {\n result = toCase(subject, false);\n }\n\n /// @dev Returns an UPPERCASED copy of the string.\n /// WARNING! This function is only compatible with 7-bit ASCII strings.\n function upper(string memory subject) internal pure returns (string memory result) {\n result = toCase(subject, true);\n }\n\n /// @dev Escapes the string to be used within HTML tags.\n function escapeHTML(string memory s) internal pure returns (string memory result) {\n /// @solidity memory-safe-assembly\n assembly {\n let end := add(s, mload(s))\n result := add(mload(0x40), 0x20)\n // Store the bytes of the packed offsets and strides into the scratch space.\n // `packed = (stride << 5) | offset`. Max offset is 20. Max stride is 6.\n mstore(0x1f, 0x900094)\n mstore(0x08, 0xc0000000a6ab)\n // Store \""&'<>\" into the scratch space.\n mstore(0x00, shl(64, 0x2671756f743b26616d703b262333393b266c743b2667743b))\n for {} iszero(eq(s, end)) {} {\n s := add(s, 1)\n let c := and(mload(s), 0xff)\n // Not in `[\"\\\"\",\"'\",\"&\",\"<\",\">\"]`.\n if iszero(and(shl(c, 1), 0x500000c400000000)) {\n mstore8(result, c)\n result := add(result, 1)\n continue\n }\n let t := shr(248, mload(c))\n mstore(result, mload(and(t, 0x1f)))\n result := add(result, shr(5, t))\n }\n let last := result\n mstore(last, 0) // Zeroize the slot after the string.\n result := mload(0x40)\n mstore(result, sub(last, add(result, 0x20))) // Store the length.\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\n }\n }\n\n /// @dev Escapes the string to be used within double-quotes in a JSON.\n /// If `addDoubleQuotes` is true, the result will be enclosed in double-quotes.\n function escapeJSON(string memory s, bool addDoubleQuotes)\n internal\n pure\n returns (string memory result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let end := add(s, mload(s))\n result := add(mload(0x40), 0x20)\n if addDoubleQuotes {\n mstore8(result, 34)\n result := add(1, result)\n }\n // Store \"\\\\u0000\" in scratch space.\n // Store \"0123456789abcdef\" in scratch space.\n // Also, store `{0x08:\"b\", 0x09:\"t\", 0x0a:\"n\", 0x0c:\"f\", 0x0d:\"r\"}`.\n // into the scratch space.\n mstore(0x15, 0x5c75303030303031323334353637383961626364656662746e006672)\n // Bitmask for detecting `[\"\\\"\",\"\\\\\"]`.\n let e := or(shl(0x22, 1), shl(0x5c, 1))\n for {} iszero(eq(s, end)) {} {\n s := add(s, 1)\n let c := and(mload(s), 0xff)\n if iszero(lt(c, 0x20)) {\n if iszero(and(shl(c, 1), e)) {\n // Not in `[\"\\\"\",\"\\\\\"]`.\n mstore8(result, c)\n result := add(result, 1)\n continue\n }\n mstore8(result, 0x5c) // \"\\\\\".\n mstore8(add(result, 1), c)\n result := add(result, 2)\n continue\n }\n if iszero(and(shl(c, 1), 0x3700)) {\n // Not in `[\"\\b\",\"\\t\",\"\\n\",\"\\f\",\"\\d\"]`.\n mstore8(0x1d, mload(shr(4, c))) // Hex value.\n mstore8(0x1e, mload(and(c, 15))) // Hex value.\n mstore(result, mload(0x19)) // \"\\\\u00XX\".\n result := add(result, 6)\n continue\n }\n mstore8(result, 0x5c) // \"\\\\\".\n mstore8(add(result, 1), mload(add(c, 8)))\n result := add(result, 2)\n }\n if addDoubleQuotes {\n mstore8(result, 34)\n result := add(1, result)\n }\n let last := result\n mstore(last, 0) // Zeroize the slot after the string.\n result := mload(0x40)\n mstore(result, sub(last, add(result, 0x20))) // Store the length.\n mstore(0x40, add(last, 0x20)) // Allocate the memory.\n }\n }\n\n /// @dev Escapes the string to be used within double-quotes in a JSON.\n function escapeJSON(string memory s) internal pure returns (string memory result) {\n result = escapeJSON(s, false);\n }\n\n /// @dev Returns whether `a` equals `b`.\n function eq(string memory a, string memory b) internal pure returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := eq(keccak256(add(a, 0x20), mload(a)), keccak256(add(b, 0x20), mload(b)))\n }\n }\n\n /// @dev Returns whether `a` equals `b`, where `b` is a null-terminated small string.\n function eqs(string memory a, bytes32 b) internal pure returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n // These should be evaluated on compile time, as far as possible.\n let m := not(shl(7, div(not(iszero(b)), 255))) // `0x7f7f ...`.\n let x := not(or(m, or(b, add(m, and(b, m)))))\n let r := shl(7, iszero(iszero(shr(128, x))))\n r := or(r, shl(6, iszero(iszero(shr(64, shr(r, x))))))\n r := or(r, shl(5, lt(0xffffffff, shr(r, x))))\n r := or(r, shl(4, lt(0xffff, shr(r, x))))\n r := or(r, shl(3, lt(0xff, shr(r, x))))\n // forgefmt: disable-next-item\n result := gt(eq(mload(a), add(iszero(x), xor(31, shr(3, r)))),\n xor(shr(add(8, r), b), shr(add(8, r), mload(add(a, 0x20)))))\n }\n }\n\n /// @dev Packs a single string with its length into a single word.\n /// Returns `bytes32(0)` if the length is zero or greater than 31.\n function packOne(string memory a) internal pure returns (bytes32 result) {\n /// @solidity memory-safe-assembly\n assembly {\n // We don't need to zero right pad the string,\n // since this is our own custom non-standard packing scheme.\n result :=\n mul(\n // Load the length and the bytes.\n mload(add(a, 0x1f)),\n // `length != 0 && length < 32`. Abuses underflow.\n // Assumes that the length is valid and within the block gas limit.\n lt(sub(mload(a), 1), 0x1f)\n )\n }\n }\n\n /// @dev Unpacks a string packed using {packOne}.\n /// Returns the empty string if `packed` is `bytes32(0)`.\n /// If `packed` is not an output of {packOne}, the output behavior is undefined.\n function unpackOne(bytes32 packed) internal pure returns (string memory result) {\n /// @solidity memory-safe-assembly\n assembly {\n // Grab the free memory pointer.\n result := mload(0x40)\n // Allocate 2 words (1 for the length, 1 for the bytes).\n mstore(0x40, add(result, 0x40))\n // Zeroize the length slot.\n mstore(result, 0)\n // Store the length and bytes.\n mstore(add(result, 0x1f), packed)\n // Right pad with zeroes.\n mstore(add(add(result, 0x20), mload(result)), 0)\n }\n }\n\n /// @dev Packs two strings with their lengths into a single word.\n /// Returns `bytes32(0)` if combined length is zero or greater than 30.\n function packTwo(string memory a, string memory b) internal pure returns (bytes32 result) {\n /// @solidity memory-safe-assembly\n assembly {\n let aLength := mload(a)\n // We don't need to zero right pad the strings,\n // since this is our own custom non-standard packing scheme.\n result :=\n mul(\n // Load the length and the bytes of `a` and `b`.\n or(\n shl(shl(3, sub(0x1f, aLength)), mload(add(a, aLength))),\n mload(sub(add(b, 0x1e), aLength))\n ),\n // `totalLength != 0 && totalLength < 31`. Abuses underflow.\n // Assumes that the lengths are valid and within the block gas limit.\n lt(sub(add(aLength, mload(b)), 1), 0x1e)\n )\n }\n }\n\n /// @dev Unpacks strings packed using {packTwo}.\n /// Returns the empty strings if `packed` is `bytes32(0)`.\n /// If `packed` is not an output of {packTwo}, the output behavior is undefined.\n function unpackTwo(bytes32 packed)\n internal\n pure\n returns (string memory resultA, string memory resultB)\n {\n /// @solidity memory-safe-assembly\n assembly {\n // Grab the free memory pointer.\n resultA := mload(0x40)\n resultB := add(resultA, 0x40)\n // Allocate 2 words for each string (1 for the length, 1 for the byte). Total 4 words.\n mstore(0x40, add(resultB, 0x40))\n // Zeroize the length slots.\n mstore(resultA, 0)\n mstore(resultB, 0)\n // Store the lengths and bytes.\n mstore(add(resultA, 0x1f), packed)\n mstore(add(resultB, 0x1f), mload(add(add(resultA, 0x20), mload(resultA))))\n // Right pad with zeroes.\n mstore(add(add(resultA, 0x20), mload(resultA)), 0)\n mstore(add(add(resultB, 0x20), mload(resultB)), 0)\n }\n }\n\n /// @dev Directly returns `a` without copying.\n function directReturn(string memory a) internal pure {\n assembly {\n // Assumes that the string does not start from the scratch space.\n let retStart := sub(a, 0x20)\n let retSize := add(mload(a), 0x40)\n // Right pad with zeroes. Just in case the string is produced\n // by a method that doesn't zero right pad.\n mstore(add(retStart, retSize), 0)\n // Store the return offset.\n mstore(retStart, 0x20)\n // End the transaction, returning the string.\n return(retStart, retSize)\n }\n }\n}\n" + }, + "solady/src/utils/MerkleProofLib.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Gas optimized verification of proof of inclusion for a leaf in a Merkle tree.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/MerkleProofLib.sol)\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol)\nlibrary MerkleProofLib {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* MERKLE PROOF VERIFICATION OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`.\n function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf)\n internal\n pure\n returns (bool isValid)\n {\n /// @solidity memory-safe-assembly\n assembly {\n if mload(proof) {\n // Initialize `offset` to the offset of `proof` elements in memory.\n let offset := add(proof, 0x20)\n // Left shift by 5 is equivalent to multiplying by 0x20.\n let end := add(offset, shl(5, mload(proof)))\n // Iterate over proof elements to compute root hash.\n for {} 1 {} {\n // Slot of `leaf` in scratch space.\n // If the condition is true: 0x20, otherwise: 0x00.\n let scratch := shl(5, gt(leaf, mload(offset)))\n // Store elements to hash contiguously in scratch space.\n // Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes.\n mstore(scratch, leaf)\n mstore(xor(scratch, 0x20), mload(offset))\n // Reuse `leaf` to store the hash to reduce stack operations.\n leaf := keccak256(0x00, 0x40)\n offset := add(offset, 0x20)\n if iszero(lt(offset, end)) { break }\n }\n }\n isValid := eq(leaf, root)\n }\n }\n\n /// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`.\n function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf)\n internal\n pure\n returns (bool isValid)\n {\n /// @solidity memory-safe-assembly\n assembly {\n if proof.length {\n // Left shift by 5 is equivalent to multiplying by 0x20.\n let end := add(proof.offset, shl(5, proof.length))\n // Initialize `offset` to the offset of `proof` in the calldata.\n let offset := proof.offset\n // Iterate over proof elements to compute root hash.\n for {} 1 {} {\n // Slot of `leaf` in scratch space.\n // If the condition is true: 0x20, otherwise: 0x00.\n let scratch := shl(5, gt(leaf, calldataload(offset)))\n // Store elements to hash contiguously in scratch space.\n // Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes.\n mstore(scratch, leaf)\n mstore(xor(scratch, 0x20), calldataload(offset))\n // Reuse `leaf` to store the hash to reduce stack operations.\n leaf := keccak256(0x00, 0x40)\n offset := add(offset, 0x20)\n if iszero(lt(offset, end)) { break }\n }\n }\n isValid := eq(leaf, root)\n }\n }\n\n /// @dev Returns whether all `leaves` exist in the Merkle tree with `root`,\n /// given `proof` and `flags`.\n ///\n /// Note:\n /// - Breaking the invariant `flags.length == (leaves.length - 1) + proof.length`\n /// will always return false.\n /// - The sum of the lengths of `proof` and `leaves` must never overflow.\n /// - Any non-zero word in the `flags` array is treated as true.\n /// - The memory offset of `proof` must be non-zero\n /// (i.e. `proof` is not pointing to the scratch space).\n function verifyMultiProof(\n bytes32[] memory proof,\n bytes32 root,\n bytes32[] memory leaves,\n bool[] memory flags\n ) internal pure returns (bool isValid) {\n // Rebuilds the root by consuming and producing values on a queue.\n // The queue starts with the `leaves` array, and goes into a `hashes` array.\n // After the process, the last element on the queue is verified\n // to be equal to the `root`.\n //\n // The `flags` array denotes whether the sibling\n // should be popped from the queue (`flag == true`), or\n // should be popped from the `proof` (`flag == false`).\n /// @solidity memory-safe-assembly\n assembly {\n // Cache the lengths of the arrays.\n let leavesLength := mload(leaves)\n let proofLength := mload(proof)\n let flagsLength := mload(flags)\n\n // Advance the pointers of the arrays to point to the data.\n leaves := add(0x20, leaves)\n proof := add(0x20, proof)\n flags := add(0x20, flags)\n\n // If the number of flags is correct.\n for {} eq(add(leavesLength, proofLength), add(flagsLength, 1)) {} {\n // For the case where `proof.length + leaves.length == 1`.\n if iszero(flagsLength) {\n // `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`.\n isValid := eq(mload(xor(leaves, mul(xor(proof, leaves), proofLength))), root)\n break\n }\n\n // The required final proof offset if `flagsLength` is not zero, otherwise zero.\n let proofEnd := add(proof, shl(5, proofLength))\n // We can use the free memory space for the queue.\n // We don't need to allocate, since the queue is temporary.\n let hashesFront := mload(0x40)\n // Copy the leaves into the hashes.\n // Sometimes, a little memory expansion costs less than branching.\n // Should cost less, even with a high free memory offset of 0x7d00.\n leavesLength := shl(5, leavesLength)\n for { let i := 0 } iszero(eq(i, leavesLength)) { i := add(i, 0x20) } {\n mstore(add(hashesFront, i), mload(add(leaves, i)))\n }\n // Compute the back of the hashes.\n let hashesBack := add(hashesFront, leavesLength)\n // This is the end of the memory for the queue.\n // We recycle `flagsLength` to save on stack variables (sometimes save gas).\n flagsLength := add(hashesBack, shl(5, flagsLength))\n\n for {} 1 {} {\n // Pop from `hashes`.\n let a := mload(hashesFront)\n // Pop from `hashes`.\n let b := mload(add(hashesFront, 0x20))\n hashesFront := add(hashesFront, 0x40)\n\n // If the flag is false, load the next proof,\n // else, pops from the queue.\n if iszero(mload(flags)) {\n // Loads the next proof.\n b := mload(proof)\n proof := add(proof, 0x20)\n // Unpop from `hashes`.\n hashesFront := sub(hashesFront, 0x20)\n }\n\n // Advance to the next flag.\n flags := add(flags, 0x20)\n\n // Slot of `a` in scratch space.\n // If the condition is true: 0x20, otherwise: 0x00.\n let scratch := shl(5, gt(a, b))\n // Hash the scratch space and push the result onto the queue.\n mstore(scratch, a)\n mstore(xor(scratch, 0x20), b)\n mstore(hashesBack, keccak256(0x00, 0x40))\n hashesBack := add(hashesBack, 0x20)\n if iszero(lt(hashesBack, flagsLength)) { break }\n }\n isValid :=\n and(\n // Checks if the last value in the queue is same as the root.\n eq(mload(sub(hashesBack, 0x20)), root),\n // And whether all the proofs are used, if required.\n eq(proofEnd, proof)\n )\n break\n }\n }\n }\n\n /// @dev Returns whether all `leaves` exist in the Merkle tree with `root`,\n /// given `proof` and `flags`.\n ///\n /// Note:\n /// - Breaking the invariant `flags.length == (leaves.length - 1) + proof.length`\n /// will always return false.\n /// - Any non-zero word in the `flags` array is treated as true.\n /// - The calldata offset of `proof` must be non-zero\n /// (i.e. `proof` is from a regular Solidity function with a 4-byte selector).\n function verifyMultiProofCalldata(\n bytes32[] calldata proof,\n bytes32 root,\n bytes32[] calldata leaves,\n bool[] calldata flags\n ) internal pure returns (bool isValid) {\n // Rebuilds the root by consuming and producing values on a queue.\n // The queue starts with the `leaves` array, and goes into a `hashes` array.\n // After the process, the last element on the queue is verified\n // to be equal to the `root`.\n //\n // The `flags` array denotes whether the sibling\n // should be popped from the queue (`flag == true`), or\n // should be popped from the `proof` (`flag == false`).\n /// @solidity memory-safe-assembly\n assembly {\n // If the number of flags is correct.\n for {} eq(add(leaves.length, proof.length), add(flags.length, 1)) {} {\n // For the case where `proof.length + leaves.length == 1`.\n if iszero(flags.length) {\n // `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`.\n // forgefmt: disable-next-item\n isValid := eq(\n calldataload(\n xor(leaves.offset, mul(xor(proof.offset, leaves.offset), proof.length))\n ),\n root\n )\n break\n }\n\n // The required final proof offset if `flagsLength` is not zero, otherwise zero.\n let proofEnd := add(proof.offset, shl(5, proof.length))\n // We can use the free memory space for the queue.\n // We don't need to allocate, since the queue is temporary.\n let hashesFront := mload(0x40)\n // Copy the leaves into the hashes.\n // Sometimes, a little memory expansion costs less than branching.\n // Should cost less, even with a high free memory offset of 0x7d00.\n calldatacopy(hashesFront, leaves.offset, shl(5, leaves.length))\n // Compute the back of the hashes.\n let hashesBack := add(hashesFront, shl(5, leaves.length))\n // This is the end of the memory for the queue.\n // We recycle `flagsLength` to save on stack variables (sometimes save gas).\n flags.length := add(hashesBack, shl(5, flags.length))\n\n // We don't need to make a copy of `proof.offset` or `flags.offset`,\n // as they are pass-by-value (this trick may not always save gas).\n\n for {} 1 {} {\n // Pop from `hashes`.\n let a := mload(hashesFront)\n // Pop from `hashes`.\n let b := mload(add(hashesFront, 0x20))\n hashesFront := add(hashesFront, 0x40)\n\n // If the flag is false, load the next proof,\n // else, pops from the queue.\n if iszero(calldataload(flags.offset)) {\n // Loads the next proof.\n b := calldataload(proof.offset)\n proof.offset := add(proof.offset, 0x20)\n // Unpop from `hashes`.\n hashesFront := sub(hashesFront, 0x20)\n }\n\n // Advance to the next flag offset.\n flags.offset := add(flags.offset, 0x20)\n\n // Slot of `a` in scratch space.\n // If the condition is true: 0x20, otherwise: 0x00.\n let scratch := shl(5, gt(a, b))\n // Hash the scratch space and push the result onto the queue.\n mstore(scratch, a)\n mstore(xor(scratch, 0x20), b)\n mstore(hashesBack, keccak256(0x00, 0x40))\n hashesBack := add(hashesBack, 0x20)\n if iszero(lt(hashesBack, flags.length)) { break }\n }\n isValid :=\n and(\n // Checks if the last value in the queue is same as the root.\n eq(mload(sub(hashesBack, 0x20)), root),\n // And whether all the proofs are used, if required.\n eq(proofEnd, proof.offset)\n )\n break\n }\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EMPTY CALLDATA HELPERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns an empty calldata bytes32 array.\n function emptyProof() internal pure returns (bytes32[] calldata proof) {\n /// @solidity memory-safe-assembly\n assembly {\n proof.length := 0\n }\n }\n\n /// @dev Returns an empty calldata bytes32 array.\n function emptyLeaves() internal pure returns (bytes32[] calldata leaves) {\n /// @solidity memory-safe-assembly\n assembly {\n leaves.length := 0\n }\n }\n\n /// @dev Returns an empty calldata bool array.\n function emptyFlags() internal pure returns (bool[] calldata flags) {\n /// @solidity memory-safe-assembly\n assembly {\n flags.length := 0\n }\n }\n}\n" + }, + "solady/src/utils/SafeTransferLib.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @author Permit2 operations from (https://github.com/Uniswap/permit2/blob/main/src/libraries/Permit2Lib.sol)\n///\n/// @dev Note:\n/// - For ETH transfers, please use `forceSafeTransferETH` for DoS protection.\n/// - For ERC20s, this implementation won't check that a token has code,\n/// responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The ETH transfer has failed.\n error ETHTransferFailed();\n\n /// @dev The ERC20 `transferFrom` has failed.\n error TransferFromFailed();\n\n /// @dev The ERC20 `transfer` has failed.\n error TransferFailed();\n\n /// @dev The ERC20 `approve` has failed.\n error ApproveFailed();\n\n /// @dev The Permit2 operation has failed.\n error Permit2Failed();\n\n /// @dev The Permit2 amount must be less than `2**160 - 1`.\n error Permit2AmountOverflow();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CONSTANTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Suggested gas stipend for contract receiving ETH that disallows any storage writes.\n uint256 internal constant GAS_STIPEND_NO_STORAGE_WRITES = 2300;\n\n /// @dev Suggested gas stipend for contract receiving ETH to perform a few\n /// storage reads and writes, but low enough to prevent griefing.\n uint256 internal constant GAS_STIPEND_NO_GRIEF = 100000;\n\n /// @dev The unique EIP-712 domain domain separator for the DAI token contract.\n bytes32 internal constant DAI_DOMAIN_SEPARATOR =\n 0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;\n\n /// @dev The address for the WETH9 contract on Ethereum mainnet.\n address internal constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n\n /// @dev The canonical Permit2 address.\n /// [Github](https://github.com/Uniswap/permit2)\n /// [Etherscan](https://etherscan.io/address/0x000000000022D473030F116dDEE9F6B43aC78BA3)\n address internal constant PERMIT2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ETH OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n // If the ETH transfer MUST succeed with a reasonable gas budget, use the force variants.\n //\n // The regular variants:\n // - Forwards all remaining gas to the target.\n // - Reverts if the target reverts.\n // - Reverts if the current contract has insufficient balance.\n //\n // The force variants:\n // - Forwards with an optional gas stipend\n // (defaults to `GAS_STIPEND_NO_GRIEF`, which is sufficient for most cases).\n // - If the target reverts, or if the gas stipend is exhausted,\n // creates a temporary contract to force send the ETH via `SELFDESTRUCT`.\n // Future compatible with `SENDALL`: https://eips.ethereum.org/EIPS/eip-4758.\n // - Reverts if the current contract has insufficient balance.\n //\n // The try variants:\n // - Forwards with a mandatory gas stipend.\n // - Instead of reverting, returns whether the transfer succeeded.\n\n /// @dev Sends `amount` (in wei) ETH to `to`.\n function safeTransferETH(address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(call(gas(), to, amount, codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Sends all the ETH in the current contract to `to`.\n function safeTransferAllETH(address to) internal {\n /// @solidity memory-safe-assembly\n assembly {\n // Transfer all the ETH and check if it succeeded or not.\n if iszero(call(gas(), to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Force sends `amount` (in wei) ETH to `to`, with a `gasStipend`.\n function forceSafeTransferETH(address to, uint256 amount, uint256 gasStipend) internal {\n /// @solidity memory-safe-assembly\n assembly {\n if lt(selfbalance(), amount) {\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\n revert(0x1c, 0x04)\n }\n if iszero(call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, to) // Store the address in scratch space.\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\n if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\n }\n }\n }\n\n /// @dev Force sends all the ETH in the current contract to `to`, with a `gasStipend`.\n function forceSafeTransferAllETH(address to, uint256 gasStipend) internal {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, to) // Store the address in scratch space.\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\n if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\n }\n }\n }\n\n /// @dev Force sends `amount` (in wei) ETH to `to`, with `GAS_STIPEND_NO_GRIEF`.\n function forceSafeTransferETH(address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n if lt(selfbalance(), amount) {\n mstore(0x00, 0xb12d13eb) // `ETHTransferFailed()`.\n revert(0x1c, 0x04)\n }\n if iszero(call(GAS_STIPEND_NO_GRIEF, to, amount, codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, to) // Store the address in scratch space.\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\n if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\n }\n }\n }\n\n /// @dev Force sends all the ETH in the current contract to `to`, with `GAS_STIPEND_NO_GRIEF`.\n function forceSafeTransferAllETH(address to) internal {\n /// @solidity memory-safe-assembly\n assembly {\n // forgefmt: disable-next-item\n if iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)) {\n mstore(0x00, to) // Store the address in scratch space.\n mstore8(0x0b, 0x73) // Opcode `PUSH20`.\n mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.\n if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.\n }\n }\n }\n\n /// @dev Sends `amount` (in wei) ETH to `to`, with a `gasStipend`.\n function trySafeTransferETH(address to, uint256 amount, uint256 gasStipend)\n internal\n returns (bool success)\n {\n /// @solidity memory-safe-assembly\n assembly {\n success := call(gasStipend, to, amount, codesize(), 0x00, codesize(), 0x00)\n }\n }\n\n /// @dev Sends all the ETH in the current contract to `to`, with a `gasStipend`.\n function trySafeTransferAllETH(address to, uint256 gasStipend)\n internal\n returns (bool success)\n {\n /// @solidity memory-safe-assembly\n assembly {\n success := call(gasStipend, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC20 OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\n /// Reverts upon failure.\n ///\n /// The `from` account must have at least `amount` approved for\n /// the current contract to manage.\n function safeTransferFrom(address token, address from, address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x60, amount) // Store the `amount` argument.\n mstore(0x40, to) // Store the `to` argument.\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\n mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.\n // Perform the transfer, reverting upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\n call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\n )\n ) {\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\n revert(0x1c, 0x04)\n }\n mstore(0x60, 0) // Restore the zero slot to zero.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\n ///\n /// The `from` account must have at least `amount` approved for the current contract to manage.\n function trySafeTransferFrom(address token, address from, address to, uint256 amount)\n internal\n returns (bool success)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x60, amount) // Store the `amount` argument.\n mstore(0x40, to) // Store the `to` argument.\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\n mstore(0x0c, 0x23b872dd000000000000000000000000) // `transferFrom(address,address,uint256)`.\n success :=\n and( // The arguments of `and` are evaluated from right to left.\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\n call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\n )\n mstore(0x60, 0) // Restore the zero slot to zero.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /// @dev Sends all of ERC20 `token` from `from` to `to`.\n /// Reverts upon failure.\n ///\n /// The `from` account must have their entire balance approved for the current contract to manage.\n function safeTransferAllFrom(address token, address from, address to)\n internal\n returns (uint256 amount)\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Cache the free memory pointer.\n mstore(0x40, to) // Store the `to` argument.\n mstore(0x2c, shl(96, from)) // Store the `from` argument.\n mstore(0x0c, 0x70a08231000000000000000000000000) // `balanceOf(address)`.\n // Read the balance, reverting upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\n staticcall(gas(), token, 0x1c, 0x24, 0x60, 0x20)\n )\n ) {\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\n revert(0x1c, 0x04)\n }\n mstore(0x00, 0x23b872dd) // `transferFrom(address,address,uint256)`.\n amount := mload(0x60) // The `amount` is already at 0x60. We'll need to return it.\n // Perform the transfer, reverting upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\n call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)\n )\n ) {\n mstore(0x00, 0x7939f424) // `TransferFromFailed()`.\n revert(0x1c, 0x04)\n }\n mstore(0x60, 0) // Restore the zero slot to zero.\n mstore(0x40, m) // Restore the free memory pointer.\n }\n }\n\n /// @dev Sends `amount` of ERC20 `token` from the current contract to `to`.\n /// Reverts upon failure.\n function safeTransfer(address token, address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x14, to) // Store the `to` argument.\n mstore(0x34, amount) // Store the `amount` argument.\n mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\n // Perform the transfer, reverting upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n )\n ) {\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\n revert(0x1c, 0x04)\n }\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\n }\n }\n\n /// @dev Sends all of ERC20 `token` from the current contract to `to`.\n /// Reverts upon failure.\n function safeTransferAll(address token, address to) internal returns (uint256 amount) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, 0x70a08231) // Store the function selector of `balanceOf(address)`.\n mstore(0x20, address()) // Store the address of the current contract.\n // Read the balance, reverting upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\n staticcall(gas(), token, 0x1c, 0x24, 0x34, 0x20)\n )\n ) {\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\n revert(0x1c, 0x04)\n }\n mstore(0x14, to) // Store the `to` argument.\n amount := mload(0x34) // The `amount` is already at 0x34. We'll need to return it.\n mstore(0x00, 0xa9059cbb000000000000000000000000) // `transfer(address,uint256)`.\n // Perform the transfer, reverting upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n )\n ) {\n mstore(0x00, 0x90b8ec18) // `TransferFailed()`.\n revert(0x1c, 0x04)\n }\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\n }\n }\n\n /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.\n /// Reverts upon failure.\n function safeApprove(address token, address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x14, to) // Store the `to` argument.\n mstore(0x34, amount) // Store the `amount` argument.\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\n // Perform the approval, reverting upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n )\n ) {\n mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.\n revert(0x1c, 0x04)\n }\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\n }\n }\n\n /// @dev Sets `amount` of ERC20 `token` for `to` to manage on behalf of the current contract.\n /// If the initial attempt to approve fails, attempts to reset the approved amount to zero,\n /// then retries the approval again (some tokens, e.g. USDT, requires this).\n /// Reverts upon failure.\n function safeApproveWithRetry(address token, address to, uint256 amount) internal {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x14, to) // Store the `to` argument.\n mstore(0x34, amount) // Store the `amount` argument.\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\n // Perform the approval, retrying upon failure.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n )\n ) {\n mstore(0x34, 0) // Store 0 for the `amount`.\n mstore(0x00, 0x095ea7b3000000000000000000000000) // `approve(address,uint256)`.\n pop(call(gas(), token, 0, 0x10, 0x44, codesize(), 0x00)) // Reset the approval.\n mstore(0x34, amount) // Store back the original `amount`.\n // Retry the approval, reverting upon failure.\n if iszero(\n and(\n or(eq(mload(0x00), 1), iszero(returndatasize())), // Returned 1 or nothing.\n call(gas(), token, 0, 0x10, 0x44, 0x00, 0x20)\n )\n ) {\n mstore(0x00, 0x3e3f8f73) // `ApproveFailed()`.\n revert(0x1c, 0x04)\n }\n }\n mstore(0x34, 0) // Restore the part of the free memory pointer that was overwritten.\n }\n }\n\n /// @dev Returns the amount of ERC20 `token` owned by `account`.\n /// Returns zero if the `token` does not exist.\n function balanceOf(address token, address account) internal view returns (uint256 amount) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x14, account) // Store the `account` argument.\n mstore(0x00, 0x70a08231000000000000000000000000) // `balanceOf(address)`.\n amount :=\n mul( // The arguments of `mul` are evaluated from right to left.\n mload(0x20),\n and( // The arguments of `and` are evaluated from right to left.\n gt(returndatasize(), 0x1f), // At least 32 bytes returned.\n staticcall(gas(), token, 0x10, 0x24, 0x20, 0x20)\n )\n )\n }\n }\n\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to`.\n /// If the initial attempt fails, try to use Permit2 to transfer the token.\n /// Reverts upon failure.\n ///\n /// The `from` account must have at least `amount` approved for the current contract to manage.\n function safeTransferFrom2(address token, address from, address to, uint256 amount) internal {\n if (!trySafeTransferFrom(token, from, to, amount)) {\n permit2TransferFrom(token, from, to, amount);\n }\n }\n\n /// @dev Sends `amount` of ERC20 `token` from `from` to `to` via Permit2.\n /// Reverts upon failure.\n function permit2TransferFrom(address token, address from, address to, uint256 amount)\n internal\n {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n mstore(add(m, 0x74), shr(96, shl(96, token)))\n mstore(add(m, 0x54), amount)\n mstore(add(m, 0x34), to)\n mstore(add(m, 0x20), shl(96, from))\n // `transferFrom(address,address,uint160,address)`.\n mstore(m, 0x36c78516000000000000000000000000)\n let p := PERMIT2\n let exists := eq(chainid(), 1)\n if iszero(exists) { exists := iszero(iszero(extcodesize(p))) }\n if iszero(and(call(gas(), p, 0, add(m, 0x10), 0x84, codesize(), 0x00), exists)) {\n mstore(0x00, 0x7939f4248757f0fd) // `TransferFromFailed()` or `Permit2AmountOverflow()`.\n revert(add(0x18, shl(2, iszero(iszero(shr(160, amount))))), 0x04)\n }\n }\n }\n\n /// @dev Permit a user to spend a given amount of\n /// another user's tokens via native EIP-2612 permit if possible, falling\n /// back to Permit2 if native permit fails or is not implemented on the token.\n function permit2(\n address token,\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n bool success;\n /// @solidity memory-safe-assembly\n assembly {\n for {} shl(96, xor(token, WETH9)) {} {\n mstore(0x00, 0x3644e515) // `DOMAIN_SEPARATOR()`.\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n lt(iszero(mload(0x00)), eq(returndatasize(), 0x20)), // Returns 1 non-zero word.\n // Gas stipend to limit gas burn for tokens that don't refund gas when\n // an non-existing function is called. 5K should be enough for a SLOAD.\n staticcall(5000, token, 0x1c, 0x04, 0x00, 0x20)\n )\n ) { break }\n // After here, we can be sure that token is a contract.\n let m := mload(0x40)\n mstore(add(m, 0x34), spender)\n mstore(add(m, 0x20), shl(96, owner))\n mstore(add(m, 0x74), deadline)\n if eq(mload(0x00), DAI_DOMAIN_SEPARATOR) {\n mstore(0x14, owner)\n mstore(0x00, 0x7ecebe00000000000000000000000000) // `nonces(address)`.\n mstore(add(m, 0x94), staticcall(gas(), token, 0x10, 0x24, add(m, 0x54), 0x20))\n mstore(m, 0x8fcbaf0c000000000000000000000000) // `IDAIPermit.permit`.\n // `nonces` is already at `add(m, 0x54)`.\n // `1` is already stored at `add(m, 0x94)`.\n mstore(add(m, 0xb4), and(0xff, v))\n mstore(add(m, 0xd4), r)\n mstore(add(m, 0xf4), s)\n success := call(gas(), token, 0, add(m, 0x10), 0x104, codesize(), 0x00)\n break\n }\n mstore(m, 0xd505accf000000000000000000000000) // `IERC20Permit.permit`.\n mstore(add(m, 0x54), amount)\n mstore(add(m, 0x94), and(0xff, v))\n mstore(add(m, 0xb4), r)\n mstore(add(m, 0xd4), s)\n success := call(gas(), token, 0, add(m, 0x10), 0xe4, codesize(), 0x00)\n break\n }\n }\n if (!success) simplePermit2(token, owner, spender, amount, deadline, v, r, s);\n }\n\n /// @dev Simple permit on the Permit2 contract.\n function simplePermit2(\n address token,\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40)\n mstore(m, 0x927da105) // `allowance(address,address,address)`.\n {\n let addressMask := shr(96, not(0))\n mstore(add(m, 0x20), and(addressMask, owner))\n mstore(add(m, 0x40), and(addressMask, token))\n mstore(add(m, 0x60), and(addressMask, spender))\n mstore(add(m, 0xc0), and(addressMask, spender))\n }\n let p := mul(PERMIT2, iszero(shr(160, amount)))\n if iszero(\n and( // The arguments of `and` are evaluated from right to left.\n gt(returndatasize(), 0x5f), // Returns 3 words: `amount`, `expiration`, `nonce`.\n staticcall(gas(), p, add(m, 0x1c), 0x64, add(m, 0x60), 0x60)\n )\n ) {\n mstore(0x00, 0x6b836e6b8757f0fd) // `Permit2Failed()` or `Permit2AmountOverflow()`.\n revert(add(0x18, shl(2, iszero(p))), 0x04)\n }\n mstore(m, 0x2b67b570) // `Permit2.permit` (PermitSingle variant).\n // `owner` is already `add(m, 0x20)`.\n // `token` is already at `add(m, 0x40)`.\n mstore(add(m, 0x60), amount)\n mstore(add(m, 0x80), 0xffffffffffff) // `expiration = type(uint48).max`.\n // `nonce` is already at `add(m, 0xa0)`.\n // `spender` is already at `add(m, 0xc0)`.\n mstore(add(m, 0xe0), deadline)\n mstore(add(m, 0x100), 0x100) // `signature` offset.\n mstore(add(m, 0x120), 0x41) // `signature` length.\n mstore(add(m, 0x140), r)\n mstore(add(m, 0x160), s)\n mstore(add(m, 0x180), shl(248, v))\n if iszero(call(gas(), p, 0, add(m, 0x1c), 0x184, codesize(), 0x00)) {\n mstore(0x00, 0x6b836e6b) // `Permit2Failed()`.\n revert(0x1c, 0x04)\n }\n }\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 2000 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file