Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Sponsored
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x6103c060 | 17478937 | 110 days 55 mins ago | IN | Create: CurveV1Adapter4Assets | 0 ETH | 0.13819427 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
CurveV1Adapter4Assets
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 2000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-2.0-or-later // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2023 pragma solidity ^0.8.17; import {IAdapter, AdapterType} from "../../interfaces/IAdapter.sol"; import {N_COINS} from "../../integrations/curve/ICurvePool_4.sol"; import {ICurveV1_4AssetsAdapter} from "../../interfaces/curve/ICurveV1_4AssetsAdapter.sol"; import {CurveV1AdapterBase} from "./CurveV1_Base.sol"; /// @title Curve V1 4 assets adapter interface /// @notice Implements logic allowing to interact with Curve pools with 4 assets contract CurveV1Adapter4Assets is CurveV1AdapterBase, ICurveV1_4AssetsAdapter { AdapterType public constant override(CurveV1AdapterBase, IAdapter) _gearboxAdapterType = AdapterType.CURVE_V1_4ASSETS; /// @notice Constructor /// @param _creditManager Credit manager address /// @param _curvePool Target Curve pool address /// @param _lp_token Pool LP token address /// @param _metapoolBase Base pool address (for metapools only) or zero address constructor(address _creditManager, address _curvePool, address _lp_token, address _metapoolBase) CurveV1AdapterBase(_creditManager, _curvePool, _lp_token, _metapoolBase, N_COINS) {} /// @inheritdoc ICurveV1_4AssetsAdapter function add_liquidity(uint256[N_COINS] calldata amounts, uint256) external creditFacadeOnly { _add_liquidity(amounts[0] > 1, amounts[1] > 1, amounts[2] > 1, amounts[3] > 1); // F: [ACV1_4-4] } /// @inheritdoc ICurveV1_4AssetsAdapter function remove_liquidity(uint256, uint256[N_COINS] calldata) external virtual creditFacadeOnly { _remove_liquidity(); // F: [ACV1_4-5] } /// @inheritdoc ICurveV1_4AssetsAdapter function remove_liquidity_imbalance(uint256[N_COINS] calldata amounts, uint256) external virtual override creditFacadeOnly { _remove_liquidity_imbalance(amounts[0] > 1, amounts[1] > 1, amounts[2] > 1, amounts[3] > 1); // F: [ACV1_4-6] } }
// SPDX-License-Identifier: GPL-2.0-or-later // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IACL } from "../interfaces/IACL.sol"; import { IAdapter } from "../interfaces/adapters/IAdapter.sol"; import { IAddressProvider } from "../interfaces/IAddressProvider.sol"; import { ICreditManagerV2 } from "../interfaces/ICreditManagerV2.sol"; import { IPoolService } from "../interfaces/IPoolService.sol"; import { ZeroAddressException } from "../interfaces/IErrors.sol"; /// @title Abstract adapter /// @dev Inheriting adapters MUST use provided internal functions to perform all operations with credit accounts abstract contract AbstractAdapter is IAdapter { /// @notice Credit Manager the adapter is connected to ICreditManagerV2 public immutable override creditManager; /// @notice Address provider IAddressProvider public immutable override addressProvider; /// @notice Address of the contract the adapter is interacting with address public immutable override targetContract; /// @notice ACL contract to check rights IACL public immutable override _acl; /// @notice Constructor /// @param _creditManager Credit Manager to connect this adapter to /// @param _targetContract Address of the contract this adapter should interact with constructor(address _creditManager, address _targetContract) { if (_creditManager == address(0) || _targetContract == address(0)) { revert ZeroAddressException(); // F: [AA-2] } creditManager = ICreditManagerV2(_creditManager); // F: [AA-1] addressProvider = IAddressProvider( IPoolService(creditManager.pool()).addressProvider() ); // F: [AA-1] targetContract = _targetContract; // F: [AA-1] _acl = IACL(addressProvider.getACL()); // F: [AA-1] } /// @notice Reverts if caller of the function is not configurator modifier configuratorOnly() { if (!_acl.isConfigurator(msg.sender)) revert CallerNotConfiguratorException(); // F: [AA-16] _; } /// @notice Reverts if caller of the function is not the Credit Facade /// @dev Adapter functions are only allowed to be called from within the multicall /// Since at this point Credit Account is owned by the Credit Facade, all functions /// of inheriting adapters that perform actions on account MUST have this modifier modifier creditFacadeOnly() { if (msg.sender != _creditFacade()) { revert CreditFacadeOnlyException(); // F: [AA-5] } _; } /// @dev Returns the Credit Facade connected to the Credit Manager function _creditFacade() internal view returns (address) { return creditManager.creditFacade(); // F: [AA-3] } /// @dev Returns the Credit Account currently owned by the Credit Facade /// @dev Inheriting adapters MUST use this function to find the account address function _creditAccount() internal view returns (address) { return creditManager.getCreditAccountOrRevert(_creditFacade()); // F: [AA-4] } /// @dev Returns collateral token mask of given token in the Credit Manager /// @param token Token to get the mask for /// @return tokenMask Collateral token mask /// @dev Reverts if token is not registered as collateral token in the Credit Manager function _getMaskOrRevert(address token) internal view returns (uint256 tokenMask) { tokenMask = creditManager.tokenMasksMap(token); // F: [AA-6] if (tokenMask == 0) { revert TokenNotAllowedException(); // F: [AA-6] } } /// @dev Approves the target contract to spend given token from the Credit Account /// @param token Token to be approved /// @param amount Amount to be approved /// @dev Reverts if token is not registered as collateral token in the Credit Manager function _approveToken(address token, uint256 amount) internal { creditManager.approveCreditAccount( _creditFacade(), targetContract, token, amount ); // F: [AA-7, AA-8] } /// @dev Enables a token in the Credit Account /// @param token Address of the token to enable /// @dev Reverts if token is not registered as collateral token in the Credit Manager function _enableToken(address token) internal { creditManager.checkAndEnableToken(_creditAccount(), token); // F: [AA-7, AA-9] } /// @dev Disables a token in the Credit Account /// @param token Address of the token to disable function _disableToken(address token) internal { creditManager.disableToken(_creditAccount(), token); // F: [AA-7, AA-10] } /// @dev Changes enabled tokens in the Credit Account /// @param tokensToEnable Bitmask of tokens that should be enabled /// @param tokensToDisable Bitmask of tokens that should be disabled /// @dev This function might be useful for adapters that work with limited set of tokens, whose masks can be /// determined in the adapter constructor, thus saving gas by avoiding querying them during execution /// and combining multiple enable/disable operations into a single one function _changeEnabledTokens( uint256 tokensToEnable, uint256 tokensToDisable ) internal { address creditAccount = _creditAccount(); // F: [AA-7] unchecked { uint256 tokensToChange = tokensToEnable ^ tokensToDisable; address token; uint256 mask = 1; while (mask <= tokensToChange) { if (tokensToChange & mask != 0) { (token, ) = creditManager.collateralTokensByMask(mask); if (tokensToEnable & mask != 0) { creditManager.checkAndEnableToken(creditAccount, token); // F: [AA-11] } else { creditManager.disableToken(creditAccount, token); // F: [AA-11] } } if (mask == 1 << 255) break; // F: [AA-11A] mask <<= 1; } } } /// @dev Executes an arbitrary call from the Credit Account to the target contract /// @param callData Data to call the target contract with /// @return result Call output function _execute(bytes memory callData) internal returns (bytes memory result) { return creditManager.executeOrder( _creditFacade(), targetContract, callData ); // F: [AA-7, AA-12] } /// @dev Executes a swap operation on the target contract from the Credit Account /// without explicit approval to spend `tokenIn` /// @param tokenIn The token that the call is expected to spend /// @param tokenOut The token that the call is expected to produce /// @param callData Data to call the target contract with /// @param disableTokenIn Whether the input token should be disabled afterwards /// (for operations that spend the entire balance) /// @return result Call output /// @dev Reverts if tokenIn or tokenOut are not registered as collateral in the Credit Manager function _executeSwapNoApprove( address tokenIn, address tokenOut, bytes memory callData, bool disableTokenIn ) internal returns (bytes memory result) { _getMaskOrRevert(tokenIn); // F: [AA-15] result = _executeSwap(tokenIn, tokenOut, callData, disableTokenIn); // F: [AA-7, AA-13] } /// @dev Executes a swap operation on the target contract from the Credit Account /// with maximal `tokenIn` allowance, and then sets the allowance to 1 /// @param tokenIn The token that the call is expected to spend /// @param tokenOut The token that the call is expected to produce /// @param callData Data to call the target contract with /// @param disableTokenIn Whether the input token should be disabled afterwards /// (for operations that spend the entire balance) /// @return result Call output /// @dev Reverts if tokenIn or tokenOut are not registered as collateral in the Credit Manager function _executeSwapSafeApprove( address tokenIn, address tokenOut, bytes memory callData, bool disableTokenIn ) internal returns (bytes memory result) { _approveToken(tokenIn, type(uint256).max); // F: [AA-14, AA-15] result = _executeSwap(tokenIn, tokenOut, callData, disableTokenIn); // F: [AA-7, AA-14] _approveToken(tokenIn, 1); // F: [AA-14] } /// @dev Implementation of `_executeSwap...` operations /// @dev Kept private as only the internal wrappers are intended to be used /// by inheritors function _executeSwap( address tokenIn, address tokenOut, bytes memory callData, bool disableTokenIn ) private returns (bytes memory result) { result = _execute(callData); // F: [AA-13, AA-14] if (disableTokenIn) { _disableToken(tokenIn); // F: [AA-13, AA-14] } _enableToken(tokenOut); // F: [AA-13, AA-14, AA-15] } }
// SPDX-License-Identifier: BUSL-1.1 // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; /// @title Claimable /// @dev Implements logic for a two-step ownership transfer on top of Ownable contract Claimable is Ownable { /// @dev The new owner that has not claimed ownership yet address public pendingOwner; /// @dev A modifier that restricts the function to the pending owner only modifier onlyPendingOwner() { if (msg.sender != pendingOwner) { revert("Claimable: Sender is not pending owner"); } _; } /// @dev Sets pending owner to the new owner, but does not /// transfer ownership yet /// @param newOwner The address to become the future owner function transferOwnership(address newOwner) public override onlyOwner { require( newOwner != address(0), "Claimable: new owner is the zero address" ); pendingOwner = newOwner; } /// @dev Used by the pending owner to claim ownership after transferOwnership function claimOwnership() external onlyPendingOwner { _transferOwnership(pendingOwner); pendingOwner = address(0); } }
// SPDX-License-Identifier: BUSL-1.1 // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IAddressProvider } from "../interfaces/IAddressProvider.sol"; import { Claimable } from "./access/Claimable.sol"; import { Errors } from "../libraries/Errors.sol"; // Repositories & services bytes32 constant CONTRACTS_REGISTER = "CONTRACTS_REGISTER"; bytes32 constant ACL = "ACL"; bytes32 constant PRICE_ORACLE = "PRICE_ORACLE"; bytes32 constant ACCOUNT_FACTORY = "ACCOUNT_FACTORY"; bytes32 constant DATA_COMPRESSOR = "DATA_COMPRESSOR"; bytes32 constant TREASURY_CONTRACT = "TREASURY_CONTRACT"; bytes32 constant GEAR_TOKEN = "GEAR_TOKEN"; bytes32 constant WETH_TOKEN = "WETH_TOKEN"; bytes32 constant WETH_GATEWAY = "WETH_GATEWAY"; bytes32 constant LEVERAGED_ACTIONS = "LEVERAGED_ACTIONS"; /// @title AddressRepository /// @notice Stores addresses of deployed contracts contract AddressProvider is Claimable, IAddressProvider { // Mapping from contract keys to respective addresses mapping(bytes32 => address) public addresses; // Contract version uint256 public constant version = 2; constructor() { // @dev Emits first event for contract discovery emit AddressSet("ADDRESS_PROVIDER", address(this)); } /// @return Address of ACL contract function getACL() external view returns (address) { return _getAddress(ACL); // F:[AP-3] } /// @dev Sets address of ACL contract /// @param _address Address of ACL contract function setACL(address _address) external onlyOwner // F:[AP-12] { _setAddress(ACL, _address); // F:[AP-3] } /// @return Address of ContractsRegister function getContractsRegister() external view returns (address) { return _getAddress(CONTRACTS_REGISTER); // F:[AP-4] } /// @dev Sets address of ContractsRegister /// @param _address Address of ContractsRegister function setContractsRegister(address _address) external onlyOwner // F:[AP-12] { _setAddress(CONTRACTS_REGISTER, _address); // F:[AP-4] } /// @return Address of PriceOracle function getPriceOracle() external view override returns (address) { return _getAddress(PRICE_ORACLE); // F:[AP-5] } /// @dev Sets address of PriceOracle /// @param _address Address of PriceOracle function setPriceOracle(address _address) external onlyOwner // F:[AP-12] { _setAddress(PRICE_ORACLE, _address); // F:[AP-5] } /// @return Address of AccountFactory function getAccountFactory() external view returns (address) { return _getAddress(ACCOUNT_FACTORY); // F:[AP-6] } /// @dev Sets address of AccountFactory /// @param _address Address of AccountFactory function setAccountFactory(address _address) external onlyOwner // F:[AP-12] { _setAddress(ACCOUNT_FACTORY, _address); // F:[AP-6] } /// @return Address of DataCompressor function getDataCompressor() external view override returns (address) { return _getAddress(DATA_COMPRESSOR); // F:[AP-7] } /// @dev Sets address of AccountFactory /// @param _address Address of AccountFactory function setDataCompressor(address _address) external onlyOwner // F:[AP-12] { _setAddress(DATA_COMPRESSOR, _address); // F:[AP-7] } /// @return Address of Treasury contract function getTreasuryContract() external view returns (address) { return _getAddress(TREASURY_CONTRACT); // F:[AP-8] } /// @dev Sets address of Treasury Contract /// @param _address Address of Treasury Contract function setTreasuryContract(address _address) external onlyOwner // F:[AP-12] { _setAddress(TREASURY_CONTRACT, _address); // F:[AP-8] } /// @return Address of GEAR token function getGearToken() external view override returns (address) { return _getAddress(GEAR_TOKEN); // F:[AP-9] } /// @dev Sets address of GEAR token /// @param _address Address of GEAR token function setGearToken(address _address) external onlyOwner // F:[AP-12] { _setAddress(GEAR_TOKEN, _address); // F:[AP-9] } /// @return Address of WETH token function getWethToken() external view override returns (address) { return _getAddress(WETH_TOKEN); // F:[AP-10] } /// @dev Sets address of WETH token /// @param _address Address of WETH token function setWethToken(address _address) external onlyOwner // F:[AP-12] { _setAddress(WETH_TOKEN, _address); // F:[AP-10] } /// @return Address of WETH token function getWETHGateway() external view override returns (address) { return _getAddress(WETH_GATEWAY); // F:[AP-11] } /// @dev Sets address of WETH token /// @param _address Address of WETH token function setWETHGateway(address _address) external onlyOwner // F:[AP-12] { _setAddress(WETH_GATEWAY, _address); // F:[AP-11] } /// @return Address of PathFinder function getLeveragedActions() external view returns (address) { return _getAddress(LEVERAGED_ACTIONS); // T:[AP-7] } /// @dev Sets address of PathFinder /// @param _address Address of PathFinder function setLeveragedActions(address _address) external onlyOwner // T:[AP-15] { _setAddress(LEVERAGED_ACTIONS, _address); // T:[AP-7] } /// @return Address of key, reverts if the key doesn't exist function _getAddress(bytes32 key) internal view returns (address) { address result = addresses[key]; require(result != address(0), Errors.AS_ADDRESS_NOT_FOUND); // F:[AP-1] return result; // F:[AP-3, 4, 5, 6, 7, 8, 9, 10, 11] } /// @dev Sets address to map by its key /// @param key Key in string format /// @param value Address function _setAddress(bytes32 key, address value) internal { addresses[key] = value; // F:[AP-3, 4, 5, 6, 7, 8, 9, 10, 11] emit AddressSet(key, value); // F:[AP-2] } }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IACL } from "../IACL.sol"; import { IAddressProvider } from "../IAddressProvider.sol"; import { ICreditManagerV2 } from "../ICreditManagerV2.sol"; // NOTE: new values must always be added at the end of the enum enum AdapterType { ABSTRACT, UNISWAP_V2_ROUTER, UNISWAP_V3_ROUTER, CURVE_V1_EXCHANGE_ONLY, YEARN_V2, CURVE_V1_2ASSETS, CURVE_V1_3ASSETS, CURVE_V1_4ASSETS, CURVE_V1_STECRV_POOL, CURVE_V1_WRAPPER, CONVEX_V1_BASE_REWARD_POOL, CONVEX_V1_BOOSTER, CONVEX_V1_CLAIM_ZAP, LIDO_V1, UNIVERSAL, LIDO_WSTETH_V1, BALANCER_VAULT, AAVE_V2_LENDING_POOL, AAVE_V2_WRAPPED_ATOKEN, COMPOUND_V2_CERC20, COMPOUND_V2_CETHER } interface IAdapterExceptions { /// @notice Thrown when adapter tries to use a token that's not a collateral token of the connected Credit Manager error TokenNotAllowedException(); /// @notice Thrown when caller of a `creditFacadeOnly` function is not the Credit Facade error CreditFacadeOnlyException(); /// @notice Thrown when caller of a `configuratorOnly` function is not configurator error CallerNotConfiguratorException(); } interface IAdapter is IAdapterExceptions { /// @notice Credit Manager the adapter is connected to function creditManager() external view returns (ICreditManagerV2); /// @notice Address of the contract the adapter is interacting with function targetContract() external view returns (address); /// @notice Address provider function addressProvider() external view returns (IAddressProvider); /// @notice ACL contract to check rights function _acl() external view returns (IACL); /// @notice Adapter type function _gearboxAdapterType() external pure returns (AdapterType); /// @notice Adapter version function _gearboxAdapterVersion() external pure returns (uint16); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IVersion } from "./IVersion.sol"; interface IACLExceptions { /// @dev Thrown when attempting to delete an address from a set that is not a pausable admin error AddressNotPausableAdminException(address addr); /// @dev Thrown when attempting to delete an address from a set that is not a unpausable admin error AddressNotUnpausableAdminException(address addr); } interface IACLEvents { /// @dev Emits when a new admin is added that can pause contracts event PausableAdminAdded(address indexed newAdmin); /// @dev Emits when a Pausable admin is removed event PausableAdminRemoved(address indexed admin); /// @dev Emits when a new admin is added that can unpause contracts event UnpausableAdminAdded(address indexed newAdmin); /// @dev Emits when an Unpausable admin is removed event UnpausableAdminRemoved(address indexed admin); } /// @title ACL interface interface IACL is IACLEvents, IACLExceptions, IVersion { /// @dev Returns true if the address is a pausable admin and false if not /// @param addr Address to check function isPausableAdmin(address addr) external view returns (bool); /// @dev Returns true if the address is unpausable admin and false if not /// @param addr Address to check function isUnpausableAdmin(address addr) external view returns (bool); /// @dev Returns true if an address has configurator rights /// @param account Address to check function isConfigurator(address account) external view returns (bool); /// @dev Returns address of configurator function owner() external view returns (address); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IVersion } from "./IVersion.sol"; interface IAddressProviderEvents { /// @dev Emits when an address is set for a contract role event AddressSet(bytes32 indexed service, address indexed newAddress); } /// @title Optimised for front-end Address Provider interface interface IAddressProvider is IAddressProviderEvents, IVersion { /// @return Address of ACL contract function getACL() external view returns (address); /// @return Address of ContractsRegister function getContractsRegister() external view returns (address); /// @return Address of AccountFactory function getAccountFactory() external view returns (address); /// @return Address of DataCompressor function getDataCompressor() external view returns (address); /// @return Address of GEAR token function getGearToken() external view returns (address); /// @return Address of WETH token function getWethToken() external view returns (address); /// @return Address of WETH Gateway function getWETHGateway() external view returns (address); /// @return Address of PriceOracle function getPriceOracle() external view returns (address); /// @return Address of DAO Treasury Multisig function getTreasuryContract() external view returns (address); /// @return Address of PathFinder function getLeveragedActions() external view returns (address); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IPriceOracleV2 } from "./IPriceOracle.sol"; import { IVersion } from "./IVersion.sol"; enum ClosureAction { CLOSE_ACCOUNT, LIQUIDATE_ACCOUNT, LIQUIDATE_EXPIRED_ACCOUNT, LIQUIDATE_PAUSED } interface ICreditManagerV2Events { /// @dev Emits when a call to an external contract is made through the Credit Manager event ExecuteOrder(address indexed borrower, address indexed target); /// @dev Emits when a configurator is upgraded event NewConfigurator(address indexed newConfigurator); } interface ICreditManagerV2Exceptions { /// @dev Thrown if an access-restricted function is called by an address that is not /// the connected Credit Facade, or an allowed adapter error AdaptersOrCreditFacadeOnlyException(); /// @dev Thrown if an access-restricted function is called by an address that is not /// the connected Credit Facade error CreditFacadeOnlyException(); /// @dev Thrown if an access-restricted function is called by an address that is not /// the connected Credit Configurator error CreditConfiguratorOnlyException(); /// @dev Thrown on attempting to open a Credit Account for or transfer a Credit Account /// to the zero address or an address that already owns a Credit Account error ZeroAddressOrUserAlreadyHasAccountException(); /// @dev Thrown on attempting to execute an order to an address that is not an allowed /// target contract error TargetContractNotAllowedException(); /// @dev Thrown on failing a full collateral check after an operation error NotEnoughCollateralException(); /// @dev Thrown on attempting to receive a token that is not a collateral token /// or was forbidden error TokenNotAllowedException(); /// @dev Thrown if an attempt to approve a collateral token to a target contract failed error AllowanceFailedException(); /// @dev Thrown on attempting to perform an action for an address that owns no Credit Account error HasNoOpenedAccountException(); /// @dev Thrown on attempting to add a token that is already in a collateral list error TokenAlreadyAddedException(); /// @dev Thrown on configurator attempting to add more than 256 collateral tokens error TooManyTokensException(); /// @dev Thrown if more than the maximal number of tokens were enabled on a Credit Account, /// and there are not enough unused token to disable error TooManyEnabledTokensException(); /// @dev Thrown when a reentrancy into the contract is attempted error ReentrancyLockException(); } /// @notice All Credit Manager functions are access-restricted and can only be called /// by the Credit Facade or allowed adapters. Users are not allowed to /// interact with the Credit Manager directly interface ICreditManagerV2 is ICreditManagerV2Events, ICreditManagerV2Exceptions, IVersion { // // CREDIT ACCOUNT MANAGEMENT // /// @dev Opens credit account and borrows funds from the pool. /// - Takes Credit Account from the factory; /// - Requests the pool to lend underlying to the Credit Account /// /// @param borrowedAmount Amount to be borrowed by the Credit Account /// @param onBehalfOf The owner of the newly opened Credit Account function openCreditAccount(uint256 borrowedAmount, address onBehalfOf) external returns (address); /// @dev Closes a Credit Account - covers both normal closure and liquidation /// - Checks whether the contract is paused, and, if so, if the payer is an emergency liquidator. /// Only emergency liquidators are able to liquidate account while the CM is paused. /// Emergency liquidations do not pay a liquidator premium or liquidation fees. /// - Calculates payments to various recipients on closure: /// + Computes amountToPool, which is the amount to be sent back to the pool. /// This includes the principal, interest and fees, but can't be more than /// total position value /// + Computes remainingFunds during liquidations - these are leftover funds /// after paying the pool and the liquidator, and are sent to the borrower /// + Computes protocol profit, which includes interest and liquidation fees /// + Computes loss if the totalValue is less than borrow amount + interest /// - Checks the underlying token balance: /// + if it is larger than amountToPool, then the pool is paid fully from funds on the Credit Account /// + else tries to transfer the shortfall from the payer - either the borrower during closure, or liquidator during liquidation /// - Send assets to the "to" address, as long as they are not included into skipTokenMask /// - If convertWETH is true, the function converts WETH into ETH before sending /// - Returns the Credit Account back to factory /// /// @param borrower Borrower address /// @param closureActionType Whether the account is closed, liquidated or liquidated due to expiry /// @param totalValue Portfolio value for liqution, 0 for ordinary closure /// @param payer Address which would be charged if credit account has not enough funds to cover amountToPool /// @param to Address to which the leftover funds will be sent /// @param skipTokenMask Tokenmask contains 1 for tokens which needed to be skipped for sending /// @param convertWETH If true converts WETH to ETH function closeCreditAccount( address borrower, ClosureAction closureActionType, uint256 totalValue, address payer, address to, uint256 skipTokenMask, bool convertWETH ) external returns (uint256 remainingFunds); /// @dev Manages debt size for borrower: /// /// - Increase debt: /// + Increases debt by transferring funds from the pool to the credit account /// + Updates the cumulative index to keep interest the same. Since interest /// is always computed dynamically as borrowedAmount * (cumulativeIndexNew / cumulativeIndexOpen - 1), /// cumulativeIndexOpen needs to be updated, as the borrow amount has changed /// /// - Decrease debt: /// + Repays debt partially + all interest and fees accrued thus far /// + Updates cunulativeIndex to cumulativeIndex now /// /// @param creditAccount Address of the Credit Account to change debt for /// @param amount Amount to increase / decrease the principal by /// @param increase True to increase principal, false to decrease /// @return newBorrowedAmount The new debt principal function manageDebt( address creditAccount, uint256 amount, bool increase ) external returns (uint256 newBorrowedAmount); /// @dev Adds collateral to borrower's credit account /// @param payer Address of the account which will be charged to provide additional collateral /// @param creditAccount Address of the Credit Account /// @param token Collateral token to add /// @param amount Amount to add function addCollateral( address payer, address creditAccount, address token, uint256 amount ) external; /// @dev Transfers Credit Account ownership to another address /// @param from Address of previous owner /// @param to Address of new owner function transferAccountOwnership(address from, address to) external; /// @dev Requests the Credit Account to approve a collateral token to another contract. /// @param borrower Borrower's address /// @param targetContract Spender to change allowance for /// @param token Collateral token to approve /// @param amount New allowance amount function approveCreditAccount( address borrower, address targetContract, address token, uint256 amount ) external; /// @dev Requests a Credit Account to make a low-level call with provided data /// This is the intended pathway for state-changing interactions with 3rd-party protocols /// @param borrower Borrower's address /// @param targetContract Contract to be called /// @param data Data to pass with the call function executeOrder( address borrower, address targetContract, bytes memory data ) external returns (bytes memory); // // COLLATERAL VALIDITY AND ACCOUNT HEALTH CHECKS // /// @dev Enables a token on a Credit Account, including it /// into account health and total value calculations /// @param creditAccount Address of a Credit Account to enable the token for /// @param token Address of the token to be enabled function checkAndEnableToken(address creditAccount, address token) external; /// @dev Optimized health check for individual swap-like operations. /// @notice Fast health check assumes that only two tokens (input and output) /// participate in the operation and computes a % change in weighted value between /// inbound and outbound collateral. The cumulative negative change across several /// swaps in sequence cannot be larger than feeLiquidation (a fee that the /// protocol is ready to waive if needed). Since this records a % change /// between just two tokens, the corresponding % change in TWV will always be smaller, /// which makes this check safe. /// More details at https://dev.gearbox.fi/docs/documentation/risk/fast-collateral-check#fast-check-protection /// @param creditAccount Address of the Credit Account /// @param tokenIn Address of the token spent by the swap /// @param tokenOut Address of the token received from the swap /// @param balanceInBefore Balance of tokenIn before the operation /// @param balanceOutBefore Balance of tokenOut before the operation function fastCollateralCheck( address creditAccount, address tokenIn, address tokenOut, uint256 balanceInBefore, uint256 balanceOutBefore ) external; /// @dev Performs a full health check on an account, summing up /// value of all enabled collateral tokens /// @param creditAccount Address of the Credit Account to check function fullCollateralCheck(address creditAccount) external; /// @dev Checks that the number of enabled tokens on a Credit Account /// does not violate the maximal enabled token limit and tries /// to disable unused tokens if it does /// @param creditAccount Account to check enabled tokens for function checkAndOptimizeEnabledTokens(address creditAccount) external; /// @dev Disables a token on a credit account /// @notice Usually called by adapters to disable spent tokens during a multicall, /// but can also be called separately from the Credit Facade to remove /// unwanted tokens /// @return True if token mask was change otherwise False function disableToken(address creditAccount, address token) external returns (bool); // // GETTERS // /// @dev Returns the address of a borrower's Credit Account, or reverts if there is none. /// @param borrower Borrower's address function getCreditAccountOrRevert(address borrower) external view returns (address); /// @dev Computes amounts that must be sent to various addresses before closing an account /// @param totalValue Credit Accounts total value in underlying /// @param closureActionType Type of account closure /// * CLOSE_ACCOUNT: The account is healthy and is closed normally /// * LIQUIDATE_ACCOUNT: The account is unhealthy and is being liquidated to avoid bad debt /// * LIQUIDATE_EXPIRED_ACCOUNT: The account has expired and is being liquidated (lowered liquidation premium) /// * LIQUIDATE_PAUSED: The account is liquidated while the system is paused due to emergency (no liquidation premium) /// @param borrowedAmount Credit Account's debt principal /// @param borrowedAmountWithInterest Credit Account's debt principal + interest /// @return amountToPool Amount of underlying to be sent to the pool /// @return remainingFunds Amount of underlying to be sent to the borrower (only applicable to liquidations) /// @return profit Protocol's profit from fees (if any) /// @return loss Protocol's loss from bad debt (if any) function calcClosePayments( uint256 totalValue, ClosureAction closureActionType, uint256 borrowedAmount, uint256 borrowedAmountWithInterest ) external view returns ( uint256 amountToPool, uint256 remainingFunds, uint256 profit, uint256 loss ); /// @dev Calculates the debt accrued by a Credit Account /// @param creditAccount Address of the Credit Account /// @return borrowedAmount The debt principal /// @return borrowedAmountWithInterest The debt principal + accrued interest /// @return borrowedAmountWithInterestAndFees The debt principal + accrued interest and protocol fees function calcCreditAccountAccruedInterest(address creditAccount) external view returns ( uint256 borrowedAmount, uint256 borrowedAmountWithInterest, uint256 borrowedAmountWithInterestAndFees ); /// @dev Maps Credit Accounts to bit masks encoding their enabled token sets /// Only enabled tokens are counted as collateral for the Credit Account /// @notice An enabled token mask encodes an enabled token by setting /// the bit at the position equal to token's index to 1 function enabledTokensMap(address creditAccount) external view returns (uint256); /// @dev Maps the Credit Account to its current percentage drop across all swaps since /// the last full check, in RAY format function cumulativeDropAtFastCheckRAY(address creditAccount) external view returns (uint256); /// @dev Returns the collateral token at requested index and its liquidation threshold /// @param id The index of token to return function collateralTokens(uint256 id) external view returns (address token, uint16 liquidationThreshold); /// @dev Returns the collateral token with requested mask and its liquidationThreshold /// @param tokenMask Token mask corresponding to the token function collateralTokensByMask(uint256 tokenMask) external view returns (address token, uint16 liquidationThreshold); /// @dev Total number of known collateral tokens. function collateralTokensCount() external view returns (uint256); /// @dev Returns the mask for the provided token /// @param token Token to returns the mask for function tokenMasksMap(address token) external view returns (uint256); /// @dev Bit mask encoding a set of forbidden tokens function forbiddenTokenMask() external view returns (uint256); /// @dev Maps allowed adapters to their respective target contracts. function adapterToContract(address adapter) external view returns (address); /// @dev Maps 3rd party contracts to their respective adapters function contractToAdapter(address targetContract) external view returns (address); /// @dev Address of the underlying asset function underlying() external view returns (address); /// @dev Address of the connected pool function pool() external view returns (address); /// @dev Address of the connected pool /// @notice [DEPRECATED]: use pool() instead. function poolService() external view returns (address); /// @dev A map from borrower addresses to Credit Account addresses function creditAccounts(address borrower) external view returns (address); /// @dev Address of the connected Credit Configurator function creditConfigurator() external view returns (address); /// @dev Address of WETH function wethAddress() external view returns (address); /// @dev Returns the liquidation threshold for the provided token /// @param token Token to retrieve the LT for function liquidationThresholds(address token) external view returns (uint16); /// @dev The maximal number of enabled tokens on a single Credit Account function maxAllowedEnabledTokenLength() external view returns (uint8); /// @dev Maps addresses to their status as emergency liquidator. /// @notice Emergency liquidators are trusted addresses /// that are able to liquidate positions while the contracts are paused, /// e.g. when there is a risk of bad debt while an exploit is being patched. /// In the interest of fairness, emergency liquidators do not receive a premium /// And are compensated by the Gearbox DAO separately. function canLiquidateWhilePaused(address) external view returns (bool); /// @dev Returns the fee parameters of the Credit Manager /// @return feeInterest Percentage of interest taken by the protocol as profit /// @return feeLiquidation Percentage of account value taken by the protocol as profit /// during unhealthy account liquidations /// @return liquidationDiscount Multiplier that reduces the effective totalValue during unhealthy account liquidations, /// allowing the liquidator to take the unaccounted for remainder as premium. Equal to (1 - liquidationPremium) /// @return feeLiquidationExpired Percentage of account value taken by the protocol as profit /// during expired account liquidations /// @return liquidationDiscountExpired Multiplier that reduces the effective totalValue during expired account liquidations, /// allowing the liquidator to take the unaccounted for remainder as premium. Equal to (1 - liquidationPremiumExpired) function fees() external view returns ( uint16 feeInterest, uint16 feeLiquidation, uint16 liquidationDiscount, uint16 feeLiquidationExpired, uint16 liquidationDiscountExpired ); /// @dev Address of the connected Credit Facade function creditFacade() external view returns (address); /// @dev Address of the connected Price Oracle function priceOracle() external view returns (IPriceOracleV2); /// @dev Address of the universal adapter function universalAdapter() external view returns (address); /// @dev Contract's version function version() external view returns (uint256); /// @dev Paused() state function checkEmergencyPausable(address caller, bool state) external returns (bool); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; /// @dev Common contract exceptions /// @dev Thrown on attempting to set an important address to zero address error ZeroAddressException(); /// @dev Thrown on attempting to call a non-implemented function error NotImplementedException(); /// @dev Thrown on attempting to set an EOA as an important contract in the system error AddressIsNotContractException(address); /// @dev Thrown on attempting to use a non-ERC20 contract or an EOA as a token error IncorrectTokenContractException(); /// @dev Thrown on attempting to set a token price feed to an address that is not a /// correct price feed error IncorrectPriceFeedException(); /// @dev Thrown on attempting to call an access restricted function as a non-Configurator error CallerNotConfiguratorException(); /// @dev Thrown on attempting to call an access restricted function as a non-Configurator error CallerNotControllerException(); /// @dev Thrown on attempting to pause a contract as a non-Pausable admin error CallerNotPausableAdminException(); /// @dev Thrown on attempting to pause a contract as a non-Unpausable admin error CallerNotUnPausableAdminException();
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import "../core/AddressProvider.sol"; import { IVersion } from "./IVersion.sol"; interface IPoolServiceEvents { /// @dev Emits on new liquidity being added to the pool event AddLiquidity( address indexed sender, address indexed onBehalfOf, uint256 amount, uint256 referralCode ); /// @dev Emits on liquidity being removed to the pool event RemoveLiquidity( address indexed sender, address indexed to, uint256 amount ); /// @dev Emits on a Credit Manager borrowing funds for a Credit Account event Borrow( address indexed creditManager, address indexed creditAccount, uint256 amount ); /// @dev Emits on repayment of a Credit Account's debt event Repay( address indexed creditManager, uint256 borrowedAmount, uint256 profit, uint256 loss ); /// @dev Emits on updating the interest rate model event NewInterestRateModel(address indexed newInterestRateModel); /// @dev Emits on connecting a new Credit Manager event NewCreditManagerConnected(address indexed creditManager); /// @dev Emits when a Credit Manager is forbidden to borrow event BorrowForbidden(address indexed creditManager); /// @dev Emitted when loss is incurred that can't be covered by treasury funds event UncoveredLoss(address indexed creditManager, uint256 loss); /// @dev Emits when the liquidity limit is changed event NewExpectedLiquidityLimit(uint256 newLimit); /// @dev Emits when the withdrawal fee is changed event NewWithdrawFee(uint256 fee); } /// @title Pool Service Interface /// @notice Implements business logic: /// - Adding/removing pool liquidity /// - Managing diesel tokens & diesel rates /// - Taking/repaying Credit Manager debt /// More: https://dev.gearbox.fi/developers/pool/abstractpoolservice interface IPoolService is IPoolServiceEvents, IVersion { // // LIQUIDITY MANAGEMENT // /** * @dev Adds liquidity to pool * - transfers the underlying to the pool * - mints Diesel (LP) tokens to onBehalfOf * @param amount Amount of tokens to be deposited * @param onBehalfOf The address that will receive the dToken * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without a facilitator. */ function addLiquidity( uint256 amount, address onBehalfOf, uint256 referralCode ) external; /** * @dev Removes liquidity from pool * - burns LP's Diesel (LP) tokens * - returns the equivalent amount of underlying to 'to' * @param amount Amount of Diesel tokens to burn * @param to Address to transfer the underlying to */ function removeLiquidity(uint256 amount, address to) external returns (uint256); /** * @dev Lends pool funds to a Credit Account * @param borrowedAmount Credit Account's debt principal * @param creditAccount Credit Account's address */ function lendCreditAccount(uint256 borrowedAmount, address creditAccount) external; /** * @dev Repays the Credit Account's debt * @param borrowedAmount Amount of principal ro repay * @param profit The treasury profit from repayment * @param loss Amount of underlying that the CA wan't able to repay * @notice Assumes that the underlying (including principal + interest + fees) * was already transferred */ function repayCreditAccount( uint256 borrowedAmount, uint256 profit, uint256 loss ) external; // // GETTERS // /** * @dev Returns the total amount of liquidity in the pool, including borrowed and available funds */ function expectedLiquidity() external view returns (uint256); /** * @dev Returns the limit on total liquidity */ function expectedLiquidityLimit() external view returns (uint256); /** * @dev Returns the available liquidity, which is expectedLiquidity - totalBorrowed */ function availableLiquidity() external view returns (uint256); /** * @dev Calculates the current interest index, RAY format */ function calcLinearCumulative_RAY() external view returns (uint256); /** * @dev Calculates the current borrow rate, RAY format */ function borrowAPY_RAY() external view returns (uint256); /** * @dev Returns the total borrowed amount (includes principal only) */ function totalBorrowed() external view returns (uint256); /** * ç **/ function getDieselRate_RAY() external view returns (uint256); /** * @dev Returns the address of the underlying */ function underlyingToken() external view returns (address); /** * @dev Returns the address of the diesel token */ function dieselToken() external view returns (address); /** * @dev Returns the address of a Credit Manager by its id */ function creditManagers(uint256 id) external view returns (address); /** * @dev Returns the number of known Credit Managers */ function creditManagersCount() external view returns (uint256); /** * @dev Maps Credit Manager addresses to their status as a borrower. * Returns false if borrowing is not allowed. */ function creditManagersCanBorrow(address id) external view returns (bool); /// @dev Converts a quantity of the underlying to Diesel tokens function toDiesel(uint256 amount) external view returns (uint256); /// @dev Converts a quantity of Diesel tokens to the underlying function fromDiesel(uint256 amount) external view returns (uint256); /// @dev Returns the withdrawal fee function withdrawFee() external view returns (uint256); /// @dev Returns the timestamp of the pool's last update function _timestampLU() external view returns (uint256); /// @dev Returns the interest index at the last pool update function _cumulativeIndex_RAY() external view returns (uint256); /// @dev Returns the address provider function addressProvider() external view returns (AddressProvider); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; import { IVersion } from "./IVersion.sol"; interface IPriceOracleV2Events { /// @dev Emits when a new price feed is added event NewPriceFeed(address indexed token, address indexed priceFeed); } interface IPriceOracleV2Exceptions { /// @dev Thrown if a price feed returns 0 error ZeroPriceException(); /// @dev Thrown if the last recorded result was not updated in the last round error ChainPriceStaleException(); /// @dev Thrown on attempting to get a result for a token that does not have a price feed error PriceOracleNotExistsException(); } /// @title Price oracle interface interface IPriceOracleV2 is IPriceOracleV2Events, IPriceOracleV2Exceptions, IVersion { /// @dev Converts a quantity of an asset to USD (decimals = 8). /// @param amount Amount to convert /// @param token Address of the token to be converted function convertToUSD(uint256 amount, address token) external view returns (uint256); /// @dev Converts a quantity of USD (decimals = 8) to an equivalent amount of an asset /// @param amount Amount to convert /// @param token Address of the token converted to function convertFromUSD(uint256 amount, address token) external view returns (uint256); /// @dev Converts one asset into another /// /// @param amount Amount to convert /// @param tokenFrom Address of the token to convert from /// @param tokenTo Address of the token to convert to function convert( uint256 amount, address tokenFrom, address tokenTo ) external view returns (uint256); /// @dev Returns collateral values for two tokens, required for a fast check /// @param amountFrom Amount of the outbound token /// @param tokenFrom Address of the outbound token /// @param amountTo Amount of the inbound token /// @param tokenTo Address of the inbound token /// @return collateralFrom Value of the outbound token amount in USD /// @return collateralTo Value of the inbound token amount in USD function fastCheck( uint256 amountFrom, address tokenFrom, uint256 amountTo, address tokenTo ) external view returns (uint256 collateralFrom, uint256 collateralTo); /// @dev Returns token's price in USD (8 decimals) /// @param token The token to compute the price for function getPrice(address token) external view returns (uint256); /// @dev Returns the price feed address for the passed token /// @param token Token to get the price feed for function priceFeeds(address token) external view returns (address priceFeed); /// @dev Returns the price feed for the passed token, /// with additional parameters /// @param token Token to get the price feed for function priceFeedsWithFlags(address token) external view returns ( address priceFeed, bool skipCheck, uint256 decimals ); } interface IPriceOracleV2Ext is IPriceOracleV2 { /// @dev Sets a price feed if it doesn't exist, or updates an existing one /// @param token Address of the token to set the price feed for /// @param priceFeed Address of a USD price feed adhering to Chainlink's interface function addPriceFeed(address token, address priceFeed) external; }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; /// @title IVersion /// @dev Declares a version function which returns the contract's version interface IVersion { /// @dev Returns contract version function version() external view returns (uint256); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; // Denominations uint256 constant WAD = 1e18; uint256 constant RAY = 1e27; // 25% of type(uint256).max uint256 constant ALLOWANCE_THRESHOLD = type(uint96).max >> 3; // FEE = 50% uint16 constant DEFAULT_FEE_INTEREST = 50_00; // 50% // LIQUIDATION_FEE 1.5% uint16 constant DEFAULT_FEE_LIQUIDATION = 1_50; // 1.5% // LIQUIDATION PREMIUM 4% uint16 constant DEFAULT_LIQUIDATION_PREMIUM = 4_00; // 4% // LIQUIDATION_FEE_EXPIRED 2% uint16 constant DEFAULT_FEE_LIQUIDATION_EXPIRED = 1_00; // 2% // LIQUIDATION PREMIUM EXPIRED 2% uint16 constant DEFAULT_LIQUIDATION_PREMIUM_EXPIRED = 2_00; // 2% // DEFAULT PROPORTION OF MAX BORROWED PER BLOCK TO MAX BORROWED PER ACCOUNT uint16 constant DEFAULT_LIMIT_PER_BLOCK_MULTIPLIER = 2; // Seconds in a year uint256 constant SECONDS_PER_YEAR = 365 days; uint256 constant SECONDS_PER_ONE_AND_HALF_YEAR = (SECONDS_PER_YEAR * 3) / 2; // OPERATIONS // Leverage decimals - 100 is equal to 2x leverage (100% * collateral amount + 100% * borrowed amount) uint8 constant LEVERAGE_DECIMALS = 100; // Maximum withdraw fee for pool in PERCENTAGE_FACTOR format uint8 constant MAX_WITHDRAW_FEE = 100; uint256 constant EXACT_INPUT = 1; uint256 constant EXACT_OUTPUT = 2; address constant UNIVERSAL_CONTRACT = 0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC;
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2022 pragma solidity ^0.8.10; /// @title Errors library library Errors { // // COMMON // string public constant ZERO_ADDRESS_IS_NOT_ALLOWED = "Z0"; string public constant NOT_IMPLEMENTED = "NI"; string public constant INCORRECT_PATH_LENGTH = "PL"; string public constant INCORRECT_ARRAY_LENGTH = "CR"; string public constant REGISTERED_CREDIT_ACCOUNT_MANAGERS_ONLY = "CP"; string public constant REGISTERED_POOLS_ONLY = "RP"; string public constant INCORRECT_PARAMETER = "IP"; // // MATH // string public constant MATH_MULTIPLICATION_OVERFLOW = "M1"; string public constant MATH_ADDITION_OVERFLOW = "M2"; string public constant MATH_DIVISION_BY_ZERO = "M3"; // // POOL // string public constant POOL_CONNECTED_CREDIT_MANAGERS_ONLY = "PS0"; string public constant POOL_INCOMPATIBLE_CREDIT_ACCOUNT_MANAGER = "PS1"; string public constant POOL_MORE_THAN_EXPECTED_LIQUIDITY_LIMIT = "PS2"; string public constant POOL_INCORRECT_WITHDRAW_FEE = "PS3"; string public constant POOL_CANT_ADD_CREDIT_MANAGER_TWICE = "PS4"; // // ACCOUNT FACTORY // string public constant AF_CANT_CLOSE_CREDIT_ACCOUNT_IN_THE_SAME_BLOCK = "AF1"; string public constant AF_MINING_IS_FINISHED = "AF2"; string public constant AF_CREDIT_ACCOUNT_NOT_IN_STOCK = "AF3"; string public constant AF_EXTERNAL_ACCOUNTS_ARE_FORBIDDEN = "AF4"; // // ADDRESS PROVIDER // string public constant AS_ADDRESS_NOT_FOUND = "AP1"; // // CONTRACTS REGISTER // string public constant CR_POOL_ALREADY_ADDED = "CR1"; string public constant CR_CREDIT_MANAGER_ALREADY_ADDED = "CR2"; // // CREDIT ACCOUNT // string public constant CA_CONNECTED_CREDIT_MANAGER_ONLY = "CA1"; string public constant CA_FACTORY_ONLY = "CA2"; // // ACL // string public constant ACL_CALLER_NOT_PAUSABLE_ADMIN = "ACL1"; string public constant ACL_CALLER_NOT_CONFIGURATOR = "ACL2"; // // WETH GATEWAY // string public constant WG_DESTINATION_IS_NOT_WETH_COMPATIBLE = "WG1"; string public constant WG_RECEIVE_IS_NOT_ALLOWED = "WG2"; string public constant WG_NOT_ENOUGH_FUNDS = "WG3"; // // TOKEN DISTRIBUTOR // string public constant TD_WALLET_IS_ALREADY_CONNECTED_TO_VC = "TD1"; string public constant TD_INCORRECT_WEIGHTS = "TD2"; string public constant TD_NON_ZERO_BALANCE_AFTER_DISTRIBUTION = "TD3"; string public constant TD_CONTRIBUTOR_IS_NOT_REGISTERED = "TD4"; }
// SPDX-License-Identifier: GPL-2.0-or-later // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2023 pragma solidity ^0.8.17; import {AbstractAdapter} from "@gearbox-protocol/core-v2/contracts/adapters/AbstractAdapter.sol";
// SPDX-License-Identifier: GPL-2.0-or-later // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2023 pragma solidity ^0.8.17; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {ZeroAddressException} from "@gearbox-protocol/core-v2/contracts/interfaces/IErrors.sol"; import {RAY} from "@gearbox-protocol/core-v2/contracts/libraries/Constants.sol"; import {AbstractAdapter} from "../AbstractAdapter.sol"; import {AdapterType} from "../../interfaces/IAdapter.sol"; import {ICurvePool} from "../../integrations/curve/ICurvePool.sol"; import {ICurvePool2Assets} from "../../integrations/curve/ICurvePool_2.sol"; import {ICurvePool3Assets} from "../../integrations/curve/ICurvePool_3.sol"; import {ICurvePool4Assets} from "../../integrations/curve/ICurvePool_4.sol"; import {ICurveV1Adapter} from "../../interfaces/curve/ICurveV1Adapter.sol"; uint256 constant ZERO = 0; /// @title Curve V1 base adapter /// @notice Implements logic allowing to interact with all Curve pools, regardless of number of coins contract CurveV1AdapterBase is AbstractAdapter, ICurveV1Adapter { using SafeCast for uint256; using SafeCast for int256; uint16 public constant override _gearboxAdapterVersion = 2; function _gearboxAdapterType() external pure virtual override returns (AdapterType) { return AdapterType.CURVE_V1_EXCHANGE_ONLY; } /// @inheritdoc ICurveV1Adapter address public immutable override token; /// @inheritdoc ICurveV1Adapter address public immutable override lp_token; /// @inheritdoc ICurveV1Adapter uint256 public immutable override lpTokenMask; /// @inheritdoc ICurveV1Adapter address public immutable override metapoolBase; /// @inheritdoc ICurveV1Adapter uint256 public immutable override nCoins; /// @inheritdoc ICurveV1Adapter bool public immutable override use256; /// @inheritdoc ICurveV1Adapter address public immutable token0; /// @inheritdoc ICurveV1Adapter address public immutable token1; /// @inheritdoc ICurveV1Adapter address public immutable token2; /// @inheritdoc ICurveV1Adapter address public immutable token3; /// @inheritdoc ICurveV1Adapter uint256 public immutable override token0Mask; /// @inheritdoc ICurveV1Adapter uint256 public immutable override token1Mask; /// @inheritdoc ICurveV1Adapter uint256 public immutable override token2Mask; /// @inheritdoc ICurveV1Adapter uint256 public immutable override token3Mask; /// @inheritdoc ICurveV1Adapter address public immutable override underlying0; /// @inheritdoc ICurveV1Adapter address public immutable override underlying1; /// @inheritdoc ICurveV1Adapter address public immutable override underlying2; /// @inheritdoc ICurveV1Adapter address public immutable override underlying3; /// @inheritdoc ICurveV1Adapter uint256 public immutable override underlying0Mask; /// @inheritdoc ICurveV1Adapter uint256 public immutable override underlying1Mask; /// @inheritdoc ICurveV1Adapter uint256 public immutable override underlying2Mask; /// @inheritdoc ICurveV1Adapter uint256 public immutable override underlying3Mask; /// @notice Constructor /// @param _creditManager Credit manager address /// @param _curvePool Target Curve pool address /// @param _lp_token Pool LP token address /// @param _metapoolBase Base pool address (for metapools only) or zero address /// @param _nCoins Number of coins in the pool constructor(address _creditManager, address _curvePool, address _lp_token, address _metapoolBase, uint256 _nCoins) AbstractAdapter(_creditManager, _curvePool) { if (_lp_token == address(0)) revert ZeroAddressException(); // F: [ACV1-1] lpTokenMask = _getMaskOrRevert(_lp_token); // F: [ACV1-2] token = _lp_token; // F: [ACV1-2] lp_token = _lp_token; // F: [ACV1-2] metapoolBase = _metapoolBase; // F: [ACV1-2] nCoins = _nCoins; // F: [ACV1-2] { bool _use256; /// Only Curve v2 pools have mid_fee, so it can be used to determine /// whether to use int128 or uint256 function signatures try ICurvePool(targetContract).mid_fee() returns (uint256) { _use256 = true; } catch { _use256 = false; } use256 = _use256; } address[4] memory tokens; uint256[4] memory tokenMasks; for (uint256 i = 0; i < nCoins;) { address currentCoin; try ICurvePool(targetContract).coins(i) returns (address tokenAddress) { currentCoin = tokenAddress; } catch { try ICurvePool(targetContract).coins(i.toInt256().toInt128()) returns (address tokenAddress) { currentCoin = tokenAddress; } catch {} } if (currentCoin == address(0)) revert ZeroAddressException(); // F: [ACV1-1] uint256 currentMask = _getMaskOrRevert(currentCoin); tokens[i] = currentCoin; tokenMasks[i] = currentMask; unchecked { ++i; } } token0 = tokens[0]; // F: [ACV1-2] token1 = tokens[1]; // F: [ACV1-2] token2 = tokens[2]; // F: [ACV1-2] token3 = tokens[3]; // F: [ACV1-2] token0Mask = tokenMasks[0]; // F: [ACV1-2] token1Mask = tokenMasks[1]; // F: [ACV1-2] token2Mask = tokenMasks[2]; // F: [ACV1-2] token3Mask = tokenMasks[3]; // F: [ACV1-2] tokens = [address(0), address(0), address(0), address(0)]; tokenMasks = [ZERO, ZERO, ZERO, ZERO]; for (uint256 i = 0; i < 4;) { address currentCoin; uint256 currentMask; if (metapoolBase != address(0)) { if (i == 0) { currentCoin = token0; } else { try ICurvePool(metapoolBase).coins(i - 1) returns (address tokenAddress) { currentCoin = tokenAddress; } catch {} } } else { try ICurvePool(targetContract).underlying_coins(i) returns (address tokenAddress) { currentCoin = tokenAddress; } catch { try ICurvePool(targetContract).underlying_coins(i.toInt256().toInt128()) returns ( address tokenAddress ) { currentCoin = tokenAddress; } catch {} } } if (currentCoin != address(0)) { currentMask = _getMaskOrRevert(currentCoin); // F: [ACV1-1] } tokens[i] = currentCoin; tokenMasks[i] = currentMask; unchecked { ++i; } } underlying0 = tokens[0]; // F: [ACV1-2] underlying1 = tokens[1]; // F: [ACV1-2] underlying2 = tokens[2]; // F: [ACV1-2] underlying3 = tokens[3]; // F: [ACV1-2] underlying0Mask = tokenMasks[0]; // F: [ACV1-2] underlying1Mask = tokenMasks[1]; // F: [ACV1-2] underlying2Mask = tokenMasks[2]; // F: [ACV1-2] underlying3Mask = tokenMasks[3]; // F: [ACV1-2] } /// -------- /// /// EXCHANGE /// /// -------- /// /// @inheritdoc ICurveV1Adapter function exchange(int128 i, int128 j, uint256, uint256) external override creditFacadeOnly { _exchange(i, j); } /// @inheritdoc ICurveV1Adapter function exchange(uint256 i, uint256 j, uint256, uint256) external override creditFacadeOnly { _exchange(i.toInt256().toInt128(), j.toInt256().toInt128()); } /// @dev Internal implementation of `exchange` function _exchange(int128 i, int128 j) internal { _exchange_impl(i, j, msg.data, false, false); // F: [ACV1-4] } /// @inheritdoc ICurveV1Adapter function exchange_all(int128 i, int128 j, uint256 rateMinRAY) external override creditFacadeOnly { _exchange_all(i, j, rateMinRAY); } /// @inheritdoc ICurveV1Adapter function exchange_all(uint256 i, uint256 j, uint256 rateMinRAY) external override creditFacadeOnly { _exchange_all(i.toInt256().toInt128(), j.toInt256().toInt128(), rateMinRAY); } /// @dev Internal implementation of `exchange_all` function _exchange_all(int128 i, int128 j, uint256 rateMinRAY) internal { address creditAccount = _creditAccount(); // F: [ACV1-3] address tokenIn = _get_token(i, false); // F: [ACV1-5] uint256 dx = IERC20(tokenIn).balanceOf(creditAccount); // F: [ACV1-5] if (dx <= 1) return; unchecked { dx--; } uint256 min_dy = (dx * rateMinRAY) / RAY; // F: [ACV1-5] _exchange_impl(i, j, _getExchangeCallData(i, j, dx, min_dy, false), false, true); // F: [ACV1-5] } /// @inheritdoc ICurveV1Adapter function exchange_underlying(int128 i, int128 j, uint256, uint256) external override creditFacadeOnly { _exchange_underlying(i, j); } /// @inheritdoc ICurveV1Adapter function exchange_underlying(uint256 i, uint256 j, uint256, uint256) external override creditFacadeOnly { _exchange_underlying(i.toInt256().toInt128(), j.toInt256().toInt128()); } /// @dev Internal implementation of `exchange_underlying` function _exchange_underlying(int128 i, int128 j) internal { _exchange_impl(i, j, msg.data, true, false); // F: [ACV1-6] } /// @inheritdoc ICurveV1Adapter function exchange_all_underlying(int128 i, int128 j, uint256 rateMinRAY) external override creditFacadeOnly { _exchange_all_underlying(i, j, rateMinRAY); } /// @inheritdoc ICurveV1Adapter function exchange_all_underlying(uint256 i, uint256 j, uint256 rateMinRAY) external override creditFacadeOnly { _exchange_all_underlying(i.toInt256().toInt128(), j.toInt256().toInt128(), rateMinRAY); } /// @dev Internal implementation of `exchange_all_underlying` function _exchange_all_underlying(int128 i, int128 j, uint256 rateMinRAY) internal { address creditAccount = _creditAccount(); //F: [ACV1-3] address tokenIn = _get_token(i, true); // F: [ACV1-7] uint256 dx = IERC20(tokenIn).balanceOf(creditAccount); // F: [ACV1-7] if (dx <= 1) return; unchecked { dx--; // F: [ACV1-7] } uint256 min_dy = (dx * rateMinRAY) / RAY; // F: [ACV1-7] _exchange_impl(i, j, _getExchangeCallData(i, j, dx, min_dy, true), true, true); // F: [ACV1-7] } /// @dev Internal implementation of exchange functions /// - passes calldata to the target contract /// - sets max approval for the input token before the call and resets it to 1 after /// - enables output asset after the call /// - disables input asset only when exchanging the entire balance function _exchange_impl(int128 i, int128 j, bytes memory callData, bool underlying, bool disableTokenIn) internal { _approve_token(i, underlying, type(uint256).max); _execute(callData); _approve_token(i, underlying, 1); _changeEnabledTokens(_get_token_mask(j, underlying), disableTokenIn ? _get_token_mask(i, underlying) : 0); } /// @dev Returns calldata for `ICurvePool.exchange` and `ICurvePool.exchange_underlying` calls function _getExchangeCallData(int128 i, int128 j, uint256 dx, uint256 min_dy, bool underlying) internal view returns (bytes memory) { if (use256) { return underlying ? abi.encodeWithSignature( "exchange_underlying(uint256,uint256,uint256,uint256)", uint256(int256(i)), uint256(int256(j)), dx, min_dy ) : abi.encodeWithSignature( "exchange(uint256,uint256,uint256,uint256)", uint256(int256(i)), uint256(int256(j)), dx, min_dy ); } else { return underlying ? abi.encodeWithSignature("exchange_underlying(int128,int128,uint256,uint256)", i, j, dx, min_dy) : abi.encodeWithSignature("exchange(int128,int128,uint256,uint256)", i, j, dx, min_dy); } } /// ------------- /// /// ADD LIQUIDITY /// /// ------------- /// /// @dev Internal implementation of `add_liquidity` /// - passes calldata to the target contract /// - sets max approvals for the specified tokens before the call and resets them to 1 after /// - enables LP token function _add_liquidity(bool t0Approve, bool t1Approve, bool t2Approve, bool t3Approve) internal { _approve_tokens(t0Approve, t1Approve, t2Approve, t3Approve, type(uint256).max); _execute(msg.data); _approve_tokens(t0Approve, t1Approve, t2Approve, t3Approve, 1); _changeEnabledTokens(lpTokenMask, 0); } /// @inheritdoc ICurveV1Adapter function add_liquidity_one_coin(uint256 amount, int128 i, uint256 minAmount) external override creditFacadeOnly { _add_liquidity_one_coin(amount, i, minAmount); } /// @inheritdoc ICurveV1Adapter function add_liquidity_one_coin(uint256 amount, uint256 i, uint256 minAmount) external override creditFacadeOnly { _add_liquidity_one_coin(amount, i.toInt256().toInt128(), minAmount); } /// @dev Internal implementation of `add_liquidity_one_coin` function _add_liquidity_one_coin(uint256 amount, int128 i, uint256 minAmount) internal { _add_liquidity_one_coin_impl(i, _getAddLiquidityOneCoinCallData(i, amount, minAmount), false); // F: [ACV1-8] } /// @inheritdoc ICurveV1Adapter function add_all_liquidity_one_coin(int128 i, uint256 rateMinRAY) external override creditFacadeOnly { _add_all_liquidity_one_coin(i, rateMinRAY); } /// @inheritdoc ICurveV1Adapter function add_all_liquidity_one_coin(uint256 i, uint256 rateMinRAY) external override creditFacadeOnly { _add_all_liquidity_one_coin(i.toInt256().toInt128(), rateMinRAY); } /// @dev Internal implementation of `add_all_liquidity_one_coin` function _add_all_liquidity_one_coin(int128 i, uint256 rateMinRAY) internal { address creditAccount = _creditAccount(); address tokenIn = _get_token(i, false); uint256 amount = IERC20(tokenIn).balanceOf(creditAccount); // F: [ACV1-9] if (amount <= 1) return; unchecked { amount--; // F: [ACV1-9] } uint256 minAmount = (amount * rateMinRAY) / RAY; // F: [ACV1-9] _add_liquidity_one_coin_impl(i, _getAddLiquidityOneCoinCallData(i, amount, minAmount), true); // F: [ACV1-9] } /// @dev Internal implementation of `add_liquidity_one_coin` and `add_all_liquidity_one_coin` /// - passes calldata to the target contract /// - sets max approval for the input token before the call and resets it to 1 after /// - enables LP token /// - disables input token only when adding the entire balance function _add_liquidity_one_coin_impl(int128 i, bytes memory callData, bool disableTokenIn) internal { _approve_token(i, false, type(uint256).max); _execute(callData); _approve_token(i, false, 1); _changeEnabledTokens(lpTokenMask, disableTokenIn ? _get_token_mask(i, false) : 0); } /// @dev Returns calldata for `ICurvePool.add_liquidity` with one input asset function _getAddLiquidityOneCoinCallData(int128 i, uint256 amount, uint256 minAmount) internal view returns (bytes memory) { if (nCoins == 2) { uint256[2] memory amounts; if (i > 1) revert IncorrectIndexException(); amounts[uint256(uint128(i))] = amount; return abi.encodeCall(ICurvePool2Assets.add_liquidity, (amounts, minAmount)); // F: [ACV1-8, ACV1-9] } if (nCoins == 3) { uint256[3] memory amounts; if (i > 2) revert IncorrectIndexException(); amounts[uint256(uint128(i))] = amount; return abi.encodeCall(ICurvePool3Assets.add_liquidity, (amounts, minAmount)); // F: [ACV1-8, ACV1-9] } if (nCoins == 4) { uint256[4] memory amounts; if (i > 3) revert IncorrectIndexException(); amounts[uint256(uint128(i))] = amount; return abi.encodeCall(ICurvePool4Assets.add_liquidity, (amounts, minAmount)); // F: [ACV1-8, ACV1-9] } revert("Incorrect nCoins"); } /// ---------------- /// /// REMOVE LIQUIDITY /// /// ---------------- /// /// @dev Internal implementation of `remove_liquidity` /// - passes calldata to the target contract /// - enables all pool tokens function _remove_liquidity() internal { _execute(msg.data); _changeEnabledTokens(token0Mask | token1Mask | token2Mask | token3Mask, 0); // F: [ACV1_2-5, ACV1_3-5, ACV1_4-5] } /// @dev Internal implementation of `remove_liquidity_imbalance` /// - passes calldata to the target contract /// - enables specified pool tokens function _remove_liquidity_imbalance(bool t0Enable, bool t1Enable, bool t2Enable, bool t3Enable) internal { _execute(msg.data); uint256 tokensMask; if (t0Enable) tokensMask |= _get_token_mask(0, false); // F: [ACV1_2-6, ACV1_3-6, ACV1_4-6] if (t1Enable) tokensMask |= _get_token_mask(1, false); // F: [ACV1_2-6, ACV1_3-6, ACV1_4-6] if (t2Enable) tokensMask |= _get_token_mask(2, false); // F: [ACV1_3-6, ACV1_4-6] if (t3Enable) tokensMask |= _get_token_mask(3, false); // F: [ACV1_4-6] _changeEnabledTokens(tokensMask, 0); // F: [ACV1_2-6, ACV1_3-6, ACV1_4-6] } /// @inheritdoc ICurveV1Adapter function remove_liquidity_one_coin(uint256, int128 i, uint256) external virtual override creditFacadeOnly { _remove_liquidity_one_coin(i); } /// @inheritdoc ICurveV1Adapter function remove_liquidity_one_coin(uint256, uint256 i, uint256) external override creditFacadeOnly { _remove_liquidity_one_coin(i.toInt256().toInt128()); } /// @dev Internal implementation of `remove_liquidity_one_coin` function _remove_liquidity_one_coin(int128 i) internal { _remove_liquidity_one_coin_impl(i, msg.data, false); // F: [ACV1-10] } /// @inheritdoc ICurveV1Adapter function remove_all_liquidity_one_coin(int128 i, uint256 rateMinRAY) external virtual override creditFacadeOnly { _remove_all_liquidity_one_coin(i, rateMinRAY); } /// @inheritdoc ICurveV1Adapter function remove_all_liquidity_one_coin(uint256 i, uint256 rateMinRAY) external override creditFacadeOnly { _remove_all_liquidity_one_coin(i.toInt256().toInt128(), rateMinRAY); } /// @dev Internal implementation of `remove_all_liquidity_one_coin` function _remove_all_liquidity_one_coin(int128 i, uint256 rateMinRAY) internal { address creditAccount = _creditAccount(); uint256 amount = IERC20(lp_token).balanceOf(creditAccount); // F: [ACV1-11] if (amount <= 1) return; unchecked { amount--; // F: [ACV1-11] } uint256 minAmount = (amount * rateMinRAY) / RAY; // F: [ACV1-11] _remove_liquidity_one_coin_impl(i, _getRemoveLiquidityOneCoinCallData(i, amount, minAmount), true); // F: [ACV1-11] } /// @dev Internal implementation of `remove_liquidity_one_coin` and `remove_all_liquidity_one_coin` /// - passes calldata to the targe contract /// - enables received asset /// - disables LP token only when removing all liquidity function _remove_liquidity_one_coin_impl(int128 i, bytes memory callData, bool disableLP) internal { _execute(callData); _changeEnabledTokens(_get_token_mask(i, false), disableLP ? lpTokenMask : 0); } /// @dev Returns calldata for `ICurvePool.remove_liquidity_one_coin` call function _getRemoveLiquidityOneCoinCallData(int128 i, uint256 amount, uint256 minAmount) internal view returns (bytes memory) { if (use256) { return abi.encodeWithSignature( "remove_liquidity_one_coin(uint256,uint256,uint256)", amount, uint256(int256(i)), minAmount ); } else { return abi.encodeWithSignature("remove_liquidity_one_coin(uint256,int128,uint256)", amount, i, minAmount); } } /// ------- /// /// HELPERS /// /// ------- /// /// @dev Returns token `i`'s address function _get_token(int128 i, bool underlying) internal view returns (address addr) { if (i == 0) { addr = underlying ? underlying0 : token0; } else if (i == 1) { addr = underlying ? underlying1 : token1; } else if (i == 2) { addr = underlying ? underlying2 : token2; } else if (i == 3) { addr = underlying ? underlying3 : token3; } if (addr == address(0)) revert IncorrectIndexException(); } /// @dev Returns token `i`'s mask function _get_token_mask(int128 i, bool underlying) internal view returns (uint256 mask) { if (i == 0) { mask = underlying ? underlying0Mask : token0Mask; } else if (i == 1) { mask = underlying ? underlying1Mask : token1Mask; } else if (i == 2) { mask = underlying ? underlying2Mask : token2Mask; } else if (i == 3) { mask = underlying ? underlying3Mask : token3Mask; } if (mask == 0) revert IncorrectIndexException(); } /// @dev Sets target contract's approval for token `i` to `amount` function _approve_token(int128 i, bool underlying, uint256 amount) internal { _approveToken(_get_token(i, underlying), amount); } /// @dev Sets target contract's approval for specified tokens to `amount` function _approve_tokens(bool t0Approve, bool t1Approve, bool t2Approve, bool t3Approve, uint256 amount) internal { if (t0Approve) _approveToken(token0, amount); // F: [ACV1_2-4, ACV1_3-4, ACV1_4-4] if (t1Approve) _approveToken(token1, amount); // F: [ACV1_2-4, ACV1_3-4, ACV1_4-4] if (t2Approve) _approveToken(token2, amount); // F: [ACV1_3-4, ACV1_4-4] if (t3Approve) _approveToken(token3, amount); // F: [ACV1_4-4] } /// @inheritdoc ICurveV1Adapter function calc_add_one_coin(uint256 amount, int128 i) public view returns (uint256) { if (nCoins == 2) { return i == 0 ? ICurvePool2Assets(targetContract).calc_token_amount([amount, 0], true) : ICurvePool2Assets(targetContract).calc_token_amount([0, amount], true); } else if (nCoins == 3) { return i == 0 ? ICurvePool3Assets(targetContract).calc_token_amount([amount, 0, 0], true) : i == 1 ? ICurvePool3Assets(targetContract).calc_token_amount([0, amount, 0], true) : ICurvePool3Assets(targetContract).calc_token_amount([0, 0, amount], true); } else if (nCoins == 4) { return i == 0 ? ICurvePool4Assets(targetContract).calc_token_amount([amount, 0, 0, 0], true) : i == 1 ? ICurvePool4Assets(targetContract).calc_token_amount([0, amount, 0, 0], true) : i == 2 ? ICurvePool4Assets(targetContract).calc_token_amount([0, 0, amount, 0], true) : ICurvePool4Assets(targetContract).calc_token_amount([0, 0, 0, amount], true); } else { revert("Incorrect nCoins"); } } /// @inheritdoc ICurveV1Adapter function calc_add_one_coin(uint256 amount, uint256 i) external view returns (uint256) { return calc_add_one_coin(amount, i.toInt256().toInt128()); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import {ICurvePool} from "./ICurvePool.sol"; uint256 constant N_COINS = 2; /// @title ICurvePool2Assets /// @dev Extends original pool contract with liquidity functions interface ICurvePool2Assets is ICurvePool { function add_liquidity(uint256[N_COINS] memory amounts, uint256 min_mint_amount) external; function remove_liquidity(uint256 _amount, uint256[N_COINS] memory min_amounts) external; function remove_liquidity_imbalance(uint256[N_COINS] calldata amounts, uint256 max_burn_amount) external; function calc_token_amount(uint256[N_COINS] calldata _amounts, bool _is_deposit) external view returns (uint256); function get_twap_balances( uint256[N_COINS] calldata _first_balances, uint256[N_COINS] calldata _last_balances, uint256 _time_elapsed ) external view returns (uint256[N_COINS] memory); function get_balances() external view returns (uint256[N_COINS] memory); function get_previous_balances() external view returns (uint256[N_COINS] memory); function get_price_cumulative_last() external view returns (uint256[N_COINS] memory); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import {ICurvePool} from "./ICurvePool.sol"; uint256 constant N_COINS = 3; /// @title ICurvePool3Assets /// @dev Extends original pool contract with liquidity functions interface ICurvePool3Assets is ICurvePool { function add_liquidity(uint256[N_COINS] memory amounts, uint256 min_mint_amount) external; function remove_liquidity(uint256 _amount, uint256[N_COINS] memory min_amounts) external; function remove_liquidity_imbalance(uint256[N_COINS] memory amounts, uint256 max_burn_amount) external; function calc_token_amount(uint256[N_COINS] calldata _amounts, bool _is_deposit) external view returns (uint256); function get_twap_balances( uint256[N_COINS] calldata _first_balances, uint256[N_COINS] calldata _last_balances, uint256 _time_elapsed ) external view returns (uint256[N_COINS] memory); function get_balances() external view returns (uint256[N_COINS] memory); function get_previous_balances() external view returns (uint256[N_COINS] memory); function get_price_cumulative_last() external view returns (uint256[N_COINS] memory); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; import {ICurvePool} from "./ICurvePool.sol"; uint256 constant N_COINS = 4; /// @title ICurvePool4Assets /// @dev Extends original pool contract with liquidity functions interface ICurvePool4Assets is ICurvePool { function add_liquidity(uint256[N_COINS] memory amounts, uint256 min_mint_amount) external; function remove_liquidity(uint256 _amount, uint256[N_COINS] memory min_amounts) external; function remove_liquidity_imbalance(uint256[N_COINS] memory amounts, uint256 max_burn_amount) external; function calc_token_amount(uint256[N_COINS] calldata _amounts, bool _is_deposit) external view returns (uint256); function get_twap_balances( uint256[N_COINS] calldata _first_balances, uint256[N_COINS] calldata _last_balances, uint256 _time_elapsed ) external view returns (uint256[N_COINS] memory); function get_balances() external view returns (uint256[N_COINS] memory); function get_previous_balances() external view returns (uint256[N_COINS] memory); function get_price_cumulative_last() external view returns (uint256[N_COINS] memory); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.10; interface ICurvePool { function coins(uint256 i) external view returns (address); function underlying_coins(uint256 i) external view returns (address); function balances(uint256 i) external view returns (uint256); function coins(int128) external view returns (address); function underlying_coins(int128) external view returns (address); function balances(int128) external view returns (uint256); function exchange(int128 i, int128 j, uint256 dx, uint256 min_dy) external; function exchange(uint256 i, uint256 j, uint256 dx, uint256 min_dy) external; function exchange_underlying(int128 i, int128 j, uint256 dx, uint256 min_dy) external; function exchange_underlying(uint256 i, uint256 j, uint256 dx, uint256 min_dy) external; function get_dy_underlying(int128 i, int128 j, uint256 dx) external view returns (uint256); function get_dy_underlying(uint256 i, uint256 j, uint256 dx) external view returns (uint256); function get_dy(int128 i, int128 j, uint256 dx) external view returns (uint256); function get_dy(uint256 i, uint256 j, uint256 dx) external view returns (uint256); function get_virtual_price() external view returns (uint256); function virtual_price() external view returns (uint256); function token() external view returns (address); function remove_liquidity_one_coin(uint256 _token_amount, int128 i, uint256 min_amount) external; function remove_liquidity_one_coin(uint256 _token_amount, uint256 i, uint256 min_amount) external; function A() external view returns (uint256); function A_precise() external view returns (uint256); function calc_withdraw_one_coin(uint256 _burn_amount, int128 i) external view returns (uint256); function calc_withdraw_one_coin(uint256 _burn_amount, uint256 i) external view returns (uint256); function admin_balances(uint256 i) external view returns (uint256); function admin() external view returns (address); function fee() external view returns (uint256); function admin_fee() external view returns (uint256); function block_timestamp_last() external view returns (uint256); function initial_A() external view returns (uint256); function future_A() external view returns (uint256); function initial_A_time() external view returns (uint256); function future_A_time() external view returns (uint256); function mid_fee() external view returns (uint256); // Some pools implement ERC20 function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint256); function balanceOf(address) external view returns (uint256); function allowance(address, address) external view returns (uint256); function totalSupply() external view returns (uint256); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2023 pragma solidity ^0.8.17; import {N_COINS} from "../../integrations/curve/ICurvePool_4.sol"; import {ICurveV1Adapter} from "./ICurveV1Adapter.sol"; /// @title Curve V1 4 assets adapter interface /// @notice Implements logic allowing to interact with Curve pools with 4 assets interface ICurveV1_4AssetsAdapter is ICurveV1Adapter { /// @notice Add liquidity to the pool /// @param amounts Amounts of tokens to add /// @dev `min_mint_amount` parameter is ignored because calldata is passed directly to the target contract function add_liquidity(uint256[N_COINS] calldata amounts, uint256) external; /// @notice Remove liquidity from the pool /// @dev '_amount' and 'min_amounts' parameters are ignored because calldata is directly passed to the target contract function remove_liquidity(uint256, uint256[N_COINS] calldata) external; /// @notice Withdraw exact amounts of tokens from the pool /// @param amounts Amounts of tokens to withdraw /// @dev `max_burn_amount` parameter is ignored because calldata is directly passed to the target contract function remove_liquidity_imbalance(uint256[N_COINS] calldata amounts, uint256) external; }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2023 pragma solidity ^0.8.17; import {IAdapter} from "../IAdapter.sol"; interface ICurveV1AdapterExceptions { /// @notice Thrown when trying to pass incorrect asset index as parameter to an adapter function error IncorrectIndexException(); } /// @title Curve V1 base adapter interface /// @notice Implements logic allowing to interact with all Curve pools, regardless of number of coins interface ICurveV1Adapter is IAdapter, ICurveV1AdapterExceptions { /// @notice Exchanges one pool asset to another /// @param i Index of the asset to spend /// @param j Index of the asset to receive /// @dev `dx` and `min_dy` parameters are ignored because calldata is passed directly to the target contract function exchange(int128 i, int128 j, uint256, uint256) external; /// @notice `exchange` wrapper to support newer pools which accept uint256 for token indices function exchange(uint256 i, uint256 j, uint256, uint256) external; /// @notice Exchanges the entire balance of one pool asset to another, disables input asset /// @param i Index of the asset to spend /// @param j Index of the asset to receive /// @param rateMinRAY Minimum exchange rate between assets i and j, scaled by 1e27 function exchange_all(int128 i, int128 j, uint256 rateMinRAY) external; /// @notice `exchange_all` wrapper to support newer pools which accept uint256 for token indices function exchange_all(uint256 i, uint256 j, uint256 rateMinRAY) external; /// @notice Exchanges one pool's underlying asset to another /// @param i Index of the underlying asset to spend /// @param j Index of the underlying asset to receive /// @dev `dx` and `min_dy` parameters are ignored because calldata is passed directly to the target contract function exchange_underlying(int128 i, int128 j, uint256, uint256) external; /// @notice `exchange_underlying` wrapper to support newer pools which accept uint256 for token indices function exchange_underlying(uint256 i, uint256 j, uint256, uint256) external; /// @notice Exchanges the entire balance of one pool's underlying asset to another, disables input asset /// @param i Index of the underlying asset to spend /// @param j Index of the underlying asset to receive /// @param rateMinRAY Minimum exchange rate between underlying assets i and j, scaled by 1e27 function exchange_all_underlying(int128 i, int128 j, uint256 rateMinRAY) external; /// @notice `exchange_all_underlying` wrapper to support newer pools which accept uint256 for token indices function exchange_all_underlying(uint256 i, uint256 j, uint256 rateMinRAY) external; /// @notice Adds given amount of asset as liquidity to the pool /// @param amount Amount to deposit /// @param i Index of the asset to deposit /// @param minAmount Minimum amount of LP tokens to receive function add_liquidity_one_coin(uint256 amount, int128 i, uint256 minAmount) external; /// @notice `add_liquidity_one_coin` wrapper to support newer pools which accept uint256 for token indices function add_liquidity_one_coin(uint256 amount, uint256 i, uint256 minAmount) external; /// @notice Adds the entire balance of asset as liquidity to the pool, disables this asset /// @param i Index of the asset to deposit /// @param rateMinRAY Minimum exchange rate between deposited asset and LP token, scaled by 1e27 function add_all_liquidity_one_coin(int128 i, uint256 rateMinRAY) external; /// @notice `add_all_liquidity_one_coin` wrapper to support newer pools which accept uint256 for token indices function add_all_liquidity_one_coin(uint256 i, uint256 rateMinRAY) external; /// @notice Removes liquidity from the pool in a specified asset /// @param i Index of the asset to withdraw /// @dev `_token_amount` and `min_amount` parameters are ignored because calldata is passed directly to the target contract function remove_liquidity_one_coin(uint256, int128 i, uint256) external; /// @notice `remove_liquidity_one_coin` wrapper to support newer pools which accept uint256 for token indices function remove_liquidity_one_coin(uint256, uint256 i, uint256) external; /// @notice Removes all liquidity from the pool in a specified asset /// @param i Index of the asset to withdraw /// @param rateMinRAY Minimum exchange rate between LP token and received token, scaled by 1e27 function remove_all_liquidity_one_coin(int128 i, uint256 rateMinRAY) external; /// @notice `remove_all_liquidity_one_coin` wrapper to support newer pools which accept uint256 for token indices function remove_all_liquidity_one_coin(uint256 i, uint256 rateMinRAY) external; /// @notice Pool LP token address (added for backward compatibility) function token() external view returns (address); /// @notice Pool LP token address function lp_token() external view returns (address); /// @notice Collateral token mask of pool LP token in the credit manager function lpTokenMask() external view returns (uint256); /// @notice Base pool address (for metapools only) function metapoolBase() external view returns (address); /// @notice Number of coins in the pool function nCoins() external view returns (uint256); /// @notice Whether to use uint256 for token indexes in write functions function use256() external view returns (bool); /// @notice Token in the pool under index 0 function token0() external view returns (address); /// @notice Token in the pool under index 1 function token1() external view returns (address); /// @notice Token in the pool under index 2 function token2() external view returns (address); /// @notice Token in the pool under index 3 function token3() external view returns (address); /// @notice Collateral token mask of token0 in the credit manager function token0Mask() external view returns (uint256); /// @notice Collateral token mask of token1 in the credit manager function token1Mask() external view returns (uint256); /// @notice Collateral token mask of token2 in the credit manager function token2Mask() external view returns (uint256); /// @notice Collateral token mask of token3 in the credit manager function token3Mask() external view returns (uint256); /// @notice Underlying in the pool under index 0 function underlying0() external view returns (address); /// @notice Underlying in the pool under index 1 function underlying1() external view returns (address); /// @notice Underlying in the pool under index 2 function underlying2() external view returns (address); /// @notice Underlying in the pool under index 3 function underlying3() external view returns (address); /// @notice Collateral token mask of underlying0 in the credit manager function underlying0Mask() external view returns (uint256); /// @notice Collateral token mask of underlying1 in the credit manager function underlying1Mask() external view returns (uint256); /// @notice Collateral token mask of underlying2 in the credit manager function underlying2Mask() external view returns (uint256); /// @notice Collateral token mask of underlying3 in the credit manager function underlying3Mask() external view returns (uint256); /// @notice Returns the amount of LP token received for adding a single asset to the pool /// @param amount Amount to deposit /// @param i Index of the asset to deposit function calc_add_one_coin(uint256 amount, int128 i) external view returns (uint256); /// @notice `calc_add_one_coin` wrapper to support newer pools which accept uint256 for token indices function calc_add_one_coin(uint256 amount, uint256 i) external view returns (uint256); }
// SPDX-License-Identifier: MIT // Gearbox Protocol. Generalized leverage for DeFi protocols // (c) Gearbox Holdings, 2023 pragma solidity ^0.8.17; import {IAdapter, AdapterType} from "@gearbox-protocol/core-v2/contracts/interfaces/adapters/IAdapter.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.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); }
// 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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
{ "optimizer": { "enabled": true, "runs": 2000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_creditManager","type":"address"},{"internalType":"address","name":"_curvePool","type":"address"},{"internalType":"address","name":"_lp_token","type":"address"},{"internalType":"address","name":"_metapoolBase","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CallerNotConfiguratorException","type":"error"},{"inputs":[],"name":"CreditFacadeOnlyException","type":"error"},{"inputs":[],"name":"IncorrectIndexException","type":"error"},{"inputs":[],"name":"TokenNotAllowedException","type":"error"},{"inputs":[],"name":"ZeroAddressException","type":"error"},{"inputs":[],"name":"_acl","outputs":[{"internalType":"contract IACL","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_gearboxAdapterType","outputs":[{"internalType":"enum AdapterType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_gearboxAdapterVersion","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"rateMinRAY","type":"uint256"}],"name":"add_all_liquidity_one_coin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int128","name":"i","type":"int128"},{"internalType":"uint256","name":"rateMinRAY","type":"uint256"}],"name":"add_all_liquidity_one_coin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[4]","name":"amounts","type":"uint256[4]"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"add_liquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"minAmount","type":"uint256"}],"name":"add_liquidity_one_coin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"int128","name":"i","type":"int128"},{"internalType":"uint256","name":"minAmount","type":"uint256"}],"name":"add_liquidity_one_coin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addressProvider","outputs":[{"internalType":"contract IAddressProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"int128","name":"i","type":"int128"}],"name":"calc_add_one_coin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"i","type":"uint256"}],"name":"calc_add_one_coin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creditManager","outputs":[{"internalType":"contract ICreditManagerV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int128","name":"i","type":"int128"},{"internalType":"int128","name":"j","type":"int128"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"exchange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"j","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"exchange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"j","type":"uint256"},{"internalType":"uint256","name":"rateMinRAY","type":"uint256"}],"name":"exchange_all","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int128","name":"i","type":"int128"},{"internalType":"int128","name":"j","type":"int128"},{"internalType":"uint256","name":"rateMinRAY","type":"uint256"}],"name":"exchange_all","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int128","name":"i","type":"int128"},{"internalType":"int128","name":"j","type":"int128"},{"internalType":"uint256","name":"rateMinRAY","type":"uint256"}],"name":"exchange_all_underlying","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"j","type":"uint256"},{"internalType":"uint256","name":"rateMinRAY","type":"uint256"}],"name":"exchange_all_underlying","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"j","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"exchange_underlying","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int128","name":"i","type":"int128"},{"internalType":"int128","name":"j","type":"int128"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"exchange_underlying","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lpTokenMask","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lp_token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"metapoolBase","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nCoins","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int128","name":"i","type":"int128"},{"internalType":"uint256","name":"rateMinRAY","type":"uint256"}],"name":"remove_all_liquidity_one_coin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"rateMinRAY","type":"uint256"}],"name":"remove_all_liquidity_one_coin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256[4]","name":"","type":"uint256[4]"}],"name":"remove_liquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[4]","name":"amounts","type":"uint256[4]"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"remove_liquidity_imbalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"int128","name":"i","type":"int128"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"remove_liquidity_one_coin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"i","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"remove_liquidity_one_coin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"targetContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0Mask","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1Mask","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token2","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token2Mask","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token3","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token3Mask","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying0Mask","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying1Mask","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying2","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying2Mask","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying3","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying3Mask","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"use256","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6103c06040523480156200001257600080fd5b5060405162003e1538038062003e158339810160408190526200003591620008fc565b83838383600484846001600160a01b03821615806200005b57506001600160a01b038116155b156200007a57604051635919af9760e11b815260040160405180910390fd5b6001600160a01b0382166080819052604080516316f0115b60e01b815290516316f0115b916004808201926020929091908290030181865afa158015620000c5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000eb919062000964565b6001600160a01b0316632954018c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000129573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200014f919062000964565b6001600160a01b0390811660a081905290821660c05260408051630873769560e01b815290516308737695916004808201926020929091908290030181865afa158015620001a1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001c7919062000964565b6001600160a01b0390811660e05285169150620001f9905057604051635919af9760e11b815260040160405180910390fd5b620002048362000750565b610140526001600160a01b03808416610100819052610120528281166101605261018082905260c051604080516324949b0360e21b8152905160009392909216916392526c0c916004808201926020929091908290030181865afa9250505080156200028f575060408051601f3d908101601f191682019092526200028c918101906200098b565b60015b6200029d57506000620002a3565b60019150505b15156101a052620002b3620008c5565b620002bd620008c5565b60005b610180518110156200046c5760c05160405163c661065760e01b8152600481018390526000916001600160a01b03169063c661065790602401602060405180830381865afa92505050801562000335575060408051601f3d908101601f19168201909252620003329181019062000964565b60015b620003e35760c0516001600160a01b03166323746eb8620003766200036585620007eb60201b620014811760201c565b6200085f60201b6200151d1760201c565b6040516001600160e01b031960e084901b168152600f9190910b6004820152602401602060405180830381865afa925050508015620003d4575060408051601f3d908101601f19168201909252620003d19181019062000964565b60015b15620003dd5790505b620003e6565b90505b6001600160a01b0381166200040e57604051635919af9760e11b815260040160405180910390fd5b60006200041b8262000750565b905081858460048110620004335762000433620009a5565b6001600160a01b039092166020929092020152808484600481106200045c576200045c620009a5565b60200201525050600101620002c0565b5081516001600160a01b039081166101c05260208084015182166101e0526040808501518316610200526060948501519092166102205282516102405282810151610260528282015161028052918301516102a052805160808082018352600080835282850181905282840181905282860181905283519182018452808252938101849052918201839052928101829052905b6004811015620006ef576101605160009081906001600160a01b031615620005bf578260000362000536576101c051915062000682565b610160516001600160a01b031663c661065762000555600186620009bb565b6040518263ffffffff1660e01b81526004016200057491815260200190565b602060405180830381865afa925050508015620005b0575060408051601f3d908101601f19168201909252620005ad9181019062000964565b60015b15620005b95791505b62000682565b60c051604051630b9947eb60e41b8152600481018590526001600160a01b039091169063b9947eb090602401602060405180830381865afa92505050801562000627575060408051601f3d908101601f19168201909252620006249181019062000964565b60015b6200067f5760c0516001600160a01b031663b739953e620006576200036586620007eb60201b620014811760201c565b6040516001600160e01b031960e084901b168152600f9190910b600482015260240162000574565b91505b6001600160a01b03821615620006a0576200069d8262000750565b90505b81858460048110620006b657620006b6620009a5565b6001600160a01b03909216602092909202015280848460048110620006df57620006df620009a5565b60200201525050600101620004ff565b5081516001600160a01b039081166102c05260208084015182166102e05260408085015183166103005260609485015190921661032052825161034052820151610360528101516103805201516103a05250620009e3975050505050505050565b608051604051630f67c5bd60e41b81526001600160a01b038381166004830152600092169063f67c5bd090602401602060405180830381865afa1580156200079c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007c291906200098b565b905080600003620007e65760405163700ca0af60e01b815260040160405180910390fd5b919050565b60006001600160ff1b038211156200085b5760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b60648201526084015b60405180910390fd5b5090565b80600f81900b8114620007e65760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b606482015260840162000852565b60405180608001604052806004906020820280368337509192915050565b6001600160a01b0381168114620008f957600080fd5b50565b600080600080608085870312156200091357600080fd5b84516200092081620008e3565b60208601519094506200093381620008e3565b60408601519093506200094681620008e3565b60608601519092506200095981620008e3565b939692955090935050565b6000602082840312156200097757600080fd5b81516200098481620008e3565b9392505050565b6000602082840312156200099e57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b81810381811115620009dd57634e487b7160e01b600052601160045260246000fd5b92915050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a05161318c62000c89600039600081816106b901526121bc01526000818161053101526121600152600081816104aa015261210301526000818161066b01526120a30152600081816104f7015261243301526000818161038401526123d70152600081816105dc015261237a015260008181610692015261231a01526000818161080301528181611c0d01526121960152600081816106e001528181611c2e01526121390152600081816108d901528181611c4f01526120dc01526000818161033501528181611c70015261207d01526000818161089f01528181611d36015261240d01526000818161042301528181611d0601526123b001526000818161085201528181611cd601526123530152600081816103c301528181611ca601526122f40152600081816105580152818161248101526126bb0152600081816107b501528181610a7101528181610c2501528181610d98015281816127b5015281816128930152612971015260006105a20152600081816107dc01528181611688015281816122260152612a7701526000818161064401526118ad015260006109000152600061070701526000818161076701528181610ae501528181610ba401528181610c9101528181610cf801528181610d5f01528181610e1601528181610e8401528181610ef201528181610f6001528181611d960152612b220152600061044a01526000818161078e015281816115a001528181611d5f01528181611e6d01528181611f2a01528181611fcb0152818161224f0152612aaf015261318c6000f3fe608060405234801561001057600080fd5b506004361061032b5760003560e01c806379bea664116101b2578063c12c21c0116100f9578063d21220a7116100a2578063ef14101e1161007c578063ef14101e1461089a578063f1dc3cc9146108c1578063f8f15639146108d4578063fc0c546a146108fb57600080fd5b8063d21220a71461084d578063e90d1dbc14610874578063ec026ca71461088757600080fd5b8063caed3787116100d3578063caed3787146107fe578063ce30bbdb14610825578063cf023dd01461083a57600080fd5b8063c12c21c014610789578063c21ee162146107b0578063c7c4fe1e146107d757600080fd5b80639e9c1e881161015b578063ab6548fa11610135578063ab6548fa1461073c578063ae206e241461074f578063bd90df701461076257600080fd5b80639e9c1e88146106db578063a50cf2c814610702578063a6417ed61461072957600080fd5b806387427f461161018c57806387427f46146106665780638ba51dfc1461068d57806393a58153146106b457600080fd5b806379bea664146106195780637d49d8751461062c57806382c630661461063f57600080fd5b8063403d4e4a11610276578063623d85851161021f57806365b2489b116101f957806365b2489b146105c45780636e1d8271146105d757806378aa73a4146105fe57600080fd5b8063623d85851461055357806363e73cbb1461058a57806364a89bca1461059d57600080fd5b806357d788751161025057806357d78875146104f25780635b41b908146105195780635e8d3f551461052c57600080fd5b8063403d4e4a146104a557806341c84b36146104cc5780634be97fb0146104df57600080fd5b80631af4de83116102d85780632c5788d2116102b25780632c5788d21461046c57806333d2ebf21461047f5780633df021241461049257600080fd5b80631af4de831461040b57806325be124e1461041e5780632954018c1461044557600080fd5b80630dfe1681116103095780630dfe1681146103be57806318a7bd76146103e55780631a4d01d2146103f857600080fd5b806301b44c8414610330578063029b2f341461036a578063068711631461037f575b600080fd5b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b61037d610378366004612c06565b610922565b005b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610361565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b61037d6103f3366004612c06565b610984565b61037d610406366004612c43565b6109e2565b61037d610419366004612c78565b610a29565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b61035761047a366004612ca4565b610a6d565b61037d61048d366004612cd0565b610fea565b61037d6104a0366004612cfa565b61102d565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b61037d6104da366004612d3c565b611076565b61037d6104ed366004612d3c565b6110d5565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b61037d610527366004612d68565b611124565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b61057a7f000000000000000000000000000000000000000000000000000000000000000081565b6040519015158152602001610361565b61037d610598366004612d9a565b61117d565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b61037d6105d2366004612d68565b6111cb565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b610606600281565b60405161ffff9091168152602001610361565b61037d610627366004612c78565b611224565b61037d61063a366004612dbc565b611268565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b61037d610737366004612cfa565b6112a9565b61037d61074a366004612d3c565b6112ec565b61035761075d366004612d9a565b611346565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b61082d600781565b6040516103619190612de0565b61037d610848366004612c43565b61135f565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b61037d610882366004612d9a565b6113a3565b61037d610895366004612cd0565b6113f1565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b61037d6108cf366004612d3c565b611434565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b61092a61159c565b6001600160a01b0316336001600160a01b03161461095b57604051636c01359160e11b815260040160405180910390fd5b6109806001833581109060208501358110906040860135811090606087013511611625565b5050565b61098c61159c565b6001600160a01b0316336001600160a01b0316146109bd57604051636c01359160e11b815260040160405180910390fd5b61098060018335811090602085013581109060408601358110906060870135116116ae565b6109ea61159c565b6001600160a01b0316336001600160a01b031614610a1b57604051636c01359160e11b815260040160405180910390fd5b610a2482611752565b505050565b610a3161159c565b6001600160a01b0316336001600160a01b031614610a6257604051636c01359160e11b815260040160405180910390fd5b610a24838383611796565b60007f0000000000000000000000000000000000000000000000000000000000000000600203610c235781600f0b600014610b6257604080518082018252600081526020810185905290517fed8e84f30000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163ed8e84f391610b1c9190600190600401612e41565b602060405180830381865afa158015610b39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5d9190612e5e565b610c1c565b6040805180820182528481526000602082015290517fed8e84f30000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163ed8e84f391610bdb9190600190600401612e41565b602060405180830381865afa158015610bf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1c9190612e5e565b9050610fe4565b7f0000000000000000000000000000000000000000000000000000000000000000600303610d965781600f0b600014610d2f5781600f0b600114610cc85760408051606081018252600080825260208201528082018590529051633883e11960e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691633883e11991610b1c9190600190600401612e9a565b60408051606081018252600080825260208201869052818301529051633883e11960e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691633883e11991610b1c9190600190600401612e9a565b60408051606081018252848152600060208201819052818301529051633883e11960e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691633883e11991610bdb9190600190600401612e9a565b7f0000000000000000000000000000000000000000000000000000000000000000600403610f975781600f0b600014610f295781600f0b600114610ebb5781600f0b600214610e4d57604080516080810182526000808252602082018190528183015260608101859052905163cf701ff760e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163cf701ff791610b1c9190600190600401612eda565b604080516080810182526000808252602082018190528183018690526060820152905163cf701ff760e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163cf701ff791610b1c9190600190600401612eda565b604080516080810182526000808252602082018690528183018190526060820152905163cf701ff760e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163cf701ff791610b1c9190600190600401612eda565b604080516080810182528481526000602082018190528183018190526060820152905163cf701ff760e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163cf701ff791610bdb9190600190600401612eda565b60405162461bcd60e51b815260206004820152601060248201527f496e636f7272656374206e436f696e730000000000000000000000000000000060448201526064015b60405180910390fd5b92915050565b610ff261159c565b6001600160a01b0316336001600160a01b03161461102357604051636c01359160e11b815260040160405180910390fd5b610980828261187e565b61103561159c565b6001600160a01b0316336001600160a01b03161461106657604051636c01359160e11b815260040160405180910390fd5b6110708484611967565b50505050565b61107e61159c565b6001600160a01b0316336001600160a01b0316146110af57604051636c01359160e11b815260040160405180910390fd5b610a246110c36110be85611481565b61151d565b6110cf6110be85611481565b836119ab565b6110dd61159c565b6001600160a01b0316336001600160a01b03161461110e57604051636c01359160e11b815260040160405180910390fd5b610a248361111e6110be85611481565b83611a8b565b61112c61159c565b6001600160a01b0316336001600160a01b03161461115d57604051636c01359160e11b815260040160405180910390fd5b61107061116c6110be86611481565b6111786110be86611481565b611967565b61118561159c565b6001600160a01b0316336001600160a01b0316146111b657604051636c01359160e11b815260040160405180910390fd5b6109806111c56110be84611481565b82611aa1565b6111d361159c565b6001600160a01b0316336001600160a01b03161461120457604051636c01359160e11b815260040160405180910390fd5b6110706112136110be86611481565b61121f6110be86611481565b611b82565b61122c61159c565b6001600160a01b0316336001600160a01b03161461125d57604051636c01359160e11b815260040160405180910390fd5b610a248383836119ab565b61127061159c565b6001600160a01b0316336001600160a01b0316146112a157604051636c01359160e11b815260040160405180910390fd5b610980611bc7565b6112b161159c565b6001600160a01b0316336001600160a01b0316146112e257604051636c01359160e11b815260040160405180910390fd5b6110708484611b82565b6112f461159c565b6001600160a01b0316336001600160a01b03161461132557604051636c01359160e11b815260040160405180910390fd5b610a246113346110be85611481565b6113406110be85611481565b83611796565b60006113588361047a6110be85611481565b9392505050565b61136761159c565b6001600160a01b0316336001600160a01b03161461139857604051636c01359160e11b815260040160405180910390fd5b610a24838383611a8b565b6113ab61159c565b6001600160a01b0316336001600160a01b0316146113dc57604051636c01359160e11b815260040160405180910390fd5b6109806113eb6110be84611481565b8261187e565b6113f961159c565b6001600160a01b0316336001600160a01b03161461142a57604051636c01359160e11b815260040160405180910390fd5b6109808282611aa1565b61143c61159c565b6001600160a01b0316336001600160a01b03161461146d57604051636c01359160e11b815260040160405180910390fd5b610a2461147c6110be84611481565b611752565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8211156115195760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e206160448201527f6e20696e743235360000000000000000000000000000000000000000000000006064820152608401610fdb565b5090565b80600f81900b81146115975760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f32382062697473000000000000000000000000000000000000000000000000006064820152608401610fdb565b919050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632f7a18816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116209190612f0e565b905090565b61163484848484600019611c9b565b6116746000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d5b92505050565b50611683848484846001611c9b565b6110707f00000000000000000000000000000000000000000000000000000000000000006000611e1b565b6116ee6000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d5b92505050565b506000841561170457611702600080612069565b175b83156117185761171660016000612069565b175b821561172c5761172a60026000612069565b175b81156117405761173e60036000612069565b175b61174b816000611e1b565b5050505050565b611793816000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509250612200915050565b50565b60006117a061224b565b905060006117af8560016122e0565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa1580156117fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181f9190612e5e565b90506001811161183157505050505050565b6000190160006b033b2e3c9fd0803ce800000061184e8684612f29565b6118589190612f4e565b9050611875878761186d8a8a8787600161247d565b600180612671565b50505050505050565b600061188861224b565b6040516370a0823160e01b81526001600160a01b0380831660048301529192506000917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156118f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119189190612e5e565b9050600181116119285750505050565b6000190160006b033b2e3c9fd0803ce80000006119458584612f29565b61194f9190612f4e565b905061174b856119608785856126b7565b6001612200565b61098082826000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525092508291506126719050565b60006119b561224b565b905060006119c48560006122e0565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa158015611a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a349190612e5e565b905060018111611a4657505050505050565b6000190160006b033b2e3c9fd0803ce8000000611a638684612f29565b611a6d9190612f4e565b90506118758787611a828a8a8787600061247d565b60006001612671565b610a2482611a9a8486856127b1565b6000612a4d565b6000611aab61224b565b90506000611aba8460006122e0565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa158015611b06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2a9190612e5e565b905060018111611b3b575050505050565b6000190160006b033b2e3c9fd0803ce8000000611b588684612f29565b611b629190612f4e565b9050611b7a86611b738885856127b1565b6001612a4d565b505050505050565b61098082826000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052506001935091506126719050565b611c076000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d5b92505050565b50611c997f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000001717176000611e1b565b565b8415611ccb57611ccb7f000000000000000000000000000000000000000000000000000000000000000082612aad565b8315611cfb57611cfb7f000000000000000000000000000000000000000000000000000000000000000082612aad565b8215611d2b57611d2b7f000000000000000000000000000000000000000000000000000000000000000082612aad565b811561174b5761174b7f000000000000000000000000000000000000000000000000000000000000000082612aad565b60607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636ce4074a611d9461159c565b7f0000000000000000000000000000000000000000000000000000000000000000856040518463ffffffff1660e01b8152600401611dd493929190612f94565b6000604051808303816000875af1158015611df3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610fe49190810190612ff8565b6000611e2561224b565b9050828218600060015b828111611b7a578281161561203a576040517fe75538c7000000000000000000000000000000000000000000000000000000008152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e75538c7906024016040805180830381865afa158015611ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611edf91906130a5565b50915085811615611f8b576040517f51e3f1600000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015283811660248301527f000000000000000000000000000000000000000000000000000000000000000016906351e3f16090604401600060405180830381600087803b158015611f6e57600080fd5b505af1158015611f82573d6000803e3d6000fd5b5050505061203a565b6040517f0d8f9cee0000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015283811660248301527f00000000000000000000000000000000000000000000000000000000000000001690630d8f9cee906044016020604051808303816000875af1158015612014573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061203891906130e3565b505b7f80000000000000000000000000000000000000000000000000000000000000008114611b7a5760011b611e2f565b600082600f0b6000036120ca57816120a1577f00000000000000000000000000000000000000000000000000000000000000006120c3565b7f00000000000000000000000000000000000000000000000000000000000000005b90506121df565b82600f0b6001036121275781612100577f00000000000000000000000000000000000000000000000000000000000000006120c3565b507f00000000000000000000000000000000000000000000000000000000000000006121df565b82600f0b600203612184578161215d577f00000000000000000000000000000000000000000000000000000000000000006120c3565b507f00000000000000000000000000000000000000000000000000000000000000006121df565b82600f0b6003036121df57816121ba577f00000000000000000000000000000000000000000000000000000000000000006121dc565b7f00000000000000000000000000000000000000000000000000000000000000005b90505b80600003610fe4576040516334769e6f60e21b815260040160405180910390fd5b61220982611d5b565b50610a24612218846000612069565b82612224576000611e1b565b7f00000000000000000000000000000000000000000000000000000000000000005b611e1b565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e958b70461228461159c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156115fc573d6000803e3d6000fd5b600082600f0b6000036123415781612318577f000000000000000000000000000000000000000000000000000000000000000061233a565b7f00000000000000000000000000000000000000000000000000000000000000005b9050612456565b82600f0b60010361239e5781612377577f000000000000000000000000000000000000000000000000000000000000000061233a565b507f0000000000000000000000000000000000000000000000000000000000000000612456565b82600f0b6002036123fb57816123d4577f000000000000000000000000000000000000000000000000000000000000000061233a565b507f0000000000000000000000000000000000000000000000000000000000000000612456565b82600f0b6003036124565781612431577f0000000000000000000000000000000000000000000000000000000000000000612453565b7f00000000000000000000000000000000000000000000000000000000000000005b90505b6001600160a01b038116610fe4576040516334769e6f60e21b815260040160405180910390fd5b60607f000000000000000000000000000000000000000000000000000000000000000015612589578161251857604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f5b41b90800000000000000000000000000000000000000000000000000000000179052612582565b604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f65b2489b000000000000000000000000000000000000000000000000000000001790525b9050612668565b816125fc57604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f3df0212400000000000000000000000000000000000000000000000000000000179052612582565b604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167fa6417ed60000000000000000000000000000000000000000000000000000000017905290505b95945050505050565b61267e8583600019612b88565b61268783611d5b565b5061269485836001612b88565b61174b6126a18584612069565b826126ad576000611e1b565b6122468785612069565b60607f0000000000000000000000000000000000000000000000000000000000000000156127475760405160248101849052600f85900b60448201526064810183905260840160408051601f198184030181529190526020810180516001600160e01b03167ff1dc3cc9000000000000000000000000000000000000000000000000000000001790529050611358565b60405160248101849052600f85900b60448201526064810183905260840160408051601f198184030181529190526020810180516001600160e01b03167f1a4d01d20000000000000000000000000000000000000000000000000000000017905290509392505050565b60607f0000000000000000000000000000000000000000000000000000000000000000600203612891576127e3612b9b565b600185600f0b1315612808576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166002811061282d5761282d612e08565b60200201526040516128459082908590602401613105565b60408051601f198184030181529190526020810180516001600160e01b03167f0b4c7e4d0000000000000000000000000000000000000000000000000000000017905291506113589050565b7f000000000000000000000000000000000000000000000000000000000000000060030361296f576128c1612bb9565b600285600f0b13156128e6576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166003811061290b5761290b612e08565b60200201526040516129239082908590602401613120565b60408051601f198184030181529190526020810180516001600160e01b03167f4515cef30000000000000000000000000000000000000000000000000000000017905291506113589050565b7f0000000000000000000000000000000000000000000000000000000000000000600403610f975761299f612bd7565b600385600f0b13156129c4576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff16600481106129e9576129e9612e08565b6020020152604051612a01908290859060240161313b565b60408051601f198184030181529190526020810180516001600160e01b03167f029b2f340000000000000000000000000000000000000000000000000000000017905291506113589050565b612a5b836000600019612b88565b612a6482611d5b565b50612a728360006001612b88565b610a247f000000000000000000000000000000000000000000000000000000000000000082612aa2576000611e1b565b612246856000612069565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166346fb371d612ae461159c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b0391821660048201527f000000000000000000000000000000000000000000000000000000000000000082166024820152908516604482015260648101849052608401600060405180830381600087803b158015612b7457600080fd5b505af1158015611b7a573d6000803e3d6000fd5b610a24612b9584846122e0565b82612aad565b60405180604001604052806002906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b8060808101831015610fe457600080fd5b60008060a08385031215612c1957600080fd5b612c238484612bf5565b946080939093013593505050565b8035600f81900b811461159757600080fd5b600080600060608486031215612c5857600080fd5b83359250612c6860208501612c31565b9150604084013590509250925092565b600080600060608486031215612c8d57600080fd5b612c9684612c31565b9250612c6860208501612c31565b60008060408385031215612cb757600080fd5b82359150612cc760208401612c31565b90509250929050565b60008060408385031215612ce357600080fd5b612cec83612c31565b946020939093013593505050565b60008060008060808587031215612d1057600080fd5b612d1985612c31565b9350612d2760208601612c31565b93969395505050506040820135916060013590565b600080600060608486031215612d5157600080fd5b505081359360208301359350604090920135919050565b60008060008060808587031215612d7e57600080fd5b5050823594602084013594506040840135936060013592509050565b60008060408385031215612dad57600080fd5b50508035926020909101359150565b60008060a08385031215612dcf57600080fd5b82359150612cc78460208501612bf5565b6020810160158310612e0257634e487b7160e01b600052602160045260246000fd5b91905290565b634e487b7160e01b600052603260045260246000fd5b8060005b6002811015611070578151845260209384019390910190600101612e22565b60608101612e4f8285612e1e565b82151560408301529392505050565b600060208284031215612e7057600080fd5b5051919050565b8060005b6003811015611070578151845260209384019390910190600101612e7b565b60808101612ea88285612e77565b82151560608301529392505050565b8060005b6004811015611070578151845260209384019390910190600101612ebb565b60a08101612ee88285612eb7565b82151560808301529392505050565b80516001600160a01b038116811461159757600080fd5b600060208284031215612f2057600080fd5b61135882612ef7565b8082028115828204841417610fe457634e487b7160e01b600052601160045260246000fd5b600082612f6b57634e487b7160e01b600052601260045260246000fd5b500490565b60005b83811015612f8b578181015183820152602001612f73565b50506000910152565b60006001600160a01b038086168352808516602084015250606060408301528251806060840152612fcc816080850160208701612f70565b601f01601f191691909101608001949350505050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561300a57600080fd5b815167ffffffffffffffff8082111561302257600080fd5b818401915084601f83011261303657600080fd5b81518181111561304857613048612fe2565b604051601f8201601f19908116603f0116810190838211818310171561307057613070612fe2565b8160405282815287602084870101111561308957600080fd5b61309a836020830160208801612f70565b979650505050505050565b600080604083850312156130b857600080fd5b6130c183612ef7565b9150602083015161ffff811681146130d857600080fd5b809150509250929050565b6000602082840312156130f557600080fd5b8151801515811461135857600080fd5b606081016131138285612e1e565b8260408301529392505050565b6080810161312e8285612e77565b8260608301529392505050565b60a081016131498285612eb7565b826080830152939250505056fea26469706673582212204d0909a514b29f4c955d0322a0a3e98a982ecea7b25d46d5bdc1c0a0e841118d64736f6c63430008110033000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f7000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd000000000000000000000000c25a3a3b969415c80451098fa907ec722572917f0000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061032b5760003560e01c806379bea664116101b2578063c12c21c0116100f9578063d21220a7116100a2578063ef14101e1161007c578063ef14101e1461089a578063f1dc3cc9146108c1578063f8f15639146108d4578063fc0c546a146108fb57600080fd5b8063d21220a71461084d578063e90d1dbc14610874578063ec026ca71461088757600080fd5b8063caed3787116100d3578063caed3787146107fe578063ce30bbdb14610825578063cf023dd01461083a57600080fd5b8063c12c21c014610789578063c21ee162146107b0578063c7c4fe1e146107d757600080fd5b80639e9c1e881161015b578063ab6548fa11610135578063ab6548fa1461073c578063ae206e241461074f578063bd90df701461076257600080fd5b80639e9c1e88146106db578063a50cf2c814610702578063a6417ed61461072957600080fd5b806387427f461161018c57806387427f46146106665780638ba51dfc1461068d57806393a58153146106b457600080fd5b806379bea664146106195780637d49d8751461062c57806382c630661461063f57600080fd5b8063403d4e4a11610276578063623d85851161021f57806365b2489b116101f957806365b2489b146105c45780636e1d8271146105d757806378aa73a4146105fe57600080fd5b8063623d85851461055357806363e73cbb1461058a57806364a89bca1461059d57600080fd5b806357d788751161025057806357d78875146104f25780635b41b908146105195780635e8d3f551461052c57600080fd5b8063403d4e4a146104a557806341c84b36146104cc5780634be97fb0146104df57600080fd5b80631af4de83116102d85780632c5788d2116102b25780632c5788d21461046c57806333d2ebf21461047f5780633df021241461049257600080fd5b80631af4de831461040b57806325be124e1461041e5780632954018c1461044557600080fd5b80630dfe1681116103095780630dfe1681146103be57806318a7bd76146103e55780631a4d01d2146103f857600080fd5b806301b44c8414610330578063029b2f341461036a578063068711631461037f575b600080fd5b6103577f000000000000000000000000000000000000000000000000000000000000000181565b6040519081526020015b60405180910390f35b61037d610378366004612c06565b610922565b005b6103a67f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b6040516001600160a01b039091168152602001610361565b6103a67f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b61037d6103f3366004612c06565b610984565b61037d610406366004612c43565b6109e2565b61037d610419366004612c78565b610a29565b6103a67f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b6103a67f000000000000000000000000cf64698aff7e5f27a11dff868af228653ba53be081565b61035761047a366004612ca4565b610a6d565b61037d61048d366004612cd0565b610fea565b61037d6104a0366004612cfa565b61102d565b6103577f000000000000000000000000000000000000000000000000000000000000001081565b61037d6104da366004612d3c565b611076565b61037d6104ed366004612d3c565b6110d5565b6103a67f00000000000000000000000057ab1ec28d129707052df4df418d58a2d46d5f5181565b61037d610527366004612d68565b611124565b6103577f000000000000000000000000000000000000000000000000000000000000002081565b61057a7f000000000000000000000000000000000000000000000000000000000000000081565b6040519015158152602001610361565b61037d610598366004612d9a565b61117d565b6103a67f000000000000000000000000000000000000000000000000000000000000000081565b61037d6105d2366004612d68565b6111cb565b6103a67f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b610606600281565b60405161ffff9091168152602001610361565b61037d610627366004612c78565b611224565b61037d61063a366004612dbc565b611268565b6103a67f000000000000000000000000c25a3a3b969415c80451098fa907ec722572917f81565b6103577f000000000000000000000000000000000000000000000000000000000000000181565b6103a67f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b6103577f000000000000000000000000000000000000000000000000000000000000004081565b6103577f000000000000000000000000000000000000000000000000000000000000002081565b6103a67f000000000000000000000000523da3a8961e4dd4f6206dbf7e6c749f51796bb381565b61037d610737366004612cfa565b6112a9565b61037d61074a366004612d3c565b6112ec565b61035761075d366004612d9a565b611346565b6103a67f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd81565b6103a67f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f781565b6103577f000000000000000000000000000000000000000000000000000000000000000481565b6103577f000000000000000000000000000000000000000000000000000000000004000081565b6103577f000000000000000000000000000000000000000000000000000000000000004081565b61082d600781565b6040516103619190612de0565b61037d610848366004612c43565b61135f565b6103a67f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b61037d610882366004612d9a565b6113a3565b61037d610895366004612cd0565b6113f1565b6103a67f00000000000000000000000057ab1ec28d129707052df4df418d58a2d46d5f5181565b61037d6108cf366004612d3c565b611434565b6103577f000000000000000000000000000000000000000000000000000000000000001081565b6103a67f000000000000000000000000c25a3a3b969415c80451098fa907ec722572917f81565b61092a61159c565b6001600160a01b0316336001600160a01b03161461095b57604051636c01359160e11b815260040160405180910390fd5b6109806001833581109060208501358110906040860135811090606087013511611625565b5050565b61098c61159c565b6001600160a01b0316336001600160a01b0316146109bd57604051636c01359160e11b815260040160405180910390fd5b61098060018335811090602085013581109060408601358110906060870135116116ae565b6109ea61159c565b6001600160a01b0316336001600160a01b031614610a1b57604051636c01359160e11b815260040160405180910390fd5b610a2482611752565b505050565b610a3161159c565b6001600160a01b0316336001600160a01b031614610a6257604051636c01359160e11b815260040160405180910390fd5b610a24838383611796565b60007f0000000000000000000000000000000000000000000000000000000000000004600203610c235781600f0b600014610b6257604080518082018252600081526020810185905290517fed8e84f30000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd169163ed8e84f391610b1c9190600190600401612e41565b602060405180830381865afa158015610b39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5d9190612e5e565b610c1c565b6040805180820182528481526000602082015290517fed8e84f30000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd169163ed8e84f391610bdb9190600190600401612e41565b602060405180830381865afa158015610bf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1c9190612e5e565b9050610fe4565b7f0000000000000000000000000000000000000000000000000000000000000004600303610d965781600f0b600014610d2f5781600f0b600114610cc85760408051606081018252600080825260208201528082018590529051633883e11960e01b81526001600160a01b037f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd1691633883e11991610b1c9190600190600401612e9a565b60408051606081018252600080825260208201869052818301529051633883e11960e01b81526001600160a01b037f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd1691633883e11991610b1c9190600190600401612e9a565b60408051606081018252848152600060208201819052818301529051633883e11960e01b81526001600160a01b037f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd1691633883e11991610bdb9190600190600401612e9a565b7f0000000000000000000000000000000000000000000000000000000000000004600403610f975781600f0b600014610f295781600f0b600114610ebb5781600f0b600214610e4d57604080516080810182526000808252602082018190528183015260608101859052905163cf701ff760e01b81526001600160a01b037f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd169163cf701ff791610b1c9190600190600401612eda565b604080516080810182526000808252602082018190528183018690526060820152905163cf701ff760e01b81526001600160a01b037f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd169163cf701ff791610b1c9190600190600401612eda565b604080516080810182526000808252602082018690528183018190526060820152905163cf701ff760e01b81526001600160a01b037f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd169163cf701ff791610b1c9190600190600401612eda565b604080516080810182528481526000602082018190528183018190526060820152905163cf701ff760e01b81526001600160a01b037f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd169163cf701ff791610bdb9190600190600401612eda565b60405162461bcd60e51b815260206004820152601060248201527f496e636f7272656374206e436f696e730000000000000000000000000000000060448201526064015b60405180910390fd5b92915050565b610ff261159c565b6001600160a01b0316336001600160a01b03161461102357604051636c01359160e11b815260040160405180910390fd5b610980828261187e565b61103561159c565b6001600160a01b0316336001600160a01b03161461106657604051636c01359160e11b815260040160405180910390fd5b6110708484611967565b50505050565b61107e61159c565b6001600160a01b0316336001600160a01b0316146110af57604051636c01359160e11b815260040160405180910390fd5b610a246110c36110be85611481565b61151d565b6110cf6110be85611481565b836119ab565b6110dd61159c565b6001600160a01b0316336001600160a01b03161461110e57604051636c01359160e11b815260040160405180910390fd5b610a248361111e6110be85611481565b83611a8b565b61112c61159c565b6001600160a01b0316336001600160a01b03161461115d57604051636c01359160e11b815260040160405180910390fd5b61107061116c6110be86611481565b6111786110be86611481565b611967565b61118561159c565b6001600160a01b0316336001600160a01b0316146111b657604051636c01359160e11b815260040160405180910390fd5b6109806111c56110be84611481565b82611aa1565b6111d361159c565b6001600160a01b0316336001600160a01b03161461120457604051636c01359160e11b815260040160405180910390fd5b6110706112136110be86611481565b61121f6110be86611481565b611b82565b61122c61159c565b6001600160a01b0316336001600160a01b03161461125d57604051636c01359160e11b815260040160405180910390fd5b610a248383836119ab565b61127061159c565b6001600160a01b0316336001600160a01b0316146112a157604051636c01359160e11b815260040160405180910390fd5b610980611bc7565b6112b161159c565b6001600160a01b0316336001600160a01b0316146112e257604051636c01359160e11b815260040160405180910390fd5b6110708484611b82565b6112f461159c565b6001600160a01b0316336001600160a01b03161461132557604051636c01359160e11b815260040160405180910390fd5b610a246113346110be85611481565b6113406110be85611481565b83611796565b60006113588361047a6110be85611481565b9392505050565b61136761159c565b6001600160a01b0316336001600160a01b03161461139857604051636c01359160e11b815260040160405180910390fd5b610a24838383611a8b565b6113ab61159c565b6001600160a01b0316336001600160a01b0316146113dc57604051636c01359160e11b815260040160405180910390fd5b6109806113eb6110be84611481565b8261187e565b6113f961159c565b6001600160a01b0316336001600160a01b03161461142a57604051636c01359160e11b815260040160405180910390fd5b6109808282611aa1565b61143c61159c565b6001600160a01b0316336001600160a01b03161461146d57604051636c01359160e11b815260040160405180910390fd5b610a2461147c6110be84611481565b611752565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8211156115195760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e206160448201527f6e20696e743235360000000000000000000000000000000000000000000000006064820152608401610fdb565b5090565b80600f81900b81146115975760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f32382062697473000000000000000000000000000000000000000000000000006064820152608401610fdb565b919050565b60007f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b0316632f7a18816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116209190612f0e565b905090565b61163484848484600019611c9b565b6116746000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d5b92505050565b50611683848484846001611c9b565b6110707f00000000000000000000000000000000000000000000000000000000000400006000611e1b565b6116ee6000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d5b92505050565b506000841561170457611702600080612069565b175b83156117185761171660016000612069565b175b821561172c5761172a60026000612069565b175b81156117405761173e60036000612069565b175b61174b816000611e1b565b5050505050565b611793816000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509250612200915050565b50565b60006117a061224b565b905060006117af8560016122e0565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa1580156117fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181f9190612e5e565b90506001811161183157505050505050565b6000190160006b033b2e3c9fd0803ce800000061184e8684612f29565b6118589190612f4e565b9050611875878761186d8a8a8787600161247d565b600180612671565b50505050505050565b600061188861224b565b6040516370a0823160e01b81526001600160a01b0380831660048301529192506000917f000000000000000000000000c25a3a3b969415c80451098fa907ec722572917f16906370a0823190602401602060405180830381865afa1580156118f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119189190612e5e565b9050600181116119285750505050565b6000190160006b033b2e3c9fd0803ce80000006119458584612f29565b61194f9190612f4e565b905061174b856119608785856126b7565b6001612200565b61098082826000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525092508291506126719050565b60006119b561224b565b905060006119c48560006122e0565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa158015611a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a349190612e5e565b905060018111611a4657505050505050565b6000190160006b033b2e3c9fd0803ce8000000611a638684612f29565b611a6d9190612f4e565b90506118758787611a828a8a8787600061247d565b60006001612671565b610a2482611a9a8486856127b1565b6000612a4d565b6000611aab61224b565b90506000611aba8460006122e0565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa158015611b06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2a9190612e5e565b905060018111611b3b575050505050565b6000190160006b033b2e3c9fd0803ce8000000611b588684612f29565b611b629190612f4e565b9050611b7a86611b738885856127b1565b6001612a4d565b505050505050565b61098082826000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052506001935091506126719050565b611c076000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d5b92505050565b50611c997f00000000000000000000000000000000000000000000000000000000000000407f00000000000000000000000000000000000000000000000000000000000000207f00000000000000000000000000000000000000000000000000000000000000107f00000000000000000000000000000000000000000000000000000000000000011717176000611e1b565b565b8415611ccb57611ccb7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f82612aad565b8315611cfb57611cfb7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4882612aad565b8215611d2b57611d2b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec782612aad565b811561174b5761174b7f00000000000000000000000057ab1ec28d129707052df4df418d58a2d46d5f5182612aad565b60607f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b0316636ce4074a611d9461159c565b7f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd856040518463ffffffff1660e01b8152600401611dd493929190612f94565b6000604051808303816000875af1158015611df3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610fe49190810190612ff8565b6000611e2561224b565b9050828218600060015b828111611b7a578281161561203a576040517fe75538c7000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b03169063e75538c7906024016040805180830381865afa158015611ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611edf91906130a5565b50915085811615611f8b576040517f51e3f1600000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015283811660248301527f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f716906351e3f16090604401600060405180830381600087803b158015611f6e57600080fd5b505af1158015611f82573d6000803e3d6000fd5b5050505061203a565b6040517f0d8f9cee0000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015283811660248301527f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f71690630d8f9cee906044016020604051808303816000875af1158015612014573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061203891906130e3565b505b7f80000000000000000000000000000000000000000000000000000000000000008114611b7a5760011b611e2f565b600082600f0b6000036120ca57816120a1577f00000000000000000000000000000000000000000000000000000000000000016120c3565b7f00000000000000000000000000000000000000000000000000000000000000015b90506121df565b82600f0b6001036121275781612100577f00000000000000000000000000000000000000000000000000000000000000106120c3565b507f00000000000000000000000000000000000000000000000000000000000000106121df565b82600f0b600203612184578161215d577f00000000000000000000000000000000000000000000000000000000000000206120c3565b507f00000000000000000000000000000000000000000000000000000000000000206121df565b82600f0b6003036121df57816121ba577f00000000000000000000000000000000000000000000000000000000000000406121dc565b7f00000000000000000000000000000000000000000000000000000000000000405b90505b80600003610fe4576040516334769e6f60e21b815260040160405180910390fd5b61220982611d5b565b50610a24612218846000612069565b82612224576000611e1b565b7f00000000000000000000000000000000000000000000000000000000000400005b611e1b565b60007f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b031663e958b70461228461159c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156115fc573d6000803e3d6000fd5b600082600f0b6000036123415781612318577f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f61233a565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f5b9050612456565b82600f0b60010361239e5781612377577f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4861233a565b507f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48612456565b82600f0b6002036123fb57816123d4577f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec761233a565b507f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7612456565b82600f0b6003036124565781612431577f00000000000000000000000057ab1ec28d129707052df4df418d58a2d46d5f51612453565b7f00000000000000000000000057ab1ec28d129707052df4df418d58a2d46d5f515b90505b6001600160a01b038116610fe4576040516334769e6f60e21b815260040160405180910390fd5b60607f000000000000000000000000000000000000000000000000000000000000000015612589578161251857604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f5b41b90800000000000000000000000000000000000000000000000000000000179052612582565b604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f65b2489b000000000000000000000000000000000000000000000000000000001790525b9050612668565b816125fc57604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f3df0212400000000000000000000000000000000000000000000000000000000179052612582565b604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167fa6417ed60000000000000000000000000000000000000000000000000000000017905290505b95945050505050565b61267e8583600019612b88565b61268783611d5b565b5061269485836001612b88565b61174b6126a18584612069565b826126ad576000611e1b565b6122468785612069565b60607f0000000000000000000000000000000000000000000000000000000000000000156127475760405160248101849052600f85900b60448201526064810183905260840160408051601f198184030181529190526020810180516001600160e01b03167ff1dc3cc9000000000000000000000000000000000000000000000000000000001790529050611358565b60405160248101849052600f85900b60448201526064810183905260840160408051601f198184030181529190526020810180516001600160e01b03167f1a4d01d20000000000000000000000000000000000000000000000000000000017905290509392505050565b60607f0000000000000000000000000000000000000000000000000000000000000004600203612891576127e3612b9b565b600185600f0b1315612808576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166002811061282d5761282d612e08565b60200201526040516128459082908590602401613105565b60408051601f198184030181529190526020810180516001600160e01b03167f0b4c7e4d0000000000000000000000000000000000000000000000000000000017905291506113589050565b7f000000000000000000000000000000000000000000000000000000000000000460030361296f576128c1612bb9565b600285600f0b13156128e6576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166003811061290b5761290b612e08565b60200201526040516129239082908590602401613120565b60408051601f198184030181529190526020810180516001600160e01b03167f4515cef30000000000000000000000000000000000000000000000000000000017905291506113589050565b7f0000000000000000000000000000000000000000000000000000000000000004600403610f975761299f612bd7565b600385600f0b13156129c4576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff16600481106129e9576129e9612e08565b6020020152604051612a01908290859060240161313b565b60408051601f198184030181529190526020810180516001600160e01b03167f029b2f340000000000000000000000000000000000000000000000000000000017905291506113589050565b612a5b836000600019612b88565b612a6482611d5b565b50612a728360006001612b88565b610a247f000000000000000000000000000000000000000000000000000000000004000082612aa2576000611e1b565b612246856000612069565b7f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b03166346fb371d612ae461159c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b0391821660048201527f000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd82166024820152908516604482015260648101849052608401600060405180830381600087803b158015612b7457600080fd5b505af1158015611b7a573d6000803e3d6000fd5b610a24612b9584846122e0565b82612aad565b60405180604001604052806002906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b8060808101831015610fe457600080fd5b60008060a08385031215612c1957600080fd5b612c238484612bf5565b946080939093013593505050565b8035600f81900b811461159757600080fd5b600080600060608486031215612c5857600080fd5b83359250612c6860208501612c31565b9150604084013590509250925092565b600080600060608486031215612c8d57600080fd5b612c9684612c31565b9250612c6860208501612c31565b60008060408385031215612cb757600080fd5b82359150612cc760208401612c31565b90509250929050565b60008060408385031215612ce357600080fd5b612cec83612c31565b946020939093013593505050565b60008060008060808587031215612d1057600080fd5b612d1985612c31565b9350612d2760208601612c31565b93969395505050506040820135916060013590565b600080600060608486031215612d5157600080fd5b505081359360208301359350604090920135919050565b60008060008060808587031215612d7e57600080fd5b5050823594602084013594506040840135936060013592509050565b60008060408385031215612dad57600080fd5b50508035926020909101359150565b60008060a08385031215612dcf57600080fd5b82359150612cc78460208501612bf5565b6020810160158310612e0257634e487b7160e01b600052602160045260246000fd5b91905290565b634e487b7160e01b600052603260045260246000fd5b8060005b6002811015611070578151845260209384019390910190600101612e22565b60608101612e4f8285612e1e565b82151560408301529392505050565b600060208284031215612e7057600080fd5b5051919050565b8060005b6003811015611070578151845260209384019390910190600101612e7b565b60808101612ea88285612e77565b82151560608301529392505050565b8060005b6004811015611070578151845260209384019390910190600101612ebb565b60a08101612ee88285612eb7565b82151560808301529392505050565b80516001600160a01b038116811461159757600080fd5b600060208284031215612f2057600080fd5b61135882612ef7565b8082028115828204841417610fe457634e487b7160e01b600052601160045260246000fd5b600082612f6b57634e487b7160e01b600052601260045260246000fd5b500490565b60005b83811015612f8b578181015183820152602001612f73565b50506000910152565b60006001600160a01b038086168352808516602084015250606060408301528251806060840152612fcc816080850160208701612f70565b601f01601f191691909101608001949350505050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561300a57600080fd5b815167ffffffffffffffff8082111561302257600080fd5b818401915084601f83011261303657600080fd5b81518181111561304857613048612fe2565b604051601f8201601f19908116603f0116810190838211818310171561307057613070612fe2565b8160405282815287602084870101111561308957600080fd5b61309a836020830160208801612f70565b979650505050505050565b600080604083850312156130b857600080fd5b6130c183612ef7565b9150602083015161ffff811681146130d857600080fd5b809150509250929050565b6000602082840312156130f557600080fd5b8151801515811461135857600080fd5b606081016131138285612e1e565b8260408301529392505050565b6080810161312e8285612e77565b8260608301529392505050565b60a081016131498285612eb7565b826080830152939250505056fea26469706673582212204d0909a514b29f4c955d0322a0a3e98a982ecea7b25d46d5bdc1c0a0e841118d64736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f7000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd000000000000000000000000c25a3a3b969415c80451098fa907ec722572917f0000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _creditManager (address): 0x672461Bfc20DD783444a830Ad4c38b345aB6E2f7
Arg [1] : _curvePool (address): 0xA5407eAE9Ba41422680e2e00537571bcC53efBfD
Arg [2] : _lp_token (address): 0xC25a3A3b969415c80451098fa907EC722572917F
Arg [3] : _metapoolBase (address): 0x0000000000000000000000000000000000000000
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f7
Arg [1] : 000000000000000000000000a5407eae9ba41422680e2e00537571bcc53efbfd
Arg [2] : 000000000000000000000000c25a3a3b969415c80451098fa907ec722572917f
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.