Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x88C88Aa6a9cedc2aff9b4cA6820292F39cc64026
Balance 0 ETH
Nonce 1
Code Size 6480 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

6480 bytes
0x608060405234801561001057600080fd5b50600436106101585760003560e01c80636cb70257116100c3578063bca7a9e21161007c578063bca7a9e2146102ef578063d0f492f7146102f7578063d38bfff41461030a578063d7b96d4e1461031d578063f7d9d0c414610344578063fc0c546a1461035557600080fd5b80636cb70257146102815780638070c5031461029c5780638fa2b36b146102af578063918f8674146102ca578063a6f19c84146102d3578063b7fa1ba7146102e657600080fd5b80634f1bfc9e116101155780634f1bfc9e146101f757806355a68ed31461022c5780635aa6e6751461023f578063601aff1214610252578063638126f814610265578063684ed2b11461026e57600080fd5b8063075461721461015d57806316f0115b146101a1578063238efcbc146101b45780632968f616146101be5780633d18678e146101d15780634437152a146101e4575b600080fd5b6101847f000000000000000000000000d1b5651e55d4ceed36251c61c50c889b36f6abb581565b6040516001600160a01b0390911681526020015b60405180910390f35b600554610184906001600160a01b031681565b6101bc61037c565b005b6101bc6101cc366004611626565b6103e7565b6101bc6101df36600461166e565b610554565b6101bc6101f2366004611687565b6105c2565b61021e7f000000000000000000000000000000000000000000000000000000000784ce0081565b604051908152602001610198565b6101bc61023a366004611687565b610646565b600354610184906001600160a01b031681565b6101bc610260366004611687565b6106d0565b61021e60015481565b6101bc61027c36600461166e565b6107ad565b61018473478bbc744811ee8310b461514bdc29d03739084d81565b600454610184906001600160a01b031681565b610184735f3b5dfeb7b28cdbd7faba78963ee202a494e2a281565b61021e61271081565b600254610184906001600160a01b031681565b61021e60005481565b6101bc6108b3565b6101bc6103053660046116a9565b610a6f565b6101bc610318366004611687565b610ec6565b6101847f00000000000000000000000052f541764e6e90eebc5c21ff570de0e2d63766b681565b6101bc61035236600461166e565b50565b6101847f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5281565b6004546001600160a01b031633146103a7576040516305189e0d60e21b815260040160405180910390fd5b600380546001600160a01b031916339081179091556040517fa6a85f15b976d399f39ad43e515e75910bac714bc55eeff6131fb90780d6f74690600090a2565b83600003610408576040516301f4d90760e41b815260040160405180910390fd5b6001600160a01b03811661042f576040516366e7950960e01b815260040160405180910390fd5b6104646001600160a01b037f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5216333087610f13565b81801561047b57506002546001600160a01b031615155b156104f85761048b848430610f84565b600254604051636e553f6560e01b8152600481018390526001600160a01b038481166024830152929650911690636e553f6590604401600060405180830381600087803b1580156104db57600080fd5b505af11580156104ef573d6000803e3d6000fd5b50505050610506565b610503848483610f84565b93505b6040805185815283151560208201526001600160a01b0383169133917fb32af138549e2a71563d1f2b1f7f0a139b3cdbc83d877d13603de1c3c5fd487a91015b60405180910390a350505050565b6003546001600160a01b0316331461057f576040516305189e0d60e21b815260040160405180910390fd5b601e81116103525760008190556040518181527f3dda580d2b9d92da338ef46ec718e7b1dd0a2c505e3df4aa8d40360192a0f8229060200160405180910390a150565b6003546001600160a01b031633146105ed576040516305189e0d60e21b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b03831690811790915515610352576103526001600160a01b037f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52168260001961101a565b6003546001600160a01b03163314610671576040516305189e0d60e21b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0383169081179091551561035257600254610352906001600160a01b037f000000000000000000000000d1b5651e55d4ceed36251c61c50c889b36f6abb58116911660001961101a565b6003546001600160a01b031633146106fb576040516305189e0d60e21b815260040160405180910390fd5b60405163b3ab15fb60e01b81526001600160a01b0382811660048301527f000000000000000000000000d1b5651e55d4ceed36251c61c50c889b36f6abb5169063b3ab15fb90602401600060405180830381600087803b15801561075e57600080fd5b505af1158015610772573d6000803e3d6000fd5b50506040516001600160a01b03841692507f860079172b8d313ffe6600be83301a99a5099e33a3f5cbe541d97e98074cbfe79150600090a250565b6040516323b872dd60e01b81523360048201523060248201526044810182905273478bbc744811ee8310b461514bdc29d03739084d906323b872dd906064016020604051808303816000875af115801561080b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082f91906116e1565b506040516340c10f1960e01b8152336004820152602481018290527f000000000000000000000000d1b5651e55d4ceed36251c61c50c889b36f6abb56001600160a01b0316906340c10f1990604401600060405180830381600087803b15801561089857600080fd5b505af11580156108ac573d6000803e3d6000fd5b5050505050565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd526001600160a01b0316906370a0823190602401602060405180830381865afa15801561091a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061093e91906116fe565b905080156109a35761099a6001600160a01b037f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52167f00000000000000000000000052f541764e6e90eebc5c21ff570de0e2d63766b683611139565b6109a381611169565b60015415610352576001546040516340c10f1960e01b815233600482015260248101919091527f000000000000000000000000d1b5651e55d4ceed36251c61c50c889b36f6abb56001600160a01b0316906340c10f1990604401600060405180830381600087803b158015610a1757600080fd5b505af1158015610a2b573d6000803e3d6000fd5b50506001546040519081523392507f70220290ea80981efd0f0f7e6b1b5085605eb976822c8b8422e5bcc53e4c6d63915060200160405180910390a2600060015550565b83600003610a90576040516301f4d90760e41b815260040160405180910390fd5b6001600160a01b038116610ab7576040516366e7950960e01b815260040160405180910390fd5b8215610c7357610b126001600160a01b037f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5216337f00000000000000000000000052f541764e6e90eebc5c21ff570de0e2d63766b687610f13565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd526001600160a01b0316906370a0823190602401602060405180830381865afa158015610b79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9d91906116fe565b90508015610bf957610bf96001600160a01b037f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52167f00000000000000000000000052f541764e6e90eebc5c21ff570de0e2d63766b683611139565b610c0b610c06868361172d565b611169565b60015415610c6d57600154610c20908661172d565b9450336001600160a01b03167f70220290ea80981efd0f0f7e6b1b5085605eb976822c8b8422e5bcc53e4c6d63600154604051610c5f91815260200190565b60405180910390a260006001555b50610cec565b610ca86001600160a01b037f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5216333087610f13565b600061271060005486610cbb9190611746565b610cc5919061175d565b9050610cd1818661177f565b94508060016000828254610ce5919061172d565b9091555050505b818015610d0357506002546001600160a01b031615155b15610df3576040516340c10f1960e01b8152306004820152602481018590527f000000000000000000000000d1b5651e55d4ceed36251c61c50c889b36f6abb56001600160a01b0316906340c10f1990604401600060405180830381600087803b158015610d7057600080fd5b505af1158015610d84573d6000803e3d6000fd5b5050600254604051636e553f6560e01b8152600481018890526001600160a01b0385811660248301529091169250636e553f659150604401600060405180830381600087803b158015610dd657600080fd5b505af1158015610dea573d6000803e3d6000fd5b50505050610e76565b6040516340c10f1960e01b81526001600160a01b038281166004830152602482018690527f000000000000000000000000d1b5651e55d4ceed36251c61c50c889b36f6abb516906340c10f1990604401600060405180830381600087803b158015610e5d57600080fd5b505af1158015610e71573d6000803e3d6000fd5b505050505b604080518581528415156020820152831515918101919091526001600160a01b0382169033907f1652dc46c7c8f691f8e51f9897515fc24cbd8cafd7eb97f620fe1635399d8c7690606001610546565b6003546001600160a01b03163314610ef1576040516305189e0d60e21b815260040160405180910390fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6040516001600160a01b0380851660248301528316604482015260648101829052610f7e9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611404565b50505050565b60055460405163ddc1f59d60e01b81526000600482018190526001602483015260448201869052606482018590526001600160a01b0384811660848401529092169063ddc1f59d9060a4016020604051808303816000875af1158015610fee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101291906116fe565b949350505050565b8015806110945750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561106e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061109291906116fe565b155b6111045760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084015b60405180910390fd5b6040516001600160a01b03831660248201526044810182905261113490849063095ea7b360e01b90606401610f47565b505050565b6040516001600160a01b03831660248201526044810182905261113490849063a9059cbb60e01b90606401610f47565b801561035257604051630aa2b75d60e11b8152600481018290527f00000000000000000000000052f541764e6e90eebc5c21ff570de0e2d63766b66001600160a01b0316906315456eba90602401600060405180830381600087803b1580156111d157600080fd5b505af11580156111e5573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000784ce0042611217919061172d565b60405163adc6358960e01b81526001600160a01b037f00000000000000000000000052f541764e6e90eebc5c21ff570de0e2d63766b6166004820152909150600090735f3b5dfeb7b28cdbd7faba78963ee202a494e2a29063adc6358990602401602060405180830381865afa158015611295573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b991906116fe565b6112c662093a808461175d565b6112d39062093a80611746565b11905080156113ca577f00000000000000000000000052f541764e6e90eebc5c21ff570de0e2d63766b66001600160a01b031663b61d27f6735f3b5dfeb7b28cdbd7faba78963ee202a494e2a260008560405160240161133591815260200190565b60408051601f198184030181529181526020820180516001600160e01b03166377fbd30960e11b1790525160e085901b6001600160e01b0319168152611380939291906004016117e2565b6000604051808303816000875af115801561139f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113c79190810190611828565b50505b60405183815233907ff9626bca62c59d77fa45a204dc096874ee066a5c5e124aa9ce6c438dbdf7387a9060200160405180910390a2505050565b6000611459826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114d99092919063ffffffff16565b905080516000148061147a57508080602001905181019061147a91906116e1565b6111345760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016110fb565b6060611012848460008585600080866001600160a01b0316858760405161150091906118eb565b60006040518083038185875af1925050503d806000811461153d576040519150601f19603f3d011682016040523d82523d6000602084013e611542565b606091505b50915091506115538783838761155e565b979650505050505050565b606083156115cd5782516000036115c6576001600160a01b0385163b6115c65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016110fb565b5081611012565b61101283838151156115e25781518083602001fd5b8060405162461bcd60e51b81526004016110fb9190611907565b801515811461035257600080fd5b80356001600160a01b038116811461162157600080fd5b919050565b6000806000806080858703121561163c57600080fd5b84359350602085013592506040850135611655816115fc565b91506116636060860161160a565b905092959194509250565b60006020828403121561168057600080fd5b5035919050565b60006020828403121561169957600080fd5b6116a28261160a565b9392505050565b600080600080608085870312156116bf57600080fd5b8435935060208501356116d1816115fc565b92506040850135611655816115fc565b6000602082840312156116f357600080fd5b81516116a2816115fc565b60006020828403121561171057600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561174057611740611717565b92915050565b808202811582820484141761174057611740611717565b60008261177a57634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111561174057611740611717565b60005b838110156117ad578181015183820152602001611795565b50506000910152565b600081518084526117ce816020860160208601611792565b601f01601f19169290920160200192915050565b60018060a01b038416815282602082015260606040820152600061180960608301846117b6565b95945050505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561183b57600080fd5b8251611846816115fc565b602084015190925067ffffffffffffffff8082111561186457600080fd5b818501915085601f83011261187857600080fd5b81518181111561188a5761188a611812565b604051601f8201601f19908116603f011681019083821181831017156118b2576118b2611812565b816040528281528860208487010111156118cb57600080fd5b6118dc836020830160208801611792565b80955050505050509250929050565b600082516118fd818460208701611792565b9190910192915050565b6020815260006116a260208301846117b656fea2646970667358221220a0bb8b06baf90ede2fc0a5ddcb205867aa91c605a32677c1387908b42ef5858564736f6c63430008130033

Verified Source Code Partial Match

Compiler: v0.8.19+commit.7dd6d404 EVM: paris Optimization: Yes (200 runs)
CRVDepositorV2.sol 1133 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity =0.8.19 ^0.8.0 ^0.8.1 ^0.8.19 ^0.8.7;

// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol

// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

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

// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol

// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

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

// lib/openzeppelin-contracts/contracts/utils/Address.sol

// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

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

// src/base/interfaces/ICurvePool.sol

interface ICurvePool {
    function add_liquidity(uint256[2] calldata amounts, uint256 min_mint_amount) external returns (uint256);
    function exchange(int128 i, int128 j, uint256 _dx, uint256 _min_dy) external returns (uint256);
    function exchange(int128 i, int128 j, uint256 _dx, uint256 _min_dy, address _receiver) external returns (uint256);
    function get_dy(int128 i, int128 j, uint256 _dx) external view returns (uint256);
}

// src/base/interfaces/IExecutor.sol

interface IExecutor {
    function allowAddress(address _address) external;

    function execute(address _to, uint256 _value, bytes calldata _data) external returns (bool, bytes memory);

    function callExecuteTo(address _executor, address _to, uint256 _value, bytes calldata _data)
        external
        returns (bool, bytes memory);
}

// src/base/interfaces/ILiquidityGauge.sol

interface ILiquidityGauge {
    struct Reward {
        address token;
        address distributor;
        // solhint-disable-next-line
        uint256 period_finish;
        uint256 rate;
        // solhint-disable-next-line
        uint256 last_update;
        uint256 integral;
    }

    // solhint-disable-next-line
    function deposit_reward_token(address _rewardToken, uint256 _amount) external;

    // solhint-disable-next-line
    function claim_rewards_for(address _user, address _recipient) external;

    // solhint-disable-next-line
    function working_balances(address _address) external view returns (uint256);

    // solhint-disable-next-line
    function deposit(uint256 _value, address _addr) external;

    // solhint-disable-next-line
    function reward_tokens(uint256 _i) external view returns (address);

    // solhint-disable-next-line
    function reward_data(address _tokenReward) external view returns (Reward memory);

    function balanceOf(address) external returns (uint256);

    // solhint-disable-next-line
    function claimable_reward(address _user, address _reward_token) external view returns (uint256);

    // solhint-disable-next-line
    function claimable_tokens(address _user) external returns (uint256);

    // solhint-disable-next-line
    function user_checkpoint(address _user) external returns (bool);

    // solhint-disable-next-line
    function commit_transfer_ownership(address) external;

    // solhint-disable-next-line
    function claim_rewards() external;

    // solhint-disable-next-line
    function claim_rewards(address) external;

    // solhint-disable-next-line
    function claim_rewards(address, address) external;

    // solhint-disable-next-line
    function add_reward(address, address) external;

    // solhint-disable-next-line
    function set_claimer(address) external;

    function admin() external view returns (address);

    function future_admin() external view returns (address);

    // solhint-disable-next-line
    function set_reward_distributor(address _rewardToken, address _newDistrib) external;

    function initialize(
        // solhint-disable-next-line
        address staking_token,
        address admin,
        address sdt,
        // solhint-disable-next-line
        address voting_escrow,
        // solhint-disable-next-line
        address veBoost_proxy,
        address distributor
    ) external;

    function totalSupply() external returns (uint256);

    function withdraw(uint256 _value, bool _claimReward) external;

    // solhint-disable-next-line
    function accept_transfer_ownership() external;

    // solhint-disable-next-line
    function claimed_reward(address _addr, address _token) external view returns (uint256);

    // solhint-disable-next-line
    function set_rewards_receiver(address _receiver) external;
}

// src/base/interfaces/ILocker.sol

interface ILocker {
    function createLock(uint256, uint256) external;

    function claimAllRewards(address[] calldata _tokens, address _recipient) external;

    function increaseAmount(uint256) external;

    function increaseAmount(uint128) external;

    function increaseUnlockTime(uint256) external;

    function release() external;

    function claimRewards(address, address) external;

    function claimRewards(address, address, address) external;

    function claimFXSRewards(address) external;

    function claimFPISRewards(address) external;

    function execute(address, uint256, bytes calldata) external returns (bool, bytes memory);

    function setGovernance(address) external;

    function voteGaugeWeight(address, uint256) external;

    function setAngleDepositor(address) external;

    function setDepositor(address) external;

    function setFxsDepositor(address) external;

    function setYFIDepositor(address) external;

    function setYieldDistributor(address) external;

    function setGaugeController(address) external;

    function setAccumulator(address _accumulator) external;

    function governance() external view returns (address);

    function increaseLock(uint256 _value, uint256 _duration) external;

    function release(address _recipient) external;

    function setStrategy(address _strategy) external;
}

// src/base/interfaces/ISdToken.sol

interface ISdToken {
    function setOperator(address _operator) external;
    function balanceOf(address account) external view returns (uint256);
    function operator() external view returns (address);
}

// src/base/interfaces/ITokenMinter.sol

interface ITokenMinter {
    function mint(address, uint256) external;
    function burn(address, uint256) external;
}

// src/base/interfaces/IVeToken.sol

interface IVeToken {
    struct LockedBalance {
        int128 amount;
        uint256 end;
    }

    function create_lock(uint256 _value, uint256 _unlock_time) external;

    function increase_amount(uint256 _value) external;

    function increase_unlock_time(uint256 _unlock_time) external;

    function withdraw() external;

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

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

    function locked(address) external returns (LockedBalance memory);
}

// lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol

// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.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. Compatible with tokens that require the approval to be set to
     * 0 before setting it to a non-zero value.
     */
    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));
    }
}

// src/base/depositor/DepositorV4.sol

/// @title Depositor
/// @notice Contract that accepts tokens and locks them in the Locker, minting sdToken in return
/// @dev Adapted for veCRV like Locker.
/// @author StakeDAO
/// @custom:contact [email protected]
abstract contract DepositorV4 {
    using SafeERC20 for IERC20;

    /// @notice Denominator for fixed point math.
    uint256 public constant DENOMINATOR = 10_000;

    /// @notice Maximum lock duration.
    uint256 public immutable MAX_LOCK_DURATION;

    /// @notice Address of the token to be locked.
    address public immutable token;

    /// @notice Address of the locker contract.
    address public immutable locker;

    /// @notice Address of the sdToken minter contract.
    address public immutable minter;

    /// @notice Fee percent to users who spend gas to increase lock.
    uint256 public lockIncentivePercent = 10;

    /// @notice Incentive accrued in token to users who spend gas to increase lock.
    uint256 public incentiveToken;

    /// @notice Gauge to deposit sdToken into.
    address public gauge;

    /// @notice Address of the governance.
    address public governance;

    /// @notice Address of the future governance contract.
    address public futureGovernance;

    ////////////////////////////////////////////////////////////////
    /// --- EVENTS & ERRORS
    ///////////////////////////////////////////////////////////////

    /// @notice Event emitted when a lock is created.
    /// @param amount Amount of tokens locked.
    /// @param duration Duration of the lock.
    event CreateLock(uint256 amount, uint256 duration);

    /// @notice Event emitted when tokens are deposited.
    /// @param caller Address of the caller.
    /// @param user Address of the user.
    /// @param amount Amount of tokens deposited.
    /// @param lock Whether the tokens are locked.
    /// @param stake Whether the sdToken is staked in the gauge.
    event Deposited(address indexed caller, address indexed user, uint256 amount, bool lock, bool stake);

    /// @notice Event emitted when incentive tokens are received.
    /// @param caller Address of the caller.
    /// @param amount Amount of tokens received.
    event IncentiveReceived(address indexed caller, uint256 amount);

    /// @notice Event emitted when tokens are locked.
    /// @param user Address of the user.
    /// @param amount Amount of tokens locked.
    event TokenLocked(address indexed user, uint256 amount);

    /// @notice Event emitted when governance is changed.
    /// @param newGovernance Address of the new governance.
    event GovernanceChanged(address indexed newGovernance);

    /// @notice Event emitted when the sdToken Operator is changed.
    event SdTokenOperatorChanged(address indexed newSdToken);

    /// @notice Event emitted Incentive percent is changed.
    event FeesChanged(uint256 newFee);

    /// @notice Throws if caller is not the governance.
    error GOVERNANCE();

    /// @notice Throws if the deposit amount is zero.
    error AMOUNT_ZERO();

    /// @notice Throws if the address is zero.
    error ADDRESS_ZERO();

    ////////////////////////////////////////////////////////////////
    /// --- MODIFIERS
    ///////////////////////////////////////////////////////////////

    modifier onlyGovernance() {
        if (msg.sender != governance) revert GOVERNANCE();
        _;
    }

    constructor(address _token, address _locker, address _minter, address _gauge, uint256 _maxLockDuration) {
        governance = msg.sender;

        token = _token;
        gauge = _gauge;
        minter = _minter;
        locker = _locker;

        MAX_LOCK_DURATION = _maxLockDuration;

        /// Approve sdToken to gauge.
        if (gauge != address(0)) {
            IERC20(minter).safeApprove(gauge, type(uint256).max);
        }
    }

    ////////////////////////////////////////////////////////////////
    /// --- DEPOSIT & LOCK
    ///////////////////////////////////////////////////////////////

    /// @notice Initiate a lock in the Locker contract.
    /// @param _amount Amount of tokens to lock.
    function createLock(uint256 _amount) external virtual {
        /// Transfer tokens to this contract
        IERC20(token).safeTransferFrom(msg.sender, address(locker), _amount);

        /// Can be called only once.
        ILocker(locker).createLock(_amount, block.timestamp + MAX_LOCK_DURATION);

        /// Mint sdToken to msg.sender.
        ITokenMinter(minter).mint(msg.sender, _amount);

        emit CreateLock(_amount, block.timestamp + MAX_LOCK_DURATION);
    }

    /// @notice Deposit tokens, and receive sdToken or sdTokenGauge in return.
    /// @param _amount Amount of tokens to deposit.
    /// @param _lock Whether to lock the tokens in the locker contract.
    /// @param _stake Whether to stake the sdToken in the gauge.
    /// @param _user Address of the user to receive the sdToken.
    /// @dev If the lock is true, the tokens are directly sent to the locker and increase the lock amount as veToken.
    /// If the lock is false, the tokens are sent to this contract until someone locks them. A small percent of the deposit
    /// is used to incentivize users to lock the tokens.
    /// If the stake is true, the sdToken is staked in the gauge that distributes rewards. If the stake is false, the sdToken
    /// is sent to the user.
    function deposit(uint256 _amount, bool _lock, bool _stake, address _user) public {
        if (_amount == 0) revert AMOUNT_ZERO();
        if (_user == address(0)) revert ADDRESS_ZERO();

        /// If _lock is true, lock tokens in the locker contract.
        if (_lock) {
            /// Transfer tokens to this contract
            IERC20(token).safeTransferFrom(msg.sender, locker, _amount);

            /// Transfer the balance
            uint256 balance = IERC20(token).balanceOf(address(this));

            if (balance != 0) {
                IERC20(token).safeTransfer(locker, balance);
            }

            /// Lock the amount sent + balance of the contract.
            _lockToken(balance + _amount);

            /// If an incentive is available, add it to the amount.
            if (incentiveToken != 0) {
                _amount += incentiveToken;

                emit IncentiveReceived(msg.sender, incentiveToken);

                incentiveToken = 0;
            }
        } else {
            /// Transfer tokens to the locker contract and lock them.
            IERC20(token).safeTransferFrom(msg.sender, address(this), _amount);

            /// Compute call incentive and add to incentiveToken
            uint256 callIncentive = (_amount * lockIncentivePercent) / DENOMINATOR;

            /// Subtract call incentive from _amount
            _amount -= callIncentive;

            /// Add call incentive to incentiveToken
            incentiveToken += callIncentive;
        }
        // Mint sdtoken to the user if the gauge is not set
        if (_stake && gauge != address(0)) {
            /// Mint sdToken to this contract.
            ITokenMinter(minter).mint(address(this), _amount);

            /// Deposit sdToken into gauge for _user.
            ILiquidityGauge(gauge).deposit(_amount, _user);
        } else {
            /// Mint sdToken to _user.
            ITokenMinter(minter).mint(_user, _amount);
        }
        emit Deposited(msg.sender, _user, _amount, _lock, _stake);
    }

    /// @notice Lock tokens held by the contract
    /// @dev The contract must have Token to lock
    function lockToken() external {
        uint256 tokenBalance = IERC20(token).balanceOf(address(this));

        if (tokenBalance != 0) {
            /// Transfer tokens to the locker contract and lock them.
            IERC20(token).safeTransfer(locker, tokenBalance);
            _lockToken(tokenBalance);
        }

        /// If there is incentive available give it to the user calling lockToken.
        if (incentiveToken != 0) {
            /// Mint incentiveToken to msg.sender.
            ITokenMinter(minter).mint(msg.sender, incentiveToken);

            emit IncentiveReceived(msg.sender, incentiveToken);

            /// Reset incentiveToken.
            incentiveToken = 0;
        }
    }

    /// @notice Locks the tokens held by the contract
    /// @dev The contract must have tokens to lock
    function _lockToken(uint256 _amount) internal virtual {
        // If there is Token available in the contract transfer it to the locker
        if (_amount != 0) {
            /// Increase the lock.
            ILocker(locker).increaseLock(_amount, block.timestamp + MAX_LOCK_DURATION);

            emit TokenLocked(msg.sender, _amount);
        }
    }

    ////////////////////////////////////////////////////////////////
    /// --- GOVERNANCE PARAMETERS
    ///////////////////////////////////////////////////////////////

    /// @notice Transfer the governance to a new address.
    /// @param _governance Address of the new governance.
    function transferGovernance(address _governance) external onlyGovernance {
        futureGovernance = _governance;
    }

    /// @notice Accept the governance transfer.
    function acceptGovernance() external {
        if (msg.sender != futureGovernance) revert GOVERNANCE();

        governance = msg.sender;
        emit GovernanceChanged(msg.sender);
    }

    /// @notice Set the new operator for minting sdToken
    /// @param _minter operator minter address
    function setSdTokenMinterOperator(address _minter) external onlyGovernance {
        ISdToken(minter).setOperator(_minter);
        emit SdTokenOperatorChanged(_minter);
    }

    /// @notice Set the gauge to deposit sdToken
    /// @param _gauge gauge address
    function setGauge(address _gauge) external onlyGovernance {
        gauge = _gauge;
        if (_gauge != address(0)) {
            /// Approve sdToken to gauge.
            IERC20(minter).safeApprove(gauge, type(uint256).max);
        }
    }

    /// @notice Set the percentage of the lock incentive
    /// @param _lockIncentive Percentage of the lock incentive
    function setFees(uint256 _lockIncentive) external onlyGovernance {
        if (_lockIncentive >= 0 && _lockIncentive <= 30) {
            emit FeesChanged(lockIncentivePercent = _lockIncentive);
        }
    }
}

// src/base/extension/CurveExchangeDepositor.sol

/// @title CurveExchange
/// @notice Contract that accepts tokens and locks them in the Locker, minting sdToken in return
/// @dev Adapted for veCRV like Locker.
/// @author StakeDAO
/// @custom:contact [email protected]
abstract contract CurveExchangeDepositor is DepositorV4 {
    using SafeERC20 for IERC20;

    /// @notice Address of the sdToken pool.
    address public pool;

    /// @notice Event emitted when tokens are deposited.
    /// @param caller Address of the caller.
    /// @param user Address of the user.
    /// @param amount Amount of tokens deposited.
    /// @param stake Whether the sdToken is staked in the gauge.
    event Deposited(address indexed caller, address indexed user, uint256 amount, bool stake);

    constructor(
        address _token,
        address _locker,
        address _minter,
        address _gauge,
        uint256 _maxLockDuration,
        address _pool
    ) DepositorV4(_token, _locker, _minter, _gauge, _maxLockDuration) {
        pool = _pool;

        /// Approve sdToken to gauge.
        if (_pool != address(0)) {
            IERC20(_token).safeApprove(_pool, type(uint256).max);
        }
    }

    /// @notice Deposit using the sdToken pool.
    /// @param _amount Amount of tokens to deposit.
    /// @param _minAmount Minimum amount of tokens to receive.
    /// @param _stake Whether to stake the sdToken in the gauge.
    /// @param _user Address of the user.
    function deposit(uint256 _amount, uint256 _minAmount, bool _stake, address _user) public {
        if (_amount == 0) revert AMOUNT_ZERO();
        if (_user == address(0)) revert ADDRESS_ZERO();

        /// Transfer tokens from the user to the contract.
        IERC20(token).safeTransferFrom(msg.sender, address(this), _amount);

        // Mint sdtoken to the user if the gauge is not set
        if (_stake && gauge != address(0)) {
            _amount = _swap(_amount, _minAmount, address(this));

            /// Deposit sdToken into gauge for _user.
            ILiquidityGauge(gauge).deposit(_amount, _user);
        } else {
            _amount = _swap(_amount, _minAmount, _user);
        }

        emit Deposited(msg.sender, _user, _amount, _stake);
    }

    /// @notice Swap tokens using the sdToken pool.
    /// @param _amount Amount of tokens to swap.
    /// @param _minAmount Minimum amount of tokens to receive.
    /// @param _receiver Address of the receiver.
    function _swap(uint256 _amount, uint256 _minAmount, address _receiver) internal returns (uint256) {
        return ICurvePool(pool).exchange(0, 1, _amount, _minAmount, _receiver);
    }

    /// @notice Set the pool address.
    /// @param _pool Address of the sdToken pool
    function setPool(address _pool) external onlyGovernance {
        pool = _pool;

        /// Approve sdToken to gauge.
        if (_pool != address(0)) {
            IERC20(token).safeApprove(_pool, type(uint256).max);
        }
    }
}

// src/curve/depositor/CRVDepositorV2.sol

/// @title Depositor
/// @notice Contract that accepts tokens and locks them in the Locker, minting sdToken in return
/// @author StakeDAO
/// @custom:contact [email protected]
contract CRVDepositorV2 is CurveExchangeDepositor {
    /// @notice Address of the veCRV token.
    address public constant VE_CRV = 0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2;

    /// @notice Address of the sdveCRV token.
    address public constant SD_VE_CRV = 0x478bBC744811eE8310B461514BDc29D03739084D;

    constructor(address _token, address _locker, address _minter, address _gauge, address _pool)
        CurveExchangeDepositor(_token, _locker, _minter, _gauge, 4 * 365 days, _pool)
    {}

    /// Override the createLock function to prevent reverting.
    function createLock(uint256 _amount) external override {}

    /// @notice Locks the tokens held by the contract
    /// @dev The contract must have tokens to lock
    function _lockToken(uint256 _amount) internal override {
        // If there is Token available in the contract transfer it to the locker
        if (_amount != 0) {
            /// Increase the lock.
            ILocker(locker).increaseAmount(_amount);

            uint256 _unlockTime = block.timestamp + MAX_LOCK_DURATION;
            bool _canIncrease = (_unlockTime / 1 weeks * 1 weeks) > (IVeToken(VE_CRV).locked__end(locker));

            /// Increase the unlock time if the lock is not at the maximum duration.
            if (_canIncrease) {
                IExecutor(locker).execute(
                    VE_CRV, 0, abi.encodeWithSignature("increase_unlock_time(uint256)", _unlockTime)
                );
            }

            emit TokenLocked(msg.sender, _amount);
        }
    }

    /// @notice Lock forever (irreversible action) old sdveCrv to sdCrv with 1:1 rate.
    /// @param _amount Amount to lock.
    function lockSdveCrvToSdCrv(uint256 _amount) external {
        IERC20(SD_VE_CRV).transferFrom(msg.sender, address(this), _amount);
        // mint new sdCrv to the user
        ITokenMinter(minter).mint(msg.sender, _amount);
    }
}

Read Contract

DENOMINATOR 0x918f8674 → uint256
MAX_LOCK_DURATION 0x4f1bfc9e → uint256
SD_VE_CRV 0x6cb70257 → address
VE_CRV 0x8fa2b36b → address
futureGovernance 0x8070c503 → address
gauge 0xa6f19c84 → address
governance 0x5aa6e675 → address
incentiveToken 0x638126f8 → uint256
lockIncentivePercent 0xb7fa1ba7 → uint256
locker 0xd7b96d4e → address
minter 0x07546172 → address
pool 0x16f0115b → address
token 0xfc0c546a → address

Write Contract 11 functions

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

acceptGovernance 0x238efcbc
No parameters
createLock 0xf7d9d0c4
uint256 _amount
deposit 0x2968f616
uint256 _amount
uint256 _minAmount
bool _stake
address _user
deposit 0xd0f492f7
uint256 _amount
bool _lock
bool _stake
address _user
lockSdveCrvToSdCrv 0x684ed2b1
uint256 _amount
lockToken 0xbca7a9e2
No parameters
setFees 0x3d18678e
uint256 _lockIncentive
setGauge 0x55a68ed3
address _gauge
setPool 0x4437152a
address _pool
setSdTokenMinterOperator 0x601aff12
address _minter
transferGovernance 0xd38bfff4
address _governance

Recent Transactions

No transactions found for this address