Address Contract Partially Verified
Address
0x0AeDcbc2c4B176c6895556acCC91aD39e27b601d
Balance
0 ETH
Nonce
1
Code Size
12073 bytes
Creator
0x49480b87...FB53 at tx 0x73624bf1...974c0e
Indexed Transactions
0
Contract Bytecode
12073 bytes
0x6080806040526004361015610012575f80fd5b5f3560e01c90816306fdde03146125f057508063095ea7b3146125ca5780631019c69514611dee57806318160ddd14611dd157806322f7003c14611d9457806323b872dd14611cdb5780632ba29d3814611cb35780632cc4721114611c84578063313ce56714611c6957806338a6318314611c415780633950935114611bf45780634334614a14611bb757806346fbf68e14611b7a5780635976362814611b0e5780635c975abb14611aec5780636e317da714611a6e57806370a0823114611a365780638408f1be146113c75780638671d23b146111ce5780638d068043146111b357806395d89b41146110d8578063a457c2d714611035578063a9059cbb14611004578063aa271e1a14610fc7578063b147a4f514610fac578063b79c22941461089e578063d051665014610861578063dbac26e914610824578063dd62ed3e146107d7578063f851a440146107af5763fc905acf14610171575f80fd5b346107ab576101203660031901126107ab5761018b6126d7565b6101936126ed565b600e60443510156107ab573660e4116107ab5767ffffffffffffffff60e435116107ab5736606460e43501116107ab576084356001600160a01b038116908190036107ab5760c4356001600160a01b038116908190036107ab576101f8911415612c40565b610104355f52609c60205261021460ff60405f20541615612c85565b610104355f52609c60205260405f20600160ff19825416179055335f5260a060205260ff60405f20541615610799575f5b600360ff82161015610419576001600160a01b0361026d61026860ff8416612ba2565b612b1c565b165f5260a060205260ff60405f205416156103c55760ff81161515806103d7575b6103c5576102a161026860ff8316612ba2565b600e60443510156103b15760206102c060ff841660e435600401612bc5565b6040516336cb86cd60e21b81526001600160a01b039485166004820152878516602482015293861660448086019190915260648035908601523560ff166084850152610104803560a48601524660c486015261010060e48601528492839261032a92840191612c20565b03817372e0b96288822c745ca0a7d41b53dc96d16a34e35af49081156103a6575f91610377575b50156103655761036090612bb4565b610245565b60405163d25a94b160e01b8152600490fd5b610399915060203d60201161039f575b610391818361276d565b810190612c08565b5f610351565b503d610387565b6040513d5f823e3d90fd5b634e487b7160e01b5f52602160045260245ffd5b604051631cbf9e4760e11b8152600490fd5b506103e761026860ff8316612ba2565b6001600160a01b0361040661026860ff61040086612cc0565b16612ba2565b6001600160a01b0390921691161461028e565b50600e60443510156103b1576044356002036104d9576001600160a01b0382165f908152609a602052604090205460ff1680156104c6575b156104b4576001600160a01b03166104a25761046f60643582612cd2565b606435906001600160a01b03167f1b560ad975f2a2685fce792af7ad191c5f1c0bfbbf108c676319be3ccb014ddf5f80a3005b60405163f278082f60e01b8152600490fd5b60405163bd8d2d8560e01b8152600490fd5b50609b60205260ff60405f205416610451565b604435600703610582576001600160a01b0382165f908152609a602052604090205460ff16801561056f575b156104b4576001600160a01b0381161561055d57610526606435828461279c565b6001600160a01b039081169160643591167f5a592536e075e29026312219123e24de374314962469686d4c992d3c7292c1b45f80a4005b604051630930907b60e01b8152600490fd5b50609b60205260ff60405f205416610505565b50604435600403610605576001600160a01b0381165f908152609a602052604090205460ff166105f3576001600160a01b03165f818152609a60205260408120805460ff191660011790557f571f7b497ee6f6b62bf6238259f34ef72ad585355587cf9feed80bb4a2b5ce939080a2005b604051632ef7ce2960e01b8152600490fd5b604435600303610687576001600160a01b0381165f908152609b602052604090205460ff16610675576001600160a01b03165f818152609b60205260408120805460ff191660011790557f4f2a367e694e71282f29ab5eaa04c4c0be45ac5bf2ca74fb67068b98bdc2887d9080a2005b60405163e28969cf60e01b8152600490fd5b604435600603610707576001600160a01b0381165f908152609b602052604090205460ff16156106f5576001600160a01b03165f818152609b60205260408120805460ff191690557ff915cd9fe234de6e8d3afe7bf2388d35b2b6d48e8c629a24602019bde79c213a9080a2005b60405163156ba8cd60e21b8152600490fd5b604435600503610787576001600160a01b0381165f908152609a602052604090205460ff1615610775576001600160a01b03165f818152609a60205260408120805460ff191690557f129586f509bc9e1d64c9e837fe75b9fe85ea015e22bef0ef5df82eda27e1e23e9080a2005b604051630564904f60e21b8152600490fd5b6040516393b8569d60e01b8152600490fd5b60405163485955ff60e01b8152600490fd5b5f80fd5b346107ab575f3660031901126107ab576098546040516001600160a01b039091168152602090f35b346107ab5760403660031901126107ab576107f06126d7565b6107f86126ed565b9060018060a01b038091165f52603460205260405f2091165f52602052602060405f2054604051908152f35b346107ab5760203660031901126107ab576001600160a01b036108456126d7565b165f52609a602052602060ff60405f2054166040519015158152f35b346107ab5760203660031901126107ab576001600160a01b036108826126d7565b165f52609b602052602060ff60405f2054166040519015158152f35b346107ab576101003660031901126107ab576108b86126d7565b6108c06126ed565b90600e60443510156107ab573660c4116107ab5767ffffffffffffffff60e435116107ab5736606460e43501116107ab576001600160a01b0382161561055d576001600160a01b03818116908316146107875761091b612af0565b6001600160a01b0361092b612b06565b6001600160a01b039092169116146103c55760c4355f52609c60205260ff60405f2054166107875760c4355f908152609c60205260408120805460ff1916600117905591604435600a03610e9c576001600160a01b0382165f908152609d602052604090205460ff1615610e8a576001600160a01b0381165f908152609d602052604090205460ff16610e78575b5f905b600360ff83161015610c1457836103b157604435600a03610b4c576001600160a01b036109ee61026860ff8516612b90565b165f52609d60205260ff60405f205416156103c5575b5f5b60ff811660ff8416811015610a5b57610a2461026860ff8616612b90565b906001600160a01b0390610a3b9061026890612b90565b6001600160a01b039092169116146103c557610a5690612bb4565b610a06565b50509083610a6e61026860ff8416612b90565b906103b1576020610a8760ff841660e435600401612bc5565b6040516336cb86cd60e21b81526001600160a01b03948516600482015287851660248201529386166044808601919091525f60648601523560ff16608485015260c4803560a4860152469085015261010060e485015283918291610af19161010484019190612c20565b03817372e0b96288822c745ca0a7d41b53dc96d16a34e35af49081156103a6575f91610b2d575b501561036557610b2790612bb4565b906109bc565b610b46915060203d60201161039f57610391818361276d565b85610b18565b5f9350604435600b03610b8b576001600160a01b03610b7061026860ff8516612b90565b165f52609e60205260ff60405f205416156103c5575b610a04565b5f9350604435600c03610bc9576001600160a01b03610baf61026860ff8516612b90565b165f52609f60205260ff60405f205416156103c557610a04565b5f9350600c1960443501610b86576001600160a01b03610bee61026860ff8516612b90565b165f5260a060205260ff60405f205416610b8657604051631cbf9e4760e11b8152600490fd5b90508260018060a01b0382165f52609a60205260ff60405f205416610e66576001600160a01b0382165f908152609b602052604090205460ff16610e54576103b157604435600a03610cd557335f52609d60205260ff60405f20541615610799576001600160a01b039182165f818152609d6020526040808220805460ff19908116909155939094168082529381208054909316600117909255907fcba8b2f67b1b66244252c443e6260110af641687bcceb46c810da702119ec8289080a3005b604435600b03610d5457335f52609e60205260ff60405f20541615610799576001600160a01b039182165f818152609e6020526040808220805460ff19908116909155939094168082529381208054909316600117909255907fe0bc402ba4e6308bc9c5a36eb3149531532f300c90adf7c8d5c2d310b944f9629080a3005b604435600c03610dd357335f52609f60205260ff60405f20541615610799576001600160a01b039182165f818152609f6020526040808220805460ff19908116909155939094168082529381208054909316600117909255907ffdfd76ae7390cd422954eda195c5267a7b6c1b93086e198cd63a604696c6708d9080a3005b600d60443514610ddf57005b335f5260a060205260ff60405f20541615610799576001600160a01b039182165f81815260a06020526040808220805460ff19908116909155939094168082529381208054909316600117909255907f1e7beb57c07b861ad7bbf43582c52c3c319f947d0ab6cc6e7a759d41c15b37d79080a3005b604051631d4d2e1b60e31b8152600490fd5b60405163097a232760e41b8152600490fd5b604051635ca61a5560e01b8152600490fd5b60405163301888b560e01b8152600490fd5b5f9250604435600b03610eee576001600160a01b0382165f908152609e602052604090205460ff1615610e8a576001600160a01b0381165f908152609e602052604090205460ff16610e78575b6109b9565b5f9250604435600c03610f4d576001600160a01b0382165f908152609f602052604090205460ff1615610e8a576001600160a01b0381165f908152609f602052604090205460ff16156109b957604051635ca61a5560e01b8152600490fd5b5f9250604435600d03610787576001600160a01b0382165f90815260a0602052604090205460ff1615610e8a576001600160a01b0381165f90815260a0602052604090205460ff1615610ee957604051635ca61a5560e01b8152600490fd5b346107ab575f3660031901126107ab57602060405160048152f35b346107ab5760203660031901126107ab576001600160a01b03610fe86126d7565b165f52609d602052602060ff60405f2054166040519015158152f35b346107ab5760403660031901126107ab5761102a6110206126d7565b602435903361279c565b602060405160018152f35b346107ab5760403660031901126107ab5761104e6126d7565b60243590335f52603460205260405f2060018060a01b0382165f5260205260405f2054918083106110855761102a92039033612994565b60405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608490fd5b346107ab575f3660031901126107ab576040515f6037546110f881612719565b8084529060019081811690811561118c5750600114611132575b61112e846111228186038261276d565b60405191829182612690565b0390f35b60375f90815292507f42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae5b82841061117457505050810160200161112282611112565b8054602085870181019190915290930192810161115c565b60ff191660208087019190915292151560051b850190920192506111229150839050611112565b346107ab575f3660031901126107ab57602060405160038152f35b346107ab5760603660031901126107ab576004356001600160a01b03818116918290036107ab5760243590611201612703565b8160995416330361079957831561055d5782156113b5571691821561055d57825f526020609a815260ff60405f205416610e665760405181810163a9059cbb60e01b815285602483015284604483015260448252608082019067ffffffffffffffff9280831084841117611394575f9182918460405261128085612751565b8685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460a0820152519082885af1913d156113a8573d908111611394576112e892604051916112d986601f19601f840116018461276d565b82523d5f8684013e5b85612e5e565b80519082821592831561137c575b5050501561132557507f16fdc9425c0d3fa4cb9f0bfc60771e70fb89e4589a3fb8abab308e823308efe65f80a4005b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b61138c9350820181019101612c08565b8582816112f6565b634e487b7160e01b5f52604160045260245ffd5b506112e8916060906112e2565b604051631411ba7760e21b8152600490fd5b346107ab576101003660031901126107ab576113e16126d7565b600e60443510156107ab573660c4116107ab5767ffffffffffffffff60c435116107ab5736606460c43501116107ab5761144061141c612af0565b6001600160a01b0361142c612b06565b6001600160a01b0390921691161415612c40565b60e4355f52609c60205261145b60ff60405f20541615612c85565b60e4355f52609c60205260405f20600160ff198254161790555f90600160443514611a0f575b5f5b600360ff821610156116aa57826103b15760443561160a576001600160a01b036114b261026860ff8416612b90565b165f52609d60205260ff60405f205416156103c5575b60ff81161515806115c8575b6103c557826114e861026860ff8416612b90565b906103b157602061150160ff841660c435600401612bc5565b6040516336cb86cd60e21b81526001600160a01b0394851660048201529386166024808601919091525f604480870191909152903560648601523560ff16608485015260e4803560a48601524660c4860152610100908501528391829161156e9161010484019190612c20565b03817372e0b96288822c745ca0a7d41b53dc96d16a34e35af49081156103a6575f916115a9575b5015610365576115a490612bb4565b611483565b6115c2915060203d60201161039f57610391818361276d565b84611595565b506115d861026860ff8316612b90565b6001600160a01b036115f761026860ff6115f186612cc0565b16612b90565b6001600160a01b039092169116146114d4565b5f9250604435600103611649576001600160a01b0361162e61026860ff8416612b90565b165f52609e60205260ff60405f205416156103c5575b6114c8565b5f9250604435600814801561169b575b156114c8576001600160a01b0361167561026860ff8416612b90565b165f52609f60205260ff60405f20541661164457604051631cbf9e4760e11b8152600490fd5b505f9250604435600914611659565b50906103b15760443561187857335f52609d60205260ff60405f20541615610799576001600160a01b0381161561183357335f5260a060205260ff60405f205416156117be575b6001600160a01b0381165f908152609a602052604090205460ff16610e665760ff606554166117ac5761172860243560355461278f565b6035556001600160a01b0381165f818152603360209081526040808320805460243590810190915590519081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a3602435906001600160a01b03167f3f2c9d57c068687834f0de942a9babb9e5acab57d516d3480a3c16ee165a42735f80a3005b6040516321b1d79d60e21b8152600490fd5b5f8052609a6020527fbe6620bd3346e5d7f8387fbec0981aa0d6289d22efa7c935f9ef6841bf2a98c75460ff16610e66575f8052609b6020527f10afac9233b4ccc54d6404ffc1cf3b47515a2b8edbf675d15eddce05a027dcbd5460ff16156116f157604051631d4d2e1b60e31b8152600490fd5b60405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606490fd5b506044356001036118da57335f52609e60205260ff60405f20541615610799576097546118b190602435906001600160a01b0316612cd2565b6024357f3db896db0b7a2f53b4a4550f52efed13d6733eb1b099bbd99c3b74c3b90e97475f80a2005b6044356008145f818015611a01575b1561078757335f52609f60205260ff60405f20541615610799576103b157156119865760655460ff811661194e5760019060ff1916176065557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b60655460ff8116156119c55760ff19166065557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b50505f6009604435146118e9565b6097546001600160a01b0382811691161461148157604051631bd81ca160e31b8152600490fd5b346107ab5760203660031901126107ab576001600160a01b03611a576126d7565b165f526033602052602060405f2054604051908152f35b346107ab5760203660031901126107ab576001600160a01b0380611a906126d7565b1690811561055d57609854163303611ada57609780546001600160a01b031916821790557ff8aa9f66564d7b9dddf65c8ed3a5ad8e33c35b56665bd51c91a2d1d4d44859385f80a2005b6040516352fbc11f60e11b8152600490fd5b346107ab575f3660031901126107ab57602060ff606554166040519015158152f35b346107ab5760203660031901126107ab576001600160a01b0380611b306126d7565b1690811561055d57609854163303611ada57609980546001600160a01b031916821790557f4ec27e43a81e2b38375c5f060c9a661f938179a2d7a33737588b9e428854f9485f80a2005b346107ab5760203660031901126107ab576001600160a01b03611b9b6126d7565b165f52609f602052602060ff60405f2054166040519015158152f35b346107ab5760203660031901126107ab576001600160a01b03611bd86126d7565b165f52609e602052602060ff60405f2054166040519015158152f35b346107ab5760403660031901126107ab5761102a611c106126d7565b335f52603460205260405f2060018060a01b0382165f52602052611c3a60243560405f205461278f565b9033612994565b346107ab575f3660031901126107ab576099546040516001600160a01b039091168152602090f35b346107ab575f3660031901126107ab57602060405160128152f35b346107ab5760203660031901126107ab576004355f52609c602052602060ff60405f2054166040519015158152f35b346107ab575f3660031901126107ab576097546040516001600160a01b039091168152602090f35b346107ab5760603660031901126107ab57611cf46126d7565b611cfc6126ed565b6044359060018060a01b0383165f52603460205260405f20335f5260205260405f2054925f198403611d33575b61102a935061279c565b828410611d4f57611d4a8361102a95033383612994565b611d29565b60405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606490fd5b346107ab5760203660031901126107ab576001600160a01b03611db56126d7565b165f5260a0602052602060ff60405f2054166040519015158152f35b346107ab575f3660031901126107ab576020603554604051908152f35b346107ab576102603660031901126107ab57611e086126d7565b611e106126ed565b611e18612703565b3660e4116107ab5736610164116107ab57366101e4116107ab5736610264116107ab575f549260ff8460081c1615938480956125bd575b80156125a6575b1561254a5760ff1981166001175f5584612539575b506001600160a01b03169081158015612528575b8015612517575b61055d576001600160601b0360a01b9182609754161760975560018060a01b03831682609854161760985560018060a01b031690609954161760995560405191611ecf83612751565b601383527226a722a2902aa9a21029ba30b13632b1b7b4b760691b602084015260405191611efc83612751565b60048352634d4e454560e01b6020840152611f2660ff5f5460081c16611f2181612b30565b612b30565b835167ffffffffffffffff811161139457611f42603654612719565b601f81116124b4575b50602094601f8211600114612433579481929394955f92612428575b50508160011b915f199060031b1c1916176036555b825167ffffffffffffffff811161139457611f98603754612719565b601f81116123c5575b506020601f821160011461234457819293945f92612339575b50508160011b915f199060031b1c1916176037555b6001600160a01b0381165f818152609d602090815260408083208054600160ff199182168117909255609e84528285208054821683179055609f8452828520805482168317905560a090935290832080549092161790557fcba8b2f67b1b66244252c443e6260110af641687bcceb46c810da702119ec8288180a36001600160a01b0381165f7fe0bc402ba4e6308bc9c5a36eb3149531532f300c90adf7c8d5c2d310b944f9628180a36001600160a01b0381165f7ffdfd76ae7390cd422954eda195c5267a7b6c1b93086e198cd63a604696c6708d8180a36001600160a01b03165f7f1e7beb57c07b861ad7bbf43582c52c3c319f947d0ab6cc6e7a759d41c15b37d78180a35f5b60046001600160601b03821610156122fc576001600160a01b036121076102686001600160601b038416612a92565b165f908152609d60205260409020805460ff191660011790556001600160a01b0361213d6102686001600160601b038416612ab8565b165f908152609e60205260409020805460ff191660011790556001600160a01b036121736102686001600160601b038416612aca565b165f908152609f60205260409020805460ff191660011790556001600160a01b036121a96102686001600160601b038416612add565b165f90815260a060205260409020805460ff191660011790556001600160a01b036121df6102686001600160601b038416612a92565b165f7fcba8b2f67b1b66244252c443e6260110af641687bcceb46c810da702119ec8288180a36001600160a01b036122226102686001600160601b038416612ab8565b165f7fe0bc402ba4e6308bc9c5a36eb3149531532f300c90adf7c8d5c2d310b944f9628180a36001600160a01b036122656102686001600160601b038416612aca565b165f7ffdfd76ae7390cd422954eda195c5267a7b6c1b93086e198cd63a604696c6708d8180a36001600160a01b036122a86102686001600160601b038416612add565b165f7f1e7beb57c07b861ad7bbf43582c52c3c319f947d0ab6cc6e7a759d41c15b37d78180a36001600160601b0380808316146122e857166001016120d8565b634e487b7160e01b5f52601160045260245ffd5b5061230357005b61ff00195f54165f557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160018152a1005b015190508480611fba565b601f1982169060375f527f42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae915f5b8181106123ad57509583600195969710612395575b505050811b01603755611fcf565b01515f1960f88460031b161c19169055848080612387565b9192602060018192868b015181550194019201612372565b60375f527f42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae601f830160051c8101916020841061241e575b601f0160051c01905b8181106124135750611fa1565b5f8155600101612406565b90915081906123fd565b015190508580611f67565b601f1982169560365f527f4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b8915f5b88811061249c57508360019596979810612484575b505050811b01603655611f7c565b01515f1960f88460031b161c19169055858080612476565b91926020600181928685015181550194019201612461565b60365f527f4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b8601f830160051c8101916020841061250d575b601f0160051c01905b8181106125025750611f4b565b5f81556001016124f5565b90915081906124ec565b506001600160a01b03831615611e86565b506001600160a01b03811615611e7f565b61ffff1916610101175f5584611e6b565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b50303b158015611e565750600160ff821614611e56565b50600160ff821610611e4f565b346107ab5760403660031901126107ab5761102a6125e66126d7565b6024359033612994565b346107ab575f3660031901126107ab575f60365461260d81612719565b8084529060019081811690811561118c57506001146126365761112e846111228186038261276d565b60365f90815292507f4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b85b82841061267857505050810160200161112282611112565b80546020858701810191909152909301928101612660565b602080825282518183018190529093925f5b8281106126c357505060409293505f838284010152601f8019910116010190565b8181018601518482016040015285016126a2565b600435906001600160a01b03821682036107ab57565b602435906001600160a01b03821682036107ab57565b604435906001600160a01b03821682036107ab57565b90600182811c92168015612747575b602083101461273357565b634e487b7160e01b5f52602260045260245ffd5b91607f1691612728565b6040810190811067ffffffffffffffff82111761139457604052565b90601f8019910116810190811067ffffffffffffffff82111761139457604052565b919082018092116122e857565b6001600160a01b0390811691821561294157169182156128f0575f9033825260209160a0835260409060ff8282205416156128ba575b858152609a845260ff82822054166128a95760ff60655416612898578481526033845281812054838110612845579181847fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef969594888495526033875203828220558781522082815401905551908152a3565b825162461bcd60e51b815260048101869052602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608490fd5b81516321b1d79d60e21b8152600490fd5b815163097a232760e41b8152600490fd5b848152609a845260ff82822054166128a957848152609b845260ff8282205416156127d2578151631d4d2e1b60e31b8152600490fd5b60405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608490fd5b60405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608490fd5b6001600160a01b03908116918215612a4157169182156129f15760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591835f526034825260405f20855f5282528060405f2055604051908152a3565b60405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608490fd5b60405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b6004811015612aa45760051b60640190565b634e487b7160e01b5f52603260045260245ffd5b6004811015612aa45760051b60e40190565b6004811015612aa45760051b6101640190565b6004811015612aa45760051b6101e40190565b6064356001600160a01b03811681036107ab5790565b60a4356001600160a01b03811681036107ab5790565b356001600160a01b03811681036107ab5790565b15612b3757565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b6003811015612aa45760051b60640190565b6003811015612aa45760051b60840190565b60ff1660ff81146122e85760010190565b906003811015612aa45760051b81013590601e19813603018212156107ab57019081359167ffffffffffffffff83116107ab5760200182360381136107ab579190565b908160209103126107ab575180151581036107ab5790565b908060209392818452848401375f828201840152601f01601f1916010190565b15612c4757565b60405162461bcd60e51b81526020600482015260166024820152755369676e657273206d75737420626520756e6971756560501b6044820152606490fd5b15612c8c57565b60405162461bcd60e51b815260206004820152600c60248201526b125b9d985b1a59081d5d5a5960a21b6044820152606490fd5b60ff5f199116019060ff82116122e857565b6001600160a01b03168015612e0f575f9133835260209060a08252604060ff818620541615612dda575b848052609a835260ff8186205416612dca5760ff60655416612dba578385526033835280852054828110612d6b5790827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef949392868852603385520381872055816035540360355551908152a3565b815162461bcd60e51b815260048101859052602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608490fd5b516321b1d79d60e21b8152600490fd5b5163097a232760e41b8152600490fd5b838552609a835260ff8186205416612dca57838552609b835260ff818620541615612cfc5751631d4d2e1b60e31b8152600490fd5b60405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608490fd5b91929015612ec05750815115612e72575090565b3b15612e7b5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b825190915015612ed35750805190602001fd5b60405162461bcd60e51b8152908190612eef9060048301612690565b0390fdfea2646970667358221220345dd1be64d793a143a3a4a6c66b1693ea7b56e64aaf8a0c23da20d81ac27fb564736f6c63430008140033
Verified Source Code Partial Match
Compiler: v0.8.20+commit.a1b79de6
EVM: shanghai
Optimization: Yes (200 runs)
MNEEv2.sol 464 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "./SigningLibrary.sol";
/**
* @title MNEE USD Stablecoin – Implementation v1.1 (upgrade)
* @author Monkhub Innovations
*
* @notice
* ▸ Audit-hardened upgrade: fixes validator-set inflation in `replaceValidator`.
* ▸ **Storage layout is unchanged** from v1, therefore this contract is safe
* to deploy as a new implementation behind the existing UUPS / Transparent proxy.
*/
contract MNEE is Initializable, ERC20Upgradeable, PausableUpgradeable {
using SafeERC20 for IERC20;
/*════════════════════════════════ STATE ════════════════════════════════*/
address public redeemer;
uint8 public constant requiredSignatures = 3;
uint8 public constant roleHolders = 4;
address public admin;
address public rescuer;
mapping(address => bool) public blacklisted;
mapping(address => bool) public frozen;
mapping(bytes32 => bool) public instanceNonces;
mapping(address => bool) public isMinter;
mapping(address => bool) public isBurner;
mapping(address => bool) public isPauser;
mapping(address => bool) public isBlacklisterFreezer;
enum validatorRole {
minter,
burner,
pauser,
blacklister_freezer
}
/* Use enum index when signing */
enum functionType {
mint,
burn,
burnHoldings,
freeze,
blacklist,
delist,
unfreeze,
confiscate,
pause,
unpause,
changeMinter,
changeBurner,
changePauser,
changeBlacklisterFreezer
}
/*══════════════════════════════ EVENTS ════════════════════════════════*/
event TokensMinted(address indexed account, uint256 indexed amount);
event TokensBurnt(uint256 indexed amount);
event HoldingsBurnt(address indexed account, uint256 indexed amount);
event AccountFrozen(address indexed account);
event AccountUnfrozen(address indexed account);
event AccountBlacklisted(address indexed account);
event AccountDelisted(address indexed account);
event FundsConfiscated(
address indexed account,
uint256 indexed amount,
address indexed sentTo
);
event FundsRescued(
address indexed token,
uint256 indexed amount,
address indexed sentTo
);
event ChangeMinter(address indexed old, address indexed _new);
event ChangeBurner(address indexed old, address indexed _new);
event ChangePauser(address indexed old, address indexed _new);
event ChangeBlacklisterFreezer(address indexed old, address indexed _new);
event ChangeRedeemer(address indexed _new);
event ChangeRescuer(address indexed _new);
/*══════════════════════════════ ERRORS ════════════════════════════════*/
error zeroAddress();
error notZeroAddress();
error onlyAdmin();
error onlyCorrectValidator();
error invalidSigner();
error invalidSign();
error neitherBLnorF();
error blacklistedAddress();
error frozenAddress();
error BLorF();
error notBL();
error notF();
error tokenPaused();
error invalidAmt();
error wrongFunction();
/* NEW errors (byte-code only, no storage impact) */
error oldNotValidator();
error newAlreadyValidator();
error burnTargetMismatch();
error alreadyBlacklisted();
/*════════════════════════════ INITIALIZER ═════════════════════════════*/
function initialize(
address _redeemer,
address _admin,
address _rescuer,
address[roleHolders] calldata _minters,
address[roleHolders] calldata _burners,
address[roleHolders] calldata _pausers,
address[roleHolders] calldata _blacklisters_freezers
) public initializer {
if (
_redeemer == address(0) ||
_rescuer == address(0) ||
_admin == address(0)
) revert zeroAddress();
redeemer = _redeemer;
admin = _admin;
rescuer = _rescuer;
/* Validate array lengths match roleHolders constant */
if (
_minters.length != roleHolders ||
_burners.length != roleHolders ||
_pausers.length != roleHolders ||
_blacklisters_freezers.length != roleHolders
) revert wrongFunction();
__ERC20_init("MNEE USD Stablecoin", "MNEE");
/* Give admin every validator role */
isMinter[_admin] = true;
isBurner[_admin] = true;
isPauser[_admin] = true;
isBlacklisterFreezer[_admin] = true;
emit ChangeMinter(address(0), _admin);
emit ChangeBurner(address(0), _admin);
emit ChangePauser(address(0), _admin);
emit ChangeBlacklisterFreezer(address(0), _admin);
/* Set initial validator sets */
for (uint96 i = 0; i < _minters.length; i++) {
isMinter[_minters[i]] = true;
isBurner[_burners[i]] = true;
isPauser[_pausers[i]] = true;
isBlacklisterFreezer[_blacklisters_freezers[i]] = true;
emit ChangeMinter(address(0), _minters[i]);
emit ChangeBurner(address(0), _burners[i]);
emit ChangePauser(address(0), _pausers[i]);
emit ChangeBlacklisterFreezer(
address(0),
_blacklisters_freezers[i]
);
}
}
/*════════════════════════════ ADMIN SETTERS ═══════════════════════════*/
function changeRedeemer(address _newRedeemer) external {
if (_newRedeemer == address(0)) revert zeroAddress();
if (_msgSender() != admin) revert onlyAdmin();
redeemer = _newRedeemer;
emit ChangeRedeemer(_newRedeemer);
}
function changeRescuer(address _newrescuer) external {
if (_newrescuer == address(0)) revert zeroAddress();
if (_msgSender() != admin) revert onlyAdmin();
rescuer = _newrescuer;
emit ChangeRescuer(_newrescuer);
}
/*══════════════════════ VALIDATOR MANAGEMENT ════════════════════════*/
/**
* @dev Replaces an existing validator of a role with a new address.
* Requires `requiredSignatures` approvals by *current* validators
* of that same role.
*
* ── Audit fix ──
* Ensures `_old` **is** currently a validator for the role,
* and `_new` **is not** one already – preventing silent set inflation.
*/
function replaceValidator(
address _old,
address _new,
functionType fType,
address[requiredSignatures] calldata signers,
bytes32 instanceIdentifier,
bytes[requiredSignatures] calldata signatures
) external {
/* Basic sanity guards */
if (_new == address(0)) revert zeroAddress();
if (_old == _new) revert wrongFunction();
if (signers[0] == signers[2]) revert invalidSigner();
if (instanceNonces[instanceIdentifier]) revert wrongFunction();
instanceNonces[instanceIdentifier] = true;
/* Role-specific presence checks (── NEW) */
if (fType == functionType.changeMinter) {
if (!isMinter[_old]) revert oldNotValidator();
if (isMinter[_new]) revert newAlreadyValidator();
} else if (fType == functionType.changeBurner) {
if (!isBurner[_old]) revert oldNotValidator();
if (isBurner[_new]) revert newAlreadyValidator();
} else if (fType == functionType.changePauser) {
if (!isPauser[_old]) revert oldNotValidator();
if (isPauser[_new]) revert newAlreadyValidator();
} else if (fType == functionType.changeBlacklisterFreezer) {
if (!isBlacklisterFreezer[_old]) revert oldNotValidator();
if (isBlacklisterFreezer[_new]) revert newAlreadyValidator();
} else {
revert wrongFunction();
}
/* Validate each signer */
for (uint8 i = 0; i < requiredSignatures; i++) {
/* Must hold correct role */
if (fType == functionType.changeMinter) {
if (!isMinter[signers[i]]) revert invalidSigner();
} else if (fType == functionType.changeBurner) {
if (!isBurner[signers[i]]) revert invalidSigner();
} else if (fType == functionType.changePauser) {
if (!isPauser[signers[i]]) revert invalidSigner();
} else if (fType == functionType.changeBlacklisterFreezer) {
if (!isBlacklisterFreezer[signers[i]]) revert invalidSigner();
}
/* No duplicate signers */
for (uint8 j = 0; j < i; j++) {
if (signers[i] == signers[j]) revert invalidSigner();
}
/* Signature verification */
if (
!SigningLibrary.verify(
signers[i],
_old,
_new,
0,
uint8(fType),
instanceIdentifier,
block.chainid,
signatures[i]
)
) revert invalidSign();
}
/* Check if new address is blacklisted or frozen */
if (blacklisted[_new]) revert blacklistedAddress();
if (frozen[_new]) revert frozenAddress();
/* Role map updates */
if (fType == functionType.changeMinter) {
if (!isMinter[_msgSender()]) revert onlyCorrectValidator();
isMinter[_old] = false;
isMinter[_new] = true;
emit ChangeMinter(_old, _new);
} else if (fType == functionType.changeBurner) {
if (!isBurner[_msgSender()]) revert onlyCorrectValidator();
isBurner[_old] = false;
isBurner[_new] = true;
emit ChangeBurner(_old, _new);
} else if (fType == functionType.changePauser) {
if (!isPauser[_msgSender()]) revert onlyCorrectValidator();
isPauser[_old] = false;
isPauser[_new] = true;
emit ChangePauser(_old, _new);
} else if (fType == functionType.changeBlacklisterFreezer) {
if (!isBlacklisterFreezer[_msgSender()])
revert onlyCorrectValidator();
isBlacklisterFreezer[_old] = false;
isBlacklisterFreezer[_new] = true;
emit ChangeBlacklisterFreezer(_old, _new);
}
}
/*═════════════════════ CORE ROLE OPERATIONS (UNCHANGED) ══════════════*/
/**
* Mint, Burn (to `redeemer`), Pause, Unpause — requires 3 valid signatures
* from validators of the relevant role.
*
* Burns always deduct from `redeemer` (centralised redemption model).
* `_target` is used for mint operations and MUST equal `redeemer` for burns.
*/
function mintBurnPauseUnpause(
address _target,
uint256 _amount,
functionType fType,
address[requiredSignatures] calldata signers,
bytes[requiredSignatures] calldata signatures,
bytes32 instanceIdentifier
) external {
require(signers[0] != signers[2], "Signers must be unique");
require(!instanceNonces[instanceIdentifier], "Invalid uuid");
instanceNonces[instanceIdentifier] = true;
// For burns, target must equal redeemer
if (fType == functionType.burn) {
if (_target != redeemer) revert burnTargetMismatch();
}
for (uint8 i = 0; i < requiredSignatures; i++) {
if (fType == functionType.mint) {
if (!(isMinter[signers[i]])) revert invalidSigner();
} else if (fType == functionType.burn) {
if (!(isBurner[signers[i]])) revert invalidSigner();
} else if (
fType == functionType.pause || fType == functionType.unpause
) {
if (!(isPauser[signers[i]])) revert invalidSigner();
}
if (i > 0 && signers[i] == signers[i - 1]) revert invalidSigner();
if (
!SigningLibrary.verify(
signers[i],
_target,
address(0),
_amount,
uint8(fType),
instanceIdentifier,
block.chainid,
signatures[i]
)
) revert invalidSign();
}
if (fType == functionType.mint) {
if (!isMinter[_msgSender()]) revert onlyCorrectValidator();
_mint(_target, _amount);
emit TokensMinted(_target, _amount);
} else if (fType == functionType.burn) {
if (!isBurner[_msgSender()]) revert onlyCorrectValidator();
super._burn(redeemer, _amount);
emit TokensBurnt(_amount);
} else if (
fType == functionType.pause || fType == functionType.unpause
) {
if (!isPauser[_msgSender()]) revert onlyCorrectValidator();
if (fType == functionType.pause) super._pause();
else super._unpause();
} else {
revert wrongFunction();
}
}
/**
* Blacklist / Freeze / Confiscate / BurnHoldings — requires 3 signatures
* from blacklisterFreezer validators.
*/
function blacklisterFreezerOps(
address _address,
address _to,
functionType fType,
uint256 _amount,
address[requiredSignatures] calldata signers,
bytes[requiredSignatures] calldata signatures,
bytes32 instanceIdentifier
) external {
require(signers[0] != signers[2], "Signers must be unique");
require(!instanceNonces[instanceIdentifier], "Invalid uuid");
instanceNonces[instanceIdentifier] = true;
if (!isBlacklisterFreezer[_msgSender()]) revert onlyCorrectValidator();
for (uint8 i = 0; i < requiredSignatures; i++) {
if (!(isBlacklisterFreezer[signers[i]])) revert invalidSigner();
if (i > 0 && signers[i] == signers[i - 1]) revert invalidSigner();
if (
!SigningLibrary.verify(
signers[i],
_address,
_to,
_amount,
uint8(fType),
instanceIdentifier,
block.chainid,
signatures[i]
)
) revert invalidSign();
}
if (fType == functionType.burnHoldings) {
if (!(blacklisted[_address] || frozen[_address]))
revert neitherBLnorF();
if (_to != address(0)) revert notZeroAddress();
super._burn(_address, _amount);
emit HoldingsBurnt(_address, _amount);
} else if (fType == functionType.confiscate) {
if (!(blacklisted[_address] || frozen[_address]))
revert neitherBLnorF();
if (_to == address(0)) revert zeroAddress();
_transfer(_address, _to, _amount);
emit FundsConfiscated(_address, _amount, _to);
} else if (fType == functionType.blacklist) {
// A frozen address can still be blacklisted; only duplicate blacklist attempts revert
if (blacklisted[_address]) revert alreadyBlacklisted();
// it may be frozen; escalation from freeze → blacklist is allowed
blacklisted[_address] = true;
emit AccountBlacklisted(_address);
} else if (fType == functionType.freeze) {
if (frozen[_address]) revert BLorF();
frozen[_address] = true;
emit AccountFrozen(_address);
} else if (fType == functionType.unfreeze) {
if (!frozen[_address]) revert notF();
frozen[_address] = false;
emit AccountUnfrozen(_address);
} else if (fType == functionType.delist) {
if (!blacklisted[_address]) revert notBL();
blacklisted[_address] = false;
emit AccountDelisted(_address);
} else {
revert wrongFunction();
}
}
/*════════════════════════════ TOKEN RESCUE ════════════════════════════*/
function rescue(
IERC20 token,
uint256 _amount,
address _requester
) external {
if (rescuer != _msgSender()) revert onlyCorrectValidator();
if (address(token) == address(0)) revert zeroAddress();
if (_amount == 0) revert invalidAmt();
if (_requester == address(0)) revert zeroAddress();
// Check if requester is blacklisted
if (blacklisted[_requester]) revert blacklistedAddress();
token.safeTransfer(_requester, _amount);
emit FundsRescued(address(token), _amount, _requester);
}
/*══════════════════ TOKEN TRANSFER HOOK (UNCHANGED) ══════════════════*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override {
if (!isBlacklisterFreezer[msg.sender]) {
if (blacklisted[from]) revert blacklistedAddress();
if (frozen[from]) revert frozenAddress();
}
if (blacklisted[to]) revert blacklistedAddress();
if (paused()) revert tokenPaused();
super._beforeTokenTransfer(from, to, amount);
}
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
Initializable.sol 166 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}
ERC20Upgradeable.sol 377 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[45] private __gap;
}
PausableUpgradeable.sol 117 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
SigningLibrary.sol 109 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
/**
* @title Signing Library
* @author Monkhub Innovations
* @notice A signature library to use for signature generation and verification, using basic and versatile parameters
*/
library SigningLibrary {
function getMessageHash(
address target,
address target2,
uint256 amount,
uint8 functionType,
bytes32 instanceIdentifier,
uint256 chainId
) public pure returns (bytes32) {
return keccak256(abi.encodePacked(target, target2, amount, functionType, instanceIdentifier, chainId));
}
/**
* @dev Generates signing format for messageHash
* @param _messageHash messageHash from getMessageHash
*/
function getEthSignedMessageHash(
bytes32 _messageHash
) public pure returns (bytes32) {
/*
Signature is produced by signing a keccak256 hash with the following format:
"\x19Ethereum Signed Message\n" + len(msg) + msg
*/
return
keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
_messageHash
)
);
}
function verify(
address _signer,
address target,
address target2,
uint256 amount,
uint8 functionType,
bytes32 instanceIdentifier,
uint256 chainId,
bytes memory signature
) public pure returns (bool) {
bytes32 messageHash = getMessageHash(
target, target2, amount, functionType, instanceIdentifier, chainId
);
bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash);
return recoverSigner(ethSignedMessageHash, signature) == _signer;
}
// recoverSigner and splitSignature functions remain unchanged
/**
* @dev recovers signer from signature using signedMessageHash structure
*/
function recoverSigner(
bytes32 _ethSignedMessageHash,
bytes memory _signature
) public pure returns (address) {
(bytes32 r, bytes32 s, uint8 v) = splitSignature(_signature);
return ecrecover(_ethSignedMessageHash, v, r, s);
}
/**
* @dev splits signature into components
*/
function splitSignature(
bytes memory sig
) public pure returns (bytes32 r, bytes32 s, uint8 v) {
require(sig.length == 65, "invalid signature length");
assembly {
/*
First 32 bytes stores the length of the signature
add(sig, 32) = pointer of sig + 32
effectively, skips first 32 bytes of signature
mload(p) loads next 32 bytes starting at the memory address p into memory
*/
// first 32 bytes, after the length prefix
r := mload(add(sig, 32))
// second 32 bytes
s := mload(add(sig, 64))
// final byte (first byte of the next 32 bytes)
v := byte(0, mload(add(sig, 96)))
}
// implicitly return (r, s, v)
}
}
IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
AddressUpgradeable.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
IERC20Upgradeable.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
IERC20MetadataUpgradeable.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
ContextUpgradeable.sol 37 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
Read Contract
admin 0xf851a440 → address
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
blacklisted 0xdbac26e9 → bool
decimals 0x313ce567 → uint8
frozen 0xd0516650 → bool
instanceNonces 0x2cc47211 → bool
isBlacklisterFreezer 0x22f7003c → bool
isBurner 0x4334614a → bool
isMinter 0xaa271e1a → bool
isPauser 0x46fbf68e → bool
name 0x06fdde03 → string
paused 0x5c975abb → bool
redeemer 0x2ba29d38 → address
requiredSignatures 0x8d068043 → uint8
rescuer 0x38a63183 → address
roleHolders 0xb147a4f5 → uint8
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
blacklisterFreezerOps 0xfc905acf
address _address
address _to
uint8 fType
uint256 _amount
address[3] signers
bytes[3] signatures
bytes32 instanceIdentifier
changeRedeemer 0x6e317da7
address _newRedeemer
changeRescuer 0x59763628
address _newrescuer
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
initialize 0x1019c695
address _redeemer
address _admin
address _rescuer
address[4] _minters
address[4] _burners
address[4] _pausers
address[4] _blacklisters_freezers
mintBurnPauseUnpause 0x8408f1be
address _target
uint256 _amount
uint8 fType
address[3] signers
bytes[3] signatures
bytes32 instanceIdentifier
replaceValidator 0xb79c2294
address _old
address _new
uint8 fType
address[3] signers
bytes32 instanceIdentifier
bytes[3] signatures
rescue 0x8671d23b
address token
uint256 _amount
address _requester
transfer 0xa9059cbb
address to
uint256 amount
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 amount
returns: bool
Recent Transactions
No transactions found for this address