Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x407CF653C4ebb3c2025DfB7f00D5C0dCFc347dB4
Balance 0 ETH
Nonce 1
Code Size 8100 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

8100 bytes
0x608060405234801561001057600080fd5b50600436106101c45760003560e01c8063861894ed116100f9578063b5bfca5b11610097578063c8a22eb411610071578063c8a22eb4146103eb578063d23ab97a14610417578063ecd0c0c314610437578063f21b7ec11461044a57600080fd5b8063b5bfca5b146103b2578063bae04c9a146103c5578063bdebee99146103d857600080fd5b806391c1aa1a116100d357806391c1aa1a146103705780639e281a98146103845780639ea0e07414610397578063b21dd53a1461039f57600080fd5b8063861894ed1461030e5780638da5cb5b1461033257806391656e371461035d57600080fd5b8063523a3f08116101665780636215be77116101405780636215be77146102cc578063689191f0146102df5780636aeb5c26146102e85780637a10babe146102fb57600080fd5b8063523a3f081461029e57806356a5c973146102b157806357e88aa2146102c457600080fd5b806313af4035116101a257806313af40351461023d5780631bae91a414610250578063415d65fd1461026357806347b33b491461027657600080fd5b806301713a02146101c95780630880cae8146101fc5780630aa9d26c14610211575b600080fd5b6101e96101d7366004611c5a565b60036020526000908152604090205481565b6040519081526020015b60405180910390f35b61020f61020a366004611c84565b61045d565b005b6101e961021f366004611cbd565b6001600160a01b031660009081526020819052604090206008015490565b61020f61024b366004611cbd565b6104ae565b6101e961025e366004611cbd565b6104fa565b61020f610271366004611c84565b610515565b610289610284366004611c5a565b61055d565b604080519283526020830191909152016101f3565b61020f6102ac366004611c5a565b6105aa565b6101e96102bf366004611cd8565b6106d0565b61020f6108d4565b61020f6102da366004611c5a565b610983565b6101e960065481565b61020f6102f6366004611c5a565b610b87565b61020f610309366004611d02565b610c0e565b60015461032290600160a01b900460ff1681565b60405190151581526020016101f3565b600254610345906001600160a01b031681565b6040516001600160a01b0390911681526020016101f3565b6101e961036b366004611cd8565b610c9b565b60015461032290600160a81b900460ff1681565b61020f610392366004611cd8565b610d5b565b61020f610e6e565b6101e96103ad366004611cd8565b61100c565b61020f6103c0366004611d24565b611043565b61020f6103d3366004611d02565b61144f565b6101e96103e6366004611d57565b61162f565b6101e96103f9366004611cbd565b6001600160a01b031660009081526020819052604090206001015490565b6101e9610425366004611c5a565b60009081526003602052604090205490565b600154610345906001600160a01b031681565b61020f610458366004611d97565b611730565b6002546001600160a01b031633146104905760405162461bcd60e51b815260040161048790611e23565b60405180910390fd5b60018054911515600160a81b0260ff60a81b19909216919091179055565b6002546001600160a01b031633146104d85760405162461bcd60e51b815260040161048790611e23565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b031660009081526020819052604090205490565b6002546001600160a01b0316331461053f5760405162461bcd60e51b815260040161048790611e23565b60018054911515600160a01b0260ff60a01b19909216919091179055565b3360009081526020819052604081208054829190829082908690811061058557610585611e46565b9060005260206000209060050201905080600001548160010154935093505050915091565b60006105b633836106d0565b6001546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610604573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106289190611e5c565b90508181101561064a5760405162461bcd60e51b815260040161048790611e75565b610654338461176b565b60015460405163a9059cbb60e01b8152336004820152602481018490526001600160a01b039091169063a9059cbb906044015b6020604051808303816000875af11580156106a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ca9190611eac565b50505050565b60008042816106de866104fa565b6001600160a01b03871660009081526020819052604081209192505b828110156108c657600082600001828154811061071957610719611e46565b60009182526020822060059091020180546001820154919350919061073e9088611edf565b9050600061075d603c85600201548a6107579190611edf565b9061182d565b60048501549091508b81146107765750505050506108b4565b620151808311158015610787575080155b156107b4576015546107ad90610757600860005b01546107a78887611840565b90611840565b93506108a2565b62093a8083111580156107c75750806001145b156107df576015546107ad906107576008600161079b565b6212750083111580156107f25750806002145b1561080a576015546107ad906107576008600261079b565b62278d00831115801561081d5750806003145b15610835576015546107ad906107576008600361079b565b62ed4e0083111580156108485750806004145b15610860576015546107ad906107576008600461079b565b6301e1338083111580156108745750806005145b1561088c576015546107ad906107576008600561079b565b60155461089f906107576008600061079b565b93505b6108ac8a8561184c565b995050505050505b806108be81611ef2565b9150506106fa565b509293505050505b92915050565b6002546001600160a01b031633146108fe5760405162461bcd60e51b815260040161048790611e23565b60015460025460065460405163a9059cbb60e01b81526001600160a01b039283166004820152602481019190915291169063a9059cbb906044016020604051808303816000875af1158015610957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097b9190611eac565b506000600655565b6002546001600160a01b031633146109ad5760405162461bcd60e51b815260040161048790611e23565b600081116109fd5760405162461bcd60e51b815260206004820152601f60248201527f796f752063616e206465706f736974206d6f7265207468616e203020736e74006044820152606401610487565b6001546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610a46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6a9190611e5c565b600154604051636eb1769f60e11b81523360048201523060248201529192506000916001600160a01b039091169063dd62ed3e90604401602060405180830381865afa158015610abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae29190611e5c565b9050828210158015610af45750828110155b610b4a5760405162461bcd60e51b815260206004820152602160248201527f496e73756666696369656e742062616c616e6365206f7220616c6c6f77616e636044820152606560f81b6064820152608401610487565b6001546040516323b872dd60e01b8152336004820152306024820152604481018590526001600160a01b03909116906323b872dd90606401610687565b6002546001600160a01b03163314610bb15760405162461bcd60e51b815260040161048790611e23565b610bbd81600754101590565b610c095760405162461bcd60e51b815260206004820152601c60248201527f796f752063616e7420736574206974206d6f7265207468616e203525000000006044820152606401610487565b601455565b6002546001600160a01b03163314610c385760405162461bcd60e51b815260040161048790611e23565b610c4482600754101590565b610c905760405162461bcd60e51b815260206004820152601c60248201527f796f752063616e7420736574206974206d6f7265207468616e203525000000006044820152606401610487565b600491909155600555565b600080610ca7846104fa565b6001600160a01b0385166000908152602081905260408120919250610ccd600184611edf565b905060005b6000836000018381548110610ce957610ce9611e46565b9060005260206000209060050201905086816004015403610d3e57600e816004015460068110610d1b57610d1b611e46565b01548160010154610d2c9190611f0b565b610d369083611f0b565b915050610d51565b82610d4881611f1e565b93505050610cd2565b9695505050505050565b6002546001600160a01b03163314610d855760405162461bcd60e51b815260040161048790611e23565b6001546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df29190611e5c565b905080821115610e355760015460405163a9059cbb60e01b81526001600160a01b038581166004830152602482018490529091169063a9059cbb90604401610687565b60015460405163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529091169063a9059cbb90604401610687565b33600090815260208190526040902060018054600160a01b900460ff16151514610eeb5760405162461bcd60e51b815260206004820152602860248201527f526566657272616c2073797374656d2069732063757272656e746c7920756e616044820152677661696c61626c6560c01b6064820152608401610487565b60088101546001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015610f38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5c9190611e5c565b1015610f7a5760405162461bcd60e51b815260040161048790611e75565b600154600882015460405163a9059cbb60e01b815233600482015260248101919091526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015610fd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff59190611eac565b505033600090815260208190526040812060080155565b6001600160a01b038216600090815260208190526040812060028101836006811061103957611039611e46565b0154949350505050565b600154604051636eb1769f60e11b8152336004820152306024820152839182916001600160a01b039091169063dd62ed3e90604401602060405180830381865afa158015611095573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b99190611e5c565b10156110f95760405162461bcd60e51b815260206004820152600f60248201526e20b63637bbb0b731b29022b93937b960891b6044820152606401610487565b6000831161113e5760405162461bcd60e51b8152602060048201526012602482015271496e737566666963696e65742076616c756560701b6044820152606401610487565b6001546040516323b872dd60e01b8152336004820152306024820152604481018590526001600160a01b03909116906323b872dd906064016020604051808303816000875af1158015611195573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b99190611eac565b506001548390600160a81b900460ff16156112755760006111eb6015546107576004548561184090919063ffffffff16565b60015460025460405163a9059cbb60e01b81526001600160a01b03918216600482015260248101849052929350169063a9059cbb906044016020604051808303816000875af1158015611242573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112669190611eac565b506112718183611edf565b9150505b6040805160a081018252828152426020808301828152838501928352600060608501818152608086018a81523380845283865297832080546001808201835582865296852089516005909202019081559451958501959095559451600280850191909155905160038401805460ff1916911515919091179055935160049092019190915593909352909161131f91849101866006811061131757611317611e46565b01549061184c565b336000908152602081905260409020600201856006811061134257611342611e46565b015560008481526003602052604090205461135d908361184c565b6000858152600360205260409020556001600160a01b038616331480159061138e5750600154600160a01b900460ff165b15611447576113ae6015546107576014548861184090919063ffffffff16565b6040805180820182528281523360208083019182526001600160a01b038b81166000818152808452958620600180820180548083018255908952948820875160029096020194855594519390940180546001600160a01b0319169390921692909217905590925260089091015491935090611429908461184c565b6001600160a01b038816600090815260208190526040902060080155505b505050505050565b600061145c338385611858565b90508083111561149e5760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a5908125b9c1d5d609a1b6044820152606401610487565b6001546040516370a0823160e01b815230600482015284916001600160a01b0316906370a0823190602401602060405180830381865afa1580156114e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150a9190611e5c565b10156115285760405162461bcd60e51b815260040161048790611e75565b611531826105aa565b80925061153f3384846119d5565b600154600160a81b900460ff16156115f857600061156e6015546107576004548761184090919063ffffffff16565b60015460025460405163a9059cbb60e01b81526001600160a01b03918216600482015260248101849052929350169063a9059cbb906044016020604051808303816000875af11580156115c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e99190611eac565b506115f48185611edf565b9350505b60015460405163a9059cbb60e01b8152336004820152602481018590526001600160a01b039091169063a9059cbb90604401610687565b6000808061163c866104fa565b6001600160a01b03871660009081526020819052604081209192504291905b8381101561172357600082600001828154811061167a5761167a611e46565b90600052602060002090600502019050600081600101548561169c9190611edf565b82546004840154919250908b810361170c57600e8460040154600681106116c5576116c5611e46565b0154831080156116d257508a5b156116ff576116f26015546107576005548561184090919063ffffffff16565b6116fc9083611edf565b91505b611709898361184c565b98505b50505050808061171b90611ef2565b91505061165b565b5092979650505050505050565b6002546001600160a01b0316331461175a5760405162461bcd60e51b815260040161048790611e23565b6117676008826006611c07565b5050565b6000611776836104fa565b6001600160a01b038416600090815260208190526040812091925042905b83811015611447576001600160a01b03861660009081526020819052604081208054839081106117c6576117c6611e46565b906000526020600020906005020190506000816004015490508681146117ed57505061181b565b8385600001848154811061180357611803611e46565b90600052602060002090600502016002018190555050505b8061182581611ef2565b915050611794565b60006118398284611f35565b9392505050565b60006118398284611f57565b60006118398284611f0b565b60008080611865866104fa565b6001600160a01b03871660009081526020819052604081209192504291905b838110156117235760008260000182815481106118a3576118a3611e46565b9060005260206000209060050201905060008160010154856118c59190611edf565b82546004840154919250908b81036119be57835460008d815260036020526040812080549091906118f7908490611edf565b90915550600e9050816006811061191057611910611e46565b01548310156119b157601554600554855461193092916107579190611840565b600660008282546119419190611f0b565b909155505060155460055461195c9190610757908590611840565b6119669083611edf565b601554600554865492945061197e9261075791611840565b845461198a9190611edf565b86600001868154811061199f5761199f611e46565b60009182526020909120600590910201555b6119bb898361184c565b98505b5050505080806119cd90611ef2565b915050611884565b60006119e0846104fa565b90508260005b82811015611447576001600160a01b0386166000908152602081905260408120805483908110611a1857611a18611e46565b6000918252602090912060036005909202019081015490915060ff16151560011480611a48575084816004015414155b15611a535750611be9565b80548310611b1c578054611a68908490611bfb565b6001600160a01b038816600090815260208190526040902080549194509083908110611a9657611a96611e46565b60009182526020808320600590920290910182815560018082018490556002820184905560038201805460ff1916905560049091018390556001600160a01b038a168352908290526040909120805484908110611af557611af5611e46565b60009182526020909120600590910201600301805460ff1916911515919091179055611be7565b6001600160a01b03871660009081526020819052604090208054611b6391859185908110611b4c57611b4c611e46565b600091825260209091206005909102015490611bfb565b6001600160a01b0388166000908152602081905260409020805484908110611b8d57611b8d611e46565b600091825260208083206005909202909101929092556001600160a01b03891681529081905260409020805442919084908110611bcc57611bcc611e46565b90600052602060002090600502016001018190555050611447565b505b80611bf381611ef2565b9150506119e6565b60006118398284611edf565b8260068101928215611c35579160200282015b82811115611c35578251825591602001919060010190611c1a565b50611c41929150611c45565b5090565b5b80821115611c415760008155600101611c46565b600060208284031215611c6c57600080fd5b5035919050565b8015158114611c8157600080fd5b50565b600060208284031215611c9657600080fd5b813561183981611c73565b80356001600160a01b0381168114611cb857600080fd5b919050565b600060208284031215611ccf57600080fd5b61183982611ca1565b60008060408385031215611ceb57600080fd5b611cf483611ca1565b946020939093013593505050565b60008060408385031215611d1557600080fd5b50508035926020909101359150565b600080600060608486031215611d3957600080fd5b611d4284611ca1565b95602085013595506040909401359392505050565b600080600060608486031215611d6c57600080fd5b611d7584611ca1565b9250602084013591506040840135611d8c81611c73565b809150509250925092565b600060c08284031215611da957600080fd5b82601f830112611db857600080fd5b60405160c0810181811067ffffffffffffffff82111715611de957634e487b7160e01b600052604160045260246000fd5b6040528060c0840185811115611dfe57600080fd5b845b81811015611e18578035835260209283019201611e00565b509195945050505050565b6020808252600990820152682737ba1037bbb732b960b91b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611e6e57600080fd5b5051919050565b6020808252601a908201527f506f6f6c20686173206e6f7420656e6f7567682063727970746f000000000000604082015260600190565b600060208284031215611ebe57600080fd5b815161183981611c73565b634e487b7160e01b600052601160045260246000fd5b818103818111156108ce576108ce611ec9565b600060018201611f0457611f04611ec9565b5060010190565b808201808211156108ce576108ce611ec9565b600081611f2d57611f2d611ec9565b506000190190565b600082611f5257634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176108ce576108ce611ec956fea2646970667358221220b420c3a3d070d2ac326742b62998dd184da27440a062528bcef5240d3141303464736f6c63430008120033

Verified Source Code Partial Match

Compiler: v0.8.18+commit.87f61d96 EVM: paris Optimization: Yes (200 runs)
Renq_Staking.sol 786 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IBEP20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the token decimals.
     */
    function decimals() external view returns (uint8);

    /**
     * @dev Returns the token symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the token name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the bep token owner.
     */
    function getOwner() external view returns (address);

    /**
     * @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
    );
}

library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(
        uint256 a,
        uint256 b
    ) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(
        uint256 a,
        uint256 b
    ) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(
        uint256 a,
        uint256 b
    ) internal pure returns (bool, uint256) {
        unchecked {
            // 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 (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(
        uint256 a,
        uint256 b
    ) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(
        uint256 a,
        uint256 b
    ) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @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) {
        return a + b;
    }

    /**
     * @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 a - b;
    }

    /**
     * @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) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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 a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting 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) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

contract Renq_Staking {
    using SafeMath for uint256;

    struct depositStatus {
        uint256 amount_in;
        uint256 start_date;
        uint256 reward_date;
        bool deleted;
        uint256 pool;
    }
    struct referralStatus {
        uint256 amount_in;
        address ref_address;
    }
    struct userInfo {
        depositStatus[] deposits;
        referralStatus[] refs;
        uint256[6] total_deposit;
        uint256 total_ref;
    }

    mapping(address => userInfo) users;

    IBEP20 public _token;
    bool public referralStatusBool = false;
    bool public stakeUnstakeFeeBool = false;

    address public owner;
    mapping(uint256 => uint256) public totalDepositPerPool;
    uint256 private owner_fee = 2000000000000;
    uint256 private early_fee = 20000000000000;
    uint256 public early_record;
    uint256 private max_percent = 20000000000000;
    uint256[6] private minute_percent = [
        22831050,
        38051750,
        47564687,
        57077625,
        142694063,
        285388127
    ];

    uint256[6] private pools = [
        1 days,
        7 days,
        14 days,
        30 days,
        180 days,
        365 days
    ];
    uint256 private ref_percent = 2000000000000;
    uint256 private percent = 100000000000000;

    modifier onlyOwner() {
        require(msg.sender == owner, "Not owner");
        _;
    }

    modifier checkAllowance(uint256 amount) {
        require(
            _token.allowance(msg.sender, address(this)) >= amount,
            "Allowance Error"
        );
        _;
    }

    constructor(address token) {
        owner = 0x2D3C5979d582400708Eb1dc3Be24a06a7864c292;

        _token = IBEP20(token);
    }

    function userDeposit(
        address referral,
        uint256 _amount,
        uint256 _pool
    ) public checkAllowance(_amount) {
        // require(contractStarted(), "Contract not started yet.");
        require(_amount > 0, "Insufficinet value");
        _token.transferFrom(msg.sender, address(this), _amount);
        uint256 value = _amount;
        // send fee to owner
        if (stakeUnstakeFeeBool) {
            uint256 fee = value.mul(owner_fee).div(percent);
            _token.transfer(owner, fee);
            value = value - fee;
        }

        // save information
        depositStatus memory temp = depositStatus(
            value,
            block.timestamp,
            block.timestamp,
            false,
            _pool
        );
        users[msg.sender].deposits.push(temp);
        users[msg.sender].total_deposit[_pool] = users[msg.sender]
            .total_deposit[_pool]
            .add(value);

        totalDepositPerPool[_pool] = totalDepositPerPool[_pool].add(value);

        // // if user enter with referral link, save referral data
        if (referral != msg.sender && referralStatusBool) {
            value = _amount.mul(ref_percent).div(percent);
            referralStatus memory temp1 = referralStatus(value, msg.sender);
            users[referral].refs.push(temp1);
            users[referral].total_ref = users[referral].total_ref.add(value);
        }
    }

    function withdrawReward(uint256 _pool) public {
        uint256 total_amount = calcReward(msg.sender, _pool);
        uint256 balance = _token.balanceOf(address(this));
        require(balance >= total_amount, "Pool has not enough crypto");
        removeAfterReward(msg.sender, _pool);
        _token.transfer(msg.sender, total_amount);
    }

    function removeAfterReward(address to, uint256 _pool) internal {
        uint256 count = getUserDepositCount(to);
        userInfo storage user = users[to];
        uint256 current = block.timestamp;
        for (uint256 i = 0; i < count; i++) {
            depositStatus storage perStatus = users[to].deposits[i];
            uint256 poolx = perStatus.pool;

            if (poolx != _pool) {
                continue;
            }

            user.deposits[i].reward_date = current;
        }
    }

    function withdrawDeposit(uint256 amount, uint256 _pool) public {
        uint256 total_amount = calcWithdrawCall(msg.sender, _pool, amount);
        require(amount <= total_amount, "Invalid Input");
        require(
            _token.balanceOf(address(this)) >= amount,
            "Pool has not enough crypto"
        );
        withdrawReward(_pool);
        amount = total_amount;
        removeAfterWithdraw(msg.sender, amount, _pool);
        if (stakeUnstakeFeeBool) {
            uint256 fee = amount.mul(owner_fee).div(percent);
            _token.transfer(owner, fee);
            amount = amount - fee;
        }

        //  users[msg.sender].total_deposit[_pool] = users[msg.sender]
        //     .total_deposit[_pool]
        //     .sub(amount);

        // totalDepositPerPool[_pool] = totalDepositPerPool[_pool].sub(amount);

        _token.transfer(msg.sender, amount);
    }

    function withdrawToken(address to, uint256 amount) external onlyOwner {
        uint256 balance = _token.balanceOf(address(this));
        if (amount > balance) {
            _token.transfer(to, balance);
        } else {
            _token.transfer(to, amount);
        }
    }

    function depositToken(uint256 amount) external onlyOwner {
        require(amount > 0, "you can deposit more than 0 snt");
        uint256 balance = _token.balanceOf(msg.sender);
        uint256 allowance = _token.allowance(msg.sender, address(this));

        require(
            balance >= amount && allowance >= amount,
            "Insufficient balance or allowance"
        );

        _token.transferFrom(msg.sender, address(this), amount);
    }

    function removeAfterWithdraw(
        address to,
        uint256 amount,
        uint256 _pool
    ) internal {
        uint256 count = getUserDepositCount(to);
        uint256 tamt = amount;

        for (uint256 i = 0; i < count; i++) {
            depositStatus storage perStatus = users[to].deposits[i];

            if (perStatus.deleted == true || perStatus.pool != _pool) {
                continue;
            } else if (perStatus.amount_in <= tamt) {
                tamt = tamt.sub(perStatus.amount_in);
                delete users[to].deposits[i];
                users[to].deposits[i].deleted = true;

                // i = i.sub(1);
                // count = count.sub(1);
            } else {
                users[to].deposits[i].amount_in = users[to]
                    .deposits[i]
                    .amount_in
                    .sub(tamt);
                users[to].deposits[i].start_date = block.timestamp;

                break;
            }
        }
    }

    function withdrawReferral() public {
        userInfo storage user = users[msg.sender];
        require(
            referralStatusBool == true,
            "Referral system is currently unavailable"
        );
        require(
            _token.balanceOf(address(this)) >= user.total_ref,
            "Pool has not enough crypto"
        );
        _token.transfer(msg.sender, user.total_ref);
        users[msg.sender].total_ref = 0;
    }

    function calcWithdrawCall(
        address to,
        uint256 _pool,
        uint256 _amount
    ) internal returns (uint256) {
        uint256 value = 0;
        uint256 count = getUserDepositCount(to);
        uint256 current = block.timestamp;
        userInfo storage user = users[to];

        // uint256 tamt = _amount.mul(early_fee).div(percent);
        // early_record += tamt;
        for (uint256 i = 0; i < count; i++) {
            depositStatus storage perStatus = user.deposits[i];

            uint256 stakeTime = current - perStatus.start_date;
            uint256 eachReward = perStatus.amount_in;
            uint256 poolx = perStatus.pool;

            if (poolx == _pool) {
                totalDepositPerPool[_pool] -= perStatus.amount_in;
                if (stakeTime < pools[poolx]) {
                    early_record += perStatus.amount_in.mul(early_fee).div(
                        percent
                    );

                    eachReward =
                        eachReward -
                        eachReward.mul(early_fee).div(percent);

                    user.deposits[i].amount_in =
                        perStatus.amount_in -
                        perStatus.amount_in.mul(early_fee).div(percent);
                }

                value = value.add(eachReward);
            }
        }
        return value;
    }

    function calcWithdraw(
        address to,
        uint256 _pool,
        bool _bool
    ) public view returns (uint256) {
        uint256 value = 0;
        uint256 count = getUserDepositCount(to);
        uint256 current = block.timestamp;
        userInfo storage user = users[to];
        for (uint256 i = 0; i < count; i++) {
            depositStatus storage perStatus = user.deposits[i];
            uint256 stakeTime = current - perStatus.start_date;
            uint256 eachReward = perStatus.amount_in;
            uint256 poolx = perStatus.pool;

            if (poolx == _pool) {
                if (stakeTime < pools[perStatus.pool] && _bool) {
                    eachReward =
                        eachReward -
                        eachReward.mul(early_fee).div(percent);
                }

                value = value.add(eachReward);
            }
        }
        return value;
    }

    function calcReward(
        address to,
        uint256 _pool
    ) public view returns (uint256) {
        uint256 value = 0;
        uint256 current = block.timestamp;
        uint256 count = getUserDepositCount(to);
        userInfo storage user = users[to];

        for (uint256 i = 0; i < count; i++) {
            depositStatus storage perStatus = user.deposits[i];
            uint256 eachReward = perStatus.amount_in;
            uint256 stakeTime = current - perStatus.start_date;
            uint256 period = (current - perStatus.reward_date).div(1 minutes);
            uint256 stakePlan = perStatus.pool;

            if (stakePlan != _pool) {
                continue;
            }

            if (stakeTime <= 1 days && stakePlan == 0) {
                eachReward = eachReward.mul(period).mul(minute_percent[0]).div(
                    percent
                );
            } else if (stakeTime <= 7 days && stakePlan == 1) {
                eachReward = eachReward.mul(period).mul(minute_percent[1]).div(
                    percent
                );
            } else if (stakeTime <= 14 days && stakePlan == 2) {
                eachReward = eachReward.mul(period).mul(minute_percent[2]).div(
                    percent
                );
            } else if (stakeTime <= 30 days && stakePlan == 3) {
                eachReward = eachReward.mul(period).mul(minute_percent[3]).div(
                    percent
                );
            } else if (stakeTime <= 180 days && stakePlan == 4) {
                eachReward = eachReward.mul(period).mul(minute_percent[4]).div(
                    percent
                );
            } else if (stakeTime <= 365 days && stakePlan == 5) {
                eachReward = eachReward.mul(period).mul(minute_percent[5]).div(
                    percent
                );
            } else {
                eachReward = eachReward.mul(period).mul(minute_percent[0]).div(
                    percent
                );
            }

            value = value.add(eachReward);
        }
        return value;
    }

    function getUserDepositCount(address to) public view returns (uint256) {
        userInfo storage user = users[to];
        return user.deposits.length;
    }

    function getUserReferralCount(address to) public view returns (uint256) {
        userInfo storage user = users[to];
        return user.refs.length;
    }

    function getUserDeposit(
        uint256 index
    ) public view returns (uint256, uint256) {
        userInfo storage user = users[msg.sender];
        depositStatus storage userCurrent = user.deposits[index];
        return (userCurrent.amount_in, userCurrent.start_date);
    }

    function getTotalReferral(address to) public view returns (uint256) {
        userInfo storage user = users[to];
        return user.total_ref;
    }

    function getTotalDeposit(uint256 _pool) public view returns (uint256) {
        return totalDepositPerPool[_pool];
    }

    function getUserTotalDeposit(
        address to,
        uint256 _pool
    ) public view returns (uint256) {
        userInfo storage user = users[to];
        return user.total_deposit[_pool];
    }

    function getFreeTime(
        address to,
        uint256 _pool
    ) public view returns (uint256) {
        uint256 count = getUserDepositCount(to);
        userInfo storage user = users[to];
        uint256 i = count - 1;
        uint256 time = 0;
        while (i >= 0) {
            depositStatus storage perStatus = user.deposits[i];
            if (perStatus.pool == _pool) {
                time += perStatus.start_date + pools[perStatus.pool];
                break;
            }
            i--;
        }

        return time;
    }

    function checkFeePercent(uint256 fee) internal view returns (bool) {
        return fee <= max_percent;
    }

    function setOwnerFee(uint256 fee, uint256 _early_fee) public onlyOwner {
        require(checkFeePercent(fee), "you cant set it more than 5%");
        owner_fee = fee;
        early_fee = _early_fee;
    }

    function setOwner(address to) public onlyOwner {
        owner = to;
    }

    function adminClaimEarlyFees() public onlyOwner {
        _token.transfer(owner, early_record);
        early_record = 0;
    }

    function setRefFee(uint256 fee) public onlyOwner {
        require(checkFeePercent(fee), "you cant set it more than 5%");
        ref_percent = fee;
    }

    function setMinuteFee(uint256[6] memory fee) public onlyOwner {
        // require(checkFeePercent(fee), "you cant set it more than 5%");
        minute_percent = fee;
    }

    function setReferralStatus(bool _referralStatusBool) public onlyOwner {
        referralStatusBool = _referralStatusBool;
    }

    function setstakeUnstakeFeeBool(
        bool _stakeUnstakeFeeBool
    ) public onlyOwner {
        stakeUnstakeFeeBool = _stakeUnstakeFeeBool;
    }
}

Read Contract

_token 0xecd0c0c3 → address
calcReward 0x56a5c973 → uint256
calcWithdraw 0xbdebee99 → uint256
early_record 0x689191f0 → uint256
getFreeTime 0x91656e37 → uint256
getTotalDeposit 0xd23ab97a → uint256
getTotalReferral 0x0aa9d26c → uint256
getUserDeposit 0x47b33b49 → uint256, uint256
getUserDepositCount 0x1bae91a4 → uint256
getUserReferralCount 0xc8a22eb4 → uint256
getUserTotalDeposit 0xb21dd53a → uint256
owner 0x8da5cb5b → address
referralStatusBool 0x861894ed → bool
stakeUnstakeFeeBool 0x91c1aa1a → bool
totalDepositPerPool 0x01713a02 → uint256

Write Contract 13 functions

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

adminClaimEarlyFees 0x57e88aa2
No parameters
depositToken 0x6215be77
uint256 amount
setMinuteFee 0xf21b7ec1
uint256[6] fee
setOwner 0x13af4035
address to
setOwnerFee 0x7a10babe
uint256 fee
uint256 _early_fee
setRefFee 0x6aeb5c26
uint256 fee
setReferralStatus 0x415d65fd
bool _referralStatusBool
setstakeUnstakeFeeBool 0x0880cae8
bool _stakeUnstakeFeeBool
userDeposit 0xb5bfca5b
address referral
uint256 _amount
uint256 _pool
withdrawDeposit 0xbae04c9a
uint256 amount
uint256 _pool
withdrawReferral 0x9ea0e074
No parameters
withdrawReward 0x523a3f08
uint256 _pool
withdrawToken 0x9e281a98
address to
uint256 amount

Recent Transactions

No transactions found for this address