Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0xbeC45A9506d191F9705C77dccd291c2609d18e4c
Balance 0 ETH
Nonce 1
Code Size 7894 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7894 bytes
0x608060405260043610610147575f3560e01c8063a69f4935116100b3578063dcc3e06e1161006d578063dcc3e06e1461036f578063e30c397814610383578063f1068454146103a0578063f2fde38b146103b4578063f3fef3a3146103d3578063fc0c546a146103f2575f80fd5b8063a69f4935146102c7578063b61d27f6146102db578063ba2ee65c146102fc578063bf6f5b0014610310578063c0c53b8b1461032f578063c4f59f9b1461034e575f80fd5b80634d567e62116101045780634d567e6214610207578063570ca735146102325780637108576e14610269578063715018a61461027d57806379ba5097146102915780638da5cb5b146102a5575f80fd5b80630e5c011e1461014b5780631902fe6f1461016c57806322f3e2d4146101935780633edd1128146101b557806341c0e1b5146101d45780634350df3d146101e8575b5f80fd5b348015610156575f80fd5b5061016a610165366004611b91565b610411565b005b348015610177575f80fd5b50610180610733565b6040519081526020015b60405180910390f35b34801561019e575f80fd5b50600554600116604051901515815260200161018a565b3480156101c0575f80fd5b5061016a6101cf366004611bc0565b61074a565b3480156101df575f80fd5b5061016a6107b1565b3480156101f3575f80fd5b5061016a610202366004611bff565b61080b565b348015610212575f80fd5b50610180610221366004611b91565b60046020525f908152604090205481565b34801561023d575f80fd5b50600254610251906001600160a01b031681565b6040516001600160a01b03909116815260200161018a565b348015610274575f80fd5b5061016a6108b1565b348015610288575f80fd5b5061016a610cd0565b34801561029c575f80fd5b5061016a610ce3565b3480156102b0575f80fd5b505f546201000090046001600160a01b0316610251565b3480156102d2575f80fd5b50610180610d5f565b6102ee6102e9366004611c22565b610d71565b60405161018a929190611cf1565b348015610307575f80fd5b5061016a610de8565b34801561031b575f80fd5b5061016a61032a366004611bff565b610e69565b34801561033a575f80fd5b5061016a610349366004611d0b565b610f06565b348015610359575f80fd5b506103626110dd565b60405161018a9190611d48565b34801561037a575f80fd5b5061025161113d565b34801561038e575f80fd5b506001546001600160a01b0316610251565b3480156103ab575f80fd5b5061018061114f565b3480156103bf575f80fd5b5061016a6103ce366004611b91565b611161565b3480156103de575f80fd5b5061016a6103ed366004611d94565b6111d8565b3480156103fd575f80fd5b50600354610251906001600160a01b031681565b6003546040516370a0823160e01b81523060048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa158015610457573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061047b9190611dbe565b905080156105145773f403c135812408bfbe8713b5a23a04b3d48aae316343a0d0666104a561114f565b6040516001600160e01b031960e084901b168152600481019190915260248101849052600160448201526064016020604051808303815f875af11580156104ee573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105129190611dd5565b505b61051c61113d565b6001600160a01b0316633d18b9126040518163ffffffff1660e01b81526004016020604051808303815f875af1158015610558573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061057c9190611dd5565b505f610586610d5f565b90505f610591610733565b603454600254919250906001600160a01b03165f5b8281101561072a575f603482815481106105c2576105c2611df0565b5f918252602080832091909101546001600160a01b031680835260049182905260408084205490516370a0823160e01b815230938101939093529093509083906370a0823190602401602060405180830381865afa158015610626573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061064a9190611dbe565b6106549190611e18565b9050805f0361066457505061071a565b633b9aca00868202048015610691576001600160a01b0383165f9081526004602052604090208054820190555b633b9aca008883020480156106b4576106b46001600160a01b0385168c8361123d565b604051637db4e28f60e01b81526001600160a01b0385811660048301528385038390036024830152871690637db4e28f906044015f604051808303815f87803b1580156106ff575f80fd5b505af1158015610711573d5f803e3d5ffd5b50505050505050505b61072381611e31565b90506105a6565b50505050505050565b6005545f90610745906001601e6112a0565b905090565b6002546001600160a01b0316336001600160a01b03161461077e5760405163683b4ec760e11b815260040160405180910390fd5b6005546001166107a157604051633d24012960e11b815260040160405180910390fd5b6107ac8383836112ae565b505050565b6107b9611332565b6005546001166107dc57604051633d24012960e11b815260040160405180910390fd5b600554600119166005555f6107ef611392565b600254909150610808906001600160a01b031682611473565b50565b610813611332565b631dcd65008163ffffffff16111561083e57604051639a451f3d60e01b815260040160405180910390fd5b6005545f61084f826001601e6112a0565b905061086a8263ffffffff80861690600190601e9061157f16565b6005556040805182815263ffffffff851660208201527f31847b566e19cccc4a2cce6544d2e8c1a91362c7a2a4cf6f1ec84dcd0a494b1791015b60405180910390a1505050565b6108bc60345f611b4f565b5f6108c561113d565b90506034816001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610905573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109299190611e49565b81546001810183555f928352602080842090910180546001600160a01b0319166001600160a01b039384161790556040805163355688fd60e21b815290519285169263d55a23f4926004808401939192918290030181865afa158015610991573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109b59190611dbe565b90505f805b82811015610bf657604051632061aa2360e11b8152600481018290525f906001600160a01b038616906340c3544690602401602060405180830381865afa158015610a07573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a2b9190611e49565b90505f816001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a6a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a8e9190611e49565b9050806001600160a01b031663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015610aea575060408051601f3d908101601f19168201909252610ae791810190611e49565b60015b610b6757734e3fbd56cd56c3e72c1403e103b45db9da5b9d2a196001600160a01b03821601610b1857600193505b603480546001810182555f919091527f46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c10180546001600160a01b0319166001600160a01b038316179055610be1565b734e3fbd56cd56c3e72c1403e103b45db9da5b9d2a196001600160a01b03821601610b9157600194505b603480546001810182555f919091527f46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c10180546001600160a01b0319166001600160a01b03929092169190911790555b50508080610bee90611e31565b9150506109ba565b5080610c5257603480546001810182555f919091527f46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c10180546001600160a01b031916734e3fbd56cd56c3e72c1403e103b45db9da5b9d2b1790555b60345491505f5b82811015610cca575f60348281548110610c7557610c75611df0565b5f9182526020822001546002546001600160a01b039182169350610c9e92849290911690611593565b600254610cb9906001600160a01b0383811691165f19611593565b50610cc381611e31565b9050610c59565b50505050565b610cd8611332565b610ce15f6116a6565b565b60015433906001600160a01b03168114610d565760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b60648201526084015b60405180910390fd5b610808816116a6565b6005545f9061074590601f601e6112a0565b5f6060610d7c611332565b5f80876001600160a01b0316878787604051610d99929190611e64565b5f6040518083038185875af1925050503d805f8114610dd3576040519150601f19603f3d011682016040523d82523d5f602084013e610dd8565b606091505b5090999098509650505050505050565b6003546040516370a0823160e01b81523060048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa158015610e2e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e529190611dbe565b9050805f03610e5e5750565b6108085f825f6116bf565b610e71611332565b6305f5e1008163ffffffff161115610e9c57604051633421169f60e21b815260040160405180910390fd5b6005545f610ead82601f601e6112a0565b9050610ec88263ffffffff80861690601f90601e9061157f16565b6005556040805182815263ffffffff851660208201527f2c3b971a5011a057ee9b96ea2aa1504d93d268e5c9cfdee7581d31435b24435e91016108a4565b5f54610100900460ff1615808015610f2457505f54600160ff909116105b80610f3d5750303b158015610f3d57505f5460ff166001145b610fa05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610d4d565b5f805460ff191660011790558015610fc1575f805461ff0019166101001790555b610fcb84846117ea565b5f826001600160a01b031663f10684546040518163ffffffff1660e01b8152600401602060405180830381865afa158015611008573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061102c9190611dbe565b6005549091506110408183603d601061157f565b9050611059816001600160a01b038616604d60a061157f565b600581905590506110896001600160a01b03861673f403c135812408bfbe8713b5a23a04b3d48aae315f19611593565b6110916108b1565b50508015610cca575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050565b6060603480548060200260200160405190810160405280929190818152602001828054801561113357602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311611115575b5050505050905090565b6005545f9061074590604d60a06112a0565b6005545f9061074590603d60106112a0565b611169611332565b600180546001600160a01b0383166001600160a01b031990911681179091556111a05f546001600160a01b03620100009091041690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6002546001600160a01b0316336001600160a01b03161461120c5760405163683b4ec760e11b815260040160405180910390fd5b60055460011661122f57604051633d24012960e11b815260040160405180910390fd5b6112398282611473565b5050565b6040516001600160a01b0383166024820152604481018290526107ac90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611898565b6001901b5f190191901c1690565b80156107ac576003546040516370a0823160e01b81523060048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa1580156112fa573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061131e9190611dbe565b90508015610cca57610cca848260016116bf565b5f546001600160a01b0362010000909104163314610ce15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610d4d565b5f61139b61113d565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156113df573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114039190611dbe565b6003546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611449573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061146d9190611dbe565b01905090565b8015611239576003546040516370a0823160e01b81523060048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa1580156114bf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114e39190611dbe565b905080821115611568576114f561113d565b604051636197390160e11b815282840360048201525f60248201526001600160a01b03919091169063c32e7202906044016020604051808303815f875af1158015611542573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115669190611dd5565b505b6003546107ac906001600160a01b0316848461123d565b6001901b5f1901811b1992909216911b1790565b80158061160b5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156115e5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116099190611dbe565b155b6116765760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610d4d565b6040516001600160a01b0383166024820152604481018290526107ac90849063095ea7b360e01b90606401611269565b600180546001600160a01b03191690556108088161196b565b73f403c135812408bfbe8713b5a23a04b3d48aae316343a0d0666116e161114f565b6040516001600160e01b031960e084901b168152600481019190915260248101859052600160448201526064016020604051808303815f875af115801561172a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061174e9190611dd5565b5080156107ac576034545f5b818110156117e3575f6034828154811061177657611776611df0565b5f9182526020808320909101546001600160a01b0316808352600490915260409091205490915080156117d0576117b76001600160a01b038316888361123d565b6001600160a01b0382165f908152600460205260408120555b5050806117dc90611e31565b905061175a565b5050505050565b5f54610100900460ff166118545760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610d4d565b61185d336116a6565b600280546001600160a01b039384166001600160a01b0319918216179091556003805492909316911617905560058054600119166001179055565b5f6118ec826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166119c59092919063ffffffff16565b905080515f148061190c57508080602001905181019061190c9190611dd5565b6107ac5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610d4d565b5f80546001600160a01b038381166201000081810262010000600160b01b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b60606119d384845f856119db565b949350505050565b606082471015611a3c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610d4d565b5f80866001600160a01b03168587604051611a579190611e73565b5f6040518083038185875af1925050503d805f8114611a91576040519150601f19603f3d011682016040523d82523d5f602084013e611a96565b606091505b5091509150611aa787838387611ab2565b979650505050505050565b60608315611b205782515f03611b19576001600160a01b0385163b611b195760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610d4d565b50816119d3565b6119d38383815115611b355781518083602001fd5b8060405162461bcd60e51b8152600401610d4d9190611e8e565b5080545f8255905f5260205f209081019061080891905b80821115611b79575f8155600101611b66565b5090565b6001600160a01b0381168114610808575f80fd5b5f60208284031215611ba1575f80fd5b8135611bac81611b7d565b9392505050565b8015158114610808575f80fd5b5f805f60608486031215611bd2575f80fd5b8335611bdd81611b7d565b9250602084013591506040840135611bf481611bb3565b809150509250925092565b5f60208284031215611c0f575f80fd5b813563ffffffff81168114611bac575f80fd5b5f805f8060608587031215611c35575f80fd5b8435611c4081611b7d565b935060208501359250604085013567ffffffffffffffff80821115611c63575f80fd5b818701915087601f830112611c76575f80fd5b813581811115611c84575f80fd5b886020828501011115611c95575f80fd5b95989497505060200194505050565b5f5b83811015611cbe578181015183820152602001611ca6565b50505f910152565b5f8151808452611cdd816020860160208601611ca4565b601f01601f19169290920160200192915050565b8215158152604060208201525f6119d36040830184611cc6565b5f805f60608486031215611d1d575f80fd5b8335611d2881611b7d565b92506020840135611d3881611b7d565b91506040840135611bf481611b7d565b602080825282518282018190525f9190848201906040850190845b81811015611d885783516001600160a01b031683529284019291840191600101611d63565b50909695505050505050565b5f8060408385031215611da5575f80fd5b8235611db081611b7d565b946020939093013593505050565b5f60208284031215611dce575f80fd5b5051919050565b5f60208284031215611de5575f80fd5b8151611bac81611bb3565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b81810381811115611e2b57611e2b611e04565b92915050565b5f60018201611e4257611e42611e04565b5060010190565b5f60208284031215611e59575f80fd5b8151611bac81611b7d565b818382375f9101908152919050565b5f8251611e84818460208701611ca4565b9190910192915050565b602081525f611bac6020830184611cc656fea2646970667358221220d6117db28317c666cf7ffed39142131741f76c0c3b0d58897f3902d307c260e064736f6c63430008140033

Verified Source Code Full Match

Compiler: v0.8.20+commit.a1b79de6 EVM: shanghai Optimization: Yes (200 runs)
WordCodec.sol 120 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// solhint-disable no-inline-assembly

/// @dev A subset copied from the following contracts:
///
/// + `balancer-labs/v2-solidity-utils/contracts/helpers/WordCodec.sol`
/// + `balancer-labs/v2-solidity-utils/contracts/helpers/WordCodecHelpers.sol`
library WordCodec {
  /// @dev Inserts an unsigned integer of bitLength, shifted by an offset, into a 256 bit word,
  /// replacing the old value. Returns the new word.
  function insertUint(
    bytes32 word,
    uint256 value,
    uint256 offset,
    uint256 bitLength
  ) internal pure returns (bytes32 result) {
    // Equivalent to:
    // uint256 mask = (1 << bitLength) - 1;
    // bytes32 clearedWord = bytes32(uint256(word) & ~(mask << offset));
    // result = clearedWord | bytes32(value << offset);
    assembly {
      let mask := sub(shl(bitLength, 1), 1)
      let clearedWord := and(word, not(shl(offset, mask)))
      result := or(clearedWord, shl(offset, value))
    }
  }

  /// @dev Decodes and returns an unsigned integer with `bitLength` bits, shifted by an offset, from a 256 bit word.
  function decodeUint(
    bytes32 word,
    uint256 offset,
    uint256 bitLength
  ) internal pure returns (uint256 result) {
    // Equivalent to:
    // result = uint256(word >> offset) & ((1 << bitLength) - 1);
    assembly {
      result := and(shr(offset, word), sub(shl(bitLength, 1), 1))
    }
  }

  /// @dev Inserts a signed integer shifted by an offset into a 256 bit word, replacing the old value. Returns
  /// the new word.
  ///
  /// Assumes `value` can be represented using `bitLength` bits.
  function insertInt(
    bytes32 word,
    int256 value,
    uint256 offset,
    uint256 bitLength
  ) internal pure returns (bytes32) {
    unchecked {
      uint256 mask = (1 << bitLength) - 1;
      bytes32 clearedWord = bytes32(uint256(word) & ~(mask << offset));
      // Integer values need masking to remove the upper bits of negative values.
      return clearedWord | bytes32((uint256(value) & mask) << offset);
    }
  }

  /// @dev Decodes and returns a signed integer with `bitLength` bits, shifted by an offset, from a 256 bit word.
  function decodeInt(
    bytes32 word,
    uint256 offset,
    uint256 bitLength
  ) internal pure returns (int256 result) {
    unchecked {
      int256 maxInt = int256((1 << (bitLength - 1)) - 1);
      uint256 mask = (1 << bitLength) - 1;

      int256 value = int256(uint256(word >> offset) & mask);
      // In case the decoded value is greater than the max positive integer that can be represented with bitLength
      // bits, we know it was originally a negative integer. Therefore, we mask it to restore the sign in the 256 bit
      // representation.
      //
      // Equivalent to:
      // result = value > maxInt ? (value | int256(~mask)) : value;
      assembly {
        result := or(mul(gt(value, maxInt), not(mask)), value)
      }
    }
  }

  /// @dev Decodes and returns a boolean shifted by an offset from a 256 bit word.
  function decodeBool(bytes32 word, uint256 offset) internal pure returns (bool result) {
    // Equivalent to:
    // result = (uint256(word >> offset) & 1) == 1;
    assembly {
      result := and(shr(offset, word), 1)
    }
  }

  /// @dev Inserts a boolean value shifted by an offset into a 256 bit word, replacing the old value. Returns the new
  /// word.
  function insertBool(
    bytes32 word,
    bool value,
    uint256 offset
  ) internal pure returns (bytes32 result) {
    // Equivalent to:
    // bytes32 clearedWord = bytes32(uint256(word) & ~(1 << offset));
    // bytes32 referenceInsertBool = clearedWord | bytes32(uint256(value ? 1 : 0) << offset);
    assembly {
      let clearedWord := and(word, not(shl(offset, 1)))
      result := or(clearedWord, shl(offset, value))
    }
  }

  function clearWordAtPosition(
    bytes32 word,
    uint256 offset,
    uint256 bitLength
  ) internal pure returns (bytes32 clearedWord) {
    unchecked {
      uint256 mask = (1 << bitLength) - 1;
      clearedWord = bytes32(uint256(word) & ~(mask << offset));
    }
  }
}
IConvexBooster.sol 29 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0 || ^0.8.0;
pragma abicoder v2;

interface IConvexBooster {
  struct PoolInfo {
    address lptoken;
    address token;
    address gauge;
    address crvRewards;
    address stash;
    bool shutdown;
  }

  function poolInfo(uint256 _pid) external view returns (PoolInfo memory);

  function depositAll(uint256 _pid, bool _stake) external returns (bool);

  function deposit(
    uint256 _pid,
    uint256 _amount,
    bool _stake
  ) external returns (bool);

  function earmarkRewards(uint256 _pid) external returns (bool);

  function earmarkFees() external returns (bool);
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
IConvexBasicRewards.sol 37 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0 || ^0.8.0;

interface IConvexBasicRewards {
  function pid() external view returns (uint256);

  function totalSupply() external view returns (uint256);

  function periodFinish() external view returns (uint256);

  function rewardRate() external view returns (uint256);

  function stakingToken() external view returns (address);

  function stakeFor(address, uint256) external returns (bool);

  function balanceOf(address) external view returns (uint256);

  function earned(address) external view returns (uint256);

  function withdrawAll(bool) external returns (bool);

  function withdraw(uint256, bool) external returns (bool);

  function withdrawAndUnwrap(uint256, bool) external returns (bool);

  function getReward() external returns (bool);

  function stake(uint256) external returns (bool);

  function rewardToken() external view returns (address);

  function extraRewards(uint256) external view returns (address);

  function extraRewardsLength() external view returns (uint256);
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
Ownable2Step.sol 57 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;

import "./Ownable.sol";

/**
 * @dev Contract module which provides 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} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
    }
}
IStashTokenWrapper.sol 23 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0 || ^0.8.0;

interface IStashTokenWrapper {
  function token() external view returns (address);

  function rewardPool() external view returns (address);

  function isInvalid() external view returns (bool);

  function name() external view returns (string memory);

  function symbol() external view returns (string memory);

  function decimals() external view returns (uint8);

  function totalSupply() external view returns (uint256);

  function balanceOf(address _account) external view returns (uint256);

  function transfer(address _recipient, uint256 _amount) external returns (bool);
}
ConvexCurveManager.sol 226 lines
// SPDX-License-Identifier: MIT

pragma solidity =0.8.20;

import { IERC20 } from "@openzeppelin/contracts-v4/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts-v4/token/ERC20/utils/SafeERC20.sol";

import { IMultipleRewardDistributor } from "../../common/rewards/distributor/IMultipleRewardDistributor.sol";
import { IConvexVirtualBalanceRewardPool } from "../../interfaces/convex/IConvexVirtualBalanceRewardPool.sol";
import { IStashTokenWrapper } from "../../interfaces/convex/IStashTokenWrapper.sol";
import { ILiquidityManager } from "../../interfaces/voting-escrow/ILiquidityManager.sol";
import { IConvexBasicRewards } from "../../interfaces/IConvexBasicRewards.sol";
import { IConvexBooster } from "../../interfaces/IConvexBooster.sol";

import { WordCodec } from "../../common/codec/WordCodec.sol";

import { LiquidityManagerBase } from "./LiquidityManagerBase.sol";

contract ConvexCurveManager is LiquidityManagerBase {
  using SafeERC20 for IERC20;
  using WordCodec for bytes32;

  /*************
   * Constants *
   *************/

  /// @dev The address of Convex CVX token.
  address private constant CVX = 0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B;

  /// @dev The address of Convex Booster.
  address private constant BOOSTER = 0xF403C135812408BFbE8713b5A23a04b3D48AAE31;

  /// @dev The offset of pid in `_miscData`.
  uint256 private constant PID_OFFSET = 61;

  /// @dev The rewarder of pid in `_miscData`.
  uint256 private constant REWARDER_OFFSET = 77;

  /*************
   * Variables *
   *************/

  /// @dev the list of reward tokens.
  address[] private rewards;

  /***************
   * Constructor *
   ***************/

  function initialize(
    address _operator,
    address _token,
    address _rewarder
  ) external initializer {
    __LiquidityManagerBase_init(_operator, _token);

    uint256 _pid = IConvexBasicRewards(_rewarder).pid();

    bytes32 _data = _miscData;
    _data = _data.insertUint(_pid, PID_OFFSET, 16);
    _data = _data.insertUint(uint256(uint160(_rewarder)), REWARDER_OFFSET, 160);
    _miscData = _data;

    IERC20(_token).safeApprove(BOOSTER, type(uint256).max);
    syncRewardToken();
  }

  /*************************
   * Public View Functions *
   *************************/

  /// @inheritdoc ILiquidityManager
  function getRewardTokens() external view returns (address[] memory) {
    return rewards;
  }

  /// @notice Return the pid in Convex Booster.
  function pid() public view returns (uint256) {
    return _miscData.decodeUint(PID_OFFSET, 16);
  }

  /// @notice Return the address of rewarder.
  function rewarder() public view returns (address) {
    return address(uint160(_miscData.decodeUint(REWARDER_OFFSET, 160)));
  }

  /****************************
   * Public Mutated Functions *
   ****************************/

  /// @notice Sync reward tokens from ConvexBasicRewards contract.
  function syncRewardToken() public {
    delete rewards;

    address staker = rewarder();
    rewards.push(IConvexBasicRewards(staker).rewardToken());

    uint256 _length = IConvexBasicRewards(staker).extraRewardsLength();
    bool _hasCVX = false;
    for (uint256 i = 0; i < _length; i++) {
      address _rewarder = IConvexBasicRewards(staker).extraRewards(i);
      address _wrapper = IConvexVirtualBalanceRewardPool(_rewarder).rewardToken();
      // old rewarders didn't use token wrapper
      try IStashTokenWrapper(_wrapper).token() returns (address _token) {
        if (_token == CVX) _hasCVX = true;
        rewards.push(_token);
      } catch {
        if (_wrapper == CVX) _hasCVX = true;
        rewards.push(_wrapper);
      }
    }
    if (!_hasCVX) rewards.push(CVX);

    _length = rewards.length;
    for (uint256 i = 0; i < _length; ++i) {
      address _token = rewards[i];
      IERC20(_token).safeApprove(operator, 0);
      IERC20(_token).safeApprove(operator, type(uint256).max);
    }
  }

  /// @inheritdoc ILiquidityManager
  function manage() public override {
    uint256 _balance = IERC20(token).balanceOf(address(this));
    if (_balance == 0) return;

    _manageUnderlying(address(0), _balance, false);
  }

  /// @inheritdoc ILiquidityManager
  function harvest(address _receiver) external {
    // try to deposit first
    uint256 _balance = IERC20(token).balanceOf(address(this));
    if (_balance > 0) {
      IConvexBooster(BOOSTER).deposit(pid(), _balance, true);
    }

    // harvest
    IConvexBasicRewards(rewarder()).getReward();

    // distribute rewards
    uint256 _harvesterRatio = getHarvesterRatio();
    uint256 _managerRatio = getManagerRatio();
    uint256 _length = rewards.length;
    address _operator = operator;
    for (uint256 i = 0; i < _length; ++i) {
      address _rewardToken = rewards[i];
      uint256 _rewardAmount = IERC20(_rewardToken).balanceOf(address(this)) - incentive[_rewardToken];
      if (_rewardAmount == 0) continue;

      unchecked {
        uint256 _incentive = (_rewardAmount * _managerRatio) / FEE_PRECISION;
        if (_incentive > 0) incentive[_rewardToken] += _incentive;

        uint256 _bounty = (_rewardAmount * _harvesterRatio) / FEE_PRECISION;
        if (_bounty > 0) {
          IERC20(_rewardToken).safeTransfer(_receiver, _bounty);
        }

        IMultipleRewardDistributor(_operator).depositReward(_rewardToken, _rewardAmount - _incentive - _bounty);
      }
    }
  }

  /**********************
   * Internal Functions *
   **********************/

  /// @inheritdoc LiquidityManagerBase
  function _managedBalance() internal view virtual override returns (uint256) {
    unchecked {
      return IERC20(token).balanceOf(address(this)) + IConvexBasicRewards(rewarder()).balanceOf(address(this));
    }
  }

  /// @inheritdoc LiquidityManagerBase
  function _deposit(
    address _receiver,
    uint256,
    bool _manage
  ) internal virtual override {
    if (_manage) {
      // deposit to underlying strategy
      uint256 _balance = IERC20(token).balanceOf(address(this));
      if (_balance > 0) {
        _manageUnderlying(_receiver, _balance, true);
      }
    }
  }

  /// @inheritdoc LiquidityManagerBase
  function _withdraw(address _receiver, uint256 _amount) internal virtual override {
    if (_amount > 0) {
      uint256 _balance = IERC20(token).balanceOf(address(this));
      if (_amount > _balance) {
        unchecked {
          IConvexBasicRewards(rewarder()).withdrawAndUnwrap(_amount - _balance, false);
        }
      }
      IERC20(token).safeTransfer(_receiver, _amount);
    }
  }

  /// @dev Internal function to manage underlying assets
  function _manageUnderlying(
    address _receiver,
    uint256 _balance,
    bool _incentived
  ) internal {
    // deposit to booster
    IConvexBooster(BOOSTER).deposit(pid(), _balance, true);

    // send incentive
    if (_incentived) {
      uint256 _length = rewards.length;
      for (uint256 i = 0; i < _length; ++i) {
        address _rewardToken = rewards[i];
        uint256 _incentive = incentive[_rewardToken];
        if (_incentive > 0) {
          IERC20(_rewardToken).safeTransfer(_receiver, _incentive);
          incentive[_rewardToken] = 0;
        }
      }
    }
  }
}
Initializable.sol 166 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/Address.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}
ILiquidityManager.sol 98 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface ILiquidityManager {
  /**********
   * Events *
   **********/

  /// @notice Emitted when the ratio for manager is updated.
  /// @param oldRatio The value of the previous ratio, multipled by 1e9.
  /// @param newRatio The value of the current ratio, multipled by 1e9.
  event UpdateManagerRatio(uint256 oldRatio, uint256 newRatio);

  /// @notice Emitted when the ratio for harvester is updated.
  /// @param oldRatio The value of the previous ratio, multipled by 1e9.
  /// @param newRatio The value of the current ratio, multipled by 1e9.
  event UpdateHarvesterRatio(uint256 oldRatio, uint256 newRatio);

  /**********
   * Errors *
   **********/

  /// @dev Thrown when try to kill the manager more than once.
  error AlreadyKilled();

  /// @dev Thrown when the call is not operator.
  error CallerIsNotOperator();

  /// @dev Thrown when the manager ratio exceeds `MAX_MANAGER_RATIO`.
  error ManagerRatioTooLarge();

  /// @dev Thrown when the harvester ratio exceeds `MAX_HARVESTER_RATIO`.
  error HarvesterRatioTooLarge();

  /*************************
   * Public View Functions *
   *************************/

  /// @notice Return whether the manager is active.
  function isActive() external view returns (bool);

  /// @notice Return the list of reward tokens.
  function getRewardTokens() external view returns (address[] memory);

  /// @notice Return the fee ratio distributed to treasury, multipled by 1e9.
  function getManagerRatio() external view returns (uint256);

  /// @notice Return the fee ratio distributed to harvester, multipled by 1e9.
  function getHarvesterRatio() external view returns (uint256);

  /****************************
   * Public Mutated Functions *
   ****************************/

  /// @notice Deposit token to corresponding manager.
  /// @dev Requirements:
  ///   + Caller should make sure the token is already transfered into the manager contract.
  ///   + Caller should make sure the deposit amount is greater than zero.
  ///
  /// @param receiver The address of recipient who will receive the share.
  /// @param amount The amount of token to deposit.
  /// @param manage Whether to deposit the token to underlying strategy.
  function deposit(
    address receiver,
    uint256 amount,
    bool manage
  ) external;

  /// @notice Withdraw underlying token from corresponding manager.
  /// @dev Requirements:
  ///   + Caller should make sure the withdraw amount is greater than zero.
  ///
  /// @param receiver The address of recipient who will receive the token.
  /// @param amount The amount of token to withdraw.
  function withdraw(address receiver, uint256 amount) external;

  /// @notice Emergency function to execute arbitrary call.
  /// @dev This function should be only used in case of emergency. It should never be called explicitly
  ///  in any contract in normal case.
  ///
  /// @param to The address of target contract to call.
  /// @param value The value passed to the target contract.
  /// @param data The calldata pseed to the target contract.
  function execute(
    address to,
    uint256 value,
    bytes calldata data
  ) external payable returns (bool, bytes memory);

  /// @notice Manage the deposited token. Usually the token will be
  /// deposited to another protocol which could generate more yields.
  function manage() external;

  /// @notice Harvest pending rewards from underlying protocol.
  /// @param receiver The address of the recipient for harvest incentive.
  function harvest(address receiver) external;
}
LiquidityManagerBase.sol 212 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import { Ownable2Step } from "@openzeppelin/contracts-v4/access/Ownable2Step.sol";
import { Initializable } from "@openzeppelin/contracts-v4/proxy/utils/Initializable.sol";

import { WordCodec } from "../../common/codec/WordCodec.sol";

import { ILiquidityManager } from "../../interfaces/voting-escrow/ILiquidityManager.sol";

// solhint-disable func-name-mixedcase

abstract contract LiquidityManagerBase is Initializable, Ownable2Step, ILiquidityManager {
  using WordCodec for bytes32;

  /*************
   * Constants *
   *************/

  /// @dev The offset of active flag in `_miscData`.
  uint256 private constant ACTIVE_FLAG_OFFSET = 0;

  /// @dev The offset of manager ratio in `_miscData`.
  uint256 private constant MANAGER_RATIO_OFFSET = 1;

  /// @dev The offset of harvester ratio in `_miscData`.
  uint256 private constant HARVESTER_RATIO_OFFSET = 31;

  /// @dev The maximum manager ratio.
  uint256 private constant MAX_MANAGER_RATIO = 5e8; // 20%

  /// @dev The maximum harvester ratio.
  uint256 private constant MAX_HARVESTER_RATIO = 1e8; // 20%

  /// @dev The fee denominator used for rate calculation.
  uint256 internal constant FEE_PRECISION = 1e9;

  /*************
   * Variables *
   *************/

  /// @notice The address of operator, usually the `LiquidityGauge` contract.
  address public operator;

  /// @notice The address of managed token.
  address public token;

  /// @notice Mapping from reward token address to the amount of incentive for manager.
  mapping(address => uint256) public incentive;

  /// @dev `_miscData` is a storage slot that can be used to store unrelated pieces of information.
  /// All LiquidityManagerBase store the *active flag*, *manager ratio* and *harvester ratio*, but
  /// the `miscData`can be extended to store more pieces of information.
  ///
  /// The *active flag* is stored in the first bit, and the *manager ratio* is stored in the next most
  /// significant 30 bits, and the *harvester ratio* is stored in the next most significant 30 bits,
  /// leaving the remaining 195 bits free to store any other information derived pools might need.
  ///
  /// - The *manager ratio* and *harvester ratio* are charged each time when harvester harvest the pool revenue.
  ///
  /// [ active flag | manager ratio | harvester ratio | available ]
  /// [    1 bit    |    30 bits    |     30 bits     |  195 bits ]
  /// [ MSB                                                   LSB ]
  bytes32 internal _miscData;

  /// @dev reserved slots.
  uint256[46] private __gap;

  /*************
   * Modifiers *
   *************/

  modifier onlyOperator() {
    if (_msgSender() != operator) {
      revert CallerIsNotOperator();
    }
    _;
  }

  modifier whenNotKilled() {
    if (!isActive()) revert AlreadyKilled();
    _;
  }

  /***************
   * Constructor *
   ***************/

  function __LiquidityManagerBase_init(address _operator, address _token) internal onlyInitializing {
    _transferOwnership(_msgSender());

    operator = _operator;
    token = _token;

    // Set active
    _miscData = _miscData.insertBool(true, ACTIVE_FLAG_OFFSET);
  }

  /*************************
   * Public View Functions *
   *************************/

  /// @inheritdoc ILiquidityManager
  function isActive() public view override returns (bool) {
    return _miscData.decodeBool(ACTIVE_FLAG_OFFSET);
  }

  /// @inheritdoc ILiquidityManager
  function getManagerRatio() public view override returns (uint256) {
    return _miscData.decodeUint(MANAGER_RATIO_OFFSET, 30);
  }

  /// @inheritdoc ILiquidityManager
  function getHarvesterRatio() public view override returns (uint256) {
    return _miscData.decodeUint(HARVESTER_RATIO_OFFSET, 30);
  }

  /****************************
   * Public Mutated Functions *
   ****************************/

  /// @inheritdoc ILiquidityManager
  function deposit(
    address _receiver,
    uint256 _amount,
    bool _manage
  ) external onlyOperator whenNotKilled {
    _deposit(_receiver, _amount, _manage);
  }

  /// @inheritdoc ILiquidityManager
  function withdraw(address _receiver, uint256 _amount) external onlyOperator whenNotKilled {
    _withdraw(_receiver, _amount);
  }

  /************************
   * Restricted Functions *
   ************************/

  /// @inheritdoc ILiquidityManager
  function execute(
    address _to,
    uint256 _value,
    bytes calldata _data
  ) external payable onlyOwner returns (bool, bytes memory) {
    // solhint-disable-next-line avoid-low-level-calls
    (bool success, bytes memory result) = _to.call{ value: _value }(_data);
    return (success, result);
  }

  /// @notice Kill the liquidity manager and withdraw all token back to operator.
  function kill() external onlyOwner whenNotKilled {
    _miscData = _miscData.insertBool(false, ACTIVE_FLAG_OFFSET);

    // Send all funds back to operator
    uint256 _balance = _managedBalance();
    _withdraw(operator, _balance);
  }

  /// @notice Update the fee ratio distributed to manager.
  /// @param _newRatio The new ratio to update, multipled by 1e9.
  function updateManagerRatio(uint32 _newRatio) external onlyOwner {
    if (uint256(_newRatio) > MAX_MANAGER_RATIO) {
      revert ManagerRatioTooLarge();
    }

    bytes32 _data = _miscData;
    uint256 _oldRatio = _miscData.decodeUint(MANAGER_RATIO_OFFSET, 30);
    _miscData = _data.insertUint(_newRatio, MANAGER_RATIO_OFFSET, 30);

    emit UpdateManagerRatio(_oldRatio, _newRatio);
  }

  /// @notice Update the fee ratio distributed to harvester.
  /// @param _newRatio The new ratio to update, multipled by 1e9.
  function updateHarvesterRatio(uint32 _newRatio) external onlyOwner {
    if (uint256(_newRatio) > MAX_HARVESTER_RATIO) {
      revert HarvesterRatioTooLarge();
    }

    bytes32 _data = _miscData;
    uint256 _oldRatio = _miscData.decodeUint(HARVESTER_RATIO_OFFSET, 30);
    _miscData = _data.insertUint(_newRatio, HARVESTER_RATIO_OFFSET, 30);

    emit UpdateHarvesterRatio(_oldRatio, _newRatio);
  }

  /**********************
   * Internal Functions *
   **********************/

  /// @dev Internal function to return all managed tokens.
  function _managedBalance() internal view virtual returns (uint256);

  /// @dev Internal function to deposit token.
  ///
  /// @param _receiver The address of recipient who will receive the share.
  /// @param _amount The amount of token to deposit.
  /// @param _manage Whether to deposit the token to underlying strategy.
  function _deposit(
    address _receiver,
    uint256 _amount,
    bool _manage
  ) internal virtual;

  /// @dev Internal function to withdraw token.
  ///
  /// @param _receiver The address of recipient who will receive the token.
  /// @param _amount The amount of token to withdraw.
  function _withdraw(address _receiver, uint256 _amount) internal virtual;
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.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;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}
IConvexVirtualBalanceRewardPool.sol 9 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0 || ^0.8.0;

interface IConvexVirtualBalanceRewardPool {
  function rewardToken() external view returns (address);

  function earned(address account) external view returns (uint256);
}
IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
IMultipleRewardDistributor.sol 84 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IMultipleRewardDistributor {
  /**********
   * Events *
   **********/

  /// @notice Emitted when new reward token is registered.
  ///
  /// @param token The address of reward token.
  /// @param distributor The address of reward distributor.
  event RegisterRewardToken(address indexed token, address indexed distributor);

  /// @notice Emitted when the reward distributor is updated.
  ///
  /// @param token The address of reward token.
  /// @param oldDistributor The address of previous reward distributor.
  /// @param newDistributor The address of current reward distributor.
  event UpdateRewardDistributor(address indexed token, address indexed oldDistributor, address indexed newDistributor);

  /// @notice Emitted when a reward token is unregistered.
  ///
  /// @param token The address of reward token.
  event UnregisterRewardToken(address indexed token);

  /// @notice Emitted when a reward token is deposited.
  ///
  /// @param token The address of reward token.
  /// @param amount The amount of reward token deposited.
  event DepositReward(address indexed token, uint256 amount);

  /**********
   * Errors *
   **********/

  /// @dev Thrown when caller access an unactive reward token.
  error NotActiveRewardToken();

  /// @dev Thrown when the address of reward distributor is `address(0)`.
  error RewardDistributorIsZero();

  /// @dev Thrown when caller is not reward distributor.
  error NotRewardDistributor();

  /// @dev Thrown when caller try to register an existing reward token.
  error DuplicatedRewardToken();

  /// @dev Thrown when caller try to unregister a reward with pending rewards.
  error RewardDistributionNotFinished();

  /*************************
   * Public View Functions *
   *************************/

  /// @notice Return the address of reward distributor.
  ///
  /// @param token The address of reward token.
  function distributors(address token) external view returns (address);

  /// @notice Return the list of active reward tokens.
  function getActiveRewardTokens() external view returns (address[] memory);

  /// @notice Return the list of historical reward tokens.
  function getHistoricalRewardTokens() external view returns (address[] memory);

  /// @notice Return the amount of pending distributed rewards in current period.
  ///
  /// @param token The address of reward token.
  /// @return distributable The amount of reward token can be distributed in current period.
  /// @return undistributed The amount of reward token still locked in current period.
  function pendingRewards(address token) external view returns (uint256 distributable, uint256 undistributed);

  /****************************
   * Public Mutated Functions *
   ****************************/

  /// @notice Deposit new rewards to this contract.
  ///
  /// @param token The address of reward token.
  /// @param amount The amount of new rewards.
  function depositReward(address token, uint256 amount) external;
}

Read Contract

getHarvesterRatio 0xa69f4935 → uint256
getManagerRatio 0x1902fe6f → uint256
getRewardTokens 0xc4f59f9b → address[]
incentive 0x4d567e62 → uint256
isActive 0x22f3e2d4 → bool
operator 0x570ca735 → address
owner 0x8da5cb5b → address
pendingOwner 0xe30c3978 → address
pid 0xf1068454 → uint256
rewarder 0xdcc3e06e → address
token 0xfc0c546a → address

Write Contract 13 functions

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

acceptOwnership 0x79ba5097
No parameters
deposit 0x3edd1128
address _receiver
uint256 _amount
bool _manage
execute 0xb61d27f6
address _to
uint256 _value
bytes _data
returns: bool, bytes
harvest 0x0e5c011e
address _receiver
initialize 0xc0c53b8b
address _operator
address _token
address _rewarder
kill 0x41c0e1b5
No parameters
manage 0xba2ee65c
No parameters
renounceOwnership 0x715018a6
No parameters
syncRewardToken 0x7108576e
No parameters
transferOwnership 0xf2fde38b
address newOwner
updateHarvesterRatio 0xbf6f5b00
uint32 _newRatio
updateManagerRatio 0x4350df3d
uint32 _newRatio
withdraw 0xf3fef3a3
address _receiver
uint256 _amount

Recent Transactions

No transactions found for this address