Address Contract Verified
Address
0x918B7Ce7Bfc40C20aEE5B4c8e9e606a3666779bd
Balance
0 ETH
Nonce
1
Code Size
8912 bytes
Creator
0xAE2c0c6e...a7e1 at tx 0x4236e486...ef307d
Indexed Transactions
0
Contract Bytecode
8912 bytes
0x608060405234801561000f575f5ffd5b5060043610610291575f3560e01c8063021919801461029557806306fdde031461029f578063095ea7b3146102bd578063151d9b74146102e057806318160ddd1461030157806323b872dd146103095780632c28f0261461031c5780632e1a7d4d1461032f578063313ce5671461034257806335981fd814610351578063394edada14610359578063395093511461036c57806340d0dcdd1461037f5780634e71e0c81461039f5780635438ebaa146103a7578063574eab01146103af5780635c975abb146103c35780635db88e85146103cb5780635f3743df146103d45780635f84f302146103f65780635fed40da146104095780636095ad551461041c57806363d8882a1461042457806364259daa1461042c5780636c561567146104345780636f9170f61461044757806370a0823114610469578063715018a61461047c57806378357689146104845780637c3a00fd146104985780637d31de9c146104a15780638c859fca146104b4578063900eb005146104c757806395b20d6e146104da57806395d89b41146104f95780639d23c812146105015780639f7096b6146105355780639f981e1a146105485780639fa8e27214610550578063a457c2d714610563578063a9059cbb14610576578063abec101f14610589578063aecf8a6d1461059c578063b5ed298a146105af578063b6b55f25146105c2578063c35ad6b0146105d5578063ce114c25146105de578063cf52a7b2146105f1578063d3573a3314610604578063d5dc58d614610617578063dd62ed3e1461062a578063e425e8b51461063d578063e742806a14610645578063ebbf5c1714610658578063ed9c68341461066b578063ee97f7f31461068a578063f1ead2521461069c575b5f5ffd5b61029d6106a4565b005b6102a76106c8565b6040516102b49190611ee5565b60405180910390f35b6102d06102cb366004611f30565b610758565b60405190151581526020016102b4565b6102f36102ee366004611f58565b610771565b6040519081526020016102b4565b6005546102f3565b6102d0610317366004611f71565b61077c565b6102f361032a366004611f30565b6107a6565b61029d61033d366004611fab565b6107da565b604051601281526020016102b4565b6102f36109dd565b6102f3610367366004611f30565b610a11565b6102d061037a366004611f30565b610af4565b61039261038d366004612079565b610b15565b6040516102b491906120ba565b61029d610bff565b61029d610c1a565b600a546102d090600160a01b900460ff1681565b6102d0610c45565b6102f3600b5481565b6102d06103e2366004611f58565b600c6020525f908152604090205460ff1681565b61029d610404366004611fab565b610c55565b6103926104173660046120fc565b610c74565b61029d610c80565b61029d610ca7565b61029d610cbf565b610392610442366004612079565b610ce7565b6102d0610455366004611f58565b600d6020525f908152604090205460ff1681565b6102f3610477366004611f58565b610d74565b61029d610d8e565b600a546102d090600160a81b900460ff1681565b6102f360085481565b6102f36104af366004611f58565b610dda565b61029d6104c2366004611f58565b610ec8565b6103926104d53660046120fc565b610efb565b6102f36104e8366004611f58565b600e6020525f908152604090205481565b6102a7610f07565b6105287f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b6040516102b4919061212d565b600a54610528906001600160a01b031681565b61029d610f16565b6102f361055e366004611fab565b610f43565b6102d0610571366004611f30565b610f7c565b6102d0610584366004611f30565b611001565b6102f3610597366004611fab565b611029565b61029d6105aa366004611f30565b611056565b61029d6105bd366004611f58565b6110b4565b61029d6105d0366004611fab565b61112e565b6102f360095481565b61029d6105ec366004611f58565b611151565b61029d6105ff366004611f58565b61118a565b600154610528906001600160a01b031681565b6102f3610625366004611f58565b6111c6565b6102f3610638366004612141565b6111d1565b6102f36111fb565b61029d610653366004611f30565b61121e565b61029d610666366004611fab565b61126d565b6102f3610679366004611f58565b600f6020525f908152604090205481565b5f54610528906001600160a01b031681565b61029d61128c565b6106ac6112b9565b6106b46112ed565b6106bc611344565b6106c66001600255565b565b6060600680546106d790612172565b80601f016020809104026020016040519081016040528092919081815260200182805461070390612172565b801561074e5780601f106107255761010080835404028352916020019161074e565b820191905f5260205f20905b81548152906001019060200180831161073157829003601f168201915b5050505050905090565b5f3361076581858561139e565b60019150505b92915050565b5f61076b8242610a11565b5f83610787816114c1565b83610791816114c1565b61079c86868661151c565b9695505050505050565b5f6107b18383610a11565b6001600160a01b0384165f908152600f60205260409020546107d391906121be565b9392505050565b6107e26112ed565b6107ea611534565b336107f4816114c1565b600a54600160a01b900460ff1661081e576040516315e34e0560e01b815260040160405180910390fd5b8161082833610d74565b101561084757604051631e9acf1760e31b815260040160405180910390fd5b6040516370a0823160e01b815282906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816906370a082319061089590309060040161212d565b602060405180830381865afa1580156108b0573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108d491906121d1565b1015827f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610923919061212d565b602060405180830381865afa15801561093e573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061096291906121d1565b909161098f57604051630c9dfce960e11b8152600481019290925260248201526044015b60405180910390fd5b505061099b338361157c565b6109cf6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816338461169b565b506109da6001600255565b50565b5f6109e66112ed565b6109ee611534565b336109f8816114c1565b610a01336116fe565b915050610a0e6001600255565b90565b5f5f610a1c84610d74565b9050805f03610a2e575f91505061076b565b6001600160a01b0384165f908152600e602052604081205415610a68576001600160a01b0385165f908152600e6020526040902054610a6a565b835b9050808411610a7d575f9250505061076b565b5f610a8882866121e8565b90505f6301e14320610aa2670de0b6b3a7640000846121fb565b610aac9190612212565b90505f670de0b6b3a76400006127108360085488610aca91906121fb565b610ad491906121fb565b610ade9190612212565b610ae89190612212565b98975050505050505050565b5f33610765818585610b0683836111d1565b610b1091906121be565b61139e565b60605f83516001600160401b03811115610b3157610b31611fc2565b604051908082528060200260200182016040528015610b5a578160200160208202803683370190505b5090505f5b8451811015610bf757610b8b858281518110610b7d57610b7d612231565b602002602001015185610a11565b600f5f878481518110610ba057610ba0612231565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f2054610bd291906121be565b828281518110610be457610be4612231565b6020908102919091010152600101610b5f565b509392505050565b610c0761177c565b5f80546001600160a01b03191633179055565b610c226112ed565b335f908152600c60205260409020805460ff191660011790556106c66001600255565b600154600160a01b900460ff1690565b610c5d6117a9565b610c656112ed565b60088190556109da6001600255565b606061076b8242610ce7565b610c886117a9565b610c906112ed565b600a805460ff60a01b191690556106c66001600255565b610caf6112b9565b610cb76112ed565b6106bc6117ec565b610cc76112ed565b335f908152600c60205260409020805460ff191690556106c66001600255565b60605f83516001600160401b03811115610d0357610d03611fc2565b604051908082528060200260200182016040528015610d2c578160200160208202803683370190505b5090505f5b8451811015610bf757610d4f858281518110610b7d57610b7d612231565b828281518110610d6157610d61612231565b6020908102919091010152600101610d31565b6001600160a01b03165f9081526003602052604090205490565b610d96611828565b5f80546001600160a01b0319908116825560018054909116905560405133917f6172baf984ea013d88b784409f46655b96ba7f2ff91bca1ac9bcd27b113e6eb091a2565b5f610de36112ed565b81610ded816114c1565b33610df7816114c1565b610dff611534565b610e076112b9565b6001600160a01b0384165f908152600c602052604090205460ff16610e3f5760405163e35e1ed360e01b815260040160405180910390fd5b5f610e49856116fe565b90505f61271060095483610e5d91906121fb565b610e679190612212565b90505f610e7482846121e8565b9050610e7f81611854565b80610e8a33336111d1565b1015610ea657610e9b33335f61139e565b610ea633338361139e565b610eb133888361077c565b5091945050505050610ec36001600255565b919050565b610ed06117a9565b610ed86112ed565b600a80546001600160a01b0319166001600160a01b038316179055600160025550565b606061076b8242610b15565b6060600780546106d790612172565b610f1e6117a9565b610f266112ed565b600a805460ff60a81b1916600160a81b1790556106c66001600255565b5f610f4c6112ed565b610f54611534565b33610f5e816114c1565b610f6783611854565b610f6f6118d6565b915050610ec36001600255565b5f3381610f8982866111d1565b905083811015610fe95760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610986565b610ff6828686840361139e565b506001949350505050565b5f3361100c816114c1565b83611016816114c1565b61102085856118ec565b95945050505050565b5f6110326112ed565b61103a611534565b33611044816114c1565b61104d83611854565b610f6f336116fe565b61105e6117a9565b81611068816114c1565b6110706112ed565b600a54600160a81b900460ff161561109b5760405163443da05b60e01b815260040160405180910390fd5b6110a5838361157c565b6110af6001600255565b505050565b6110bc611828565b6001600160a01b0381166110e35760405163f2365b5b60e01b815260040160405180910390fd5b600180546001600160a01b0319166001600160a01b03831690811790915560405133907f322fd6444c59daffa82e4689b7685b6fafc6109a1eff8a6ca10c5a8e3206cda1905f90a350565b611136611534565b61113e6112ed565b33611148816114c1565b6109cf82611854565b6111596117a9565b6111616112ed565b6001600160a01b0381165f908152600d60205260409020805460ff191690556109da6001600255565b6111926117a9565b61119a6112ed565b6001600160a01b0381165f908152600d60205260409020805460ff191660011790556109da6001600255565b5f61076b82426107a6565b6001600160a01b039182165f90815260046020908152604080832093909416825291909152205490565b5f6112046112ed565b61120c611534565b33611216816114c1565b610a016118d6565b6112266117a9565b81611230816114c1565b6112386112ed565b600a54600160a81b900460ff16156112635760405163443da05b60e01b815260040160405180910390fd5b6110a583836118f9565b6112756117a9565b61127d6112ed565b600b8190556109da6001600255565b6112946117a9565b61129c6112ed565b600a805460ff60a01b1916600160a01b1790556106c66001600255565b335f908152600d602052604090205460ff1615156001146106c657604051636a9a57a560e01b815260040160405180910390fd5b600280540361133e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610986565b60028055565b61134c611534565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586113873390565b604051611394919061212d565b60405180910390a1565b6001600160a01b0383166114005760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610986565b6001600160a01b0382166114615760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610986565b6001600160a01b038381165f8181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b5f6114cb82610771565b90508015611500576001600160a01b0382165f908152600f6020526040812080548392906114fa9084906121be565b90915550505b506001600160a01b03165f908152600e60205260409020429055565b5f336115298582856119a5565b610ff6858585611a1d565b61153c610c45565b156106c65760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610986565b6001600160a01b0382166115dc5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610986565b6001600160a01b0382165f908152600360205260409020548181101561164f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610986565b6001600160a01b0383165f8181526003602090815260408083208686039055600580548790039055518581529192915f51602061227b5f395f51905f52910160405180910390a3505050565b6040516001600160a01b0383166024820152604481018290526110af90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611bb3565b6001600160a01b0381165f908152600f6020526040812054808203611736576040516379a85f2d60e01b815260040160405180910390fd5b6001600160a01b038084165f908152600f602052604081205561076b907f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816338361169b565b6001546001600160a01b0316330361179057565b6040516379543eaf60e11b815260040160405180910390fd5b5f546001600160a01b0316338082146117e85760405163a3ee740f60e01b81526001600160a01b03928316600482015291166024820152604401610986565b5050565b6117f4611c86565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611387565b5f546001600160a01b0316330361183b57565b604051635a7617f960e11b815260040160405180910390fd5b61185d81611cd1565b61186733826118f9565b61189c6001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816333084611d27565b600a546109da906001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48811691168361169b565b5f5f6118e1336116fe565b9050610ec381611854565b5f33610765818585611a1d565b6001600160a01b03821661194f5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610986565b8060055f82825461196091906121be565b90915550506001600160a01b0382165f818152600360209081526040808320805486019055518481525f51602061227b5f395f51905f52910160405180910390a35050565b5f6119b084846111d1565b90505f198114611a175781811015611a0a5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610986565b611a17848484840361139e565b50505050565b6001600160a01b038316611a815760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610986565b6001600160a01b038216611ae35760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610986565b6001600160a01b0383165f9081526003602052604090205481811015611b5a5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610986565b6001600160a01b038085165f8181526003602052604080822086860390559286168082529083902080548601905591515f51602061227b5f395f51905f5290611ba69086815260200190565b60405180910390a3611a17565b5f611c07826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611d5f9092919063ffffffff16565b905080515f1480611c27575080806020019051810190611c279190612245565b6110af5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610986565b611c8e610c45565b6106c65760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610986565b805f03611cf157604051632a9ffab760e21b815260040160405180910390fd5b600b5481611cfe60055490565b611d0891906121be565b11156109da57604051639c960c6360e01b815260040160405180910390fd5b6040516001600160a01b0380851660248301528316604482015260648101829052611a179085906323b872dd60e01b906084016116c7565b6060611d6d84845f85611d75565b949350505050565b606082471015611dd65760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610986565b5f5f866001600160a01b03168587604051611df19190612264565b5f6040518083038185875af1925050503d805f8114611e2b576040519150601f19603f3d011682016040523d82523d5f602084013e611e30565b606091505b5091509150611e4187838387611e4c565b979650505050505050565b60608315611eba5782515f03611eb3576001600160a01b0385163b611eb35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610986565b5081611d6d565b611d6d8383815115611ecf5781518083602001fd5b8060405162461bcd60e51b815260040161098691905b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b0381168114610ec3575f5ffd5b5f5f60408385031215611f41575f5ffd5b611f4a83611f1a565b946020939093013593505050565b5f60208284031215611f68575f5ffd5b6107d382611f1a565b5f5f5f60608486031215611f83575f5ffd5b611f8c84611f1a565b9250611f9a60208501611f1a565b929592945050506040919091013590565b5f60208284031215611fbb575f5ffd5b5035919050565b634e487b7160e01b5f52604160045260245ffd5b5f82601f830112611fe5575f5ffd5b81356001600160401b03811115611ffe57611ffe611fc2565b604051600582901b90603f8201601f191681016001600160401b038111828210171561202c5761202c611fc2565b604052918252602081850181019290810186841115612049575f5ffd5b6020860192505b8383101561206f5761206183611f1a565b815260209283019201612050565b5095945050505050565b5f5f6040838503121561208a575f5ffd5b82356001600160401b0381111561209f575f5ffd5b6120ab85828601611fd6565b95602094909401359450505050565b602080825282518282018190525f918401906040840190835b818110156120f15783518352602093840193909201916001016120d3565b509095945050505050565b5f6020828403121561210c575f5ffd5b81356001600160401b03811115612121575f5ffd5b611d6d84828501611fd6565b6001600160a01b0391909116815260200190565b5f5f60408385031215612152575f5ffd5b61215b83611f1a565b915061216960208401611f1a565b90509250929050565b600181811c9082168061218657607f821691505b6020821081036121a457634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561076b5761076b6121aa565b5f602082840312156121e1575f5ffd5b5051919050565b8181038181111561076b5761076b6121aa565b808202811582820484141761076b5761076b6121aa565b5f8261222c57634e487b7160e01b5f52601260045260245ffd5b500490565b634e487b7160e01b5f52603260045260245ffd5b5f60208284031215612255575f5ffd5b815180151581146107d3575f5ffd5b5f82518060208501845e5f92019182525091905056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212203b55ba93602cb55c26dc43d1afdd5ca33bb0bf46a4233e843f052473b2462e9264736f6c634300081c0033
Verified Source Code Full Match
Compiler: v0.8.28+commit.7893614a
EVM: cancun
Optimization: Yes (1 runs)
ForwardVaultERC20.sol 761 lines
// SPDX-License-Identifier: -- WISE --
pragma solidity =0.8.28;
import "./OwnableMaster.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract ForwardVaultERC20 is OwnableMaster, Pausable, ReentrancyGuard, ERC20 {
using SafeERC20 for IERC20;
error NoRewards();
error NotWhiteListed();
error NoInterest();
error InvalidValue();
error InvalidPosition();
error DepositExceedCap();
error OnlyOwner(
address owner,
address caller
);
error InsufficientBalanceInContract(
uint256 attemptedWithdrawAmount,
uint256 contractBalance
);
error CompoundNotAllowed();
error WithdrawNotAllowed();
error InsufficientBalance();
error SupplyChangeNotAllowed();
IERC20 public immutable USD_TOKEN;
uint256 public interestRate;
uint256 public autoCompoundIncentive;
address public thirdPartyAddress;
bool public withdrawAllowed;
bool public supplyChangeByOwnerNotAllowed;
uint256 public totalDepositCap;
uint256 constant SECONDS_IN_YEAR = 31_540_000;
uint256 constant PRECISION_RATE = 10_000;
uint256 constant PRECISION_FACTOR_E18 = 1e18;
mapping (address => bool) public autoCompoundAllowed;
mapping (address => bool) public isWhiteListed;
mapping (address => uint256) public lastSyncTimeStamp;
mapping (address => uint256) public cashedInterest;
modifier onlyOwner() {
_onlyOwner();
_;
}
modifier onlyWhiteListed() {
_onlyWhiteListed();
_;
}
modifier assignInterest(
address _user
) {
_assignInterest(
_user
);
_;
}
constructor(
address _usdAddress,
address _thirdPartyAddress,
address[] memory _initialDistributionAddresses,
uint256[] memory _initialDistributionAmounts,
uint256 _totalDepositCap,
uint256 _interestRate,
uint256 _autoCompoundIncentive,
string memory _tokenName,
string memory _tokenSymbol
)
OwnableMaster(
msg.sender
)
ERC20(
_tokenName,
_tokenSymbol
)
{
USD_TOKEN = IERC20(
_usdAddress
);
thirdPartyAddress = _thirdPartyAddress;
totalDepositCap = _totalDepositCap;
interestRate = _interestRate;
if (_interestRate == 0) {
revert InvalidValue();
}
if (_totalDepositCap == 0) {
revert InvalidValue();
}
if (_usdAddress == ZERO_ADDRESS) {
revert InvalidValue();
}
if (_thirdPartyAddress == ZERO_ADDRESS) {
revert InvalidValue();
}
for (uint256 i = 0; i < _initialDistributionAddresses.length; i++) {
_mint(
_initialDistributionAddresses[i],
_initialDistributionAmounts[i]
);
_assignInterest(
_initialDistributionAddresses[i]
);
}
autoCompoundIncentive = _autoCompoundIncentive;
isWhiteListed[msg.sender] = true;
}
function _assignInterest(
address _user
)
private
{
uint256 interest = getPendingInterest(
_user
);
if (interest > 0) {
cashedInterest[_user] += interest;
}
lastSyncTimeStamp[_user] = block.timestamp;
}
function _onlyOwner()
private
view
{
require(
msg.sender == master,
OnlyOwner(
master,
msg.sender
)
);
}
function _onlyWhiteListed()
private
view
{
require(
isWhiteListed[msg.sender] == true,
NotWhiteListed()
);
}
function allowWithdraw()
external
onlyOwner
nonReentrant
{
withdrawAllowed = true;
}
function disallowWithdraw()
external
onlyOwner
nonReentrant
{
withdrawAllowed = false;
}
function disAllowSupplyChangeByOwner()
external
onlyOwner
nonReentrant
{
supplyChangeByOwnerNotAllowed = true;
}
function mintSupply(
address _to,
uint256 _amount
)
external
onlyOwner
assignInterest(
_to
)
nonReentrant
{
require(
supplyChangeByOwnerNotAllowed == false,
SupplyChangeNotAllowed()
);
_mint(
_to,
_amount
);
}
function burnSupply(
address _from,
uint256 _amount
)
external
onlyOwner
assignInterest(
_from
)
nonReentrant
{
require(
supplyChangeByOwnerNotAllowed == false,
SupplyChangeNotAllowed()
);
_burn(
_from,
_amount
);
}
function deposit(
uint256 _amount
)
external
whenNotPaused
nonReentrant
assignInterest(
msg.sender
)
{
_deposit(
_amount
);
}
function _deposit(
uint256 _amount
)
internal
{
_checkValuesDeposit(
_amount
);
_mint(
msg.sender,
_amount
);
USD_TOKEN.safeTransferFrom(
msg.sender,
address(this),
_amount
);
USD_TOKEN.safeTransfer(
thirdPartyAddress,
_amount
);
}
function getPendingInterestByTimeStamp(
address _user,
uint256 _timestamp
)
public
view
returns (uint256)
{
uint256 currentBalance = balanceOf(
_user
);
if (currentBalance == 0) {
return 0;
}
uint256 lastSync = lastSyncTimeStamp[_user] == 0
? _timestamp
: lastSyncTimeStamp[_user];
if (_timestamp <= lastSync) {
return 0;
}
uint256 timeDelta = _timestamp
- lastSync;
uint256 yearFactor = timeDelta
* PRECISION_FACTOR_E18
/ SECONDS_IN_YEAR;
uint256 interest = currentBalance
* interestRate
* yearFactor
/ PRECISION_RATE
/ PRECISION_FACTOR_E18;
return interest;
}
function getPendingInterest(
address _user
)
public
view
returns (uint256)
{
return getPendingInterestByTimeStamp(
_user,
block.timestamp
);
}
function getPendingInterestBulkByTimeStamp(
address[] memory _users,
uint256 _timestamp
)
public
view
returns (uint256[] memory)
{
uint256[] memory pendingInterests = new uint256[](
_users.length
);
for (uint256 i = 0; i < _users.length; i++) {
pendingInterests[i] = getPendingInterestByTimeStamp(
_users[i],
_timestamp
);
}
return pendingInterests;
}
function getPendingInterestBulk(
address[] memory _users
)
public
view
returns (uint256[] memory)
{
return getPendingInterestBulkByTimeStamp(
_users,
block.timestamp
);
}
function getTotalInterestUserByTimeStamp(
address _user,
uint256 _timestamp
)
public
view
returns (uint256)
{
return cashedInterest[_user]
+ getPendingInterestByTimeStamp(
_user,
_timestamp
);
}
function getTotalInterestUser(
address _user
)
external
view
returns (uint256)
{
return getTotalInterestUserByTimeStamp(
_user,
block.timestamp
);
}
function getTotalInterestUserBulkByTimeStamp(
address[] memory _users,
uint256 _timestamp
)
public
view
returns (uint256[] memory)
{
uint256[] memory totalInterests = new uint256[](
_users.length
);
for (uint256 i = 0; i < _users.length; i++) {
totalInterests[i] = cashedInterest[_users[i]] + getPendingInterestByTimeStamp(
_users[i],
_timestamp
);
}
return totalInterests;
}
function getTotalInterestUserBulk(
address[] memory _users
)
public
view
returns (uint256[] memory)
{
return getTotalInterestUserBulkByTimeStamp(
_users,
block.timestamp
);
}
function _checkValuesDeposit(
uint256 _amount
)
private
view
{
if (_amount == 0) {
revert InvalidValue();
}
if (totalSupply() + _amount > totalDepositCap) {
revert DepositExceedCap();
}
}
function transfer(
address to,
uint256 amount
)
public
assignInterest(
msg.sender
)
assignInterest(
to
)
override
returns (bool)
{
return super.transfer(
to,
amount
);
}
function transferFrom(
address from,
address to,
uint256 amount
)
public
assignInterest(
from
)
assignInterest(
to
)
override
returns (bool)
{
return super.transferFrom(
from,
to,
amount
);
}
function pauseDeposits()
external
onlyWhiteListed
nonReentrant
{
_pause();
}
function unpauseDeposits()
external
onlyWhiteListed
nonReentrant
{
_unpause();
}
function setThirdPartyAddress(
address _thirdPartyAddress
)
external
onlyOwner
nonReentrant
{
thirdPartyAddress = _thirdPartyAddress;
}
function setInterestRate(
uint256 _interestRate
)
external
onlyOwner
nonReentrant
{
interestRate = _interestRate;
}
function setTotalDepositCap(
uint256 _totalDepositCap
)
external
onlyOwner
nonReentrant
{
totalDepositCap = _totalDepositCap;
}
function claimInterest()
external
nonReentrant
whenNotPaused
assignInterest(
msg.sender
)
returns (uint256)
{
return _claimInterest(
msg.sender
);
}
function depositAndClaimInterest(
uint256 _amount
)
external
nonReentrant
whenNotPaused
assignInterest(
msg.sender
)
returns (uint256)
{
_deposit(
_amount
);
return _claimInterest(
msg.sender
);
}
function depositAndCompoundInterest(
uint256 _amount
)
external
nonReentrant
whenNotPaused
assignInterest(
msg.sender
)
returns (uint256)
{
_deposit(
_amount
);
return _compoundInterest();
}
function _claimInterest(
address _user
)
private
returns (uint256)
{
uint256 interest = cashedInterest[_user];
if (interest == 0) {
revert NoInterest();
}
cashedInterest[_user] = 0;
USD_TOKEN.safeTransfer(
msg.sender,
interest
);
return interest;
}
function disallowAutoCompound()
external
nonReentrant
{
autoCompoundAllowed[msg.sender] = false;
}
function allowAutoCompound()
external
nonReentrant
{
autoCompoundAllowed[msg.sender] = true;
}
function compoundInterest()
public
nonReentrant
whenNotPaused
assignInterest(
msg.sender
)
returns (uint256)
{
return _compoundInterest();
}
function _compoundInterest()
private
returns (uint256)
{
uint256 interest = _claimInterest(
msg.sender
);
_deposit(
interest
);
return interest;
}
function compoundInterestOnBehalf(
address _user
)
external
nonReentrant
assignInterest(
_user
)
assignInterest(
msg.sender
)
whenNotPaused
onlyWhiteListed
returns (uint256)
{
require(
autoCompoundAllowed[_user],
CompoundNotAllowed()
);
uint256 interest = _claimInterest(
_user
);
uint256 incentive = interest
* autoCompoundIncentive
/ PRECISION_RATE;
uint256 reducedAmount = interest
- incentive;
_deposit(
reducedAmount
);
if (allowance(msg.sender,msg.sender) < reducedAmount) {
_approve(
msg.sender,
msg.sender,
0
);
_approve(
msg.sender,
msg.sender,
reducedAmount
);
}
transferFrom(
msg.sender,
_user,
reducedAmount
);
return interest;
}
function whiteListAddress(
address _friendlyUser
)
external
onlyOwner
nonReentrant
{
isWhiteListed[_friendlyUser] = true;
}
function removeWhiteListAddress(
address _unfriendlyUser
)
external
onlyOwner
nonReentrant
{
isWhiteListed[_unfriendlyUser] = false;
}
function withdraw(
uint256 _amount
)
external
nonReentrant
whenNotPaused
assignInterest(
msg.sender
)
{
require(
withdrawAllowed,
WithdrawNotAllowed()
);
require(
balanceOf(msg.sender) >= _amount,
InsufficientBalance()
);
require(
USD_TOKEN.balanceOf(address(this)) >= _amount,
InsufficientBalanceInContract(
_amount,
USD_TOKEN.balanceOf(address(this))
)
);
_burn(
msg.sender,
_amount
);
USD_TOKEN.safeTransfer(
msg.sender,
_amount
);
}
}
OwnableMaster.sol 114 lines
// SPDX-License-Identifier: -- WISE --
pragma solidity =0.8.28;
error NoValue();
error NotMaster();
error NotProposed();
contract OwnableMaster {
address public master;
address public proposedMaster;
address internal constant ZERO_ADDRESS = address(0x0);
modifier onlyProposed() {
_onlyProposed();
_;
}
function _onlyMaster()
private
view
{
if (msg.sender == master) {
return;
}
revert NotMaster();
}
modifier onlyMaster() {
_onlyMaster();
_;
}
function _onlyProposed()
private
view
{
if (msg.sender == proposedMaster) {
return;
}
revert NotProposed();
}
event MasterProposed(
address indexed proposer,
address indexed proposedMaster
);
event RenouncedOwnership(
address indexed previousMaster
);
constructor(
address _master
) {
if (_master == ZERO_ADDRESS) {
revert NoValue();
}
master = _master;
}
/**
* @dev Allows to propose next master.
* Must be claimed by proposer.
*/
function proposeOwner(
address _proposedOwner
)
external
onlyMaster
{
if (_proposedOwner == ZERO_ADDRESS) {
revert NoValue();
}
proposedMaster = _proposedOwner;
emit MasterProposed(
msg.sender,
_proposedOwner
);
}
/**
* @dev Allows to claim master role.
* Must be called by proposer.
*/
function claimOwnership()
external
onlyProposed
{
master = msg.sender;
}
/**
* @dev Removes master role.
* No ability to be in control.
*/
function renounceOwnership()
external
onlyMaster
{
master = ZERO_ADDRESS;
proposedMaster = ZERO_ADDRESS;
emit RenouncedOwnership(
msg.sender
);
}
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../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 {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
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 {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// 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;
}
}
ERC20.sol 365 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
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);
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
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].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Read Contract
USD_TOKEN 0x9d23c812 → address
allowance 0xdd62ed3e → uint256
autoCompoundAllowed 0x5f3743df → bool
autoCompoundIncentive 0xc35ad6b0 → uint256
balanceOf 0x70a08231 → uint256
cashedInterest 0xed9c6834 → uint256
decimals 0x313ce567 → uint8
getPendingInterest 0x151d9b74 → uint256
getPendingInterestBulk 0x5fed40da → uint256[]
getPendingInterestBulkByTimeStamp 0x6c561567 → uint256[]
getPendingInterestByTimeStamp 0x394edada → uint256
getTotalInterestUser 0xd5dc58d6 → uint256
getTotalInterestUserBulk 0x900eb005 → uint256[]
getTotalInterestUserBulkByTimeStamp 0x40d0dcdd → uint256[]
getTotalInterestUserByTimeStamp 0x2c28f026 → uint256
interestRate 0x7c3a00fd → uint256
isWhiteListed 0x6f9170f6 → bool
lastSyncTimeStamp 0x95b20d6e → uint256
master 0xee97f7f3 → address
name 0x06fdde03 → string
paused 0x5c975abb → bool
proposedMaster 0xd3573a33 → address
supplyChangeByOwnerNotAllowed 0x78357689 → bool
symbol 0x95d89b41 → string
thirdPartyAddress 0x9f7096b6 → address
totalDepositCap 0x5db88e85 → uint256
totalSupply 0x18160ddd → uint256
withdrawAllowed 0x574eab01 → bool
Write Contract 29 functions
These functions modify contract state and require a wallet transaction to execute.
allowAutoCompound 0x5438ebaa
No parameters
allowWithdraw 0xf1ead252
No parameters
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
burnSupply 0xaecf8a6d
address _from
uint256 _amount
claimInterest 0x35981fd8
No parameters
returns: uint256
claimOwnership 0x4e71e0c8
No parameters
compoundInterest 0xe425e8b5
No parameters
returns: uint256
compoundInterestOnBehalf 0x7d31de9c
address _user
returns: uint256
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
deposit 0xb6b55f25
uint256 _amount
depositAndClaimInterest 0xabec101f
uint256 _amount
returns: uint256
depositAndCompoundInterest 0x9fa8e272
uint256 _amount
returns: uint256
disAllowSupplyChangeByOwner 0x9f981e1a
No parameters
disallowAutoCompound 0x64259daa
No parameters
disallowWithdraw 0x6095ad55
No parameters
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
mintSupply 0xe742806a
address _to
uint256 _amount
pauseDeposits 0x02191980
No parameters
proposeOwner 0xb5ed298a
address _proposedOwner
removeWhiteListAddress 0xce114c25
address _unfriendlyUser
renounceOwnership 0x715018a6
No parameters
setInterestRate 0x5f84f302
uint256 _interestRate
setThirdPartyAddress 0x8c859fca
address _thirdPartyAddress
setTotalDepositCap 0xebbf5c17
uint256 _totalDepositCap
transfer 0xa9059cbb
address to
uint256 amount
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 amount
returns: bool
unpauseDeposits 0x63d8882a
No parameters
whiteListAddress 0xcf52a7b2
address _friendlyUser
withdraw 0x2e1a7d4d
uint256 _amount
Recent Transactions
No transactions found for this address