Address Contract Verified
Address
0xab1C247Aa727b39C25B6310603Fc19e99774AdD4
Balance
0 ETH
Nonce
1
Code Size
10660 bytes
Creator
0x471aEa3d...DB79 at tx 0x24e094e7...e4e4a6
Indexed Transactions
0 (1 on-chain, 1.3% indexed)
Contract Bytecode
10660 bytes
0x608060405234801561001057600080fd5b50600436106102695760003560e01c8063715018a611610151578063b9cbd8c4116100c3578063dba0290f11610087578063dba0290f1461060b578063ec342ad014610631578063edf8bc1314610639578063f2fde38b14610641578063fbbc892514610667578063fce51aeb1461069d57610269565b8063b9cbd8c4146105e3578063ba94dc0c146105eb578063c545633c146105f3578063cfadb0a5146105fb578063d53ea8ba1461060357610269565b80638828a817116101155780638828a817146105895780638da5cb5b146105915780638fd3ab80146105995780639ce29133146105a1578063a3cbae46146105be578063b6b55f25146105c657610269565b8063715018a6146104f45780637637c1b6146104fc57806378d6425a146105385780638129fc1c1461055b5780638462d6611461056357610269565b80633934fa56116101ea57806355fc9fc4116101ae57806355fc9fc4146104205780635d837d7a1461043d5780635fcbd28514610463578063634459891461046b57806363568502146104c65780636a678a9c146104ce57610269565b80633934fa56146103a05780633ee9f334146103a8578063439e52fb146103b057806345c626c5146103d457806350dfed89146103fa57610269565b80631f8b0867116102315780631f8b0867146102ec5780632d291cad1461031257806330cb11ee1461034c57806337080fcc14610372578063386a95251461039857610269565b80630359fea91461026e57806306c324e7146102885780630c6dfcc5146102925780630de839e1146102b85780631436ee18146102e4575b600080fd5b6102766106c3565b60408051918252519081900360200190f35b6102906107b5565b005b610276600480360360208110156102a857600080fd5b50356001600160a01b03166107cc565b610290600480360360408110156102ce57600080fd5b506001600160a01b038135169060200135610816565b6102766109c4565b6102766004803603602081101561030257600080fd5b50356001600160a01b03166109ef565b6103386004803603602081101561032857600080fd5b50356001600160a01b0316610a01565b604080519115158252519081900360200190f35b6102766004803603602081101561036257600080fd5b50356001600160a01b0316610a79565b61037a610a8b565b60408051938452602084019290925282820152519081900360600190f35b610276610b09565b610276610b0f565b610276610b15565b6103b8610b1b565b604080516001600160a01b039092168252519081900360200190f35b610276600480360360208110156103ea57600080fd5b50356001600160a01b0316610b2a565b6102766004803603602081101561041057600080fd5b50356001600160a01b0316610b3c565b6102906004803603602081101561043657600080fd5b5035610b4e565b61037a6004803603602081101561045357600080fd5b50356001600160a01b0316610bab565b6103b8610c87565b6104916004803603602081101561048157600080fd5b50356001600160a01b0316610c96565b60408051968752602087019590955260ff909316858501526060850191909152608084015260a0830152519081900360c00190f35b610276610d6d565b610290600480360360208110156104e457600080fd5b50356001600160a01b0316610d73565b610290610ded565b6105226004803603602081101561051257600080fd5b50356001600160a01b0316610e8f565b6040805160ff9092168252519081900360200190f35b6102906004803603604081101561054e57600080fd5b5080359060200135610ea4565b610290610f07565b6102766004803603602081101561057957600080fd5b50356001600160a01b0316610fb1565b610276610fe6565b6103b8610fec565b610290610ffb565b610290600480360360208110156105b757600080fd5b50356114d2565b61027661152f565b610290600480360360208110156105dc57600080fd5b5035611535565b6102766117ee565b6102766117f4565b6102906117fa565b610276611b7c565b610276611b82565b6102906004803603602081101561062157600080fd5b50356001600160a01b0316611b88565b6103b8611c02565b610290611c11565b6102906004803603602081101561065757600080fd5b50356001600160a01b031661213d565b6102906004803603606081101561067d57600080fd5b506001600160a01b03813581169160208101359091169060400135612236565b610290600480360360208110156106b357600080fd5b50356001600160a01b03166123e5565b60a354604080516370a0823160e01b8152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b15801561071357600080fd5b505afa158015610727573d6000803e3d6000fd5b505050506040513d602081101561073d57600080fd5b505160a554909150600090156107ac57600061076460a5544261245f90919063ffffffff16565b905060a654811115610778578291506107a6565b6107a360a65461079d61079660a5544261245f90919063ffffffff16565b86906124a8565b90612501565b91505b506107af565b50805b91505090565b6107bd610a8b565b60a055609f55609e554260a155565b6000806000806107db85610bab565b9194509250905061080b6107f08260036124a8565b6108056107fe8560026124a8565b8690612543565b90612543565b93505050505b919050565b61081e61259d565b6065546001600160a01b0390811691161461086e576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b6001600160a01b0382166108b9576040805162461bcd60e51b815260206004820152600d60248201526c189859081c9958da5c1a595b9d609a1b604482015290519081900360640190fd5b600081116108fb576040805162461bcd60e51b815260206004820152600a60248201526918985908185b5bdd5b9d60b21b604482015290519081900360640190fd5b60a3546040805163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529151600093929092169163a9059cbb9160448082019260209290919082900301818787803b15801561095457600080fd5b505af1158015610968573d6000803e3d6000fd5b505050506040513d602081101561097e57600080fd5b50519050806109bf576040805162461bcd60e51b81526020600482015260086024820152673a3930b739b332b960c11b604482015290519081900360640190fd5b505050565b6000806000806109d2610a8b565b919450925090506109e76107f08260036124a8565b935050505090565b60986020526000908152604090205481565b6001600160a01b0381166000908152609a602052604081205415610a4b5760a4546001600160a01b0383166000908152609a6020526040902054610a4491612543565b4211610a73565b60a4546001600160a01b038316600090815260986020526040902054610a7091612543565b42115b92915050565b609a6020526000908152604090205481565b600080600080610aa660a1544261245f90919063ffffffff16565b9050610ac9610ac082609b546124a890919063ffffffff16565b609e5490612543565b609c54610ae390610ada90846124a8565b609f5490612543565b609d54610afd90610af490856124a8565b60a05490612543565b93509350935050909192565b60a65481565b609f5481565b609e5481565b60a9546001600160a01b031681565b60a76020526000908152604090205481565b60976020526000908152604090205481565b610b5661259d565b6065546001600160a01b03908116911614610ba6576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b60a455565b6001600160a01b038116600090815260986020526040812054819081908190610bd590429061245f565b6001600160a01b038616600090815260996020908152604080832054609790925282205492935060ff16919080806001851415610c1457859250610c56565b8460021415610c345762278d009250610c2d868461245f565b9150610c56565b8460031415610c565762278d009250829150610c5386624f1a0061245f565b90505b610c6084846124a8565b610c6a85846124a8565b610c7486846124a8565b9850985098505050505050509193909250565b60a2546001600160a01b031681565b6000806000806000806000610cb660a1544261245f90919063ffffffff16565b9050610d0f610cde6003610cd8610af485609d546124a890919063ffffffff16565b906124a8565b610805610cfe6002610cd8610ada87609c546124a890919063ffffffff16565b609b5461080590610ac090876124a8565b6001600160a01b03891660009081526097602090815260408083205460988352818420546099845282852054609a9094529190932054939550919260ff90911690610d598c6107cc565b965096509650965096505091939550919395565b60a55481565b610d7b61259d565b6065546001600160a01b03908116911614610dcb576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b60a280546001600160a01b0319166001600160a01b0392909216919091179055565b610df561259d565b6065546001600160a01b03908116911614610e45576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b6065546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3606580546001600160a01b0319169055565b60996020526000908152604090205460ff1681565b610eac61259d565b6065546001600160a01b03908116911614610efc576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b60a59190915560a655565b600054610100900460ff1680610f205750610f206125a1565b80610f2e575060005460ff16155b610f695760405162461bcd60e51b815260040180806020018281038252602e815260200180612941602e913960400191505060405180910390fd5b600054610100900460ff16158015610f94576000805460ff1961ff0019909116610100171660011790555b610f9c6125a7565b8015610fae576000805461ff00191690555b50565b6000610fbb6109c4565b610fc757506000610811565b610a73610fd26109c4565b61079d610fde856107cc565b610cd86106c3565b609b5481565b6065546001600160a01b031690565b3360009081526099602052604090205460ff1661104c576040805162461bcd60e51b815260206004820152600a6024820152691b9bc819195c1bdcda5d60b21b604482015290519081900360640190fd5b60a9546001600160a01b0316611099576040805162461bcd60e51b815260206004820152600d60248201526c37379031b0b9b1b0b232903b1960991b604482015290519081900360640190fd5b6110a16107b5565b33600090815260976020526040812054906111466110bd6109c4565b61079d6110c9336107cc565b60a354604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561111457600080fd5b505afa158015611128573d6000803e3d6000fd5b505050506040513d602081101561113e57600080fd5b5051906124a8565b60a9546040805163ce5494bb60e01b815233600482015290519293506001600160a01b039091169163ce5494bb9160248082019260009290919082900301818387803b15801561119557600080fd5b505af11580156111a9573d6000803e3d6000fd5b5050505060008060006111bb33610bab565b9250925092506111d683609e5461245f90919063ffffffff16565b609e55609f546111e6908361245f565b609f5560a0546111f6908261245f565b60a0553360009081526099602052604090205460ff16600114156112385733600090815260976020526040902054609b546112309161245f565b609b556112b2565b3360009081526099602052604090205460ff16600214156112775733600090815260976020526040902054609c5461126f9161245f565b609c556112b2565b3360009081526099602052604090205460ff16600314156112b25733600090815260976020526040902054609d546112ae9161245f565b609d555b60a25460a95433600090815260976020908152604080832054815163a9059cbb60e01b81526001600160a01b039586166004820152602481019190915290519294939093169263a9059cbb926044808301939282900301818787803b15801561131a57600080fd5b505af115801561132e573d6000803e3d6000fd5b505050506040513d602081101561134457600080fd5b505190508061138d576040805162461bcd60e51b815260206004820152601060248201526f1d1c985b9cd9995c8819195c1bdcda5d60821b604482015290519081900360640190fd5b60a35460a9546040805163a9059cbb60e01b81526001600160a01b039283166004820152602481018990529051919092169163a9059cbb9160448083019260209291908290030181600087803b1580156113e657600080fd5b505af11580156113fa573d6000803e3d6000fd5b505050506040513d602081101561141057600080fd5b5051905080611459576040805162461bcd60e51b815260206004820152601060248201526f7472616e73666572207265776172647360801b604482015290519081900360640190fd5b3360008181526097602090815260408083208390556098825280832083905560998252808320805460ff19169055609a825280832092909255815189815290810188905281517fd44a6dd2bfac4f6bc02d116d96aa12c24e8580626b95cb6a2f543f18cb61bd4c929181900390910190a2505050505050565b6114da61259d565b6065546001600160a01b0390811691161461152a576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b60a855565b60a15481565b33600090815260a7602052604090205415611591576040805162461bcd60e51b81526020600482015260176024820152766d756c7469706c69656420746f6f20726563656e746c7960481b604482015290519081900360640190fd5b6115996107b5565b60a25460408051636eb1769f60e11b815233600482015230602482015290516000926001600160a01b03169163dd62ed3e916044808301926020929190829003018186803b1580156115ea57600080fd5b505afa1580156115fe573d6000803e3d6000fd5b505050506040513d602081101561161457600080fd5b5051905080821115611659576040805162461bcd60e51b8152602060048201526009602482015268616c6c6f77616e636560b81b604482015290519081900360640190fd5b609b546116669083612543565b609b55336000908152609760205260409020546116839083612543565b3360009081526097602090815260408083209390935560998152828220805460ff191660011790556098905220546116c8573360009081526098602052604090204290555b60a254604080516323b872dd60e01b81523360048201523060248201526044810185905290516000926001600160a01b0316916323b872dd91606480830192602092919082900301818787803b15801561172157600080fd5b505af1158015611735573d6000803e3d6000fd5b505050506040513d602081101561174b57600080fd5b5051905080611790576040805162461bcd60e51b815260206004820152600c60248201526b7472616e7366657246726f6d60a01b604482015290519081900360640190fd5b336000818152609760205260409020547f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e906117cc908661245f565b60408051918252602082018790524282820152519081900360600190a2505050565b60a45481565b609c5481565b3360009081526099602052604090205460ff1661184b576040805162461bcd60e51b815260206004820152600a6024820152691b9bc819195c1bdcda5d60b21b604482015290519081900360640190fd5b33600090815260996020526040902054600360ff909116106118a5576040805162461bcd60e51b815260206004820152600e60248201526d199d5b1b1e481d5c19dc9859195960921b604482015290519081900360640190fd5b33600090815260a7602052604090204290556118bf6107b5565b33600090815260996020908152604080832054609890925282205460ff90911691906118ec90429061245f565b336000908152609760209081526040808320546099909252909120549192509060ff1660011480156119215750624f1a008210155b156119b45760006119358362278d0061245f565b9050600061194684624f1a0061245f565b609b54909150611956908461245f565b609b55609d546119669084612543565b609d55611976610ada84846124a8565b609f55611990610af46119898484612543565b85906124a8565b60a0555050336000908152609960205260409020805460ff19166003179055611b1f565b3360009081526099602052604090205460ff1660011480156119d9575062278d008210155b15611a595760006119ed8362278d0061245f565b609b549091506119fd908361245f565b609b55609c54611a0d9083612543565b609c55611a26611a1d83836124a8565b609e549061245f565b609e55611a36610ada83836124a8565b609f5550336000908152609960205260409020805460ff19166002179055611b1f565b3360009081526099602052604090205460ff166002148015611a7e5750624f1a008210155b15611ae5576000611a9283624f1a0061245f565b609c54909150611aa2908361245f565b609c55609d54611ab29083612543565b609d55611ac2610af483836124a8565b60a05550336000908152609960205260409020805460ff19166003179055611b1f565b6040805162461bcd60e51b815260206004820152600a602482015269696e656c696769626c6560b01b604482015290519081900360640190fd5b3360008181526099602090815260409182902054825160ff808916825290911691810191909152428183015290517fd0b066a41d49239ec2b44120eec3c161ea40257f36cbda292cb9ea9c00fabd339181900360600190a2505050565b609d5481565b60a05481565b611b9061259d565b6065546001600160a01b03908116911614611be0576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b60a980546001600160a01b0319166001600160a01b0392909216919091179055565b60a3546001600160a01b031681565b33600090815260a7602052604090205415611c6d576040805162461bcd60e51b81526020600482015260176024820152766d756c7469706c69656420746f6f20726563656e746c7960481b604482015290519081900360640190fd5b611c756107b5565b6000611c8033610fb1565b60a354604080516370a0823160e01b8152306004820152905192935083926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015611cd057600080fd5b505afa158015611ce4573d6000803e3d6000fd5b505050506040513d6020811015611cfa57600080fd5b50511015611d42576040805162461bcd60e51b815260206004820152601060248201526f617661696c61626c6520746f6b656e7360801b604482015290519081900360640190fd5b3360009081526099602052604090205460ff16611d96576040805162461bcd60e51b815260206004820152600d60248201526c191bd95cdb89dd08195e1a5cdd609a1b604482015290519081900360640190fd5b33600090815260976020526040902054611de2576040805162461bcd60e51b81526020600482015260086024820152676e6f207374616b6560c01b604482015290519081900360640190fd5b611deb33610a01565b611e27576040805162461bcd60e51b81526020600482015260086024820152673a37b79039b7b7b760c11b604482015290519081900360640190fd5b336000818152609a602052604081204290559081908190611e4790610bab565b925092509250611e6283609e5461245f90919063ffffffff16565b609e55609f54611e72908361245f565b609f5560a054611e82908261245f565b60a0553360009081526099602052604090205460ff1660011415611ec45733600090815260976020526040902054609b54611ebc9161245f565b609b55611f3e565b3360009081526099602052604090205460ff1660021415611f035733600090815260976020526040902054609c54611efb9161245f565b609c55611f3e565b3360009081526099602052604090205460ff1660031415611f3e5733600090815260976020526040902054609d54611f3a9161245f565b609d555b3360008181526097602090815260408083208054908490556098835281842084905560998352818420805460ff19169055609a835281842084905560a254825163a9059cbb60e01b8152600481019690965260248601829052915190946001600160a01b039092169263a9059cbb926044808201939182900301818787803b158015611fc957600080fd5b505af1158015611fdd573d6000803e3d6000fd5b505050506040513d6020811015611ff357600080fd5b5051905080612034576040805162461bcd60e51b81526020600482015260086024820152673a3930b739b332b960c11b604482015290519081900360640190fd5b60a3546040805163a9059cbb60e01b81523360048201526024810189905290516001600160a01b039092169163a9059cbb916044808201926020929091908290030181600087803b15801561208857600080fd5b505af115801561209c573d6000803e3d6000fd5b505050506040513d60208110156120b257600080fd5b50519050806120f3576040805162461bcd60e51b81526020600482015260086024820152673a3930b739b332b960c11b604482015290519081900360640190fd5b60408051838152602081018890524281830152905133917f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca94919081900360600190a2505050505050565b61214561259d565b6065546001600160a01b03908116911614612195576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b6001600160a01b0381166121da5760405162461bcd60e51b81526004018080602001828103825260268152602001806128da6026913960400191505060405180910390fd5b6065546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3606580546001600160a01b0319166001600160a01b0392909216919091179055565b61223e61259d565b6065546001600160a01b0390811691161461228e576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b6001600160a01b0382166122d9576040805162461bcd60e51b815260206004820152600d60248201526c189859081c9958da5c1a595b9d609a1b604482015290519081900360640190fd5b6000811161231b576040805162461bcd60e51b815260206004820152600a60248201526918985908185b5bdd5b9d60b21b604482015290519081900360640190fd5b6000836001600160a01b031663a9059cbb84846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561237457600080fd5b505af1158015612388573d6000803e3d6000fd5b505050506040513d602081101561239e57600080fd5b50519050806123df576040805162461bcd60e51b81526020600482015260086024820152673a3930b739b332b960c11b604482015290519081900360640190fd5b50505050565b6123ed61259d565b6065546001600160a01b0390811691161461243d576040805162461bcd60e51b81526020600482018190526024820152600080516020612921833981519152604482015290519081900360640190fd5b60a380546001600160a01b0319166001600160a01b0392909216919091179055565b60006124a183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612644565b9392505050565b6000826124b757506000610a73565b828202828482816124c457fe5b04146124a15760405162461bcd60e51b81526004018080602001828103825260218152602001806129006021913960400191505060405180910390fd5b60006124a183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506126db565b6000828201838110156124a1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3390565b303b1590565b600054610100900460ff16806125c057506125c06125a1565b806125ce575060005460ff16155b6126095760405162461bcd60e51b815260040180806020018281038252602e815260200180612941602e913960400191505060405180910390fd5b600054610100900460ff16158015612634576000805460ff1961ff0019909116610100171660011790555b61263c612740565b610f9c6127e0565b600081848411156126d35760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612698578181015183820152602001612680565b50505050905090810190601f1680156126c55780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000818361272a5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315612698578181015183820152602001612680565b50600083858161273657fe5b0495945050505050565b600054610100900460ff168061275957506127596125a1565b80612767575060005460ff16155b6127a25760405162461bcd60e51b815260040180806020018281038252602e815260200180612941602e913960400191505060405180910390fd5b600054610100900460ff16158015610f9c576000805460ff1961ff0019909116610100171660011790558015610fae576000805461ff001916905550565b600054610100900460ff16806127f957506127f96125a1565b80612807575060005460ff16155b6128425760405162461bcd60e51b815260040180806020018281038252602e815260200180612941602e913960400191505060405180910390fd5b600054610100900460ff1615801561286d576000805460ff1961ff0019909116610100171660011790555b600061287761259d565b606580546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508015610fae576000805461ff00191690555056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a6564a26469706673582212209c79a1065ab33cf376e781bee0afbc44c27a782db34c7757ae3c39d37f0a7b8864736f6c634300060c0033
Verified Source Code Full Match
Compiler: v0.6.12+commit.27d51765
EVM: istanbul
Optimization: Yes (200 runs)
Cascade.sol 419 lines
pragma solidity 0.6.12;
import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol";
import "./lib/SafeMathInt.sol";
import "./BaseToken.sol";
interface ICascadeV2 {
function migrate(address user) external;
}
contract Cascade is OwnableUpgradeSafe {
using SafeMath for uint256;
using SafeMathInt for int256;
function migrate()
public
{
require(deposits_multiplierLevel[msg.sender] > 0, "no deposit");
require(address(cascadeV2) != address(0x0), "no cascade v2");
updateDepositSeconds();
uint256 numLPTokens = deposits_lpTokensDeposited[msg.sender];
uint256 numRewardTokens = BASE.balanceOf(address(this)).mul(sumOfUserDepositSeconds(msg.sender)).div(totalDepositSeconds());
cascadeV2.migrate(msg.sender);
(uint256 level1, uint256 level2, uint256 level3) = userDepositSeconds(msg.sender);
totalDepositSecondsLevel1 = totalDepositSecondsLevel1.sub(level1);
totalDepositSecondsLevel2 = totalDepositSecondsLevel2.sub(level2);
totalDepositSecondsLevel3 = totalDepositSecondsLevel3.sub(level3);
if (deposits_multiplierLevel[msg.sender] == 1) {
totalDepositedLevel1 = totalDepositedLevel1.sub(deposits_lpTokensDeposited[msg.sender]);
} else if (deposits_multiplierLevel[msg.sender] == 2) {
totalDepositedLevel2 = totalDepositedLevel2.sub(deposits_lpTokensDeposited[msg.sender]);
} else if (deposits_multiplierLevel[msg.sender] == 3) {
totalDepositedLevel3 = totalDepositedLevel3.sub(deposits_lpTokensDeposited[msg.sender]);
}
bool ok = lpToken.transfer(address(cascadeV2), deposits_lpTokensDeposited[msg.sender]);
require(ok, "transfer deposit");
ok = BASE.transfer(address(cascadeV2), numRewardTokens);
require(ok, "transfer rewards");
delete deposits_lpTokensDeposited[msg.sender];
delete deposits_depositTimestamp[msg.sender];
delete deposits_multiplierLevel[msg.sender];
delete deposits_mostRecentBASEWithdrawal[msg.sender];
emit Migrate(msg.sender, numLPTokens, numRewardTokens);
}
mapping(address => uint256) public deposits_lpTokensDeposited;
mapping(address => uint256) public deposits_depositTimestamp;
mapping(address => uint8) public deposits_multiplierLevel;
mapping(address => uint256) public deposits_mostRecentBASEWithdrawal;
uint256 public totalDepositedLevel1;
uint256 public totalDepositedLevel2;
uint256 public totalDepositedLevel3;
uint256 public totalDepositSecondsLevel1;
uint256 public totalDepositSecondsLevel2;
uint256 public totalDepositSecondsLevel3;
uint256 public lastAccountingUpdateTimestamp;
IERC20 public lpToken;
BaseToken public BASE;
uint256 public minTimeBetweenWithdrawals;
uint256 public rewardsStartTimestamp;
uint256 public rewardsDuration;
mapping(address => uint256) public deposits_lastMultiplierUpgradeTimestamp;
uint256 multiplierUpgradeTimeout;
ICascadeV2 public cascadeV2;
event Deposit(address indexed user, uint256 previousLPTokens, uint256 additionalTokens, uint256 timestamp);
event Withdraw(address indexed user, uint256 lpTokens, uint256 baseTokens, uint256 timestamp);
event UpgradeMultiplierLevel(address indexed user, uint8 oldLevel, uint256 newLevel, uint256 timestamp);
event Migrate(address indexed user, uint256 lpTokens, uint256 rewardTokens);
function initialize()
public
initializer
{
__Ownable_init();
}
/**
* Admin
*/
function setLPToken(address _lpToken)
public
onlyOwner
{
lpToken = IERC20(_lpToken);
}
function setBASEToken(address _baseToken)
public
onlyOwner
{
BASE = BaseToken(_baseToken);
}
function setCascadeV2(address _cascadeV2)
public
onlyOwner
{
cascadeV2 = ICascadeV2(_cascadeV2);
}
function setMinTimeBetweenWithdrawals(uint256 _minTimeBetweenWithdrawals)
public
onlyOwner
{
minTimeBetweenWithdrawals = _minTimeBetweenWithdrawals;
}
function setRewardsParams(uint256 _rewardsStartTimestamp, uint256 _rewardsDuration)
public
onlyOwner
{
rewardsStartTimestamp = _rewardsStartTimestamp;
rewardsDuration = _rewardsDuration;
}
function setMultiplierUpgradeTimeout(uint256 _multiplierUpgradeTimeout)
public
onlyOwner
{
multiplierUpgradeTimeout = _multiplierUpgradeTimeout;
}
function adminWithdrawBASE(address recipient, uint256 amount)
public
onlyOwner
{
require(recipient != address(0x0), "bad recipient");
require(amount > 0, "bad amount");
bool ok = BASE.transfer(recipient, amount);
require(ok, "transfer");
}
function rescueMistakenlySentTokens(address token, address recipient, uint256 amount)
public
onlyOwner
{
require(recipient != address(0x0), "bad recipient");
require(amount > 0, "bad amount");
bool ok = IERC20(token).transfer(recipient, amount);
require(ok, "transfer");
}
/**
* Public methods
*/
function deposit(uint256 amount)
public
{
require(deposits_lastMultiplierUpgradeTimestamp[msg.sender] == 0, "multiplied too recently");
updateDepositSeconds();
uint256 allowance = lpToken.allowance(msg.sender, address(this));
require(amount <= allowance, "allowance");
totalDepositedLevel1 = totalDepositedLevel1.add(amount);
deposits_lpTokensDeposited[msg.sender] = deposits_lpTokensDeposited[msg.sender].add(amount);
deposits_multiplierLevel[msg.sender] = 1;
if (deposits_depositTimestamp[msg.sender] == 0) {
deposits_depositTimestamp[msg.sender] = now;
}
bool ok = lpToken.transferFrom(msg.sender, address(this), amount);
require(ok, "transferFrom");
emit Deposit(msg.sender, deposits_lpTokensDeposited[msg.sender].sub(amount), amount, now);
}
function upgradeMultiplierLevel()
public
{
require(deposits_multiplierLevel[msg.sender] > 0, "no deposit");
require(deposits_multiplierLevel[msg.sender] < 3, "fully upgraded");
deposits_lastMultiplierUpgradeTimestamp[msg.sender] = block.timestamp;
updateDepositSeconds();
uint8 oldLevel = deposits_multiplierLevel[msg.sender];
uint256 age = now.sub(deposits_depositTimestamp[msg.sender]);
uint256 lpTokensDeposited = deposits_lpTokensDeposited[msg.sender];
if (deposits_multiplierLevel[msg.sender] == 1 && age >= 60 days) {
uint256 secondsSinceLevel2 = age.sub(30 days);
uint256 secondsSinceLevel3 = age.sub(60 days);
totalDepositedLevel1 = totalDepositedLevel1.sub(lpTokensDeposited);
totalDepositedLevel3 = totalDepositedLevel3.add(lpTokensDeposited);
totalDepositSecondsLevel2 = totalDepositSecondsLevel2.add( lpTokensDeposited.mul(secondsSinceLevel2) );
totalDepositSecondsLevel3 = totalDepositSecondsLevel3.add( lpTokensDeposited.mul(secondsSinceLevel2.add(secondsSinceLevel3)) );
deposits_multiplierLevel[msg.sender] = 3;
} else if (deposits_multiplierLevel[msg.sender] == 1 && age >= 30 days) {
uint256 secondsSinceLevel2 = age.sub(30 days);
totalDepositedLevel1 = totalDepositedLevel1.sub(lpTokensDeposited);
totalDepositedLevel2 = totalDepositedLevel2.add(lpTokensDeposited);
totalDepositSecondsLevel1 = totalDepositSecondsLevel1.sub( lpTokensDeposited.mul(secondsSinceLevel2) );
totalDepositSecondsLevel2 = totalDepositSecondsLevel2.add( lpTokensDeposited.mul(secondsSinceLevel2) );
deposits_multiplierLevel[msg.sender] = 2;
} else if (deposits_multiplierLevel[msg.sender] == 2 && age >= 60 days) {
uint256 secondsSinceLevel3 = age.sub(60 days);
totalDepositedLevel2 = totalDepositedLevel2.sub(lpTokensDeposited);
totalDepositedLevel3 = totalDepositedLevel3.add(lpTokensDeposited);
totalDepositSecondsLevel3 = totalDepositSecondsLevel3.add( lpTokensDeposited.mul(secondsSinceLevel3) );
deposits_multiplierLevel[msg.sender] = 3;
} else {
revert("ineligible");
}
emit UpgradeMultiplierLevel(msg.sender, oldLevel, deposits_multiplierLevel[msg.sender], now);
}
function withdrawLPTokens()
public
{
require(deposits_lastMultiplierUpgradeTimestamp[msg.sender] == 0, "multiplied too recently");
updateDepositSeconds();
uint256 owed = owedTo(msg.sender);
require(BASE.balanceOf(address(this)) >= owed, "available tokens");
require(deposits_multiplierLevel[msg.sender] > 0, "doesn't exist");
require(deposits_lpTokensDeposited[msg.sender] > 0, "no stake");
require(allowedToWithdraw(msg.sender), "too soon");
deposits_mostRecentBASEWithdrawal[msg.sender] = now;
(uint256 level1, uint256 level2, uint256 level3) = userDepositSeconds(msg.sender);
totalDepositSecondsLevel1 = totalDepositSecondsLevel1.sub(level1);
totalDepositSecondsLevel2 = totalDepositSecondsLevel2.sub(level2);
totalDepositSecondsLevel3 = totalDepositSecondsLevel3.sub(level3);
if (deposits_multiplierLevel[msg.sender] == 1) {
totalDepositedLevel1 = totalDepositedLevel1.sub(deposits_lpTokensDeposited[msg.sender]);
} else if (deposits_multiplierLevel[msg.sender] == 2) {
totalDepositedLevel2 = totalDepositedLevel2.sub(deposits_lpTokensDeposited[msg.sender]);
} else if (deposits_multiplierLevel[msg.sender] == 3) {
totalDepositedLevel3 = totalDepositedLevel3.sub(deposits_lpTokensDeposited[msg.sender]);
}
uint256 deposited = deposits_lpTokensDeposited[msg.sender];
delete deposits_lpTokensDeposited[msg.sender];
delete deposits_depositTimestamp[msg.sender];
delete deposits_multiplierLevel[msg.sender];
delete deposits_mostRecentBASEWithdrawal[msg.sender];
bool ok = lpToken.transfer(msg.sender, deposited);
require(ok, "transfer");
ok = BASE.transfer(msg.sender, owed);
require(ok, "transfer");
emit Withdraw(msg.sender, deposited, owed, now);
}
/**
* Accounting utilities
*/
function updateDepositSeconds()
public
{
(totalDepositSecondsLevel1, totalDepositSecondsLevel2, totalDepositSecondsLevel3) = getUpdatedDepositSeconds();
lastAccountingUpdateTimestamp = now;
}
function getUpdatedDepositSeconds()
public
view
returns (uint256 level1, uint256 level2, uint256 level3)
{
uint256 delta = now.sub(lastAccountingUpdateTimestamp);
return (
totalDepositSecondsLevel1.add(totalDepositedLevel1.mul(delta)),
totalDepositSecondsLevel2.add(totalDepositedLevel2.mul(delta)),
totalDepositSecondsLevel3.add(totalDepositedLevel3.mul(delta))
);
}
/**
* Getters
*/
function depositInfo(address user)
public
view
returns (
uint256 _lpTokensDeposited,
uint256 _depositTimestamp,
uint8 _multiplierLevel,
uint256 _mostRecentBASEWithdrawal,
uint256 _userDepositSeconds,
uint256 _totalDepositSeconds
)
{
uint256 delta = now.sub(lastAccountingUpdateTimestamp);
_totalDepositSeconds = totalDepositSecondsLevel1.add(totalDepositedLevel1.mul(delta))
.add(totalDepositSecondsLevel2.add(totalDepositedLevel2.mul(delta)).mul(2))
.add(totalDepositSecondsLevel3.add(totalDepositedLevel3.mul(delta)).mul(3));
return (
deposits_lpTokensDeposited[user],
deposits_depositTimestamp[user],
deposits_multiplierLevel[user],
deposits_mostRecentBASEWithdrawal[user],
sumOfUserDepositSeconds(user),
_totalDepositSeconds
);
}
function allowedToWithdraw(address user)
public
view
returns (bool)
{
return deposits_mostRecentBASEWithdrawal[user] == 0
? now > deposits_depositTimestamp[user].add(minTimeBetweenWithdrawals)
: now > deposits_mostRecentBASEWithdrawal[user].add(minTimeBetweenWithdrawals);
}
function userDepositSeconds(address user)
public
view
returns (uint256 level1, uint256 level2, uint256 level3)
{
uint256 timeSinceDeposit = now.sub(deposits_depositTimestamp[user]);
uint256 multiplier = deposits_multiplierLevel[user];
uint256 lpTokens = deposits_lpTokensDeposited[user];
uint256 secondsLevel1;
uint256 secondsLevel2;
uint256 secondsLevel3;
if (multiplier == 1) {
secondsLevel1 = timeSinceDeposit;
} else if (multiplier == 2) {
secondsLevel1 = 30 days;
secondsLevel2 = timeSinceDeposit.sub(30 days);
} else if (multiplier == 3) {
secondsLevel1 = 30 days;
secondsLevel2 = 30 days;
secondsLevel3 = timeSinceDeposit.sub(60 days);
}
return (
lpTokens.mul(secondsLevel1),
lpTokens.mul(secondsLevel2),
lpTokens.mul(secondsLevel3)
);
}
function sumOfUserDepositSeconds(address user)
public
view
returns (uint256)
{
(uint256 level1, uint256 level2, uint256 level3) = userDepositSeconds(user);
return level1.add(level2.mul(2)).add(level3.mul(3));
}
function totalDepositSeconds()
public
view
returns (uint256)
{
(uint256 level1, uint256 level2, uint256 level3) = getUpdatedDepositSeconds();
return level1.add(level2.mul(2)).add(level3.mul(3));
}
function rewardsPool()
public
view
returns (uint256)
{
uint256 baseBalance = BASE.balanceOf(address(this));
uint256 unlocked;
if (rewardsStartTimestamp > 0) {
uint256 secondsIntoVesting = now.sub(rewardsStartTimestamp);
if (secondsIntoVesting > rewardsDuration) {
unlocked = baseBalance;
} else {
unlocked = baseBalance.mul( now.sub(rewardsStartTimestamp) ).div(rewardsDuration);
}
} else {
unlocked = baseBalance;
}
return unlocked;
}
function owedTo(address user)
public
view
returns (uint256 amount)
{
if (totalDepositSeconds() == 0) {
return 0;
}
return rewardsPool().mul(sumOfUserDepositSeconds(user)).div(totalDepositSeconds());
}
}
BaseToken.sol 319 lines
pragma solidity 0.6.12;
import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";
import "./lib/SafeMathInt.sol";
import "./ERC20UpgradeSafe.sol";
import "./ERC677Token.sol";
interface ISync {
function sync() external;
}
interface IGulp {
function gulp(address token) external;
}
/**
* @title BASE ERC20 token
* @dev This is part of an implementation of the BASE Index Fund protocol.
* BASE is a normal ERC20 token, but its supply can be adjusted by splitting and
* combining tokens proportionally across all wallets.
*
* BASE balances are internally represented with a hidden denomination, 'shares'.
* We support splitting the currency in expansion and combining the currency on contraction by
* changing the exchange rate between the hidden 'shares' and the public 'BASE'.
*/
contract BaseToken is ERC20UpgradeSafe, ERC677Token, OwnableUpgradeSafe {
// PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH
// Anytime there is division, there is a risk of numerical instability from rounding errors. In
// order to minimize this risk, we adhere to the following guidelines:
// 1) The conversion rate adopted is the number of shares that equals 1 BASE.
// The inverse rate must not be used--totalShares is always the numerator and _totalSupply is
// always the denominator. (i.e. If you want to convert shares to BASE instead of
// multiplying by the inverse rate, you should divide by the normal rate)
// 2) Share balances converted into BaseToken are always rounded down (truncated).
//
// We make the following guarantees:
// - If address 'A' transfers x BaseToken to address 'B'. A's resulting external balance will
// be decreased by precisely x BaseToken, and B's external balance will be precisely
// increased by x BaseToken.
//
// We do not guarantee that the sum of all balances equals the result of calling totalSupply().
// This is because, for any conversion function 'f()' that has non-zero rounding error,
// f(x0) + f(x1) + ... + f(xn) is not always equal to f(x0 + x1 + ... xn).
using SafeMath for uint256;
using SafeMathInt for int256;
event LogRebase(uint256 indexed epoch, uint256 totalSupply);
event LogMonetaryPolicyUpdated(address monetaryPolicy);
// Used for authentication
address public monetaryPolicy;
modifier validRecipient(address to) {
require(to != address(0x0));
require(to != address(this));
_;
}
uint256 private constant DECIMALS = 9;
uint256 private constant MAX_UINT256 = ~uint256(0);
uint256 private constant INITIAL_SUPPLY = 8795645 * 10**DECIMALS;
uint256 private constant INITIAL_SHARES = (MAX_UINT256 / (10 ** 36)) - ((MAX_UINT256 / (10 ** 36)) % INITIAL_SUPPLY);
uint256 private constant MAX_SUPPLY = ~uint128(0); // (2^128) - 1
uint256 private _totalShares;
uint256 private _totalSupply;
uint256 private _sharesPerBASE;
mapping(address => uint256) private _shareBalances;
mapping(address => bool) public bannedUsers; // Deprecated
// This is denominated in BaseToken, because the shares-BASE conversion might change before
// it's fully paid.
mapping (address => mapping (address => uint256)) private _allowedBASE;
bool private transfersPaused;
bool public rebasesPaused;
mapping(address => bool) private transferPauseExemptList;
function setRebasesPaused(bool _rebasesPaused)
public
onlyOwner
{
rebasesPaused = _rebasesPaused;
}
/**
* @param monetaryPolicy_ The address of the monetary policy contract to use for authentication.
*/
function setMonetaryPolicy(address monetaryPolicy_)
external
onlyOwner
{
monetaryPolicy = monetaryPolicy_;
emit LogMonetaryPolicyUpdated(monetaryPolicy_);
}
/**
* @dev Notifies BaseToken contract about a new rebase cycle.
* @param supplyDelta The number of new BASE tokens to add into circulation via expansion.
* @return The total number of BASE after the supply adjustment.
*/
function rebase(uint256 epoch, int256 supplyDelta)
external
returns (uint256)
{
require(msg.sender == monetaryPolicy, "only monetary policy");
require(!rebasesPaused, "rebases paused");
if (supplyDelta == 0) {
emit LogRebase(epoch, _totalSupply);
return _totalSupply;
}
if (supplyDelta < 0) {
_totalSupply = _totalSupply.sub(uint256(supplyDelta.abs()));
} else {
_totalSupply = _totalSupply.add(uint256(supplyDelta));
}
if (_totalSupply > MAX_SUPPLY) {
_totalSupply = MAX_SUPPLY;
}
_sharesPerBASE = _totalShares.div(_totalSupply);
// From this point forward, _sharesPerBASE is taken as the source of truth.
// We recalculate a new _totalSupply to be in agreement with the _sharesPerBASE
// conversion rate.
// This means our applied supplyDelta can deviate from the requested supplyDelta,
// but this deviation is guaranteed to be < (_totalSupply^2)/(totalShares - _totalSupply).
//
// In the case of _totalSupply <= MAX_UINT128 (our current supply cap), this
// deviation is guaranteed to be < 1, so we can omit this step. If the supply cap is
// ever increased, it must be re-included.
emit LogRebase(epoch, _totalSupply);
ISync(0xdE5b7Ff5b10CC5F8c95A2e2B643e3aBf5179C987).sync(); // Uniswap BASE/ETH
ISync(0xD8B8B575c943f3d63638c9563B464D204ED8B710).sync(); // Sushiswap BASE/ETH
IGulp(0x19B770c8F9d5439C419864d8458255791f7e736C).gulp(address(this)); // Value BASE/USDC
return _totalSupply;
}
function totalShares()
public
view
returns (uint256)
{
return _totalShares;
}
function sharesOf(address user)
public
view
returns (uint256)
{
return _shareBalances[user];
}
function initialize()
public
initializer
{
__ERC20_init("Base Protocol", "BASE");
_setupDecimals(uint8(DECIMALS));
__Ownable_init();
_totalShares = INITIAL_SHARES;
_totalSupply = INITIAL_SUPPLY;
_shareBalances[owner()] = _totalShares;
_sharesPerBASE = _totalShares.div(_totalSupply);
emit Transfer(address(0x0), owner(), _totalSupply);
}
/**
* @return The total number of BASE.
*/
function totalSupply()
public
override
view
returns (uint256)
{
return _totalSupply;
}
/**
* @param who The address to query.
* @return The balance of the specified address.
*/
function balanceOf(address who)
public
override
view
returns (uint256)
{
return _shareBalances[who].div(_sharesPerBASE);
}
/**
* @dev Transfer tokens to a specified address.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return True on success, false otherwise.
*/
function transfer(address to, uint256 value)
public
override(ERC20UpgradeSafe, ERC677)
validRecipient(to)
returns (bool)
{
uint256 shareValue = value.mul(_sharesPerBASE);
_shareBalances[msg.sender] = _shareBalances[msg.sender].sub(shareValue);
_shareBalances[to] = _shareBalances[to].add(shareValue);
emit Transfer(msg.sender, to, value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner has allowed to a spender.
* @param owner_ The address which owns the funds.
* @param spender The address which will spend the funds.
* @return The number of tokens still available for the spender.
*/
function allowance(address owner_, address spender)
public
override
view
returns (uint256)
{
return _allowedBASE[owner_][spender];
}
/**
* @dev Transfer tokens from one address to another.
* @param from The address you want to send tokens from.
* @param to The address you want to transfer to.
* @param value The amount of tokens to be transferred.
*/
function transferFrom(address from, address to, uint256 value)
public
override
validRecipient(to)
returns (bool)
{
_allowedBASE[from][msg.sender] = _allowedBASE[from][msg.sender].sub(value);
uint256 shareValue = value.mul(_sharesPerBASE);
_shareBalances[from] = _shareBalances[from].sub(shareValue);
_shareBalances[to] = _shareBalances[to].add(shareValue);
emit Transfer(from, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of
* msg.sender. This method is included for ERC20 compatibility.
* increaseAllowance and decreaseAllowance should be used instead.
* Changing an allowance with this method brings the risk that someone may transfer both
* the old and the new allowance - if they are both greater than zero - if a transfer
* transaction is mined before the later approve() call is mined.
*
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value)
public
override
returns (bool)
{
_allowedBASE[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Increase the amount of tokens that an owner has allowed to a spender.
* This method should be used instead of approve() to avoid the double approval vulnerability
* described above.
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(address spender, uint256 addedValue)
public
override
returns (bool)
{
_allowedBASE[msg.sender][spender] = _allowedBASE[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowedBASE[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner has allowed to a spender.
*
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(address spender, uint256 subtractedValue)
public
override
returns (bool)
{
uint256 oldValue = _allowedBASE[msg.sender][spender];
if (subtractedValue >= oldValue) {
_allowedBASE[msg.sender][spender] = 0;
} else {
_allowedBASE[msg.sender][spender] = oldValue.sub(subtractedValue);
}
emit Approval(msg.sender, spender, _allowedBASE[msg.sender][spender]);
return true;
}
}
ERC677Token.sol 44 lines
pragma solidity 0.6.12;
import "./interfaces/ERC677.sol";
import "./interfaces/ERC677Receiver.sol";
abstract contract ERC677Token is ERC677 {
/**
* @dev transfer token to a contract address with additional data if the recipient is a contact.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
* @param _data The extra data to be passed to the receiving contract.
*/
function transferAndCall(address _to, uint _value, bytes memory _data)
public
override
returns (bool success)
{
transfer(_to, _value);
// emit Transfer(msg.sender, _to, _value, _data);
if (isContract(_to)) {
contractFallback(_to, _value, _data);
}
return true;
}
function contractFallback(address _to, uint _value, bytes memory _data)
private
{
ERC677Receiver receiver = ERC677Receiver(_to);
receiver.onTokenTransfer(msg.sender, _value, _data);
}
function isContract(address _addr)
private
view
returns (bool hasCode)
{
uint length;
// solhint-disable-next-line no-inline-assembly
assembly { length := extcodesize(_addr) }
return length > 0;
}
}
SafeMathInt.sol 106 lines
/*
MIT License
Copyright (c) 2018 requestnetwork
Copyright (c) 2018 Fragments, Inc.
Copyright (c) 2020 Base Protocol, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
pragma solidity 0.6.12;
/**
* @title SafeMathInt
* @dev Math operations for int256 with overflow safety checks.
*/
library SafeMathInt {
int256 private constant MIN_INT256 = int256(1) << 255;
int256 private constant MAX_INT256 = ~(int256(1) << 255);
/**
* @dev Multiplies two int256 variables and fails on overflow.
*/
function mul(int256 a, int256 b)
internal
pure
returns (int256)
{
int256 c = a * b;
// Detect overflow when multiplying MIN_INT256 with -1
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
/**
* @dev Division of two int256 variables and fails on overflow.
*/
function div(int256 a, int256 b)
internal
pure
returns (int256)
{
// Prevent overflow when dividing MIN_INT256 by -1
require(b != -1 || a != MIN_INT256);
// Solidity already throws when dividing by 0.
return a / b;
}
/**
* @dev Subtracts two int256 variables and fails on overflow.
*/
function sub(int256 a, int256 b)
internal
pure
returns (int256)
{
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two int256 variables and fails on overflow.
*/
function add(int256 a, int256 b)
internal
pure
returns (int256)
{
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
/**
* @dev Converts to absolute value, and fails on overflow.
*/
function abs(int256 a)
internal
pure
returns (int256)
{
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
}
ERC20UpgradeSafe.sol 318 lines
pragma solidity 0.6.12;
import "@openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20MinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of 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 ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC20_init_unchained(name, symbol);
}
function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer {
_name = name;
_symbol = symbol;
_decimals = 18;
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view 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 value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* 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 returns (uint8) {
return _decimals;
}
/**
* @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:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, 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}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), 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};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(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) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is 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:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, 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
*
* - `to` 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 = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(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);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is 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 Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @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 to 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 { }
uint256[44] private __gap;
}
ERC677.sol 9 lines
pragma solidity 0.6.12;
abstract contract ERC677 {
function transfer(address to, uint256 value) public virtual returns (bool);
function transferAndCall(address to, uint value, bytes memory data) public virtual returns (bool success);
// event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
ERC677Receiver.sol 6 lines
pragma solidity 0.6.12;
abstract contract ERC677Receiver {
function onTokenTransfer(address _sender, uint _value, bytes memory _data) virtual public;
}
Context.sol 38 lines
pragma solidity ^0.6.0;
import "../Initializable.sol";
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN 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.
*/
contract ContextUpgradeSafe is Initializable {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
function __Context_init() internal initializer {
__Context_init_unchained();
}
function __Context_init_unchained() internal initializer {
}
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
uint256[50] private __gap;
}
Initializable.sol 62 lines
pragma solidity >=0.4.24 <0.7.0;
/**
* @title Initializable
*
* @dev Helper contract to support initializer functions. To use it, replace
* the constructor with a function that has the `initializer` modifier.
* WARNING: Unlike constructors, initializer functions must be manually
* invoked. This applies both to deploying an Initializable contract, as well
* as extending an Initializable contract via inheritance.
* WARNING: When used with inheritance, manual care must be taken to not invoke
* a parent initializer twice, or ensure that all initializers are idempotent,
* because this is not dealt with automatically as with constructors.
*/
contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private initializing;
/**
* @dev Modifier to use in the initializer function of a contract.
*/
modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
initializing = true;
initialized = true;
}
_;
if (isTopLevelCall) {
initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly { cs := extcodesize(self) }
return cs == 0;
}
// Reserved storage space to allow for layout changes in the future.
uint256[50] private ______gap;
}
SafeMath.sol 150 lines
pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
Address.sol 58 lines
pragma solidity ^0.6.2;
/**
* @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
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}
Ownable.sol 79 lines
pragma solidity ^0.6.0;
import "../GSN/Context.sol";
import "../Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal initializer {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
uint256[49] private __gap;
}
IERC20.sol 75 lines
pragma solidity ^0.6.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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 `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);
/**
* @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);
}
Read Contract
BASE 0xec342ad0 → address
allowedToWithdraw 0x2d291cad → bool
cascadeV2 0x439e52fb → address
depositInfo 0x63445989 → uint256, uint256, uint8, uint256, uint256, uint256
deposits_depositTimestamp 0x1f8b0867 → uint256
deposits_lastMultiplierUpgradeTimestamp 0x45c626c5 → uint256
deposits_lpTokensDeposited 0x50dfed89 → uint256
deposits_mostRecentBASEWithdrawal 0x30cb11ee → uint256
deposits_multiplierLevel 0x7637c1b6 → uint8
getUpdatedDepositSeconds 0x37080fcc → uint256, uint256, uint256
lastAccountingUpdateTimestamp 0xa3cbae46 → uint256
lpToken 0x5fcbd285 → address
minTimeBetweenWithdrawals 0xb9cbd8c4 → uint256
owedTo 0x8462d661 → uint256
owner 0x8da5cb5b → address
rewardsDuration 0x386a9525 → uint256
rewardsPool 0x0359fea9 → uint256
rewardsStartTimestamp 0x63568502 → uint256
sumOfUserDepositSeconds 0x0c6dfcc5 → uint256
totalDepositSeconds 0x1436ee18 → uint256
totalDepositSecondsLevel1 0x3ee9f334 → uint256
totalDepositSecondsLevel2 0x3934fa56 → uint256
totalDepositSecondsLevel3 0xd53ea8ba → uint256
totalDepositedLevel1 0x8828a817 → uint256
totalDepositedLevel2 0xba94dc0c → uint256
totalDepositedLevel3 0xcfadb0a5 → uint256
userDepositSeconds 0x5d837d7a → uint256, uint256, uint256
Write Contract 16 functions
These functions modify contract state and require a wallet transaction to execute.
adminWithdrawBASE 0x0de839e1
address recipient
uint256 amount
deposit 0xb6b55f25
uint256 amount
initialize 0x8129fc1c
No parameters
migrate 0x8fd3ab80
No parameters
renounceOwnership 0x715018a6
No parameters
rescueMistakenlySentTokens 0xfbbc8925
address token
address recipient
uint256 amount
setBASEToken 0xfce51aeb
address _baseToken
setCascadeV2 0xdba0290f
address _cascadeV2
setLPToken 0x6a678a9c
address _lpToken
setMinTimeBetweenWithdrawals 0x55fc9fc4
uint256 _minTimeBetweenWithdrawals
setMultiplierUpgradeTimeout 0x9ce29133
uint256 _multiplierUpgradeTimeout
setRewardsParams 0x78d6425a
uint256 _rewardsStartTimestamp
uint256 _rewardsDuration
transferOwnership 0xf2fde38b
address newOwner
updateDepositSeconds 0x06c324e7
No parameters
upgradeMultiplierLevel 0xc545633c
No parameters
withdrawLPTokens 0xedf8bc13
No parameters
Recent Transactions
This address has 1 on-chain transactions, but only 1.3% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →