Contract 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 11

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xb9f8d3d68fe784a30902f20476e65225e0659b781995c3aed5d4d767eaa4a9bdWithdraw1442342762023-10-26 16:13:25181 days 15 hrs ago0x386bd349b8395a73c22c3d13717c107090319ee9 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00007038 0.1
0x31b55ff102053763081de1acfeb24c934e4a4527fa489945cbfa33619ebba78bWithdraw1231542902023-08-20 6:34:46249 days 1 hr ago0x4a2e3806fb3803fe6b2a5d9a884ccef6b0fdd37a IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00003812 0.1
0xeb4dc43c7ce96d722fd307df81bfb6a71da4a69d18c23935d4416ad38b173376Get Reward1051571022023-06-26 16:30:53303 days 15 hrs ago0x6d4ed8a1599dee2655d51b245f786293e03d58f7 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00003959 0.1
0xb7fbc4d5a90d76f1ad0d0dbd345c51d059f4269810ec169ef7bb62827268cf9eWithdraw1041471612023-06-23 15:45:00306 days 16 hrs ago0x7d94283d7c15b87aed6a296c3d1c2fb334509907 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00008005 0.1
0xe0fb58d2b3cfd80a1825e94393ab55c0c85f795ada1891ee784f6e49b154f7ebGet Reward1041470002023-06-23 15:44:19306 days 16 hrs ago0x7d94283d7c15b87aed6a296c3d1c2fb334509907 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00006762 0.1
0xb11f8acf4aeb713e606cfc51b4b4f01b515abdca90925bb477bf639b657314b3Withdraw979377052023-06-05 5:38:50325 days 2 hrs ago0x94d00d5ffa4838ce422f3f1b534429d5a34bb0fa IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.000048770.1
0x3d52e870ea12c8239a19af87fa9cbfd2c8dab0b42a1aca4c9fc676499d2dfb72Withdraw787638632023-04-09 19:57:30381 days 11 hrs ago0xda4807e777e2e4a6b2ab075bdc0aef459e708cbe IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00005184 0.1
0x29eb61d0442ecb2cd43b2540a682e495e25a7ac96b23deb49f4bbd9e0b2aa1f0Withdraw787610292023-04-09 19:45:24381 days 12 hrs ago0xb8c9d38ba6924095062a92a581326a3ececf62d9 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.000049 0.1
0x1bdc0a5dc6e404e64d99c9f917c9123860cd54ded86d0a3ee3760e28c1f8f7a4Withdraw784467742023-04-08 21:42:25382 days 10 hrs ago0xac57d5547c7b05cea2837ddc99963d932ef9eb18 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.000050120.1
0x04055ab4882eb43ebc150381d839c13ce3354c5c33387e4c8a31cdc9c457b1dfWithdraw783772072023-04-08 16:46:15382 days 15 hrs ago0x83ba6c4c911cb7035720f9095b22d00d3864de7c IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.000054280.1
0xa1da5ea2d4fbad727d506a1d1fe759d9e918c026256b3f840d7b8347c8d8912fWithdraw783742762023-04-08 16:33:57382 days 15 hrs ago0x61f84b78dc52a26da4bced7f44429820902465b0 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.000052370.1
0x27cc823ca8a4221b4589ffa163bf79a04f546c8720b14f4bcde8d38bddb8ebdfWithdraw783702982023-04-08 16:17:15382 days 15 hrs ago0xe5cd0545be357d206187052b5018b342c26b819a IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.000054220.1
0x35f812f5288e78c1db74ea6f5a0e6c692e41bc5ca3f18105d4a968d3a9716777Withdraw730765952023-03-24 5:33:10398 days 2 hrs ago0x50b975b022abcbb16e7d8398e7143c6cfae66c74 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00005484 0.1
0xcf2388a45694e421764ee114288d7081851118dc3dd9580b2310213d6c1f038cGet Reward727973802023-03-23 10:58:11398 days 20 hrs ago0xdb876729586097cd6618add4deb4055a8467d7f2 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00002489 0.1
0x5b70ca3e57874b84a178e066a4e13b9e83ae0977179adf412c0b0b0215fb61e3Get Reward726116572023-03-22 22:21:28399 days 9 hrs ago0x262e32e50b33118ad6a08580971f00311687fe27 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00004829 0.1
0x957f39aad501949f18c89dd3a3e1786c6c06a21e1589428d477b4099f09d7b49Withdraw718284372023-03-20 16:19:56401 days 15 hrs ago0x77bfecac1d1eb046d8a75c1d4cdabe267180646c IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.0000572 0.1
0x34c2e9e3795f20bd74f81a02a2ac6f29199aa541b8a1b0fd597f6c234f7a8bf7User_checkpoint716315802023-03-20 2:43:23402 days 5 hrs ago0x947b7742c403f20e5faccdac5e092c943e7d0277 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.000059730.1
0xef81964ccfb65fe9d8888cca418349c900e221b3cb89cea8fcc9d9b449630684Get Reward712876372023-03-19 2:40:10403 days 5 hrs ago0x0017dfe08bcc0dc9a323ca5d4831e371534e9320 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00005976 0.1
0x4652e197a7a66b9f8607e6113630af4d6c347ebdd5755c3e882fa35dc005c495Withdraw700841582023-03-15 13:24:36406 days 18 hrs ago0xc55ce3cb45ea6e362f773f0fea7564dad0792b7a IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.000114360.1
0xe436b0b66bb48401477fec5ef4f02290ac63b79cbb298ef2f6e89fb7f216c223Withdraw694800112023-03-13 15:45:56408 days 16 hrs ago0x20f9468228a4b69b84b01e621363f58c93ad0823 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00016759 0.1
0xbea5890f8f450cb347d68eda03609ceabfab7d5e9e825539a45bd2b85f603e70Get Reward692689702023-03-12 23:21:12409 days 8 hrs ago0x11a5cc49d4c76ef6cb7e6f07e0a92d95799c908e IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00010829 0.1
0xd62be35a06af386a9e9e4219c3eecb92f0797922c4e4bb7ea46d1b809befa2e4Withdraw689286952023-03-11 19:18:01410 days 12 hrs ago0x96493e053c2865bbc25ce4ef5f99a9221e302280 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00011394 0.1
0x0301b64cb564bce7e65ee1c6c2ce325985bddf75a8a0eadb71b980d808772fb0Withdraw682348062023-03-09 14:20:31412 days 17 hrs ago0xe16dbb62bf2c69c885078db0ec071da5307cc87c IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00011421 0.1
0xc41ba42004610e4562ff70684bf98dbee5e0f4758839f71761d50b23ca6f1de5Withdraw653675342023-02-28 9:18:25421 days 22 hrs ago0xd06f95a78553fd94b05281aa97e8afd87af48cef IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00008121 0.1
0x8e90fc0afc14219374cfefdf37c550705b46c3346ea1327b04453d5d3e928b9bWithdraw591611992023-02-08 16:44:22441 days 15 hrs ago0x002ee33092457900515a4249e3ec1cd2b2dc8c32 IN  0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH0.00012049 0.1
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x32299dfcd73dbdaceb033d898abbd81fe2e0d138f414d0c23eb2d793ae61b6e6720114842023-03-21 5:09:55401 days 2 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xb952a807345991bd529fdded05009f5e80fe8f450 ETH
0x32299dfcd73dbdaceb033d898abbd81fe2e0d138f414d0c23eb2d793ae61b6e6720114842023-03-21 5:09:55401 days 2 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x11cdb42b0eb46d95f990bedd4695a6e3fa0349780 ETH
0x32299dfcd73dbdaceb033d898abbd81fe2e0d138f414d0c23eb2d793ae61b6e6720114842023-03-21 5:09:55401 days 2 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xf403c135812408bfbe8713b5a23a04b3d48aae310 ETH
0x32299dfcd73dbdaceb033d898abbd81fe2e0d138f414d0c23eb2d793ae61b6e6720114842023-03-21 5:09:55401 days 2 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x11cdb42b0eb46d95f990bedd4695a6e3fa0349780 ETH
0x32299dfcd73dbdaceb033d898abbd81fe2e0d138f414d0c23eb2d793ae61b6e6720114842023-03-21 5:09:55401 days 2 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xf403c135812408bfbe8713b5a23a04b3d48aae310 ETH
0x32299dfcd73dbdaceb033d898abbd81fe2e0d138f414d0c23eb2d793ae61b6e6720114842023-03-21 5:09:55401 days 2 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x3b2d30734491ad77880d31e8afe2a4d8ac135a9c0 ETH
0x32299dfcd73dbdaceb033d898abbd81fe2e0d138f414d0c23eb2d793ae61b6e6720114842023-03-21 5:09:55401 days 2 hrs ago 0x5b5cfe992adac0c9d48e05854b2d91c73a003858 0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH
0x07e68b1b06bbc6705b4cb4b64373565a9f648d808b498b89749dc54e4ed75e17718286632023-03-20 16:20:53401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xb952a807345991bd529fdded05009f5e80fe8f450 ETH
0x07e68b1b06bbc6705b4cb4b64373565a9f648d808b498b89749dc54e4ed75e17718286632023-03-20 16:20:53401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x11cdb42b0eb46d95f990bedd4695a6e3fa0349780 ETH
0x07e68b1b06bbc6705b4cb4b64373565a9f648d808b498b89749dc54e4ed75e17718286632023-03-20 16:20:53401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xf403c135812408bfbe8713b5a23a04b3d48aae310 ETH
0x07e68b1b06bbc6705b4cb4b64373565a9f648d808b498b89749dc54e4ed75e17718286632023-03-20 16:20:53401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x11cdb42b0eb46d95f990bedd4695a6e3fa0349780 ETH
0x07e68b1b06bbc6705b4cb4b64373565a9f648d808b498b89749dc54e4ed75e17718286632023-03-20 16:20:53401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xf403c135812408bfbe8713b5a23a04b3d48aae310 ETH
0x07e68b1b06bbc6705b4cb4b64373565a9f648d808b498b89749dc54e4ed75e17718286632023-03-20 16:20:53401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x3b2d30734491ad77880d31e8afe2a4d8ac135a9c0 ETH
0x07e68b1b06bbc6705b4cb4b64373565a9f648d808b498b89749dc54e4ed75e17718286632023-03-20 16:20:53401 days 15 hrs ago 0x5b5cfe992adac0c9d48e05854b2d91c73a003858 0xc501491b0e4a73b2efbac564a412a927d2fc83dd0 ETH
0x957f39aad501949f18c89dd3a3e1786c6c06a21e1589428d477b4099f09d7b49718284372023-03-20 16:19:56401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xf403c135812408bfbe8713b5a23a04b3d48aae310 ETH
0x957f39aad501949f18c89dd3a3e1786c6c06a21e1589428d477b4099f09d7b49718284372023-03-20 16:19:56401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xb952a807345991bd529fdded05009f5e80fe8f450 ETH
0x957f39aad501949f18c89dd3a3e1786c6c06a21e1589428d477b4099f09d7b49718284372023-03-20 16:19:56401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xf403c135812408bfbe8713b5a23a04b3d48aae310 ETH
0x957f39aad501949f18c89dd3a3e1786c6c06a21e1589428d477b4099f09d7b49718284372023-03-20 16:19:56401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x11cdb42b0eb46d95f990bedd4695a6e3fa0349780 ETH
0x957f39aad501949f18c89dd3a3e1786c6c06a21e1589428d477b4099f09d7b49718284372023-03-20 16:19:56401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xf403c135812408bfbe8713b5a23a04b3d48aae310 ETH
0x957f39aad501949f18c89dd3a3e1786c6c06a21e1589428d477b4099f09d7b49718284372023-03-20 16:19:56401 days 15 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x3b2d30734491ad77880d31e8afe2a4d8ac135a9c0 ETH
0x34c2e9e3795f20bd74f81a02a2ac6f29199aa541b8a1b0fd597f6c234f7a8bf7716315802023-03-20 2:43:23402 days 5 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xb952a807345991bd529fdded05009f5e80fe8f450 ETH
0x34c2e9e3795f20bd74f81a02a2ac6f29199aa541b8a1b0fd597f6c234f7a8bf7716315802023-03-20 2:43:23402 days 5 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xf403c135812408bfbe8713b5a23a04b3d48aae310 ETH
0x34c2e9e3795f20bd74f81a02a2ac6f29199aa541b8a1b0fd597f6c234f7a8bf7716315802023-03-20 2:43:23402 days 5 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x11cdb42b0eb46d95f990bedd4695a6e3fa0349780 ETH
0x34c2e9e3795f20bd74f81a02a2ac6f29199aa541b8a1b0fd597f6c234f7a8bf7716315802023-03-20 2:43:23402 days 5 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0xedccb35798fae4925718a43cc608ae136208aa8d0 ETH
0x34c2e9e3795f20bd74f81a02a2ac6f29199aa541b8a1b0fd597f6c234f7a8bf7716315802023-03-20 2:43:23402 days 5 hrs ago 0xc501491b0e4a73b2efbac564a412a927d2fc83dd 0x95285ea6ff14f80a2fd3989a6bab993bd6b5fa130 ETH
[ Download CSV Export 
Loading

Minimal Proxy Contract for 0x3b2d30734491ad77880d31e8afe2a4d8ac135a9c

Contract Name:
ConvexRewardPool

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license
Decompile ByteCode

Contract Source Code (Solidity)

Similar Contracts
/**
 *Submitted for verification at Arbiscan.io on 2022-11-16
*/

// File: contracts\interfaces\IGauge.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;

interface IGauge {
    function deposit(uint256) external;
    function balanceOf(address) external view returns (uint256);
    function working_balances(address) external view returns (uint256);
    function totalSupply() external view returns (uint256);
    function working_supply() external view returns (uint256);
    function withdraw(uint256) external;
    function claim_rewards() external;
    function claim_rewards(address _account) external;
    function lp_token() external view returns(address);
    function set_rewards_receiver(address _receiver) external;
    function reward_count() external view returns(uint256);
    function reward_tokens(uint256 _rid) external view returns(address _rewardToken);
    function reward_data(address _reward) external view returns(address distributor, uint256 period_finish, uint256 rate, uint256 last_update, uint256 integral);
    function claimed_reward(address _account, address _token) external view returns(uint256);
    function claimable_reward(address _account, address _token) external view returns(uint256);
    function claimable_tokens(address _account) external returns(uint256);
    function inflation_rate(uint256 _week) external view returns(uint256);
    function period() external view returns(uint256);
    function period_timestamp(uint256 _period) external view returns(uint256);
    // function claimable_reward_write(address _account, address _token) external returns(uint256);
    function add_reward(address _reward, address _distributor) external;
    function set_reward_distributor(address _reward, address _distributor) external;
    function deposit_reward_token(address _reward, uint256 _amount) external;
    function manager() external view returns(address _manager);
}

// File: contracts\interfaces\IBooster.sol

pragma solidity 0.8.10;

interface IBooster {
   function isShutdown() external view returns(bool);
   function withdrawTo(uint256,uint256,address) external;
   function claimCrv(uint256 _pid, address _gauge) external;
   function setGaugeRedirect(uint256 _pid) external returns(bool);
   function owner() external view returns(address);
   function rewardManager() external view returns(address);
   function feeDeposit() external view returns(address);
   function factoryCrv(address _factory) external view returns(address _crv);
   function calculatePlatformFees(uint256 _amount) external view returns(uint256);
   function addPool(address _lptoken, address _gauge, address _factory) external returns(bool);
   function shutdownPool(uint256 _pid) external returns(bool);
   function poolInfo(uint256) external view returns(address _lptoken, address _gauge, address _rewards,bool _shutdown, address _factory);
   function poolLength() external view returns (uint256);
   function activeMap(address) external view returns(bool);
   function fees() external view returns(uint256);
   function setPoolManager(address _poolM) external;
}

// File: contracts\interfaces\IRewardHook.sol

pragma solidity 0.8.10;

interface IRewardHook {
    function onRewardClaim() external;
    function rewardManager() external view returns(address);
    function poolRewardLength(address _pool) external view returns(uint256);
    // function poolRewardList(address _pool) external view returns(address[] memory _rewardContractList);
    function poolRewardList(address _pool, uint256 _index) external view returns(address _rewardContract);
    function clearPoolRewardList(address _pool) external;
    function addPoolReward(address _pool, address _rewardContract) external;
}

// File: contracts\interfaces\IRewardManager.sol

pragma solidity 0.8.10;

interface IRewardManager {
    function rewardHook() external view returns(address);
    function cvx() external view returns(address);
}

// File: @openzeppelin\contracts\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 `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);
}

// File: @openzeppelin\contracts\token\ERC20\extensions\IERC20Metadata.sol

pragma solidity ^0.8.0;

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

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

// File: @openzeppelin\contracts\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;
    }
}

// File: @openzeppelin\contracts\token\ERC20\ERC20.sol


pragma solidity ^0.8.0;



/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

// File: @openzeppelin\contracts\utils\Address.sol

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);
    }

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

// File: @openzeppelin\contracts\token\ERC20\utils\SafeERC20.sol


pragma solidity ^0.8.0;


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

// File: @openzeppelin\contracts\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 make 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;
    }
}

// File: contracts\ConvexRewardPool.sol

pragma solidity 0.8.10;

//claim and distribute gauge rewards without need of harvesters
//more gas cost but no delayed rewards
//
//Reward distro based on Curve.fi's gauge wrapper implementations at https://github.com/curvefi/curve-dao-contracts/tree/master/contracts/gauges/wrappers
contract ConvexRewardPool is ERC20, ReentrancyGuard{
    using SafeERC20 for IERC20;

    struct EarnedData {
        address token;
        uint256 amount;
    }

    struct RewardType {
        address reward_token;
        uint128 reward_integral;
        uint128 reward_remaining;
    }

    //pool and system info
    address public curveGauge;
    address public convexStaker;
    address public convexBooster;
    uint256 public convexPoolId;


    //rewards
    RewardType[] public rewards;
    mapping(address => mapping(address => uint256)) public reward_integral_for;// token -> account -> integral
    mapping(address => mapping(address => uint256)) public claimable_reward;//token -> account -> claimable
    mapping(address => bool) public rewardMap;
    address public rewardHook;
    address public crv;

    //management
    string internal _tokenname;
    string internal _tokensymbol;

    //events
    event Staked(address indexed _user, uint256 _amount);
    event Withdrawn(address indexed _user, uint256 _amount);
    event RewardPaid(address indexed _user, address indexed _rewardToken, address indexed _receiver, uint256 _rewardAmount);
    event RewardAdded(address indexed _rewardToken);

    constructor() ERC20(
            "TokenizedConvexPosition",
            "cvxToken"
        ){
    }

    function initialize(
        address _crv,
        address _curveGauge,
        address _convexStaker,
        address _convexBooster,
        address _lptoken,
        uint256 _poolId)
    external {
        require(bytes(_tokenname).length == 0, "already init");

        crv = _crv;
        curveGauge = _curveGauge;
        convexStaker = _convexStaker;
        convexBooster = _convexBooster;
        convexPoolId = _poolId;

        _tokenname = string(abi.encodePacked(ERC20(_lptoken).name()," Convex Deposit"));
        _tokensymbol = string(abi.encodePacked("cvx", ERC20(_lptoken).symbol()));

        //always add CRV in first slot
        _insertRewardToken(_crv);

        //add CVX in second slot
        address rmanager = IBooster(convexBooster).rewardManager();
        _insertRewardToken(IRewardManager(rmanager).cvx());

        //set default hook
        rewardHook = IRewardManager(rmanager).rewardHook();
    }

    function name() public view override returns (string memory) {
        return _tokenname;
    }

    function symbol() public view override returns (string memory) {
        return _tokensymbol;
    }

    function decimals() public pure override returns (uint8) {
        return 18;
    }

    //check curve gauge for any reward tokens
    function updateRewardList() public {

        //max rewards 8, need to check if anything new has been added
        for (uint256 i = 0; i < 8; i++) {
            address rewardToken = IGauge(curveGauge).reward_tokens(i);
            if(rewardToken == address(0)) break;

            //add to reward list if new
            _insertRewardToken(rewardToken);
        }
    }

    //register an extra reward token to be handled
    // (any new incentive that is not directly on curve gauges)
    function addExtraReward(address _token) external{
        //reward manager can set extra rewards
        require(IBooster(convexBooster).rewardManager() == msg.sender, "!owner");
        
        //add to reward list
        _insertRewardToken(_token);
    }

    //insert a new reward, ignore if already registered or invalid
    function _insertRewardToken(address _token) internal{
        if(_token == address(this) || _token == address(0)){
            //dont allow reward tracking of the staking token or invalid address
            return;
        }
        //add to reward list if new
        if(!rewardMap[_token]){
            RewardType storage r = rewards.push();
            r.reward_token = _token;
            rewardMap[_token] = true;

            //workaround: transfer 0 to self so that earned() reports correctly
            //with new tokens
            try IERC20(_token).transfer(address(this), 0){}catch{}

            emit RewardAdded(_token);
        }
    }

    //set a reward hook that calls an outside contract to pull external rewards
    function setRewardHook(address _hook) external{
        //reward manager can set reward hook
        require(IBooster(convexBooster).rewardManager() == msg.sender, "!owner");
        rewardHook = _hook;
    }

    //update and claim rewards from all locations
    function updateRewardsAndClaim() internal{
        (,,,bool _shutdown,) = IBooster(convexBooster).poolInfo(convexPoolId);

        if(!_shutdown){
            //make sure reward list is up to date
            updateRewardList();

            //claim crv
            IBooster(convexBooster).claimCrv(convexPoolId, curveGauge);

            //claim rewards from gauge
            IGauge(curveGauge).claim_rewards(convexStaker);

            //hook for external reward pulls
            if(rewardHook != address(0)){
                try IRewardHook(rewardHook).onRewardClaim(){
                }catch{}
            }
        }
    }

    //get reward count
    function rewardLength() external view returns(uint256) {
        return rewards.length;
    }

    //calculate and record an account's earnings of the given reward.  if _claimTo is given it will also claim.
    function _calcRewardIntegral(uint256 _index, address _account, address _claimTo) internal{
        RewardType storage reward = rewards[_index];

        //get difference in balance and remaining rewards
        //getReward is unguarded so we use reward_remaining to keep track of how much was actually claimed since last checkpoint
        uint256 bal = IERC20(reward.reward_token).balanceOf(address(this));

        //if reward token is crv (always slot 0), need to calculate and send fees
        if(_index == 0){
            uint256 diff = bal - reward.reward_remaining;
            uint256 fees = IBooster(convexBooster).calculatePlatformFees(diff);
            if(fees > 0){
                //send to fee deposit to process later
                IERC20(crv).safeTransfer( IBooster(convexBooster).feeDeposit() , fees);
            }
            //remove what was sent as fees
            bal -= fees;
        }

        //update the global integral
        if (totalSupply() > 0 && (bal - reward.reward_remaining) > 0) {
            reward.reward_integral = reward.reward_integral + uint128( (bal - reward.reward_remaining) * 1e20 / totalSupply());
        }

        //update user integrals
        uint userI = reward_integral_for[reward.reward_token][_account];
        if(_claimTo != address(0) || userI < reward.reward_integral){
            //_claimTo address non-zero means its a claim 
            if(_claimTo != address(0)){
                uint256 receiveable = claimable_reward[reward.reward_token][_account] + (balanceOf(_account) * uint256(reward.reward_integral - userI) / 1e20);
                if(receiveable > 0){
                    claimable_reward[reward.reward_token][_account] = 0;
                    IERC20(reward.reward_token).safeTransfer(_claimTo, receiveable);
                    emit RewardPaid(_account, reward.reward_token, _claimTo, receiveable);
                    //remove what was claimed from balance
                    bal -= receiveable;
                }
            }else{
                claimable_reward[reward.reward_token][_account] = claimable_reward[reward.reward_token][_account] + ( balanceOf(_account) * uint256(reward.reward_integral - userI) / 1e20);
            }
            reward_integral_for[reward.reward_token][_account] = reward.reward_integral;
        }


        //update remaining reward so that next claim can properly calculate the balance change
        if(bal != reward.reward_remaining){
            reward.reward_remaining = uint128(bal);
        }
    }

    //checkpoint without claiming
    function _checkpoint(address _account) internal {
        //checkpoint without claiming by passing address(0)
        _checkpoint(_account, address(0));
    }

    //checkpoint with claim
    function _checkpoint(address _account, address _claimTo) internal {
        //update rewards and claim
        updateRewardsAndClaim();

        //calc reward integrals
        uint256 rewardCount = rewards.length;
        for(uint256 i = 0; i < rewardCount; i++){
           _calcRewardIntegral(i,_account,_claimTo);
        }
    }

    //manually checkpoint a user account
    function user_checkpoint(address _account) external nonReentrant returns(bool) {
        _checkpoint(_account);
        return true;
    }

    //get earned token info
    //Note: The curve gauge function "claimable_tokens" is a write function and thus this is not by default a view
    //change ABI to view to use this off chain
    function earned(address _account) external returns(EarnedData[] memory claimable) {
        
        //because this is a state mutative function
        //we can simplify the earned() logic of all rewards (internal and external)
        //and allow this contract to be agnostic to outside reward contract design
        //by just claiming everything and checking token balances
        updateRewardsAndClaim();

        uint256 rewardCount = rewards.length;
        claimable = new EarnedData[](rewardCount);

        for (uint256 i = 0; i < rewardCount; i++) {
            RewardType storage reward = rewards[i];

            //change in reward is current balance - remaining reward + earned
            uint256 bal = IERC20(reward.reward_token).balanceOf(address(this));
            uint256 d_reward = bal - reward.reward_remaining;

            // crv is always slot 0
            if(i == 0){
                //check fees
                uint256 fees = IBooster(convexBooster).calculatePlatformFees(d_reward);
                if(fees > 0){
                    d_reward -= fees;
                }
            }

            //calc new global integral
            uint256 I = reward.reward_integral;
            if (totalSupply() > 0) {
                I = I + (d_reward * 1e20 / totalSupply());
            }

            //user claimable amount = previous recorded claimable + new user integral
            uint256 newlyClaimable = balanceOf(_account) * (I - reward_integral_for[reward.reward_token][_account]) / 1e20;
            claimable[i].amount = claimable_reward[reward.reward_token][_account] + newlyClaimable;
            claimable[i].token = reward.reward_token;
        }
    }

    //claim reward for given account (unguarded)
    function getReward(address _account) external nonReentrant {
        //claim directly in checkpoint logic to save a bit of gas
        _checkpoint(_account, _account);
    }

    //claim reward for given account and forward (guarded)
    function getReward(address _account, address _forwardTo) external nonReentrant {
        //in order to forward, must be called by the account itself
        require(msg.sender == _account, "!self");
        //use _forwardTo address instead of _account
        _checkpoint(_account,_forwardTo);
    }


    //deposit/stake on behalf of another account
    function stakeFor(address _for, uint256 _amount) external nonReentrant returns(bool){
        require(msg.sender == convexBooster, "!auth");
        require(_amount > 0, 'RewardPool : Cannot stake 0');

        //change state
        //assign to _for
        //Mint will checkpoint so safe to not call
        _mint(_for, _amount);

        emit Staked(_for, _amount);
        
        return true;
    }


    //withdraw balance and unwrap to the underlying lp token
    // function withdrawAndUnwrap(uint256 _amount, bool _claim) public nonReentrant returns(bool){
    function withdraw(uint256 _amount, bool _claim) public nonReentrant returns(bool){

        //checkpoint first if claiming, or burn will call checkpoint anyway
        if(_claim){
            //checkpoint with claim flag
            _checkpoint(msg.sender, msg.sender);
        }

        //change state
        //burn will also call checkpoint
        _burn(msg.sender, _amount);

        //tell booster to withdraw underlying lp tokens directly to user
        IBooster(convexBooster).withdrawTo(convexPoolId,_amount,msg.sender);

        emit Withdrawn(msg.sender, _amount);

        return true;
    }

    //withdraw full balance
    function withdrawAll(bool claim) external{
        withdraw(balanceOf(msg.sender),claim);
    }

    function _beforeTokenTransfer(address _from, address _to, uint256 _amount) internal override {
        if(_from != address(0)){
            _checkpoint(_from);
        }
        if(_to != address(0)){
            _checkpoint(_to);
        }
    }
}

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_rewardToken","type":"address"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"address","name":"_rewardToken","type":"address"},{"indexed":true,"internalType":"address","name":"_receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"_rewardAmount","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"addExtraReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"claimable_reward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"convexBooster","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"convexPoolId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"convexStaker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"crv","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveGauge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"earned","outputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ConvexRewardPool.EarnedData[]","name":"claimable","type":"tuple[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_forwardTo","type":"address"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_crv","type":"address"},{"internalType":"address","name":"_curveGauge","type":"address"},{"internalType":"address","name":"_convexStaker","type":"address"},{"internalType":"address","name":"_convexBooster","type":"address"},{"internalType":"address","name":"_lptoken","type":"address"},{"internalType":"uint256","name":"_poolId","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardHook","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewardMap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"reward_integral_for","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewards","outputs":[{"internalType":"address","name":"reward_token","type":"address"},{"internalType":"uint128","name":"reward_integral","type":"uint128"},{"internalType":"uint128","name":"reward_remaining","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_hook","type":"address"}],"name":"setRewardHook","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_for","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"stakeFor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateRewardList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"user_checkpoint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_claim","type":"bool"}],"name":"withdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"claim","type":"bool"}],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.