Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x19432762FE44B087D86e2F42950e0765C567CF4e
Balance 0 ETH
Nonce 1
Code Size 6345 bytes
Indexed Transactions 0 (1 on-chain, 0.8% indexed)
External Etherscan · Sourcify

Contract Bytecode

6345 bytes
0x608060405234801561001057600080fd5b50600436106101425760003560e01c80635fcbd285116100b8578063b6b55f251161007c578063b6b55f25146102b7578063c7afe9f2146102ca578063ee38db95146102dd578063f2fde38b146102e5578063f35e4a6e146102f8578063fc0c546a1461030b57600080fd5b80635fcbd28514610247578063662fac3914610272578063715018a6146102955780638cdcbdef1461029d5780638da5cb5b146102a657600080fd5b806335c8518b1161010a57806335c8518b146101fe5780633e67912814610211578063411330bd1461021a5780634198709a1461022d57806348cd4cb1146102365780634e71d92d1461023f57600080fd5b80631959a002146101475780631bd047a11461019657806323a3a616146101ad5780632e1a7d4d146101d657806331d7a262146101eb575b600080fd5b61017661015536600461156b565b600a6020526000908152604090208054600182015460029092015490919083565b604080519384526020840192909252908201526060015b60405180910390f35b61019f60065481565b60405190815260200161018d565b61019f6101bb36600461156b565b6001600160a01b03166000908152600a602052604090205490565b6101e96101e43660046115e3565b61031e565b005b61019f6101f936600461156b565b61048a565b6101e961020c3660046115e3565b610620565b61019f60075481565b6101e96102283660046115e3565b61076c565b61019f60035481565b61019f60045481565b6101e9610849565b60025461025a906001600160a01b031681565b6040516001600160a01b03909116815260200161018d565b600854600954610280919082565b6040805192835260208301919091520161018d565b6101e9610932565b61019f60055481565b6000546001600160a01b031661025a565b6101e96102c53660046115e3565b610968565b6101e96102d83660046115aa565b610a54565b6101e9610b85565b6101e96102f336600461156b565b610ddb565b6101e96103063660046115e3565b610e76565b60015461025a906001600160a01b031681565b600081116103475760405162461bcd60e51b815260040161033e90611777565b60405180910390fd5b600060045411801561035b57506004544310155b6103775760405162461bcd60e51b815260040161033e90611664565b336000908152600a6020526040902080548211156103f05760405162461bcd60e51b815260206004820152603060248201527f4661726d696e673a20796f752063616e6e6f74207769746864726177206d6f7260448201526f65207468616e20796f7520686176652160801b606482015260840161033e565b6103f8610f90565b610401336110b3565b811561042c5780546104139083611113565b815560025461042c906001600160a01b03163384611128565b600954815461044b9164e8d4a51000916104459161118b565b90611197565b600182015560405182815233907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364906020015b60405180910390a25050565b60008060045411801561049f57506004544310155b6104bb5760405162461bcd60e51b815260040161033e90611664565b6001600160a01b038281166000908152600a602052604080822060095460025492516370a0823160e01b8152306004820152919490939216906370a082319060240160206040518083038186803b15801561051557600080fd5b505afa158015610529573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054d91906115fc565b6008549091508061055d57506004545b60006105676111a3565b90508061057b575060009695505050505050565b818111801561058957508215155b156105d957600061059a8284611113565b905060006105b36003548361118b90919063ffffffff16565b90506105d46105cb866104458464e8d4a5100061118b565b600954906111d7565b955050505b610615856002015461060f876001015461060964e8d4a510006104458a8c6000015461118b90919063ffffffff16565b90611113565b906111d7565b979650505050505050565b6000546001600160a01b0316331461064a5760405162461bcd60e51b815260040161033e90611742565b6004546106695760405162461bcd60e51b815260040161033e9061169b565b600554156106b95760405162461bcd60e51b815260206004820181905260248201527f4661726d696e673a20636c6f736520626c6f636b20616c726561647920736574604482015260640161033e565b60045481116107305760405162461bcd60e51b815260206004820152603760248201527f4661726d696e673a20636c6f736520626c6f636b206e6565647320746f20626560448201527f20686967686572207468616e207374617274206f6e6521000000000000000000606482015260840161033e565b60058190556040518181527ff611389adc906823d7195c85599775805c1387992a80055df34e70b86bdde4d5906020015b60405180910390a150565b6000546001600160a01b031633146107965760405162461bcd60e51b815260040161033e90611742565b6000811161080c5760405162461bcd60e51b815260206004820152603d60248201527f4661726d696e673a20616d6f756e74206f6620746f6b656e732070657220626c60448201527f6f636b2073686f756c642062652067726561746572207468616e203021000000606482015260840161033e565b610814610f90565b60038190556040518181527fba54ce5940e90276397dfc944292ed6a6a43aa64f9deb96d5f471bef49b78e1490602001610761565b600060045411801561085d57506004544310155b6108795760405162461bcd60e51b815260040161033e90611664565b336000908152600a60205260409020610890610f90565b610899336110b3565b6002810154156109115760006108b33383600201546111e3565b60405181815290915033907f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d49060200160405180910390a260028201546108fa9082611113565b600283015560065461090c90826111d7565b600655505b600954815461092a9164e8d4a51000916104459161118b565b600190910155565b6000546001600160a01b0316331461095c5760405162461bcd60e51b815260040161033e90611742565b61096660006112a1565b565b600081116109885760405162461bcd60e51b815260040161033e90611777565b600060045411801561099c57506004544310155b6109b85760405162461bcd60e51b815260040161033e90611664565b336000908152600a602052604090206109cf610f90565b6109d8336110b3565b8115610a045780546109ea90836111d7565b8155600254610a04906001600160a01b03163330856112f1565b6009548154610a1d9164e8d4a51000916104459161118b565b600182015560405182815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200161047e565b6000546001600160a01b03163314610a7e5760405162461bcd60e51b815260040161033e90611742565b6001600160a01b038216610aa45760405162461bcd60e51b815260040161033e906116e5565b6001600160a01b038116610aca5760405162461bcd60e51b815260040161033e906116e5565b6001546001600160a01b0316158015610aec57506002546001600160a01b0316155b610b385760405162461bcd60e51b815260206004820152601c60248201527f4661726d696e673a20746f6b656e7320616c7265616479207365742100000000604482015260640161033e565b600180546001600160a01b039384166001600160a01b0319918216179091556002805492909316911617905560408051808201909152600080825260209091018190526008819055600955565b6000546001600160a01b03163314610baf5760405162461bcd60e51b815260040161033e90611742565b600454610bce5760405162461bcd60e51b815260040161033e9061169b565b600554610c305760405162461bcd60e51b815260206004820152602a60248201527f4661726d696e673a20636c6f736520626c6f636b206e6565647320746f206265604482015269081cd95d08199a5c9cdd60b21b606482015260840161033e565b6005544311610c9e5760405162461bcd60e51b815260206004820152603460248201527f4661726d696e673a207769746864726177616c206f662072656d61696e696e6760448201527308199d5b991cc81b9bdd081c9958591e481e595d60621b606482015260840161033e565b610ca6610f90565b6000610cbf60065460075461111390919063ffffffff16565b6001546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a082319060240160206040518083038186803b158015610d0857600080fd5b505afa158015610d1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4091906115fc565b9050600082821115610d5957610d568284611113565b90505b8015610dd657610d87610d746000546001600160a01b031690565b6001546001600160a01b03169083611128565b6000546001600160a01b03166001600160a01b03167fcdbc2e554e2a29ae95f46efb6591e6922a2cf48460ad9fa7e4bfad4212f21e4182604051610dcd91815260200190565b60405180910390a25b505050565b6000546001600160a01b03163314610e055760405162461bcd60e51b815260040161033e90611742565b6001600160a01b038116610e6a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161033e565b610e73816112a1565b50565b6000546001600160a01b03163314610ea05760405162461bcd60e51b815260040161033e90611742565b60045415610ef05760405162461bcd60e51b815260206004820181905260248201527f4661726d696e673a20737461727420626c6f636b20616c726561647920736574604482015260640161033e565b60008111610f5b5760405162461bcd60e51b815260206004820152603260248201527f4661726d696e673a20737461727420626c6f636b206e6565647320746f20626560448201527120686967686572207468616e207a65726f2160701b606482015260840161033e565b60048190556040518181527f2ff5a4bd003b5c8c334ec018975259184173d0eabd4384b3ddbf74f447dd5a7490602001610761565b6004541580610fa0575060045443105b15610fa757565b600854610fb5576004546008555b6000610fbf6111a3565b6008549091508111610fce5750565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561101257600080fd5b505afa158015611026573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104a91906115fc565b905080611055575050565b600854600090611066908490611113565b9050600061107f6003548361118b90919063ffffffff16565b60075490915061108f90826111d7565b6007556110a86105cb846104458464e8d4a5100061118b565b600955505050600855565b6001600160a01b0381166000908152600a60205260408120600181015460095482549293926110f292916106099164e8d4a5100091610445919061118b565b90508015610dd657600282015461110990826111d7565b6002830155505050565b600061111f8284611825565b90505b92915050565b6040516001600160a01b038316602482015260448101829052610dd690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261132f565b600061111f8284611806565b600061111f82846117e4565b6000600454600014156111b65750600090565b6005546111c257504390565b43600554106111d057504390565b5060055490565b600061111f82846117cc565b6000816111f257506000611122565b6001546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561123657600080fd5b505afa15801561124a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126e91906115fc565b90508061127f576000915050611122565b8281111561128a5750815b60015461111f906001600160a01b03168583611128565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b03808516602483015283166044820152606481018290526113299085906323b872dd60e01b90608401611154565b50505050565b6000611384826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114019092919063ffffffff16565b805190915015610dd657808060200190518101906113a29190611588565b610dd65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161033e565b6060611410848460008561141a565b90505b9392505050565b60608247101561147b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161033e565b843b6114c95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161033e565b600080866001600160a01b031685876040516114e59190611615565b60006040518083038185875af1925050503d8060008114611522576040519150601f19603f3d011682016040523d82523d6000602084013e611527565b606091505b509150915061061582828660608315611541575081611413565b8251156115515782518084602001fd5b8160405162461bcd60e51b815260040161033e9190611631565b60006020828403121561157d57600080fd5b813561111f8161187e565b60006020828403121561159a57600080fd5b8151801515811461111f57600080fd5b600080604083850312156115bd57600080fd5b82356115c88161187e565b915060208301356115d88161187e565b809150509250929050565b6000602082840312156115f557600080fd5b5035919050565b60006020828403121561160e57600080fd5b5051919050565b6000825161162781846020870161183c565b9190910192915050565b602081526000825180602084015261165081604085016020870161183c565b601f01601f19169190910160400192915050565b60208082526018908201527f4661726d696e673a206e6f742079657420737461727465640000000000000000604082015260600190565b6020808252602a908201527f4661726d696e673a20737461727420626c6f636b206e6565647320746f206265604082015269081cd95d08199a5c9cdd60b21b606082015260800190565b60208082526037908201527f4661726d696e673a20746f6b656e2061646472657373206e6565647320746f2060408201527f626520646966666572656e74207468616e207a65726f21000000000000000000606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526035908201527f4661726d696e673a20796f75206e65656420746f207370656369667920616d6f604082015274756e7420686967686572207468616e207a65726f2160581b606082015260800190565b600082198211156117df576117df611868565b500190565b60008261180157634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561182057611820611868565b500290565b60008282101561183757611837611868565b500390565b60005b8381101561185757818101518382015260200161183f565b838111156113295750506000910152565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114610e7357600080fdfea2646970667358221220c1aaef1cf470ac2ca0015332e963d32fb8cd8a6aa61040c171d4479a1e64cd3464736f6c63430008060033

Verified Source Code Partial Match

Compiler: v0.8.6+commit.11564f7e EVM: istanbul Optimization: Yes (200 runs)
FarmingV1.sol 222 lines
// SPDX-License-Identifier: MIT

pragma solidity =0.8.6;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";

/**
 * @title Token Farming
 * @dev BEP20 compatible token.
 */
contract FarmingV1 is Ownable {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    struct UserInfo {
        uint256 amount;
        uint256 rewardDebt;
        uint256 pendingRewards;
    }

    struct PoolInfo {
        uint256 lastRewardBlock;
        uint256 accTokenPerShare;
    }

    IERC20 public token;
    IERC20 public lpToken;

    uint256 public tokenPerBlock;
    uint256 public startBlock;
    uint256 public closeBlock;
    uint256 public tokenClaimed;
    uint256 public tokenRewarded;

    PoolInfo public mining;
    mapping(address => UserInfo) public userInfo;

    event Deposit(address indexed user, uint256 amount);
    event Withdraw(address indexed user, uint256 amount);
    event Claim(address indexed user, uint256 amount);
    event WithdrawRemaining(address indexed user, uint256 amount);

    event RewardChanged(uint256 reward);
    event StartBlockChanged(uint256 block);
    event CloseBlockChanged(uint256 block);

    function setTokenAddress(IERC20 _token, IERC20 _lpToken) public onlyOwner {
        require(address(_token) != address(0), 'Farming: token address needs to be different than zero!');
        require(address(_lpToken) != address(0), 'Farming: token address needs to be different than zero!');
        require(address(token) == address(0) && address(lpToken) == address(0), 'Farming: tokens already set!');
        token = _token;
        lpToken = _lpToken;
        mining = PoolInfo({
            lastRewardBlock: 0,
            accTokenPerShare: 0
        });
    }

    function setTokenPerBlock(uint256 _tokenPerBlock) public onlyOwner {
        require(_tokenPerBlock > 0, "Farming: amount of tokens per block should be greater than 0!");
        updatePool(); // update pool so it recalculates reward pool before tokenPerBlock change
        tokenPerBlock = _tokenPerBlock;
        emit RewardChanged(tokenPerBlock);
    }

    function setStartBlock(uint256 _startBlock) public onlyOwner {
        require(startBlock == 0, 'Farming: start block already set');
        require(_startBlock > 0, 'Farming: start block needs to be higher than zero!');
        startBlock = _startBlock;
        emit StartBlockChanged(startBlock);
    }

    function setCloseBlock(uint256 _closeBlock) public onlyOwner {
        require(startBlock != 0, 'Farming: start block needs to be set first');
        require(closeBlock == 0, 'Farming: close block already set');
        require(_closeBlock > startBlock, 'Farming: close block needs to be higher than start one!');
        closeBlock = _closeBlock;
        emit CloseBlockChanged(closeBlock);
    }

    function withdrawRemaining() public onlyOwner {
        require(startBlock != 0, 'Farming: start block needs to be set first');
        require(closeBlock != 0, 'Farming: close block needs to be set first');
        require(block.number > closeBlock, 'Farming: withdrawal of remaining funds not ready yet');
        updatePool();

        uint256 reservedAmount = tokenRewarded.sub(tokenClaimed);
        uint256 possibleAmount = token.balanceOf(address(this));
        uint256 unlockedAmount = 0;

        if (possibleAmount > reservedAmount) {
            unlockedAmount = possibleAmount.sub(reservedAmount);
        }
        if (unlockedAmount > 0) {
            token.safeTransfer(owner(), unlockedAmount);
            emit WithdrawRemaining(owner(), unlockedAmount);
        }
    }

    function farmingTokens(address addr) external view returns (uint256) {
        UserInfo storage user = userInfo[addr];
        return user.amount;
    }

    function pendingRewards(address _user) external view returns (uint256) {
        require(startBlock > 0 && block.number >= startBlock, 'Farming: not yet started');
        UserInfo storage user = userInfo[_user];
        uint256 accTokenPerShare = mining.accTokenPerShare;
        uint256 lpSupply = lpToken.balanceOf(address(this));
        uint256 lastMintedBlock = mining.lastRewardBlock;
        if (lastMintedBlock == 0) {
            lastMintedBlock = startBlock;
        }
        uint256 lastRewardBlock = getLastRewardBlock();
        if (lastRewardBlock == 0) {
            return 0;
        }
        if (lastRewardBlock > lastMintedBlock && lpSupply != 0) {
            uint256 multiplier = lastRewardBlock.sub(lastMintedBlock);
            uint256 tokenReward = multiplier.mul(tokenPerBlock);
            accTokenPerShare = mining.accTokenPerShare.add(tokenReward.mul(1e12).div(lpSupply));
        }
        return user.amount.mul(accTokenPerShare).div(1e12).sub(user.rewardDebt).add(user.pendingRewards);
    }

    function deposit(uint256 amount) external {
        require(amount > 0, "Farming: you need to specify amount higher than zero!");
        require(startBlock > 0 && block.number >= startBlock, 'Farming: not yet started');
        UserInfo storage user = userInfo[msg.sender];
        updatePool();
        updatePendingRewards(msg.sender);
        if (amount > 0) {
            user.amount = user.amount.add(amount);
            lpToken.safeTransferFrom(address(msg.sender), address(this), amount);
        }
        user.rewardDebt = user.amount.mul(mining.accTokenPerShare).div(1e12);
        emit Deposit(msg.sender, amount);
    }

    function withdraw(uint256 amount) external {
        require(amount > 0, "Farming: you need to specify amount higher than zero!");
        require(startBlock > 0 && block.number >= startBlock, 'Farming: not yet started');
        UserInfo storage user = userInfo[msg.sender];
        require(user.amount >= amount, "Farming: you cannot withdraw more than you have!");
        updatePool();
        updatePendingRewards(msg.sender);
        if (amount > 0) {
            user.amount = user.amount.sub(amount);
            lpToken.safeTransfer(address(msg.sender), amount);
        }
        user.rewardDebt = user.amount.mul(mining.accTokenPerShare).div(1e12);
        emit Withdraw(msg.sender, amount);
    }

    function claim() external {
        require(startBlock > 0 && block.number >= startBlock, 'Farming: not yet started');
        UserInfo storage user = userInfo[msg.sender];
        updatePool();
        updatePendingRewards(msg.sender);
        if (user.pendingRewards > 0) {
            uint256 claimedAmount = transferPendingRewards(msg.sender, user.pendingRewards);
            emit Claim(msg.sender, claimedAmount);
            user.pendingRewards = user.pendingRewards.sub(claimedAmount);
            tokenClaimed = tokenClaimed.add(claimedAmount);
        }
        user.rewardDebt = user.amount.mul(mining.accTokenPerShare).div(1e12);
    }

    function updatePool() internal {
        if (startBlock == 0 || block.number < startBlock) {
            return;
        }
        if (mining.lastRewardBlock == 0) {
            mining.lastRewardBlock = startBlock;
        }
        uint256 lastBlock = getLastRewardBlock();
        if (lastBlock <= mining.lastRewardBlock) {
            return;
        }
        uint256 lpSupply = lpToken.balanceOf(address(this));
        if (lpSupply == 0) {
            return;
        }
        uint256 multiplier = lastBlock.sub(mining.lastRewardBlock);
        uint256 tokenReward = multiplier.mul(tokenPerBlock);
        tokenRewarded = tokenRewarded.add(tokenReward);
        mining.accTokenPerShare = mining.accTokenPerShare.add(tokenReward.mul(1e12).div(lpSupply));
        mining.lastRewardBlock = lastBlock;
    }

    function updatePendingRewards(address owner) internal {
        UserInfo storage user = userInfo[owner];
        uint256 pending = user.amount.mul(mining.accTokenPerShare).div(1e12).sub(user.rewardDebt);
        if (pending > 0) {
            user.pendingRewards = user.pendingRewards.add(pending);
        }
    }

    function transferPendingRewards(address to, uint256 amount) internal returns (uint256) {
        if (amount == 0) {
            return 0;
        }
        uint256 tokenBalance = token.balanceOf(address(this));
        if (tokenBalance == 0) {
            return 0;
        }
        if (tokenBalance > amount) {
            tokenBalance = amount;
        }
        token.safeTransfer(to, tokenBalance);
        return tokenBalance;
    }

    function getLastRewardBlock() internal view returns (uint256) {
        if (startBlock == 0) return 0;
        if (closeBlock == 0) return block.number;
        return (closeBlock < block.number) ? closeBlock : block.number;
    }
}
Address.sol 210 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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);
    }

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private 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 23 lines
// SPDX-License-Identifier: MIT

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 71 lines
// SPDX-License-Identifier: MIT

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() {
        _setOwner(_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 {
        _setOwner(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");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 81 lines
// SPDX-License-Identifier: MIT

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 `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);
}
SafeMath.sol 226 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
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 substraction 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;
        }
    }
}
SafeERC20.sol 98 lines
// SPDX-License-Identifier: MIT

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

closeBlock 0x8cdcbdef → uint256
farmingTokens 0x23a3a616 → uint256
lpToken 0x5fcbd285 → address
mining 0x662fac39 → uint256, uint256
owner 0x8da5cb5b → address
pendingRewards 0x31d7a262 → uint256
startBlock 0x48cd4cb1 → uint256
token 0xfc0c546a → address
tokenClaimed 0x1bd047a1 → uint256
tokenPerBlock 0x4198709a → uint256
tokenRewarded 0x3e679128 → uint256
userInfo 0x1959a002 → uint256, uint256, uint256

Write Contract 10 functions

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

claim 0x4e71d92d
No parameters
deposit 0xb6b55f25
uint256 amount
renounceOwnership 0x715018a6
No parameters
setCloseBlock 0x35c8518b
uint256 _closeBlock
setStartBlock 0xf35e4a6e
uint256 _startBlock
setTokenAddress 0xc7afe9f2
address _token
address _lpToken
setTokenPerBlock 0x411330bd
uint256 _tokenPerBlock
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x2e1a7d4d
uint256 amount
withdrawRemaining 0xee38db95
No parameters

Recent Transactions

This address has 1 on-chain transactions, but only 0.8% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →