Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0x27fa4c5299022896cd9dB3B194ce66f6bCE004Cb
Balance 0 ETH
Nonce 1
Code Size 13576 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

13576 bytes
0x60806040526004361061019a5760003560e01c806380f288c4116100e1578063a6afeb421161008a578063de86b45b11610064578063de86b45b14610552578063e3ed417314610572578063f23a6e6114610592578063f2fde38b146105d857600080fd5b8063a6afeb42146104ca578063bc197c81146104ea578063d9caed121461053257600080fd5b806388c344fa116100bb57806388c344fa146104555780638da5cb5b14610475578063904a205a146104aa57600080fd5b806380f288c4146103f55780638134245714610415578063887268de1461043557600080fd5b80634782f779116101435780635c6f6c211161011d5780635c6f6c2114610326578063715018a61461034657806379502c551461035b57600080fd5b80634782f779146102d357806347e7ef24146102f35780635358fbda1461031357600080fd5b80631626ba7e116101745780631626ba7e146102735780632d2dcc4814610293578063355007f9146102b357600080fd5b806301ffc9a7146101a657806306948316146101db578063150b7a02146101fd57600080fd5b366101a157005b600080fd5b3480156101b257600080fd5b506101c66101c13660046129dc565b6105f8565b60405190151581526020015b60405180910390f35b3480156101e757600080fd5b506101fb6101f6366004612a1b565b610691565b005b34801561020957600080fd5b50610242610218366004612aa3565b7f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016101d2565b34801561027f57600080fd5b5061024261028e366004612b16565b6108aa565b34801561029f57600080fd5b506101fb6102ae366004612b62565b6109fd565b3480156102bf57600080fd5b506101fb6102ce366004612b7f565b610a81565b3480156102df57600080fd5b506101fb6102ee366004612bc0565b610ca6565b3480156102ff57600080fd5b506101fb61030e366004612bc0565b610e16565b6101fb610321366004612bec565b610f2e565b34801561033257600080fd5b506101fb610341366004612c4a565b610fea565b34801561035257600080fd5b506101fb611216565b34801561036757600080fd5b506002546003546004546103b39273ffffffffffffffffffffffffffffffffffffffff908116928116919081169074010000000000000000000000000000000000000000900460ff1684565b6040516101d2949392919073ffffffffffffffffffffffffffffffffffffffff9485168152928416602084015292166040820152901515606082015260800190565b34801561040157600080fd5b506101fb610410366004612cdf565b61122a565b34801561042157600080fd5b506101fb610430366004612f6c565b6113f1565b34801561044157600080fd5b506101fb610450366004613060565b6115cb565b34801561046157600080fd5b506101fb610470366004612bc0565b61164e565b34801561048157600080fd5b5060015460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101d2565b3480156104b657600080fd5b506101fb6104c5366004612b62565b6117e6565b3480156104d657600080fd5b506101fb6104e536600461307d565b611863565b3480156104f657600080fd5b506102426105053660046130cc565b7fbc197c810000000000000000000000000000000000000000000000000000000098975050505050505050565b34801561053e57600080fd5b506101fb61054d366004612b7f565b611989565b34801561055e57600080fd5b506101fb61056d36600461318b565b611b19565b34801561057e57600080fd5b506101fb61058d366004612b62565b611cd9565b34801561059e57600080fd5b506102426105ad3660046131c0565b7ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b3480156105e457600080fd5b506101fb6105f3366004612b62565b611d56565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e000000000000000000000000000000000000000000000000000000000148061068b57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b600260005403610702576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260005560035473ffffffffffffffffffffffffffffffffffffffff163314610758576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff84166107a5576040517f44d99fea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517ff242432a00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8581166024830152604482018490526064820183905260a06084830152600060a483015284169063f242432a9060c401600060405180830381600087803b15801561083057600080fd5b505af1158015610844573d6000803e3d6000fd5b5050604080518581526020810185905273ffffffffffffffffffffffffffffffffffffffff80881694508816925033917fc4d86acceb93756cc872680b8326307ac5727a6afe973f1bbb473d2fde51e678910160405180910390a4505060016000555050565b60008060006108ef8686868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611e0d92505050565b909250905060008160048111156109085761090861322a565b1461093857507fffffffff0000000000000000000000000000000000000000000000000000000091506109f69050565b60015473ffffffffffffffffffffffffffffffffffffffff838116911614806109a0575060045474010000000000000000000000000000000000000000900460ff1680156109a0575060045473ffffffffffffffffffffffffffffffffffffffff8381169116145b156109d057507f1626ba7e0000000000000000000000000000000000000000000000000000000091506109f69050565b507fffffffff000000000000000000000000000000000000000000000000000000009150505b9392505050565b610a05611e52565b600480547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff831690811790915560405190815233907f605c2dbf762e5f7d60a546d42e7205dcb1b011ebc62a61736a57c9089d3a4350906020015b60405180910390a250565b600260005403610aed576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560035473ffffffffffffffffffffffffffffffffffffffff163314610b43576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316610b90576040517f44d99fea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8481166024830152604482018390528316906342842e0e90606401600060405180830381600087803b158015610c0657600080fd5b505af1158015610c1a573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f54789674de495cad7d8be412a7be3020d5655b17b0e9a6d5760beaca3486714d84604051610c9491815260200190565b60405180910390a45050600160005550565b600260005403610d12576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560035473ffffffffffffffffffffffffffffffffffffffff163314610d68576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8216610db5576040517f44d99fea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610dbf8282611ed3565b60405181815273ffffffffffffffffffffffffffffffffffffffff83169033907f68f3f01094d76436d2b40073d16523c89b1033e2d5af5c9210fbc8cf8c8b222c906020015b60405180910390a350506001600055565b600260005403610e82576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560035473ffffffffffffffffffffffffffffffffffffffff163314610ed8576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ee482333084612032565b60405181815273ffffffffffffffffffffffffffffffffffffffff83169033907ff1444b5cad7ce70cb018d1b8edc8618fe303f3c7f034d8d572a6e27facbf2bef90602001610e05565b60035473ffffffffffffffffffffffffffffffffffffffff163314610f7f576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b803414610fb8576040517fd2ade55600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60405181815233907f6c703791f399558807424f489ccd811c72b4ff0b74af547264fad7c646776df090602001610a76565b600260005403611056576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560035473ffffffffffffffffffffffffffffffffffffffff1633146110ac576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff86166110f9576040517f44d99fea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f2eb2c2d600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff861690632eb2c2d6906111559030908a9089908990899089906004016132a4565b600060405180830381600087803b15801561116f57600080fd5b505af1158015611183573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f6b2463c151ac82c4cb0541aefb7ef273d8ddfa9e713902ac2cacd78ca019ce61878787876040516112019493929190613310565b60405180910390a45050600160005550505050565b61121e611e52565b6112286000612114565b565b600260005403611296576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560035473ffffffffffffffffffffffffffffffffffffffff1633146112ec576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f2eb2c2d600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff861690632eb2c2d690611348903390309089908990899089906004016132a4565b600060405180830381600087803b15801561136257600080fd5b505af1158015611376573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f7e56f2617c2f689fa341b07c22e2c8fecef8dc378f82de05f325570a0335d991868686866040516113dd9493929190613310565b60405180910390a350506001600055505050565b60026000540361145d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560045473ffffffffffffffffffffffffffffffffffffffff1633146114b3576040517f0642977400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025473ffffffffffffffffffffffffffffffffffffffff16611502576040517f6a1ea4f600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8151835114158061151557508051835114155b1561154c576040517f6889ba9000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b83518110156115c0576115ae84828151811061156d5761156d613337565b602002602001015184838151811061158757611587613337565b60200260200101518484815181106115a1576115a1613337565b602002602001015161218b565b806115b881613366565b91505061154f565b505060016000555050565b6115d3611e52565b6004805482151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff90911617905560405133907f5162fedc53e4434f721903247a4c636028aeaea5d7f233a08d10e4819ae168de90610a7690841515815260200190565b6002600054036116ba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560035473ffffffffffffffffffffffffffffffffffffffff163314611710576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f42842e0e0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044810182905273ffffffffffffffffffffffffffffffffffffffff8316906342842e0e90606401600060405180830381600087803b15801561178457600080fd5b505af1158015611798573d6000803e3d6000fd5b505060405183815273ffffffffffffffffffffffffffffffffffffffff851692503391507f7b0968491e6388dede5df5611efde9e7b0795034130e23853ddc87b8dffbe45290602001610e05565b6117ee611e52565b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff831690811790915560405190815233907fc204b28865760f18aa0ef147ee25573d2dba9f208385c8aa65fb79150978fb6d90602001610a76565b6002600054036118cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560045473ffffffffffffffffffffffffffffffffffffffff163314611925576040517f0642977400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025473ffffffffffffffffffffffffffffffffffffffff16611974576040517f6a1ea4f600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61197f83838361218b565b5050600160005550565b6002600054036119f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560035473ffffffffffffffffffffffffffffffffffffffff163314611a4b576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316611a98576040517f44d99fea00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611aa382848361251e565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f83833173372af3b4075d05abbc2b4aea97ebb6ba867413337693d672a92bc43e84604051610c9491815260200190565b600260005403611b85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106f9565b600260005560035473ffffffffffffffffffffffffffffffffffffffff163314611bdb576040517f29ac8f1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517ff242432a000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018390526064810182905260a06084820152600060a482015273ffffffffffffffffffffffffffffffffffffffff84169063f242432a9060c401600060405180830381600087803b158015611c6457600080fd5b505af1158015611c78573d6000803e3d6000fd5b5050604080518581526020810185905273ffffffffffffffffffffffffffffffffffffffff871693503392507f400235142db830a227212d23698fc49d9ac2a809e058be21792a7fd2f82dd8d2910160405180910390a35050600160005550565b611ce1611e52565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff831690811790915560405190815233907f14d590dc20062c9c8cf8005e532197986310804b0b6108e3b7b68321b8ac49d190602001610a76565b611d5e611e52565b73ffffffffffffffffffffffffffffffffffffffff8116611e01576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016106f9565b611e0a81612114565b50565b6000808251604103611e435760208301516040840151606085015160001a611e3787828585612574565b94509450505050611e4b565b506000905060025b9250929050565b60015473ffffffffffffffffffffffffffffffffffffffff163314611228576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106f9565b80471015611f3d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016106f9565b60008273ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d8060008114611f97576040519150601f19603f3d011682016040523d82523d6000602084013e611f9c565b606091505b505090508061202d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016106f9565b505050565b60405173ffffffffffffffffffffffffffffffffffffffff8085166024830152831660448201526064810182905261210e9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261268c565b50505050565b6001805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6002546040517f61f7cd6900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015260009216906361f7cd6990602401602060405180830381865afa1580156121fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222091906133c5565b905073ffffffffffffffffffffffffffffffffffffffff811661226f576040517f8e6a5fd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81163b6122bd576040517fc0968fab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808273ffffffffffffffffffffffffffffffffffffffff16846040516122e59190613406565b600060405180830381855afa9150503d8060008114612320576040519150601f19603f3d011682016040523d82523d6000602084013e612325565b606091505b5091509150816123385761233881612798565b8051600003612373576040517fbf51d1b400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b808060200190518101906123879190613422565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166359faaa0360e01b146123e5576040517fbf51d1b400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff86163b612433576040517fa710429d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8573ffffffffffffffffffffffffffffffffffffffff1685856040516124599190613406565b60006040518083038185875af1925050503d8060008114612496576040519150601f19603f3d011682016040523d82523d6000602084013e61249b565b606091505b509092509050816124af576124af81612798565b8573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f682f19be1a048eacbee9fac60bfc29800c7afb293721778db52a84f7ea3d8f69878760405161250e929190613489565b60405180910390a3505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905261202d9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161208c565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156125ab5750600090506003612683565b8460ff16601b141580156125c357508460ff16601c14155b156125d45750600090506004612683565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612628573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661267c57600060019250925050612683565b9150600090505b94509492505050565b60006126ee826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166127ae9092919063ffffffff16565b80519091501561202d578080602001905181019061270c91906134a2565b61202d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016106f9565b80516000036127a657600080fd5b805181602001fd5b60606127bd84846000856127c5565b949350505050565b606082471015612857576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016106f9565b73ffffffffffffffffffffffffffffffffffffffff85163b6128d5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106f9565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516128fe9190613406565b60006040518083038185875af1925050503d806000811461293b576040519150601f19603f3d011682016040523d82523d6000602084013e612940565b606091505b509150915061295082828661295b565b979650505050505050565b6060831561296a5750816109f6565b82511561297a5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f991906134bf565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114611e0a57600080fd5b6000602082840312156129ee57600080fd5b81356109f6816129ae565b73ffffffffffffffffffffffffffffffffffffffff81168114611e0a57600080fd5b60008060008060808587031215612a3157600080fd5b8435612a3c816129f9565b93506020850135612a4c816129f9565b93969395505050506040820135916060013590565b60008083601f840112612a7357600080fd5b50813567ffffffffffffffff811115612a8b57600080fd5b602083019150836020828501011115611e4b57600080fd5b600080600080600060808688031215612abb57600080fd5b8535612ac6816129f9565b94506020860135612ad6816129f9565b935060408601359250606086013567ffffffffffffffff811115612af957600080fd5b612b0588828901612a61565b969995985093965092949392505050565b600080600060408486031215612b2b57600080fd5b83359250602084013567ffffffffffffffff811115612b4957600080fd5b612b5586828701612a61565b9497909650939450505050565b600060208284031215612b7457600080fd5b81356109f6816129f9565b600080600060608486031215612b9457600080fd5b8335612b9f816129f9565b92506020840135612baf816129f9565b929592945050506040919091013590565b60008060408385031215612bd357600080fd5b8235612bde816129f9565b946020939093013593505050565b600060208284031215612bfe57600080fd5b5035919050565b60008083601f840112612c1757600080fd5b50813567ffffffffffffffff811115612c2f57600080fd5b6020830191508360208260051b8501011115611e4b57600080fd5b60008060008060008060808789031215612c6357600080fd5b8635612c6e816129f9565b95506020870135612c7e816129f9565b9450604087013567ffffffffffffffff80821115612c9b57600080fd5b612ca78a838b01612c05565b90965094506060890135915080821115612cc057600080fd5b50612ccd89828a01612c05565b979a9699509497509295939492505050565b600080600080600060608688031215612cf757600080fd5b8535612d02816129f9565b9450602086013567ffffffffffffffff80821115612d1f57600080fd5b612d2b89838a01612c05565b90965094506040880135915080821115612d4457600080fd5b50612b0588828901612c05565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715612dc757612dc7612d51565b604052919050565b600067ffffffffffffffff821115612de957612de9612d51565b5060051b60200190565b600082601f830112612e0457600080fd5b81356020612e19612e1483612dcf565b612d80565b82815260059290921b84018101918181019086841115612e3857600080fd5b8286015b84811015612e535780358352918301918301612e3c565b509695505050505050565b600082601f830112612e6f57600080fd5b813567ffffffffffffffff811115612e8957612e89612d51565b612eba60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612d80565b818152846020838601011115612ecf57600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f830112612efd57600080fd5b81356020612f0d612e1483612dcf565b82815260059290921b84018101918181019086841115612f2c57600080fd5b8286015b84811015612e5357803567ffffffffffffffff811115612f505760008081fd5b612f5e8986838b0101612e5e565b845250918301918301612f30565b600080600060608486031215612f8157600080fd5b833567ffffffffffffffff80821115612f9957600080fd5b818601915086601f830112612fad57600080fd5b81356020612fbd612e1483612dcf565b82815260059290921b8401810191818101908a841115612fdc57600080fd5b948201945b83861015613003578535612ff4816129f9565b82529482019490820190612fe1565b9750508701359250508082111561301957600080fd5b61302587838801612df3565b9350604086013591508082111561303b57600080fd5b5061304886828701612eec565b9150509250925092565b8015158114611e0a57600080fd5b60006020828403121561307257600080fd5b81356109f681613052565b60008060006060848603121561309257600080fd5b833561309d816129f9565b925060208401359150604084013567ffffffffffffffff8111156130c057600080fd5b61304886828701612e5e565b60008060008060008060008060a0898b0312156130e857600080fd5b88356130f3816129f9565b97506020890135613103816129f9565b9650604089013567ffffffffffffffff8082111561312057600080fd5b61312c8c838d01612c05565b909850965060608b013591508082111561314557600080fd5b6131518c838d01612c05565b909650945060808b013591508082111561316a57600080fd5b506131778b828c01612a61565b999c989b5096995094979396929594505050565b6000806000606084860312156131a057600080fd5b83356131ab816129f9565b95602085013595506040909401359392505050565b60008060008060008060a087890312156131d957600080fd5b86356131e4816129f9565b955060208701356131f4816129f9565b94506040870135935060608701359250608087013567ffffffffffffffff81111561321e57600080fd5b612ccd89828a01612a61565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561328b57600080fd5b8260051b80836020870137939093016020019392505050565b600073ffffffffffffffffffffffffffffffffffffffff808916835280881660208401525060a060408301526132de60a083018688613259565b82810360608401526132f1818587613259565b8381036080909401939093525050600081526020019695505050505050565b604081526000613324604083018688613259565b8281036020840152612950818587613259565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036133be577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5060010190565b6000602082840312156133d757600080fd5b81516109f6816129f9565b60005b838110156133fd5781810151838201526020016133e5565b50506000910152565b600082516134188184602087016133e2565b9190910192915050565b60006020828403121561343457600080fd5b81516109f6816129ae565b600081518084526134578160208601602086016133e2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8281526040602082015260006127bd604083018461343f565b6000602082840312156134b457600080fd5b81516109f681613052565b6020815260006109f6602083018461343f56fea26469706673582212201f8962360bc21e372fafc67869bbcb7694f0402ae016c080f20234d379e835a064736f6c63430008100033

Verified Source Code Full Match

Compiler: v0.8.16+commit.07a7930e EVM: london Optimization: Yes (9999999 runs)
TeaVaultV2.sol 335 lines
// contracts/TeaVaultV2.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;


import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "./IFilterMapper.sol";

error InvalidOwnerAddress();
error CallerIsNotInvestor();
error CallerIsNotManager();
error FilterMapperNotAssigned();
error ContractNotInWhitelist();
error InvalidFilter();
error InvalidFilterReturnValue();
error InvalidContractAddress();
error InconsistentParamsLengths();
error IncorrectValue();
error InvalidRecipientAddress();

/// @title A generalized managed investor vault
/// @notice Fund manager is only allowed to call functions whitelisted in the filters
/// @author Teahouse Finance
contract TeaVaultV2 is ReentrancyGuard, Ownable, IERC721Receiver, ERC1155Receiver {

    struct Config {
        IFilterMapper filterMapper;
        address investor;
        address manager;
        bool allowManagerSignature;
    }

    Config public config;

    event FilterMapperChanged(address indexed sender, address newFilterMapper);
    event ManagerChanged(address indexed sender, address newManager);
    event InvestorChanged(address indexed sender, address newInvestor);
    event AllowManagerSignatureChanged(address indexed sender, bool newStatus);
    event TokenDeposited(address indexed sender, address indexed token, uint256 amount);
    event TokenWithdrawed(address indexed sender, address indexed recipient, address indexed token, uint256 amount);
    event Token721Deposited(address indexed sender, address indexed token, uint256 tokenId);
    event Token721Withdrawed(address indexed sender, address indexed recipient, address indexed token, uint256 tokenId);
    event Token1155Deposited(address indexed sender, address indexed token, uint256 tokenId, uint256 amount);
    event Token1155Withdrawed(address indexed sender, address indexed recipient, address indexed token, uint256 tokenId, uint256 amount);
    event Token1155BatchDeposited(address indexed sender, address indexed token, uint256[] tokenIds, uint256[] amounts);
    event Token1155BatchWithdrawed(address indexed sender, address indexed recipient, address indexed token, uint256[] tokenIds, uint256[] amounts);
    event ETHDeposited(address indexed sender, uint256 amount);
    event ETHWithdrawed(address indexed sender, address indexed recipient, uint256 amount);
    event ManagerCall(address indexed sender, address indexed contractAddr, uint256 value, bytes data);
    
    constructor(address _owner) {
        if(_owner == address(0)) revert InvalidOwnerAddress();
        Ownable.transferOwnership(_owner);
    }

    receive() external payable {
        // do nothing
    }

    /// @notice Assign filter mapper contract
    /// @notice Only the owner can do this
    /// @param _filterMapper address of the filter mapper contract
    function assignFilterMapper(address _filterMapper) external onlyOwner {
        config.filterMapper = IFilterMapper(_filterMapper);
        emit FilterMapperChanged(msg.sender, _filterMapper);
    }

    /// @notice Assign fund manager
    /// @notice Only the owner can do this
    /// @param _manager fund manager address
    function assignManager(address _manager) external onlyOwner {
        config.manager = _manager;
        emit ManagerChanged(msg.sender, _manager);
    }

    /// @notice Assign investor
    /// @notice Only the owner can do this
    /// @param _investor investor address
    function assignInvestor(address _investor) external onlyOwner {
        config.investor = _investor;
        emit InvestorChanged(msg.sender, _investor);
    }

    /// @notice Set to allow or disallow manager signature validation
    /// @notice Only the owner can do this
    /// @param _allow true to allow, false to disallow
    /// @notice This is for EIP-1271 signature validation.
    function setAllowManagerSignature(bool _allow) external onlyOwner {
        config.allowManagerSignature = _allow;
        emit AllowManagerSignatureChanged(msg.sender, _allow);
    }

    /// @notice Deposit ERC20 tokens
    /// @notice Only the investor can do this
    /// @param _token address of the ERC-20 token
    /// @param _amount amount of the token to deposit
    function deposit(address _token, uint256 _amount) external nonReentrant onlyInvestor {
        SafeERC20.safeTransferFrom(IERC20(_token), msg.sender, address(this), _amount);
        emit TokenDeposited(msg.sender, _token, _amount);
    }

    /// @notice Withdraw ERC20 tokens
    /// @notice Only the investor can do this
    /// @param _token address of the ERC-20 token
    /// @param _amount amount of the token to withdraw
    function withdraw(address _recipient, address _token, uint256 _amount) external nonReentrant onlyInvestor {
        if (_recipient == address(0)) revert InvalidRecipientAddress();

        SafeERC20.safeTransfer(IERC20(_token), _recipient, _amount);
        emit TokenWithdrawed(msg.sender, _recipient, _token, _amount);
    }

    /// @notice Deposit ERC721 tokens
    /// @notice Only the investor can do this
    /// @param _token address of the NFT
    /// @param _tokenId the NFT to deposit
    function deposit721(address _token, uint256 _tokenId) external nonReentrant onlyInvestor {
        IERC721(_token).safeTransferFrom(msg.sender, address(this), _tokenId);
        emit Token721Deposited(msg.sender, _token, _tokenId);
    }

    /// @notice Withdraw ERC721 tokens
    /// @notice Only the investor can do this
    /// @param _token address of the NFT
    /// @param _tokenId the NFT to withdraw
    function withdraw721(address _recipient, address _token, uint256 _tokenId) external nonReentrant onlyInvestor {
        if (_recipient == address(0)) revert InvalidRecipientAddress();

        IERC721(_token).safeTransferFrom(address(this), _recipient, _tokenId);
        emit Token721Withdrawed(msg.sender, _recipient, _token, _tokenId);
    }

    /// @notice Deposit ERC1155 tokens
    /// @notice Only the investor can do this
    /// @param _token address of the token contract
    /// @param _tokenId the token to deposit
    /// @param _amount amount to deposit
    function deposit1155(address _token, uint256 _tokenId, uint256 _amount) external nonReentrant onlyInvestor {
        IERC1155(_token).safeTransferFrom(msg.sender, address(this), _tokenId, _amount, "");
        emit Token1155Deposited(msg.sender, _token, _tokenId, _amount);
    }

    /// @notice Withdraw ERC1155 tokens
    /// @notice Only the investor can do this
    /// @param _token address of the token contract
    /// @param _tokenId the token to withdraw
    /// @param _amount amount to withdraw
    function withdraw1155(address _recipient, address _token, uint256 _tokenId, uint256 _amount) external nonReentrant onlyInvestor {
        if (_recipient == address(0)) revert InvalidRecipientAddress();

        IERC1155(_token).safeTransferFrom(address(this), _recipient, _tokenId, _amount, "");
        emit Token1155Withdrawed(msg.sender, _recipient, _token, _tokenId, _amount);
    }

    /// @notice Batch deposit ERC1155 tokens
    /// @notice Only the investor can do this
    /// @param _token address of the token contract
    /// @param _tokenIds the token to deposit
    /// @param _amounts amount to deposit
    function deposit1155Batch(address _token, uint256[] calldata _tokenIds, uint256[] calldata _amounts) external nonReentrant onlyInvestor {
        IERC1155(_token).safeBatchTransferFrom(msg.sender, address(this), _tokenIds, _amounts, "");
        emit Token1155BatchDeposited(msg.sender, _token, _tokenIds, _amounts);
    }

    /// @notice Batch withdraw ERC1155 tokens
    /// @notice Only the investor can do this
    /// @param _token address of the token contract
    /// @param _tokenIds the token to withdraw
    /// @param _amounts amount to withdraw
    function withdraw1155Batch(address _recipient, address _token, uint256[] calldata _tokenIds, uint256[] calldata _amounts) external nonReentrant onlyInvestor {
        if (_recipient == address(0)) revert InvalidRecipientAddress();

        IERC1155(_token).safeBatchTransferFrom(address(this), _recipient, _tokenIds, _amounts, "");
        emit Token1155BatchWithdrawed(msg.sender, _recipient, _token, _tokenIds, _amounts);
    }    

    /// @notice Deposit ETH
    /// @notice Only the investor can do this
    /// @param _amount amount of the token to deposit
    function depositETH(uint256 _amount) external payable onlyInvestor {
        if (msg.value != _amount) revert IncorrectValue();
        emit ETHDeposited(msg.sender, _amount);
    }

    /// @notice Withdraw ETH
    /// @notice Only the investor can do this
    /// @param _amount amount of ETH to withdraw
    function withdrawETH(address payable _recipient, uint256 _amount) external nonReentrant onlyInvestor {
        if (_recipient == address(0)) revert InvalidRecipientAddress();

        Address.sendValue(_recipient, _amount);
        emit ETHWithdrawed(msg.sender, _recipient, _amount);
    }

    /// @notice Call smart contract from vault
    /// @notice Only manager can do this
    /// @notice Only smart contracts and functions whitelisted in the filters can be called
    /// @param _contract smart contract address
    /// @param _value ETH to send with the call
    /// @param _args function signature and parameters
    function managerCall(address _contract, uint256 _value, bytes memory _args) external nonReentrant onlyManager {
        if (address(config.filterMapper) == address(0)) revert FilterMapperNotAssigned();
        _internalManagerCall(_contract, _value, _args);
    }

    /// @notice Batch call smart contract from vault
    /// @notice Only manager can do this
    /// @notice Only smart contracts and functions whitelisted in the filters can be called
    /// @param _contracts smart contract addresses
    /// @param _values ETH to send with the call
    /// @param _args function signature and parameters
    function managerCallMulti(address[] memory _contracts, uint256[] memory _values, bytes[] memory _args) external nonReentrant onlyManager {
        if (address(config.filterMapper) == address(0)) revert FilterMapperNotAssigned();
        if (_contracts.length != _values.length || _contracts.length != _args.length) revert InconsistentParamsLengths();
        
        uint256 i;
        for (i = 0; i < _contracts.length; i++) {
            _internalManagerCall(_contracts[i], _values[i], _args[i]);
        }
    }

    function _internalManagerCall(address _contract, uint256 _value, bytes memory _args) internal {
        // get filter for _contract
        address filter = config.filterMapper.mapFilter(_contract);
        if (filter == address(0)) revert ContractNotInWhitelist();
        if (!Address.isContract(filter)) revert InvalidFilter();

        // call filter to check _args
        (bool success, bytes memory returndata) = filter.staticcall(_args);
        if (!success) {
            _forwardRevert(returndata);
        }

        if (returndata.length == 0) revert InvalidFilterReturnValue();
        if (abi.decode(returndata, (bytes4)) != 0x59faaa03) revert InvalidFilterReturnValue();

        // actually call _contract if filter is successful
        if (!Address.isContract(_contract)) revert InvalidContractAddress();
        (success, returndata) = _contract.call{ value: _value }(_args);
        if (!success) {
            _forwardRevert(returndata);
        }

        emit ManagerCall(msg.sender, _contract, _value, _args);
    }

    function _forwardRevert(bytes memory result) internal pure {
        // forward revert from filter
        // from OpenZeppelin's Address.sol
        // works with both revert string and custom error
        if (result.length == 0) revert();
        assembly {
            revert(add(32, result), mload(result))
        }
    }

    /// @notice EIP-1271 signature validation
    /// @notice Always validates owner's signature
    /// @notice Optionally (depends on allowManagerSignature settings) validates manager's signature
    /// @param _hash data to sign
    /// @param _signature signature
    /// @return magicNumber returns 0x1626ba7e if valid, 0xffffffff if invalid
    function isValidSignature(bytes32 _hash, bytes calldata _signature) external view returns (bytes4 magicNumber) {
        (address signer, ECDSA.RecoverError err) = ECDSA.tryRecover(_hash, _signature);
        if (err != ECDSA.RecoverError.NoError) {
            return 0xffffffff;                  // not valid signature
        }

        if (signer == Ownable.owner() ||
            (config.allowManagerSignature && signer == config.manager)) {
            return 0x1626ba7e;                  // valid signature
        }

        return 0xffffffff;
    }

    // IERC721Receiver
    function onERC721Received(
        address /*operator*/,
        address /*from*/,
        uint256 /*tokenId*/,
        bytes calldata /*data*/
    ) external pure override returns (bytes4) {
        return IERC721Receiver.onERC721Received.selector;
    }
    
    // IERC1155Receiver
    function onERC1155Received(
        address /*operator*/,
        address /*from*/,
        uint256 /*id*/,
        uint256 /*value*/,
        bytes calldata /*data*/
    ) external pure override returns (bytes4) {
        return IERC1155Receiver.onERC1155Received.selector;        
    }

    function onERC1155BatchReceived(
        address /*operator*/,
        address /*from*/,
        uint256[] calldata /*ids*/,
        uint256[] calldata /*values*/,
        bytes calldata /*data*/
    ) external pure override returns (bytes4) {
        return IERC1155Receiver.onERC1155BatchReceived.selector;
    }

    // modifiers

    /**
     * @dev Throws if called by any account other than the investor.
     */
    modifier onlyInvestor() {
        if (msg.sender != config.investor) revert CallerIsNotInvestor();
        _;
    }

    /**
     * @dev Throws if called by any account other than the manager.
     */
    modifier onlyManager() {
        if (msg.sender != config.manager) revert CallerIsNotManager();
        _;
    }    
}
IFilterMapper.sol 11 lines
// contracts/IFilterMapper.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;


interface IFilterMapper {

    function mapFilter(address _contract) external view returns(address);
    
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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
     * ====
     *
     * [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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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);
            }
        }
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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 Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.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);
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
IERC1155.sol 125 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
ECDSA.sol 218 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
SafeERC20.sol 116 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-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;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    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));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    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");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    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");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
IERC1155Receiver.sol 58 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}
ERC1155Receiver.sol 19 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }
}
draft-IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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);
}

Read Contract

config 0x79502c55 → address, address, address, bool
isValidSignature 0x1626ba7e → bytes4
onERC1155BatchReceived 0xbc197c81 → bytes4
onERC1155Received 0xf23a6e61 → bytes4
onERC721Received 0x150b7a02 → bytes4
owner 0x8da5cb5b → address
supportsInterface 0x01ffc9a7 → bool

Write Contract 18 functions

These functions modify contract state and require a wallet transaction to execute.

assignFilterMapper 0xe3ed4173
address _filterMapper
assignInvestor 0x904a205a
address _investor
assignManager 0x2d2dcc48
address _manager
deposit 0x47e7ef24
address _token
uint256 _amount
deposit1155 0xde86b45b
address _token
uint256 _tokenId
uint256 _amount
deposit1155Batch 0x80f288c4
address _token
uint256[] _tokenIds
uint256[] _amounts
deposit721 0x88c344fa
address _token
uint256 _tokenId
depositETH 0x5358fbda
uint256 _amount
managerCall 0xa6afeb42
address _contract
uint256 _value
bytes _args
managerCallMulti 0x81342457
address[] _contracts
uint256[] _values
bytes[] _args
renounceOwnership 0x715018a6
No parameters
setAllowManagerSignature 0x887268de
bool _allow
transferOwnership 0xf2fde38b
address newOwner
withdraw 0xd9caed12
address _recipient
address _token
uint256 _amount
withdraw1155 0x06948316
address _recipient
address _token
uint256 _tokenId
uint256 _amount
withdraw1155Batch 0x5c6f6c21
address _recipient
address _token
uint256[] _tokenIds
uint256[] _amounts
withdraw721 0x355007f9
address _recipient
address _token
uint256 _tokenId
withdrawETH 0x4782f779
address _recipient
uint256 _amount

Recent Transactions

No transactions found for this address