Address Contract Verified
Address
0xeF42f6A62fe8141ef93a712d35d00AF5B781cfA1
Balance
0 ETH
Nonce
1
Code Size
10021 bytes
Creator
0xB5D4b9C8...9463 at tx 0x977e40cd...3e922a
Indexed Transactions
0
Contract Bytecode
10021 bytes
0x608060405234801561001057600080fd5b50600436106101ae5760003560e01c80639d76ea58116100ee578063d814386011610097578063e7d1a8b011610071578063e7d1a8b01461039e578063ee204abb146103a7578063f2fde38b146103ba578063f444fdd8146103cd57600080fd5b8063d814386014610376578063dc92f8f014610389578063e0709a741461039157600080fd5b8063ab7922a4116100c8578063ab7922a414610322578063b6b9d02e14610335578063c34531531461034857600080fd5b80639d76ea58146102dc578063a296b323146102fc578063a694fc3a1461030f57600080fd5b80635d3eea911161015b5780636e6082a6116101355780636e6082a61461027a578063715018a61461028d5780638456cb59146102955780638da5cb5b1461029d57600080fd5b80635d3eea911461024b5780635f088f731461025e578063604e7c991461027157600080fd5b806351dfe0881161018c57806351dfe088146101e357806352454f6f146102095780635c975abb1461021c57600080fd5b806312514bba146101b3578063185a5671146101c85780633f4ba83a146101db575b600080fd5b6101c66101c13660046123e8565b6103f2565b005b6101c66101d63660046122a2565b61048e565b6101c66105d8565b6101f66101f13660046123e8565b610663565b6040519081526020015b60405180910390f35b6101f66102173660046122bd565b610684565b60015474010000000000000000000000000000000000000000900460ff165b6040519015158152602001610200565b6101c66102593660046123e8565b610aca565b6101c661026c36600461241a565b610bd3565b6101f660055481565b6101f661028836600461243c565b610cc8565b6101c661107d565b6101c6611108565b60015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610200565b6003546102b79073ffffffffffffffffffffffffffffffffffffffff1681565b6101c661030a3660046123ae565b611191565b6101c661031d3660046123e8565b611243565b6101f661033036600461241a565b6112f8565b6101c66103433660046122a2565b6114a3565b61035b6103563660046122a2565b6115e7565b60408051938452602084019290925290820152606001610200565b6101c66103843660046122e7565b61163c565b6101c6611752565b60065461023b9060ff1681565b6101f660045481565b6101f66103b53660046122a2565b6117ff565b6101c66103c83660046122a2565b61180b565b6006546102b790610100900473ffffffffffffffffffffffffffffffffffffffff1681565b60065460ff16610463576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f4572726f723a2044697361626c6564000000000000000000000000000000000060448201526064015b60405180910390fd5b60065461048b90610100900473ffffffffffffffffffffffffffffffffffffffff1682611938565b50565b60015473ffffffffffffffffffffffffffffffffffffffff16331461050f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045a565b73ffffffffffffffffffffffffffffffffffffffff811661058c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4572726f723a205a65726f206164647265737300000000000000000000000000604482015260640161045a565b6006805473ffffffffffffffffffffffffffffffffffffffff909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b60015473ffffffffffffffffffffffffffffffffffffffff163314610659576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045a565b610661611a39565b565b6002818154811061067357600080fd5b600091825260209091200154905081565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600760209081526040808320815180830190925280548083526001909101549282019290925290158015906106d9575060008160200151115b15610abe5780516000906106ed90856125d8565b905062015180811161074c57670de0b6b3a7640000600260008154811061071657610716612683565b9060005260206000200154828460200151610731919061259b565b61073b919061259b565b6107459190612560565b9250610ab8565b620a8c0081116107dd57670de0b6b3a7640000600260018154811061077357610773612683565b9060005260206000200154620151808361078d91906125d8565b610797919061259b565b60026000815481106107ab576107ab612683565b9060005260206000200154620151806107c4919061259b565b6107ce9190612548565b836020015161073b919061259b565b62321900811161088b57670de0b6b3a76400006002808154811061080357610803612683565b9060005260206000200154620a8c008361081d91906125d8565b610827919061259b565b600260018154811061083b5761083b612683565b906000526020600020015462093a80610854919061259b565b600260008154811061086857610868612683565b906000526020600020015462015180610881919061259b565b6107c49190612548565b62a8c000811161096657670de0b6b3a764000060026003815481106108b2576108b2612683565b906000526020600020015462321900836108cc91906125d8565b6108d6919061259b565b600280815481106108e9576108e9612683565b906000526020600020015462278d00610902919061259b565b600260018154811061091657610916612683565b906000526020600020015462093a8061092f919061259b565b600260008154811061094357610943612683565b90600052602060002001546201518061095c919061259b565b6108819190612548565b600061097562a8c000836125d8565b9050670de0b6b3a7640000600260048154811061099457610994612683565b90600052602060002001546301da9c0083116109b057826109b6565b6301da9c005b6109c0919061259b565b60026003815481106109d4576109d4612683565b90600052602060002001546276a7006109ed919061259b565b60028081548110610a0057610a00612683565b906000526020600020015462278d00610a19919061259b565b6002600181548110610a2d57610a2d612683565b906000526020600020015462093a80610a46919061259b565b6002600081548110610a5a57610a5a612683565b906000526020600020015462015180610a73919061259b565b610a7d9190612548565b610a879190612548565b610a919190612548565b610a9b9190612548565b8460200151610aaa919061259b565b610ab49190612560565b9350505b50610ac3565b600091505b5092915050565b60015474010000000000000000000000000000000000000000900460ff1615610b4f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161045a565b6004544210158015610b6357506005544211155b610bc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4572726f723a2054696d65206e6f742061727269766564000000000000000000604482015260640161045a565b61048b3382611938565b60015473ffffffffffffffffffffffffffffffffffffffff163314610c54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045a565b818111610cbd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600560248201527f4572726f72000000000000000000000000000000000000000000000000000000604482015260640161045a565b600491909155600555565b600080610cd585856112f8565b90508060011415610d39576002600081548110610cf457610cf4612683565b90600052602060002001548585670de0b6b3a7640000610d14919061259b565b610d1e9190612560565b610d289190612560565b610d3290846125d8565b9150611075565b8060021415610dd857620151806002600181548110610d5a57610d5a612683565b9060005260206000200154866002600081548110610d7a57610d7a612683565b90600052602060002001546201518089610d94919061259b565b610d9e919061259b565b610db088670de0b6b3a764000061259b565b610dba91906125d8565b610dc49190612560565b610dce9190612560565b610d289190612548565b8060031415610e7257620a8c0060028081548110610df857610df8612683565b9060005260206000200154866002600181548110610e1857610e18612683565b906000526020600020015462093a80610e31919061259b565b6002600081548110610e4557610e45612683565b906000526020600020015462015180610e5e919061259b565b610e689190612548565b610d9e908961259b565b8060041415610f2f57623219006002600381548110610e9357610e93612683565b90600052602060002001548660028081548110610eb257610eb2612683565b906000526020600020015462278d00610ecb919061259b565b6002600181548110610edf57610edf612683565b906000526020600020015462093a80610ef8919061259b565b6002600081548110610f0c57610f0c612683565b906000526020600020015462015180610f25919061259b565b610e5e9190612548565b62a8c0006002600481548110610f4757610f47612683565b9060005260206000200154866002600381548110610f6757610f67612683565b90600052602060002001546276a700610f80919061259b565b60028081548110610f9357610f93612683565b906000526020600020015462278d00610fac919061259b565b6002600181548110610fc057610fc0612683565b906000526020600020015462093a80610fd9919061259b565b6002600081548110610fed57610fed612683565b906000526020600020015462015180611006919061259b565b6110109190612548565b61101a9190612548565b6110249190612548565b61102e908961259b565b61104088670de0b6b3a764000061259b565b61104a91906125d8565b6110549190612560565b61105e9190612560565b6110689190612548565b61107290846125d8565b91505b509392505050565b60015473ffffffffffffffffffffffffffffffffffffffff1633146110fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045a565b6106616000611b32565b60015473ffffffffffffffffffffffffffffffffffffffff163314611189576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045a565b610661611ba9565b60015473ffffffffffffffffffffffffffffffffffffffff163314611212576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045a565b600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b600081116112ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4572726f723a205f616d6f756e74203d3d203000000000000000000000000000604482015260640161045a565b60035473ffffffffffffffffffffffffffffffffffffffff166112ea335b73ffffffffffffffffffffffffffffffffffffffff8316903085611c95565b6112f43383611d71565b5050565b600080600260008154811061130f5761130f612683565b90600052602060002001546201518085611329919061259b565b611333919061259b565b9050611347670de0b6b3a764000082612560565b831161135757600191505061149d565b6000600260018154811061136d5761136d612683565b906000526020600020015462093a8086611387919061259b565b611391919061259b565b61139b9083612548565b90506113af670de0b6b3a764000082612560565b84116113c05760029250505061149d565b6000600280815481106113d5576113d5612683565b906000526020600020015462278d00876113ef919061259b565b6113f9919061259b565b6114039083612548565b9050611417670de0b6b3a764000082612560565b8511611429576003935050505061149d565b6000600260038154811061143f5761143f612683565b90600052602060002001546276a70088611459919061259b565b611463919061259b565b61146d9083612548565b9050611481670de0b6b3a764000082612560565b861161149457600494505050505061149d565b60059450505050505b92915050565b60015473ffffffffffffffffffffffffffffffffffffffff163314611524576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045a565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015281906112f490339073ffffffffffffffffffffffffffffffffffffffff8416906370a082319060240160206040518083038186803b15801561159157600080fd5b505afa1580156115a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115c99190612401565b73ffffffffffffffffffffffffffffffffffffffff84169190611e9e565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600760209081526040808320815180830190925280548083526001909101549282018390529290611633856117ff565b93959294505050565b80518251146116a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f6c656e677468206572726f720000000000000000000000000000000000000000604482015260640161045a565b6000805b8251811015611729578281815181106116c6576116c6612683565b6020026020010151826116d99190612548565b91506117178482815181106116f0576116f0612683565b602002602001015184838151811061170a5761170a612683565b6020026020010151611d71565b806117218161261b565b9150506116ab565b5060035473ffffffffffffffffffffffffffffffffffffffff1661174c336112cb565b50505050565b60015473ffffffffffffffffffffffffffffffffffffffff1633146117d3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045a565b60405133904780156108fc02916000818181858888f1935050505015801561048b573d6000803e3d6000fd5b600061149d8242610684565b60015473ffffffffffffffffffffffffffffffffffffffff16331461188c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045a565b73ffffffffffffffffffffffffffffffffffffffff811661192f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161045a565b61048b81611b32565b336000908152600760205260409020811580159061195a575080600101548211155b6119c0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f4572726f723a205f616d6f756e74000000000000000000000000000000000000604482015260640161045a565b818160010160008282546119d491906125d8565b909155505060035473ffffffffffffffffffffffffffffffffffffffff166119fd818585611e9e565b60405183815233907fb24546d975e2628748efc9aced80665e0fad66272033e5c0ea25fd3afac99795906020015b60405180910390a250505050565b60015474010000000000000000000000000000000000000000900460ff16611abd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161045a565b600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b6001805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60015474010000000000000000000000000000000000000000900460ff1615611c2e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161045a565b600180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611b083390565b60405173ffffffffffffffffffffffffffffffffffffffff8085166024830152831660448201526064810182905261174c9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611ef9565b60015474010000000000000000000000000000000000000000900460ff1615611df6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161045a565b6000611e01836117ff565b73ffffffffffffffffffffffffffffffffffffffff841660009081526007602052604081206001810180549394509092859290611e3f908490612548565b90915550506001810154611e54908342610cc8565b815560405183815273ffffffffffffffffffffffffffffffffffffffff8516907febedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a90602001611a2b565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052611ef49084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611cef565b505050565b6000611f5b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166120059092919063ffffffff16565b805190915015611ef45780806020019051810190611f7991906123cb565b611ef4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161045a565b6060612014848460008561201e565b90505b9392505050565b6060824710156120b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161045a565b73ffffffffffffffffffffffffffffffffffffffff85163b61212e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161045a565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516121579190612468565b60006040518083038185875af1925050503d8060008114612194576040519150601f19603f3d011682016040523d82523d6000602084013e612199565b606091505b50915091506121a98282866121b4565b979650505050505050565b606083156121c3575081612017565b8251156121d35782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045a9190612484565b803573ffffffffffffffffffffffffffffffffffffffff8116811461222b57600080fd5b919050565b600082601f83011261224157600080fd5b8135602061225661225183612524565b6124d5565b80838252828201915082860187848660051b890101111561227657600080fd5b60005b8581101561229557813584529284019290840190600101612279565b5090979650505050505050565b6000602082840312156122b457600080fd5b61201782612207565b600080604083850312156122d057600080fd5b6122d983612207565b946020939093013593505050565b600080604083850312156122fa57600080fd5b823567ffffffffffffffff8082111561231257600080fd5b818501915085601f83011261232657600080fd5b8135602061233661225183612524565b8083825282820191508286018a848660051b890101111561235657600080fd5b600096505b848710156123805761236c81612207565b83526001969096019591830191830161235b565b509650508601359250508082111561239757600080fd5b506123a485828601612230565b9150509250929050565b6000602082840312156123c057600080fd5b8135612017816126e1565b6000602082840312156123dd57600080fd5b8151612017816126e1565b6000602082840312156123fa57600080fd5b5035919050565b60006020828403121561241357600080fd5b5051919050565b6000806040838503121561242d57600080fd5b50508035926020909101359150565b60008060006060848603121561245157600080fd5b505081359360208301359350604090920135919050565b6000825161247a8184602087016125ef565b9190910192915050565b60208152600082518060208401526124a38160408501602087016125ef565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561251c5761251c6126b2565b604052919050565b600067ffffffffffffffff82111561253e5761253e6126b2565b5060051b60200190565b6000821982111561255b5761255b612654565b500190565b600082612596577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156125d3576125d3612654565b500290565b6000828210156125ea576125ea612654565b500390565b60005b8381101561260a5781810151838201526020016125f2565b8381111561174c5750506000910152565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561264d5761264d612654565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b801515811461048b57600080fdfea2646970667358221220dcb275592708f54a95c41ad4c69990c29ebc3e97a708a26c638eedba3473a38864736f6c63430008070033
Verified Source Code Full Match
Compiler: v0.8.7+commit.e28d00a7
EVM: istanbul
Optimization: Yes (999999 runs)
Stake1Cat.sol 201 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
contract Stake1Cat is ReentrancyGuard, Ownable, Pausable {
using SafeERC20 for IERC20;
uint256[] public pointsSS = [11574074074075, 1653439153440, 385802469136, 128600823046, 32150205762];
uint256 private constant D1 = 1 days;
uint256 private constant D7 = 7 days;
uint256 private constant D8 = 8 days;
uint256 private constant D30 = 30 days;
uint256 private constant D38 = 38 days;
uint256 private constant D90 = 90 days;
uint256 private constant D128 = 128 days;
uint256 private constant D360 = 360 days;
address public tokenAddress;
uint256 public unStakeStartTime;
uint256 public unStakeEndTime;
bool public isTransfer;
address public transferAddress;
mapping(address => StakeInfo) private stakes;
struct StakeInfo {
uint256 lastTime;
uint256 amount;
}
event Stake(
address indexed sender,
uint256 amount
);
event UnStake(
address indexed sender,
uint256 amount
);
constructor(address _tokenAddress) {
tokenAddress = _tokenAddress;
}
function getStakeInfo(address addr) public virtual view returns (uint256 lastTime, uint256 amount, uint256 points){
StakeInfo memory info = stakes[addr];
lastTime = info.lastTime;
amount = info.amount;
points = getPoints(addr);
}
function getPoints(address sender) public virtual view returns (uint256 points){
points = getPoints(sender, block.timestamp);
}
function getPoints(address sender, uint256 timestamp) public virtual view returns (uint256 points){
StakeInfo memory info = stakes[sender];
if (info.lastTime > 0 && info.amount > 0) {
uint256 time = timestamp - info.lastTime;
if (time <= D1) {
points = (info.amount * time * pointsSS[0]) / 1e18;
} else if (time <= D8) {
points = info.amount * (D1 * pointsSS[0]
+ (time - D1) * pointsSS[1]) / 1e18;
} else if (time <= D38) {
points = info.amount * (D1 * pointsSS[0]
+ D7 * pointsSS[1]
+ (time - D8) * pointsSS[2]) / 1e18;
} else if (time <= D128) {
points = info.amount * (D1 * pointsSS[0]
+ D7 * pointsSS[1]
+ D30 * pointsSS[2]
+ (time - D38) * pointsSS[3]) / 1e18;
} else {
uint256 lTime = time - D128;
points = info.amount * (D1 * pointsSS[0]
+ D7 * pointsSS[1]
+ D30 * pointsSS[2]
+ D90 * pointsSS[3]
+ (lTime > D360 ? D360 : lTime) * pointsSS[4]) / 1e18;
}
} else points = 0;
}
function getLadder(uint256 amount, uint256 points) public view returns (uint256){
uint256 l1 = amount * D1 * pointsSS[0];
if (points <= l1 / 1e18) return 1;
uint256 l2 = l1 + amount * D7 * pointsSS[1];
if (points <= l2 / 1e18) return 2;
uint256 l3 = l2 + amount * D30 * pointsSS[2];
if (points <= l3 / 1e18) return 3;
uint256 l4 = l3 + amount * D90 * pointsSS[3];
if (points <= l4 / 1e18) return 4;
else return 5;
}
function getLastTime(uint256 amount, uint256 points, uint256 timestamp) public view returns (uint256 lastTime){
uint256 ladder = getLadder(amount, points);
if (ladder == 1) {
lastTime = timestamp - (points * 1e18 / amount / pointsSS[0]);
} else if (ladder == 2) {
lastTime = timestamp - ((points * 1e18 - amount * D1 * pointsSS[0])
/ amount / pointsSS[1] + D1);
} else if (ladder == 3) {
lastTime = timestamp - ((points * 1e18 - amount * (D1 * pointsSS[0] + D7 * pointsSS[1]))
/ amount / pointsSS[2] + D8);
} else if (ladder == 4) {
lastTime = timestamp - ((points * 1e18 - amount * (D1 * pointsSS[0] + D7 * pointsSS[1]
+ D30 * pointsSS[2]))
/ amount / pointsSS[3] + D38);
} else {
lastTime = timestamp - ((points * 1e18 - amount * (D1 * pointsSS[0] + D7 * pointsSS[1]
+ D30 * pointsSS[2] + D90 * pointsSS[3]))
/ amount / pointsSS[4] + D128);
}
}
function stakeBatch(
address[] memory tos,
uint256[] memory amounts
) public virtual {
require(tos.length == amounts.length, "length error");
uint256 amount;
for (uint256 i = 0; i < amounts.length; i++) {
amount += amounts[i];
_stake(tos[i], amounts[i]);
}
IERC20 token = IERC20(tokenAddress);
token.safeTransferFrom(_msgSender(), address(this), amount);
}
function stake(uint256 _amount) public virtual {
require(_amount > 0, 'Error: _amount == 0');
IERC20 token = IERC20(tokenAddress);
token.safeTransferFrom(_msgSender(), address(this), _amount);
_stake(_msgSender(), _amount);
}
function _stake(address _sender, uint256 _amount) internal virtual whenNotPaused {
uint256 points = getPoints(_sender);
StakeInfo storage info = stakes[_sender];
info.amount += _amount;
info.lastTime = getLastTime(info.amount, points, block.timestamp);
emit Stake(_sender, _amount);
}
function _unStake(address _receiver, uint256 _amount) internal virtual {
StakeInfo storage info = stakes[msg.sender];
require(_amount > 0 && _amount <= info.amount, 'Error: _amount');
info.amount -= _amount;
IERC20 token = IERC20(tokenAddress);
token.safeTransfer(_receiver, _amount);
emit UnStake(msg.sender, _amount);
}
function unStake(uint256 _amount) external whenNotPaused {
require(block.timestamp >= unStakeStartTime && block.timestamp <= unStakeEndTime, 'Error: Time not arrived');
_unStake(msg.sender, _amount);
}
function transfer(uint256 _amount) external {
require(isTransfer, 'Error: Disabled');
_unStake(transferAddress, _amount);
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function setTransfer(bool _isTransfer) public onlyOwner {
isTransfer = _isTransfer;
}
function setTransferAddress(address _transferAddress) public onlyOwner {
require(_transferAddress != address(0), 'Error: Zero address');
transferAddress = _transferAddress;
}
function setUnStakeTime(uint256 _unStakeStartTime, uint256 _unStakeEndTime) public onlyOwner {
require(_unStakeEndTime > _unStakeStartTime, 'Error');
unStakeStartTime = _unStakeStartTime;
unStakeEndTime = _unStakeEndTime;
}
function emergencyWithdrawEther() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
function emergencyWithdrawErc20(address _tokenAddress) public onlyOwner {
IERC20 token = IERC20(_tokenAddress);
token.safeTransfer(msg.sender, token.balanceOf(address(this)));
}
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual 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 {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Pausable.sol 91 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
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());
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.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 `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);
/**
* @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);
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
SafeERC20.sol 99 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
Read Contract
getLadder 0xab7922a4 → uint256
getLastTime 0x6e6082a6 → uint256
getPoints 0x52454f6f → uint256
getPoints 0xee204abb → uint256
getStakeInfo 0xc3453153 → uint256, uint256, uint256
isTransfer 0xe0709a74 → bool
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
pointsSS 0x51dfe088 → uint256
tokenAddress 0x9d76ea58 → address
transferAddress 0xf444fdd8 → address
unStakeEndTime 0x604e7c99 → uint256
unStakeStartTime 0xe7d1a8b0 → uint256
Write Contract 13 functions
These functions modify contract state and require a wallet transaction to execute.
emergencyWithdrawErc20 0xb6b9d02e
address _tokenAddress
emergencyWithdrawEther 0xdc92f8f0
No parameters
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
setTransfer 0xa296b323
bool _isTransfer
setTransferAddress 0x185a5671
address _transferAddress
setUnStakeTime 0x5f088f73
uint256 _unStakeStartTime
uint256 _unStakeEndTime
stake 0xa694fc3a
uint256 _amount
stakeBatch 0xd8143860
address[] tos
uint256[] amounts
transfer 0x12514bba
uint256 _amount
transferOwnership 0xf2fde38b
address newOwner
unStake 0x5d3eea91
uint256 _amount
unpause 0x3f4ba83a
No parameters
Recent Transactions
No transactions found for this address