Address Contract Verified
Address
0xa3B414875c82914698A96199f65E84BA8202eca8
Balance
0 ETH
Nonce
1
Code Size
11684 bytes
Creator
0xA47b2bC2...5A45 at tx 0xe749e792...edface
Indexed Transactions
0
Contract Bytecode
11684 bytes
0x608060405234801561001057600080fd5b50600436106102d35760003560e01c806370a0823111610186578063a9059cbb116100e3578063dd62ed3e11610097578063e4997dc511610071578063e4997dc514610680578063f2fde38b14610693578063f3bdc228146106a657600080fd5b8063dd62ed3e14610604578063de923bd01461064a578063e47d60601461065d57600080fd5b8063cae9ca51116100c8578063cae9ca51146105cb578063d8fbe994146105de578063d967f279146105f157600080fd5b8063a9059cbb146105a5578063c1d34b89146105b857600080fd5b806395d89b411161013a578063a02cd2fc1161011f578063a02cd2fc14610576578063a0712d681461057f578063a08301bc1461059257600080fd5b806395d89b411461055b5780639f8751371461056357600080fd5b8063767527ae1161016b578063767527ae146104c65780638456cb591461052b5780638da5cb5b1461053357600080fd5b806370a0823114610488578063715018a6146104be57600080fd5b8063313ce5671161023457806342966c68116101e857806359bf1abe116101cd57806359bf1abe146104195780635c975abb146104525780635d232dc31461047557600080fd5b806342966c68146103f35780635817c4b61461040657600080fd5b8063372500ab11610219578063372500ab146103d05780633f4ba83a146103d85780634000aea0146103e057600080fd5b8063313ce567146103ae5780633177029f146103bd57600080fd5b806318160ddd1161028b57806323b872dd1161027057806323b872dd1461037557806329868afd14610388578063308e401e1461039b57600080fd5b806318160ddd146103505780631afc75121461036257600080fd5b8063095ea7b3116102bc578063095ea7b3146103155780630ecb93c0146103285780631296ee621461033d57600080fd5b806301ffc9a7146102d857806306fdde0314610300575b600080fd5b6102eb6102e63660046127d4565b6106b9565b60405190151581526020015b60405180910390f35b610308610752565b6040516102f79190612855565b6102eb610323366004612891565b6107e4565b61033b6103363660046128bb565b6107fc565b005b6102eb61034b366004612891565b61088a565b6002545b6040519081526020016102f7565b6103546103703660046128d6565b6108ad565b6102eb6103833660046128ef565b610918565b6103546103963660046128d6565b610aeb565b6103546103a93660046128bb565b610cd9565b604051601281526020016102f7565b6102eb6103cb366004612891565b610d24565b61033b610d40565b61033b610fb4565b6102eb6103ee366004612a27565b610fc4565b61033b6104013660046128d6565b611032565b6103546104143660046128bb565b611092565b6102eb6104273660046128bb565b73ffffffffffffffffffffffffffffffffffffffff166000908152600b602052604090205460ff1690565b60075474010000000000000000000000000000000000000000900460ff166102eb565b61033b6104833660046128d6565b61115c565b6103546104963660046128bb565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b61033b61145d565b6105166104d43660046128bb565b73ffffffffffffffffffffffffffffffffffffffff16600090815260096020526040902054608081901c916fffffffffffffffffffffffffffffffff90911690565b604080519283526020830191909152016102f7565b61033b61146f565b60075460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016102f7565b61030861147f565b61033b6105713660046128d6565b61148e565b610354600a5481565b61033b61058d3660046128d6565b61149b565b6103546105a0366004612a7e565b6114fb565b6102eb6105b3366004612891565b611538565b6102eb6105c6366004612aa0565b6116e4565b6102eb6105d9366004612a27565b61175b565b6102eb6105ec3660046128ef565b6117c8565b6103546105ff366004612a7e565b6117e5565b610354610612366004612b08565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6103546106583660046128d6565b611894565b6102eb61066b3660046128bb565b600b6020526000908152604090205460ff1681565b61033b61068e3660046128bb565b6118b5565b61033b6106a13660046128bb565b611939565b61033b6106b43660046128bb565b61199d565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167fb0202a1100000000000000000000000000000000000000000000000000000000148061074c57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60606003805461076190612b3b565b80601f016020809104026020016040519081016040528092919081815260200182805461078d90612b3b565b80156107da5780601f106107af576101008083540402835291602001916107da565b820191906000526020600020905b8154815290600101906020018083116107bd57829003601f168201915b5050505050905090565b6000336107f2818585611ab7565b5060019392505050565b610804611ac9565b73ffffffffffffffffffffffffffffffffffffffff81166000818152600b602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905590519182527f42e160154868087d6bfdc0ca23d96a1c1cfa32f1b72ba9ba27b69b98a0d819dc91015b60405180910390a150565b60006108a6838360405180602001604052806000815250610fc4565b9392505050565b60055460009082106108f3576040517f116f2cb7000000000000000000000000000000000000000000000000000000008152600481018390526024015b60405180910390fd5b6005828154811061090657610906612b8e565b60009182526020909120015492915050565b6000610922611b1c565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600b602052604090205460ff16156109b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f426c61636b6c697374656420616464726573730000000000000000000000000060448201526064016108ea565b60003390506000608060056000815481106109cf576109cf612b8e565b600091825260209091200154901b90506109e882611092565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260096020526040902054610a2a91906fffffffffffffffffffffffffffffffff16612bec565b73ffffffffffffffffffffffffffffffffffffffff831660009081526009602052604090209082179055610a5d85611092565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260096020526040902054610a9f91906fffffffffffffffffffffffffffffffff16612bec565b73ffffffffffffffffffffffffffffffffffffffff861660009081526009602052604090209082179055610ad4868386611b71565b610adf868686611c40565b50600195945050505050565b60006005600081548110610b0157610b01612b8e565b600091825260209091200154821115610b76576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f496e646578206f7574206f6620626f756e64730000000000000000000000000060448201526064016108ea565b50600080805b60058281548110610b8f57610b8f612b8e565b60009182526020909120015490505b6000610bab600586612c2e565b118015610bb757508084105b15610c145760058281548110610bcf57610bcf612b8e565b906000526020600020018481548110610bea57610bea612b8e565b906000526020600020015483610c009190612bec565b925083610c0c81612c42565b945050610b9e565b838114610ca857600554610c29836001612bec565b1015610c4f5781610c3981612c42565b9250610c489050600585612c7a565b9350610b7c565b80841015610ca85760058281548110610c6a57610c6a612b8e565b906000526020600020018481548110610c8557610c85612b8e565b906000526020600020015483610c9b9190612bec565b6001909401939250610c4f565b60088281548110610cbb57610cbb612b8e565b906000526020600020015483610cd19190612bec565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600960205260409020546fffffffffffffffffffffffffffffffff16610d1a82611092565b61074c9082612bec565b60006108a683836040518060200160405280600081525061175b565b610d48611ceb565b610d50611b1c565b336000818152600960205260409020546fffffffffffffffffffffffffffffffff16610d7b82611092565b610d859082612bec565b905060008111610df1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f4e6f207265776172647320617661696c61626c6520666f7220636c61696d000060448201526064016108ea565b600a54811015610e83576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f5265776172647320616d6f756e74206973206c657373207468616e206d696e6960448201527f6d756d207265776172647320616d6f756e74000000000000000000000000000060648201526084016108ea565b30600090815260208190526040902054811115610f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f496e73756666696369656e742062616c616e636520666f7220636c61696d207260448201527f657761726473000000000000000000000000000000000000000000000000000060648201526084016108ea565b610f4b826005600081548110610f3a57610f3a612b8e565b600091825260208220015490611d2e565b610f56308383611c40565b8173ffffffffffffffffffffffffffffffffffffffff167fba56c3ab1f752776eef60db959a4e6b643e89595315edbbd945e104623fa03ba82604051610f9e91815260200190565b60405180910390a25050610fb26001600655565b565b610fbc611ac9565b610fb2611dc9565b6000610fd08484611538565b611025576040517f231b03ae00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602481018490526044016108ea565b6107f23333868686611e46565b61103a611ac9565b61106261105c60075473ffffffffffffffffffffffffffffffffffffffff1690565b8261208b565b6040518181527fb90306ad06b2a6ff86ddc9327db583062895ef6540e62dc50add009db5b356eb9060200161087f565b73ffffffffffffffffffffffffffffffffffffffff81166000908152602081905260408120546000036110c757506000919050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600960205260408120546110f99060801c610aeb565b90507f0000000000000000000000000000000000000000000000000de0b6b3a76400006111488473ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6111529083612c8e565b6108a69190612c7a565b611164611ac9565b8060000361119e576040517f6a63171500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6005546000036111b5576005805460010181556000525b60056000815481106111c9576111c9612b8e565b60009182526020808320909101805460018181018355918452918320909101839055600554915b828110156113ee5760006005828154811061120d5761120d612b8e565b6000918252602082200154915080611226600584612c2e565b1561124557611236600584612c2e565b6112409084612ca5565b611250565b611250600584612ca5565b90505b828110156112a9576005848154811061126e5761126e612b8e565b90600052602060002001818154811061128957611289612b8e565b90600052602060002001548261129f9190612bec565b9150600101611253565b6112b4600584612c2e565b60000361135a576112c6846001612bec565b600554036112e7576005805460019081019091556008805490910181556000525b8460056000815481106112fc576112fc612b8e565b6000918252602090912001546113129190612c2e565b600003611355576005611326856001612bec565b8154811061133657611336612b8e565b6000918252602080832090910180546001810182559083529120018290555b600091505b600854611368856001612bec565b10156113c157816008858154811061138257611382612b8e565b90600052602060002001546113979190612bec565b60086113a4866001612bec565b815481106113b4576113b4612b8e565b6000918252602090912001555b60058310156113d2575050506113ee565b6113dd600586612c8e565b945050600190920191506111f09050565b507f6ff14a8d2417aa6a0cc0d3a0917d8ce7bb037b589845c934a1dbf7205eadee4c600560008154811061142457611424612b8e565b6000918252602090912001548461143a60025490565b6040805193845260208401929092529082015260600160405180910390a1505050565b611465611ac9565b610fb260006120eb565b611477611ac9565b610fb2612162565b60606004805461076190612b3b565b611496611ac9565b600a55565b6114a3611ac9565b6114cb6114c560075473ffffffffffffffffffffffffffffffffffffffff1690565b826121d1565b6040518181527f07883703ed0e86588a40d76551c92f8a4b329e3bf19765e0e6749473c1a846659060200161087f565b6005828154811061150b57600080fd5b90600052602060002001818154811061152357600080fd5b90600052602060002001600091509150505481565b6000611542611b1c565b336000818152600b602052604090205460ff16156115bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f426c61636b6c697374656420616464726573730000000000000000000000000060448201526064016108ea565b6000608060056000815481106115d4576115d4612b8e565b600091825260209091200154901b90506115ed82611092565b73ffffffffffffffffffffffffffffffffffffffff831660009081526009602052604090205461162f91906fffffffffffffffffffffffffffffffff16612bec565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600960205260409020908217905561166285611092565b73ffffffffffffffffffffffffffffffffffffffff86166000908152600960205260409020546116a491906fffffffffffffffffffffffffffffffff16612bec565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260096020526040902090821790556116d9828686611c40565b506001949350505050565b60006116f1858585610918565b61174e576040517fb56855e600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff808716600483015285166024820152604481018490526064016108ea565b6116d93386868686611e46565b600061176784846107e4565b6117bc576040517f50e555c400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602481018490526044016108ea565b6107f23385858561222d565b6000610cd1848484604051806020016040528060008152506116e4565b6005546000908310611826576040517f116f2cb7000000000000000000000000000000000000000000000000000000008152600481018490526024016108ea565b6005838154811061183957611839612b8e565b60009182526020909120015482106118535750600061074c565b6005838154811061186657611866612b8e565b90600052602060002001828154811061188157611881612b8e565b9060005260206000200154905092915050565b600881815481106118a457600080fd5b600091825260209091200154905081565b6118bd611ac9565b73ffffffffffffffffffffffffffffffffffffffff81166000818152600b602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905590519182527fd7e9ec6e6ecd65492dce6bf513cd6867560d49544421d0783ddf06e76c24470c910161087f565b611941611ac9565b73ffffffffffffffffffffffffffffffffffffffff8116611991576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016108ea565b61199a816120eb565b50565b6119a5611ac9565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600b602052604090205460ff16611a34576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f41646472657373206973206e6f7420626c61636b6c697374656400000000000060448201526064016108ea565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260208190526040902054611a64828261208b565b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f61e6e66b0d6339b2980aecc6ccc0039736791f0ccde9ed512e789a7fbdd698c6910160405180910390a15050565b611ac4838383600161245f565b505050565b60075473ffffffffffffffffffffffffffffffffffffffff163314610fb2576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016108ea565b60075474010000000000000000000000000000000000000000900460ff1615610fb2576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114611c3a5781811015611c2b576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260248101829052604481018390526064016108ea565b611c3a8484848403600061245f565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316611c90576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016108ea565b73ffffffffffffffffffffffffffffffffffffffff8216611ce0576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016108ea565b611ac48383836125a7565b600260065403611d27576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600655565b70010000000000000000000000000000000082101580611d5f57507001000000000000000000000000000000008110155b15611d96576040517fa6a5ca5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff909216600090815260096020526040902060809190911b9091179055565b611dd1612752565b600780547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b8273ffffffffffffffffffffffffffffffffffffffff163b600003611eaf576040517f8a96cd9c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841660048201526024016108ea565b6040517f88a7ca5c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416906388a7ca5c90611f07908890889087908790600401612cb8565b6020604051808303816000875af1925050508015611f60575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252611f5d91810190612d13565b60015b611fef573d808015611f8e576040519150601f19603f3d011682016040523d82523d6000602084013e611f93565b606091505b508051600003611fe7576040517f8a96cd9c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851660048201526024016108ea565b805181602001fd5b7fffffffff0000000000000000000000000000000000000000000000000000000081167f88a7ca5c0000000000000000000000000000000000000000000000000000000014612082576040517f8a96cd9c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851660048201526024016108ea565b505b5050505050565b73ffffffffffffffffffffffffffffffffffffffff82166120db576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016108ea565b6120e7826000836125a7565b5050565b6007805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61216a611b1c565b600780547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611e1c3390565b73ffffffffffffffffffffffffffffffffffffffff8216612221576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016108ea565b6120e7600083836125a7565b8273ffffffffffffffffffffffffffffffffffffffff163b600003612296576040517fdeb6d3ed00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841660048201526024016108ea565b6040517f7b04a2d000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690637b04a2d0906122ec90879086908690600401612d30565b6020604051808303816000875af1925050508015612345575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820190925261234291810190612d13565b60015b6123cc573d808015612373576040519150601f19603f3d011682016040523d82523d6000602084013e612378565b606091505b508051600003611fe7576040517fdeb6d3ed00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851660048201526024016108ea565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f7b04a2d00000000000000000000000000000000000000000000000000000000014612084576040517fdeb6d3ed00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851660048201526024016108ea565b73ffffffffffffffffffffffffffffffffffffffff84166124af576040517fe602df05000000000000000000000000000000000000000000000000000000008152600060048201526024016108ea565b73ffffffffffffffffffffffffffffffffffffffff83166124ff576040517f94280d62000000000000000000000000000000000000000000000000000000008152600060048201526024016108ea565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526001602090815260408083209387168352929052208290558015611c3a578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161259991815260200190565b60405180910390a350505050565b73ffffffffffffffffffffffffffffffffffffffff83166125df5780600260008282546125d49190612bec565b909155506126919050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015612665576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260248101829052604481018390526064016108ea565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff82166126ba576002805482900390556126e6565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161274591815260200190565b60405180910390a3505050565b60075474010000000000000000000000000000000000000000900460ff16610fb2576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffff000000000000000000000000000000000000000000000000000000008116811461199a57600080fd5b6000602082840312156127e657600080fd5b81356108a6816127a6565b6000815180845260005b81811015612817576020818501810151868301820152016127fb565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b6020815260006108a660208301846127f1565b803573ffffffffffffffffffffffffffffffffffffffff8116811461288c57600080fd5b919050565b600080604083850312156128a457600080fd5b6128ad83612868565b946020939093013593505050565b6000602082840312156128cd57600080fd5b6108a682612868565b6000602082840312156128e857600080fd5b5035919050565b60008060006060848603121561290457600080fd5b61290d84612868565b925061291b60208501612868565b929592945050506040919091013590565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261296c57600080fd5b813567ffffffffffffffff8111156129865761298661292c565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff821117156129f2576129f261292c565b604052818152838201602001851015612a0a57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600060608486031215612a3c57600080fd5b612a4584612868565b925060208401359150604084013567ffffffffffffffff811115612a6857600080fd5b612a748682870161295b565b9150509250925092565b60008060408385031215612a9157600080fd5b50508035926020909101359150565b60008060008060808587031215612ab657600080fd5b612abf85612868565b9350612acd60208601612868565b925060408501359150606085013567ffffffffffffffff811115612af057600080fd5b612afc8782880161295b565b91505092959194509250565b60008060408385031215612b1b57600080fd5b612b2483612868565b9150612b3260208401612868565b90509250929050565b600181811c90821680612b4f57607f821691505b602082108103612b88577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561074c5761074c612bbd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082612c3d57612c3d612bff565b500690565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612c7357612c73612bbd565b5060010190565b600082612c8957612c89612bff565b500490565b808202811582820484141761074c5761074c612bbd565b8181038181111561074c5761074c612bbd565b73ffffffffffffffffffffffffffffffffffffffff8516815273ffffffffffffffffffffffffffffffffffffffff84166020820152826040820152608060608201526000612d0960808301846127f1565b9695505050505050565b600060208284031215612d2557600080fd5b81516108a6816127a6565b73ffffffffffffffffffffffffffffffffffffffff84168152826020820152606060408201526000612d6560608301846127f1565b9594505050505056fea26469706673582212205810d89194d4e79891c394804f1266147df4159781027af4d121f89460c79def64736f6c634300081b0033
Verified Source Code Full Match
Compiler: v0.8.27+commit.40a35a09
EVM: paris
Optimization: Yes (1000000 runs)
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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 {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_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);
}
}
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IERC1363Receiver.sol 32 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title IERC1363Receiver
* @dev Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall`
* from ERC-1363 token contracts.
*/
interface IERC1363Receiver {
/**
* @dev Whenever ERC-1363 tokens are transferred to this contract via `transferAndCall` or `transferFromAndCall`
* by `operator` from `from`, this function is called.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
* (i.e. 0x88a7ca5c, or its own function selector).
*
* @param operator The address which called `transferAndCall` or `transferFromAndCall` function.
* @param from The address which the tokens are transferred from.
* @param value The amount of tokens transferred.
* @param data Additional data with no specified format.
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` if transfer is allowed unless throwing.
*/
function onTransferReceived(
address operator,
address from,
uint256 value,
bytes calldata data
) external returns (bytes4);
}
IERC1363Spender.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363Spender.sol)
pragma solidity ^0.8.20;
/**
* @title IERC1363Spender
* @dev Interface for any contract that wants to support `approveAndCall`
* from ERC-1363 token contracts.
*/
interface IERC1363Spender {
/**
* @dev Whenever an ERC-1363 token `owner` approves this contract via `approveAndCall`
* to spend their tokens, this function is called.
*
* NOTE: To accept the approval, this must return
* `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
* (i.e. 0x7b04a2d0, or its own function selector).
*
* @param owner The address which called `approveAndCall` function and previously owned the tokens.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format.
* @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` if approval is allowed unless throwing.
*/
function onApprovalReceived(address owner, uint256 value, bytes calldata data) external returns (bytes4);
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
ERC20.sol 312 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
ERC1363Utils.sol 95 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/ERC1363Utils.sol)
pragma solidity ^0.8.20;
import {IERC1363Receiver} from "../../../interfaces/IERC1363Receiver.sol";
import {IERC1363Spender} from "../../../interfaces/IERC1363Spender.sol";
/**
* @dev Library that provides common ERC-1363 utility functions.
*
* See https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*/
library ERC1363Utils {
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1363InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the token `spender`. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1363InvalidSpender(address spender);
/**
* @dev Performs a call to {IERC1363Receiver-onTransferReceived} on a target address.
*
* Requirements:
*
* - The target has code (i.e. is a contract).
* - The target `to` must implement the {IERC1363Receiver} interface.
* - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
*/
function checkOnERC1363TransferReceived(
address operator,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
revert ERC1363InvalidReceiver(to);
}
try IERC1363Receiver(to).onTransferReceived(operator, from, value, data) returns (bytes4 retval) {
if (retval != IERC1363Receiver.onTransferReceived.selector) {
revert ERC1363InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
revert ERC1363InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
}
}
}
}
/**
* @dev Performs a call to {IERC1363Spender-onApprovalReceived} on a target address.
*
* Requirements:
*
* - The target has code (i.e. is a contract).
* - The target `spender` must implement the {IERC1363Spender} interface.
* - The target must return the {IERC1363Spender-onApprovalReceived} selector to accept the approval.
*/
function checkOnERC1363ApprovalReceived(
address operator,
address spender,
uint256 value,
bytes memory data
) internal {
if (spender.code.length == 0) {
revert ERC1363InvalidSpender(spender);
}
try IERC1363Spender(spender).onApprovalReceived(operator, value, data) returns (bytes4 retval) {
if (retval != IERC1363Spender.onApprovalReceived.selector) {
revert ERC1363InvalidSpender(spender);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
revert ERC1363InvalidSpender(spender);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
}
}
}
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 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);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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);
}
Pausable.sol 119 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
ReentrancyGuard.sol 87 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @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 EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* 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;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
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() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
YieldBase.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;
contract YieldBase {
// Variables
uint256[][] public yields;
/**
* @notice Calculates the yield by summing up the elements of the yields array starting from index `i` using simple iteration for tests purposes.
* @param i The starting index from which to begin summing the yields.
* @return sum The total sum of the yields from index `i` to the end of the array.
*/
// Uncomment before running tests
// function getSimpleYield(uint256 i) public view returns (uint256 sum) {
// sum = 0;
// uint256[] memory y = yields[0];
// uint256 length = y.length;
// for (; i<length; i++) {
// sum += y[i];
// }
// return sum;
// }
}
YieldTokenProtocol.sol 611 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;
import "./YieldBase.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import {IERC165, ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IERC1363} from "@openzeppelin/contracts/interfaces/IERC1363.sol";
import {ERC1363Utils} from "@openzeppelin/contracts/token/ERC20/utils/ERC1363Utils.sol";
/**
* @title YieldTokenProtocol
* @dev A smart contract for managing yield tokens and rewards in an Ethereum-based yield system.
* Inherits from ERC20, YieldBase, ReentrancyGuard, Ownable, Pausable, ERC165, and IERC1363.
*
* Events:
* - FixYield(uint256 index, uint256 yield, uint256 totalSupply): Emitted when yield is added.
* - ClaimRewards(uint256 amount, address indexed claimerAddress): Emitted when rewards are claimed.
* - DestroyedBlackFunds(address _blackListedUser, uint _balance): Emitted when blacklisted funds are destroyed.
* - AddedBlackList(address _user): Emitted when an address is added to the blacklist.
* - RemovedBlackList(address _user): Emitted when a user is removed from the blacklist.
* - Mint(uint256 amount): Emitted when tokens are minted.
* - Burn(uint256 amount): Emitted when tokens are burned.
*
* Errors:
* - ERC1363TransferFailed(address receiver, uint256 value): Thrown if the transferAndCall operation fails.
* - ERC1363TransferFromFailed(address sender, address receiver, uint256 value): Thrown if the transferFromAndCall operation fails.
* - ERC1363ApproveFailed(address spender, uint256 value): Thrown if the approveAndCall operation fails.
* - YieldIsNull: Thrown if the provided yield is zero.
* - AmountIsNull: Thrown if the amount is zero.
* - AddressIsNull: Thrown if the address is null.
* - LevelIsWrong(uint256 level): Thrown if the provided level is incorrect.
* - InsufficientBalance: Thrown if there are insufficient funds.
* - ValuesAreTooLarge: Thrown if the values are too large.
*
* Constants:
* - N: The constant value used for yield calculations.
* - DENOMINATOR: The denominator used for reward calculations.
*
* State Variables:
* - yield_tails: An array storing yield tails.
* - packedIndexesRewards: A mapping of addresses to packed index rewards.
* - min_rewards_amount: The minimum amount of rewards.
* - isBlackListed: A mapping of addresses to their blacklist status.
*
* Constructor:
* - Initializes the contract with a name, symbol, and initial supply.
*
* Functions:
* - setMinRewardsAmount(uint256 newMinRewardsAmount): Allows the owner to change the minimum rewards amount.
* - fixYield(uint256 yield): Fixes the yield by adding the provided yield value to the yields array and updating the yield tails.
* - getYieldsLength(uint256 level): Returns the length of the yields array for a given level.
* - getYield(uint256 level, uint256 index): Retrieves the yield value for a given level and index.
* - getYieldByIndex(uint256 i): Calculates the yield sum for a given index.
* - getAccumulatedReward(address accountAddress): Calculates the accumulated reward for a given account.
* - pause(): Triggers stopped state.
* - unpause(): Unpauses the contract, allowing all functions to be called.
* - getBlackListStatus(address _maker): Checks if the given address is blacklisted.
* - addBlackList(address _evilUser): Adds an address to the blacklist.
* - removeBlackList(address _clearedUser): Removes an address from the blacklist.
* - destroyBlackFunds(address _blackListedUser): Destroys the funds of a blacklisted user.
* - mint(uint256 amount): Mints a specified amount of tokens to the owner's address.
* - burn(uint256 amount): Burns a specific amount of tokens.
* - transfer(address to, uint256 value): Transfers `value` tokens from the caller's account to the `to` address.
* - transferFrom(address from, address to, uint256 value): Transfers tokens from one address to another.
* - setPackedIndexesRewards(address user, uint256 value1, uint256 value2): Sets the packed indexes rewards for a given user.
* - getPackedIndexesRewards(address user): Retrieves the packed index rewards for a given user.
* - getClaimableRewards(address accountAddress): Retrieves the total claimable rewards for a given account.
* - claimRewards(): Allows users to claim their accumulated rewards.
* - transferAndCall(address to, uint256 value): Transfers tokens and calls a function on the recipient.
* - transferAndCall(address to, uint256 value, bytes memory data): Transfers tokens and calls a function on the recipient with additional data.
* - transferFromAndCall(address from, address to, uint256 value): Transfers tokens from one address to another and calls a function on the recipient.
* - transferFromAndCall(address from, address to, uint256 value, bytes memory data): Transfers tokens from one address to another and calls a function on the recipient with additional data.
* - approveAndCall(address spender, uint256 value): Sets the allowance and calls a function on the spender.
* - approveAndCall(address spender, uint256 value, bytes memory data): Sets the allowance and calls a function on the spender with additional data.
* - supportsInterface(bytes4 interfaceId): Checks if the contract supports a given interface.
*/
contract YieldTokenProtocol is ERC20, YieldBase, ReentrancyGuard, Ownable, Pausable, ERC165, IERC1363 {
/**
* @dev Event emitted when yield is added
* @param index Current index, e.g. length of yields[0]
* @param yield The amount of yield
* @param totalSupply Current totalSupply value
*/
event FixYield(uint256 index, uint256 yield, uint256 totalSupply);
/**
* @dev Event emitted when rewards is claimed
* @param amount The amount of the rewards claimed
* @param claimerAddress The address of the claimer
*/
event ClaimRewards(uint256 amount, address indexed claimerAddress);
/**
* @dev Emitted when blacklisted funds are destroyed.
* @param _blackListedUser The address of the blacklisted user.
* @param _balance The balance of the blacklisted user that was destroyed.
*/
event DestroyedBlackFunds(address _blackListedUser, uint _balance);
/**
* @dev Emitted when an address is added to the blacklist.
* @param _user The address that was added to the blacklist.
*/
event AddedBlackList(address _user);
/**
* @dev Emitted when a user is removed from the blacklist.
* @param _user The address of the user that was removed from the blacklist.
*/
event RemovedBlackList(address _user);
/**
* @dev Event emitted when tokens are minted.
* @param amount The amount of tokens minted.
*/
event Mint(uint256 amount);
/**
* @dev Event emitted when tokens are burned.
* @param amount The amount of tokens burned.
*/
event Burn(uint256 amount);
/**
* @dev Error if the provided yield is zero
*/
error YieldIsNull();
/**
* @dev Error if the amount is zero
*/
error AmountIsNull();
/**
* @dev Error if the address is null
*/
error AddressIsNull();
/**
* @dev Incorrect level
*/
error LevelIsWrong(uint256 level);
/**
* @dev Insufficient funds
*/
error InsufficientBalance();
/**
* @dev Values are too large
*/
error ValuesAreTooLarge();
/**
* @dev Indicates a failure within the {transfer} part of a transferAndCall operation.
* @param receiver Address to which tokens are being transferred.
* @param value Amount of tokens to be transferred.
*/
error ERC1363TransferFailed(address receiver, uint256 value);
/**
* @dev Indicates a failure within the {transferFrom} part of a transferFromAndCall operation.
* @param sender Address from which to send tokens.
* @param receiver Address to which tokens are being transferred.
* @param value Amount of tokens to be transferred.
*/
error ERC1363TransferFromFailed(address sender, address receiver, uint256 value);
/**
* @dev Indicates a failure within the {approve} part of a approveAndCall operation.
* @param spender Address which will spend the funds.
* @param value Amount of tokens to be spent.
*/
error ERC1363ApproveFailed(address spender, uint256 value);
// Constants
uint256 private constant N = 5;
uint256 private immutable DENOMINATOR = 1 * (10 ** decimals());
// Variables
uint256[] public yield_tails;
mapping(address => uint256) private packedIndexesRewards;
uint256 public min_rewards_amount;
mapping(address => bool) public isBlackListed;
constructor(string memory _name, string memory _symbol, uint256 _initialSupply) ERC20(_name, _symbol) Ownable(msg.sender) {
_mint(msg.sender, _initialSupply * (10 ** decimals()));
yields.push();
yield_tails.push();
}
/**
* @notice Allows the owner to change the minimum rewards amount.
* @param newMinRewardsAmount The new minimum rewards amount to be set.
* @dev This function can only be called by the owner of the contract.
*/
function setMinRewardsAmount(uint256 newMinRewardsAmount) external onlyOwner {
min_rewards_amount = newMinRewardsAmount;
}
/**
* @notice Fixes the yield by adding the provided yield value to the yields array and updating the yield tails.
* @dev This function performs several checks and updates to maintain the integrity of the yields array and yield tails.
* @param yield The yield value to be fixed. Must be non-zero.
* @custom:events Emits a `FixYield` event with the provided yield value and a fixed value of 1.
* @custom:requirements The yield value must be non-zero.
* @custom:updates Updates the `yields` and `yield_tails` arrays based on the provided yield value.
* @custom:reverts Reverts with `YieldIsNull` if the provided yield value is zero.
*/
function fixYield(uint256 yield) external onlyOwner {
if (yield == 0) {
revert YieldIsNull();
}
if (yields.length == 0) {
yields.push();
}
yields[0].push(yield);
uint256 levels = yields.length;
uint256 size = 1;
for (uint256 level = 0; level < levels; level++) {
uint256 length = yields[level].length;
uint256 sum = 0;
uint256 i = (length % N == 0) ? length - N : length - (length % N);
for (; i < length; i++) {
sum += yields[level][i];
}
if (length % N == 0) {
if (yields.length == level + 1) {
yields.push();
yield_tails.push();
}
if (yields[0].length % size == 0) {
yields[level + 1].push(sum);
}
sum = 0;
}
if (level + 1 < yield_tails.length) yield_tails[level + 1] = yield_tails[level] + sum;
if (length < N) break;
size *= N;
}
emit FixYield(yields[0].length, yield, totalSupply());
}
/**
* @notice Returns the length of the yields array for a given level.
* @param level The index of the yields array to query.
* @return length The length of the yields array at the specified level.
* @dev Reverts with `LevelIsWrong` if the provided level is out of bounds.
*/
function getYieldsLength(uint256 level) external view returns (uint256 length) {
if (level >= yields.length) {
revert LevelIsWrong(level);
}
return yields[level].length;
}
/**
* @notice Retrieves the yield value for a given level and index.
* @param level The level of the yield to retrieve.
* @param index The index within the specified level to retrieve the yield from.
* @return yield The yield value at the specified level and index.
* @dev If the level is out of bounds, the function reverts with a LevelIsWrong error.
* If the index is out of bounds, the function returns 0.
*/
function getYield(uint256 level, uint256 index) external view returns (uint256 yield) {
if (level >= yields.length) {
revert LevelIsWrong(level);
}
if (index >= yields[level].length) {
return 0;
}
return yields[level][index];
}
/**
* @notice Calculates the yield sum for a given index.
* @param i The index for which to calculate the yield sum.
* @return sum The total yield sum for the given index.
*
* This function iterates through the levels of the `yields` array and sums up the yields
* for the specified index. It handles different levels and groups of yields, summing up
* the yields of remaining periods in each level's group until the specified index is reached.
* If the top level is reached, it continues summing up the yields for the remaining indices
* in that level. Finally, it adds the yield tail for the last level to the sum and returns it.
*/
function getYieldByIndex(uint256 i) public view returns (uint256 sum) {
require(i <= yields[0].length, "Index out of bounds");
sum = 0;
uint256 level = 0;
uint256 length;
for (;;) {
length = yields[level].length;
// sum up yields of remaining periods in this level's group (e.g. upto i multiple of N)
for (; i % N > 0 && i < length; i++) sum += yields[level][i];
// if we reach top right corner, then leave
if (i == length) break;
// continue on next level
if (level + 1 < yields.length) {
level++;
i = i / N;
} else {
// or loop on top level
for (; i < length; i++) sum += yields[level][i];
break;
}
}
return sum + yield_tails[level];
}
/**
* @notice Calculates the accumulated reward for a given account.
* @param accountAddress The address of the account to calculate the reward for.
* @return reward The accumulated reward for the specified account.
*
* This function returns 0 if the account has no balance. Otherwise, it calculates
* the reward based on the account's yield and balance.
*/
function getAccumulatedReward(address accountAddress) public view returns (uint256 reward) {
if (balanceOf(accountAddress) == 0) return 0;
uint256 accountYield = getYieldByIndex(packedIndexesRewards[accountAddress] >> 128);
reward = (accountYield * balanceOf(accountAddress)) / DENOMINATOR;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The caller must be the owner.
*
* This function pauses the contract, preventing state-changing operations.
*/
function pause() public onlyOwner {
_pause();
}
/**
* @notice Unpauses the contract, allowing all functions to be called.
* @dev This function can only be called by the owner of the contract.
* It calls the internal _unpause function to change the paused state.
*/
function unpause() public onlyOwner {
_unpause();
}
/**
* @notice Checks if the given address is blacklisted.
* @param _maker The address to check for blacklist status.
* @return bool Returns true if the address is blacklisted, false otherwise.
*/
function getBlackListStatus(address _maker) external view returns (bool) {
return isBlackListed[_maker];
}
/**
* @notice Adds an address to the blacklist.
* @dev Only the owner can call this function.
* @param _evilUser The address to be added to the blacklist.
*/
function addBlackList(address _evilUser) public onlyOwner {
isBlackListed[_evilUser] = true;
emit AddedBlackList(_evilUser);
}
/**
* @notice Remove an address from the blacklist.
* @dev Only the owner can call this function.
* @param _clearedUser The address to be added to the blacklist.
*/
function removeBlackList(address _clearedUser) public onlyOwner {
isBlackListed[_clearedUser] = false;
emit RemovedBlackList(_clearedUser);
}
/**
* @notice Destroys the funds of a blacklisted user.
* @dev This function can only be called by the owner. It checks if the user is blacklisted,
* retrieves their balance, burns the funds, and emits a DestroyedBlackFunds event.
* @param _blackListedUser The address of the blacklisted user whose funds are to be destroyed.
*/
function destroyBlackFunds(address _blackListedUser) public onlyOwner {
require(isBlackListed[_blackListedUser], "Address is not blacklisted");
uint dirtyFunds = balanceOf(_blackListedUser);
_burn(_blackListedUser, dirtyFunds);
emit DestroyedBlackFunds(_blackListedUser, dirtyFunds);
}
/**
* @notice Mints a specified amount of tokens to the owner's address.
* @dev This function can only be called by the contract owner.
* @param amount The amount of tokens to mint.
*/
function mint(uint256 amount) public onlyOwner {
_mint(owner(), amount);
emit Mint(amount);
}
/**
* @notice Burns a specific amount of tokens.
* @dev This function can only be called by the owner of the contract.
* @param amount The amount of tokens to be burned.
*/
function burn(uint256 amount) public onlyOwner {
_burn(owner(), amount);
emit Burn(amount);
}
/**
* @notice Transfers `value` tokens from the caller's account to the `to` address.
* @dev Overrides the transfer function to include yield reward calculations.
* Updates the packedIndexesRewards for both the sender and the recipient with the accumulated rewards.
* @param to The address to transfer tokens to.
* @param value The amount of tokens to transfer.
* @return bool Returns true if the transfer was successful.
*/
function transfer(address to, uint256 value) public override(ERC20, IERC20) whenNotPaused returns (bool) {
address sender = _msgSender();
require(!isBlackListed[sender], "Blacklisted address");
uint256 packed = (yields[0].length << 128);
packedIndexesRewards[sender] = packed | ((packedIndexesRewards[sender] & ((1 << 128) - 1)) + getAccumulatedReward(sender));
packedIndexesRewards[to] = packed | ((packedIndexesRewards[to] & ((1 << 128) - 1)) + getAccumulatedReward(to));
_transfer(sender, to, value);
return true;
}
/**
* @notice Transfers tokens from one address to another.
* @dev Overrides the transferFrom function to include reward accumulation logic.
* @param from The address to transfer tokens from.
* @param to The address to transfer tokens to.
* @param value The amount of tokens to transfer.
* @return bool Returns true if the transfer was successful.
*/
function transferFrom(address from, address to, uint256 value) public override(ERC20, IERC20) whenNotPaused returns (bool) {
require(!isBlackListed[from], "Blacklisted address");
address spender = _msgSender();
uint256 packed = (yields[0].length << 128);
packedIndexesRewards[spender] = packed | ((packedIndexesRewards[spender] & ((1 << 128) - 1)) + getAccumulatedReward(spender));
packedIndexesRewards[to] = packed | ((packedIndexesRewards[to] & ((1 << 128) - 1)) + getAccumulatedReward(to));
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @notice Sets the packed indexes rewards for a given user.
* @dev Combines two 128-bit values into a single 256-bit value and stores it in the packedIndexesRewards mapping.
* Reverts if either value1 or value2 is greater than or equal to 2^128.
* @param user The address of the user for whom the packed indexes rewards are being set.
* @param value1 The first 128-bit value to be packed.
* @param value2 The second 128-bit value to be packed.
*/
function setPackedIndexesRewards(address user, uint256 value1, uint256 value2) internal {
if (value1 >= 2 ** 128 || value2 >= 2 ** 128) {
revert ValuesAreTooLarge();
}
packedIndexesRewards[user] = (value1 << 128) | value2;
}
/**
* @notice Retrieves the packed index rewards for a given user.
* @param user The address of the user whose packed index rewards are being retrieved.
* @return value1 The first 128-bit value extracted from the packed index rewards.
* @return value2 The second 128-bit value extracted from the packed index rewards.
*/
function getPackedIndexesRewards(address user) public view returns (uint256, uint256) {
uint256 packed = packedIndexesRewards[user];
uint256 value1 = packed >> 128;
uint256 value2 = packed & ((1 << 128) - 1);
return (value1, value2);
}
/**
* @notice Retrieves the total claimable rewards for a given account.
* @param accountAddress The address of the account to query rewards for.
* @return reward The total amount of claimable rewards for the specified account.
*/
function getClaimableRewards(address accountAddress) public view returns (uint256 reward) {
(, reward) = getPackedIndexesRewards(accountAddress);
return reward += getAccumulatedReward(accountAddress);
}
/**
* @notice Allows users to claim their accumulated rewards.
* @dev This function is protected against reentrancy attacks using the nonReentrant modifier.
* It calculates the total rewards for the caller, ensures the contract has enough balance,
* updates the reward indexes, and transfers the rewards to the caller.
* require The caller must have rewards available to claim.
* require The contract must have sufficient balance to fulfill the reward claim.
* emit ClaimRewards Emitted when rewards are successfully claimed.
*/
function claimRewards() external nonReentrant whenNotPaused {
address claimer = _msgSender();
(, uint256 rewards) = getPackedIndexesRewards(claimer);
rewards += getAccumulatedReward(claimer);
// Ensure rewards not null
require(rewards > 0, "No rewards available for claim");
// Ensure the reward amount more or equal to min_rewards_amount
require(rewards >= min_rewards_amount, "Rewards amount is less than minimum rewards amount");
// Ensure the contract has enough balance
require(balanceOf(address(this)) >= rewards, "Insufficient balance for claim rewards");
// Update the index before transferring to prevent reentrancy
setPackedIndexesRewards(claimer, yields[0].length, 0);
// Transfer the tokens
_transfer(address(this), claimer, rewards);
// Emit the event
emit ClaimRewards(rewards, claimer);
}
/**
* @inheritdoc IERC165
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC1363).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
*
* Requirements:
*
* - The target has code (i.e. is a contract).
* - The target `to` must implement the {IERC1363Receiver} interface.
* - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
* - The internal {transfer} must succeed (returned `true`).
*/
function transferAndCall(address to, uint256 value) public returns (bool) {
return transferAndCall(to, value, "");
}
/**
* @dev Variant of {transferAndCall} that accepts an additional `data` parameter with
* no specified format.
*/
function transferAndCall(address to, uint256 value, bytes memory data) public virtual returns (bool) {
if (!transfer(to, value)) {
revert ERC1363TransferFailed(to, value);
}
ERC1363Utils.checkOnERC1363TransferReceived(_msgSender(), _msgSender(), to, value, data);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
*
* Requirements:
*
* - The target has code (i.e. is a contract).
* - The target `to` must implement the {IERC1363Receiver} interface.
* - The target must return the {IERC1363Receiver-onTransferReceived} selector to accept the transfer.
* - The internal {transferFrom} must succeed (returned `true`).
*/
function transferFromAndCall(address from, address to, uint256 value) public returns (bool) {
return transferFromAndCall(from, to, value, "");
}
/**
* @dev Variant of {transferFromAndCall} that accepts an additional `data` parameter with
* no specified format.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public virtual returns (bool) {
if (!transferFrom(from, to, value)) {
revert ERC1363TransferFromFailed(from, to, value);
}
ERC1363Utils.checkOnERC1363TransferReceived(_msgSender(), from, to, value, data);
return true;
}
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
*
* Requirements:
*
* - The target has code (i.e. is a contract).
* - The target `spender` must implement the {IERC1363Spender} interface.
* - The target must return the {IERC1363Spender-onApprovalReceived} selector to accept the approval.
* - The internal {approve} must succeed (returned `true`).
*/
function approveAndCall(address spender, uint256 value) public returns (bool) {
return approveAndCall(spender, value, "");
}
/**
* @dev Variant of {approveAndCall} that accepts an additional `data` parameter with
* no specified format.
*/
function approveAndCall(address spender, uint256 value, bytes memory data) public virtual returns (bool) {
if (!approve(spender, value)) {
revert ERC1363ApproveFailed(spender, value);
}
ERC1363Utils.checkOnERC1363ApprovalReceived(_msgSender(), spender, value, data);
return true;
}
}
Read Contract
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
decimals 0x313ce567 → uint8
getAccumulatedReward 0x5817c4b6 → uint256
getBlackListStatus 0x59bf1abe → bool
getClaimableRewards 0x308e401e → uint256
getPackedIndexesRewards 0x767527ae → uint256, uint256
getYield 0xd967f279 → uint256
getYieldByIndex 0x29868afd → uint256
getYieldsLength 0x1afc7512 → uint256
isBlackListed 0xe47d6060 → bool
min_rewards_amount 0xa02cd2fc → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
yield_tails 0xde923bd0 → uint256
yields 0xa08301bc → uint256
Write Contract 21 functions
These functions modify contract state and require a wallet transaction to execute.
addBlackList 0x0ecb93c0
address _evilUser
approve 0x095ea7b3
address spender
uint256 value
returns: bool
approveAndCall 0x3177029f
address spender
uint256 value
returns: bool
approveAndCall 0xcae9ca51
address spender
uint256 value
bytes data
returns: bool
burn 0x42966c68
uint256 amount
claimRewards 0x372500ab
No parameters
destroyBlackFunds 0xf3bdc228
address _blackListedUser
fixYield 0x5d232dc3
uint256 yield
mint 0xa0712d68
uint256 amount
pause 0x8456cb59
No parameters
removeBlackList 0xe4997dc5
address _clearedUser
renounceOwnership 0x715018a6
No parameters
setMinRewardsAmount 0x9f875137
uint256 newMinRewardsAmount
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferAndCall 0x1296ee62
address to
uint256 value
returns: bool
transferAndCall 0x4000aea0
address to
uint256 value
bytes data
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
transferFromAndCall 0xc1d34b89
address from
address to
uint256 value
bytes data
returns: bool
transferFromAndCall 0xd8fbe994
address from
address to
uint256 value
returns: bool
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
Recent Transactions
No transactions found for this address