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 | 17478921 | 110 days 33 mins ago | IN | Create: CurveV1Adapter3Assets | 0 ETH | 0.06895937 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
CurveV1Adapter3Assets
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_3.sol"; import {ICurveV1_3AssetsAdapter} from "../../interfaces/curve/ICurveV1_3AssetsAdapter.sol"; import {CurveV1AdapterBase} from "./CurveV1_Base.sol"; /// @title Curve V1 3 assets adapter /// @notice Implements logic allowing to interact with Curve pools with 3 assets contract CurveV1Adapter3Assets is CurveV1AdapterBase, ICurveV1_3AssetsAdapter { AdapterType public constant override(CurveV1AdapterBase, IAdapter) _gearboxAdapterType = AdapterType.CURVE_V1_3ASSETS; /// @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_3AssetsAdapter function add_liquidity(uint256[N_COINS] calldata amounts, uint256) external creditFacadeOnly { _add_liquidity(amounts[0] > 1, amounts[1] > 1, amounts[2] > 1, false); // F: [ACV1_3-4] } /// @inheritdoc ICurveV1_3AssetsAdapter function remove_liquidity(uint256, uint256[N_COINS] calldata) external virtual creditFacadeOnly { _remove_liquidity(); // F: [ACV1_3-5] } /// @inheritdoc ICurveV1_3AssetsAdapter 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, false); // F: [ACV1_3-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_3.sol"; import {ICurveV1Adapter} from "./ICurveV1Adapter.sol"; /// @title Curve V1 3 assets adapter interface /// @notice Implements logic allowing to interact with Curve pools with 3 assets interface ICurveV1_3AssetsAdapter 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[3]","name":"amounts","type":"uint256[3]"},{"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[3]","name":"","type":"uint256[3]"}],"name":"remove_liquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[3]","name":"amounts","type":"uint256[3]"},{"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
6103c06040523480156200001257600080fd5b5060405162003e0138038062003e018339810160408190526200003591620008fc565b83838383600384846001600160a01b03821615806200005b57506001600160a01b038116155b156200007a57604051635919af9760e11b815260040160405180910390fd5b6001600160a01b0382166080819052604080516316f0115b60e01b815290516316f0115b916004808201926020929091908290030181865afa158015620000c5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000eb919062000964565b6001600160a01b0316632954018c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000129573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200014f919062000964565b6001600160a01b0390811660a081905290821660c05260408051630873769560e01b815290516308737695916004808201926020929091908290030181865afa158015620001a1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001c7919062000964565b6001600160a01b0390811660e05285169150620001f9905057604051635919af9760e11b815260040160405180910390fd5b620002048362000750565b610140526001600160a01b03808416610100819052610120528281166101605261018082905260c051604080516324949b0360e21b8152905160009392909216916392526c0c916004808201926020929091908290030181865afa9250505080156200028f575060408051601f3d908101601f191682019092526200028c918101906200098b565b60015b6200029d57506000620002a3565b60019150505b15156101a052620002b3620008c5565b620002bd620008c5565b60005b610180518110156200046c5760c05160405163c661065760e01b8152600481018390526000916001600160a01b03169063c661065790602401602060405180830381865afa92505050801562000335575060408051601f3d908101601f19168201909252620003329181019062000964565b60015b620003e35760c0516001600160a01b03166323746eb8620003766200036585620007eb60201b620014751760201c565b6200085f60201b620015111760201c565b6040516001600160e01b031960e084901b168152600f9190910b6004820152602401602060405180830381865afa925050508015620003d4575060408051601f3d908101601f19168201909252620003d19181019062000964565b60015b15620003dd5790505b620003e6565b90505b6001600160a01b0381166200040e57604051635919af9760e11b815260040160405180910390fd5b60006200041b8262000750565b905081858460048110620004335762000433620009a5565b6001600160a01b039092166020929092020152808484600481106200045c576200045c620009a5565b60200201525050600101620002c0565b5081516001600160a01b039081166101c05260208084015182166101e0526040808501518316610200526060948501519092166102205282516102405282810151610260528282015161028052918301516102a052805160808082018352600080835282850181905282840181905282860181905283519182018452808252938101849052918201839052928101829052905b6004811015620006ef576101605160009081906001600160a01b031615620005bf578260000362000536576101c051915062000682565b610160516001600160a01b031663c661065762000555600186620009bb565b6040518263ffffffff1660e01b81526004016200057491815260200190565b602060405180830381865afa925050508015620005b0575060408051601f3d908101601f19168201909252620005ad9181019062000964565b60015b15620005b95791505b62000682565b60c051604051630b9947eb60e41b8152600481018590526001600160a01b039091169063b9947eb090602401602060405180830381865afa92505050801562000627575060408051601f3d908101601f19168201909252620006249181019062000964565b60015b6200067f5760c0516001600160a01b031663b739953e620006576200036586620007eb60201b620014751760201c565b6040516001600160e01b031960e084901b168152600f9190910b600482015260240162000574565b91505b6001600160a01b03821615620006a0576200069d8262000750565b90505b81858460048110620006b657620006b6620009a5565b6001600160a01b03909216602092909202015280848460048110620006df57620006df620009a5565b60200201525050600101620004ff565b5081516001600160a01b039081166102c05260208084015182166102e05260408085015183166103005260609485015190921661032052825161034052820151610360528101516103805201516103a05250620009e3975050505050505050565b608051604051630f67c5bd60e41b81526001600160a01b038381166004830152600092169063f67c5bd090602401602060405180830381865afa1580156200079c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007c291906200098b565b905080600003620007e65760405163700ca0af60e01b815260040160405180910390fd5b919050565b60006001600160ff1b038211156200085b5760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b60648201526084015b60405180910390fd5b5090565b80600f81900b8114620007e65760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b606482015260840162000852565b60405180608001604052806004906020820280368337509192915050565b6001600160a01b0381168114620008f957600080fd5b50565b600080600080608085870312156200091357600080fd5b84516200092081620008e3565b60208601519094506200093381620008e3565b60408601519093506200094681620008e3565b60608601519092506200095981620008e3565b939692955090935050565b6000602082840312156200097757600080fd5b81516200098481620008e3565b9392505050565b6000602082840312156200099e57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b81810381811115620009dd57634e487b7160e01b600052601160045260246000fd5b92915050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e05161020051610220516102405161026051610280516102a0516102c0516102e05161030051610320516103405161036051610380516103a05161317862000c89600039600081816106930152612a5901526000818161051e01526129fd01526000818161048401526129a001526000818161064501526129400152600081816104e40152611ec201526000818161036f0152611e660152600081816105c90152611e0901526000818161066c0152611da90152600081816107f001528181611c010152612a330152600081816106ba01528181611c2201526129d60152600081816108d901528181611c43015261297901526000818161033501528181611c64015261291a01526000818161089f01528181611e9c01526122db0152600081816103fd01528181611e3f01526122ab01526000818161083f01528181611de2015261227b0152600081816103ae01528181611d83015261224b01526000818161054501528181611f10015261214a0152600081816107a2015281816109b101528181610b6501528181610cd801528181612612015281816126f001526127ce0152600061058f0152600081816107c9015281816119bc01528181611cb501526128d401526000818161061e015261177401526000610900015260006106f401526000818161075401528181610a2501528181610ae401528181610bd101528181610c3801528181610c9f01528181610d5601528181610dc401528181610e3201528181610ea00152818161233b0152612b210152600061042401526000818161077b0152818161159401528181611cde0152818161230401528181612412015281816124cf015281816125700152612aae01526131786000f3fe608060405234801561001057600080fd5b506004361061032b5760003560e01c806382c63066116101b2578063c21ee162116100f9578063e90d1dbc116100a2578063ef14101e1161007c578063ef14101e1461089a578063f1dc3cc9146108c1578063f8f15639146108d4578063fc0c546a146108fb57600080fd5b8063e90d1dbc14610861578063ec026ca714610874578063ecb586a51461088757600080fd5b8063ce30bbdb116100d3578063ce30bbdb14610812578063cf023dd014610827578063d21220a71461083a57600080fd5b8063c21ee1621461079d578063c7c4fe1e146107c4578063caed3787146107eb57600080fd5b8063a50cf2c81161015b578063ae206e2411610135578063ae206e241461073c578063bd90df701461074f578063c12c21c01461077657600080fd5b8063a50cf2c8146106ef578063a6417ed614610716578063ab6548fa1461072957600080fd5b806393a581531161018c57806393a581531461068e5780639e9c1e88146106b55780639fdaea0c146106dc57600080fd5b806382c630661461061957806387427f46146106405780638ba51dfc1461066757600080fd5b80634515cef31161027657806363e73cbb1161021f5780636e1d8271116101f95780636e1d8271146105c457806378aa73a4146105eb57806379bea6641461060657600080fd5b806363e73cbb1461057757806364a89bca1461058a57806365b2489b146105b157600080fd5b80635b41b908116102505780635b41b908146105065780635e8d3f5514610519578063623d85851461054057600080fd5b80634515cef3146104b95780634be97fb0146104cc57806357d78875146104df57600080fd5b80632954018c116102d85780633df02124116102b25780633df021241461046c578063403d4e4a1461047f57806341c84b36146104a657600080fd5b80632954018c1461041f5780632c5788d21461044657806333d2ebf21461045957600080fd5b80631a4d01d2116103095780631a4d01d2146103d05780631af4de83146103e557806325be124e146103f857600080fd5b806301b44c8414610330578063068711631461036a5780630dfe1681146103a9575b600080fd5b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6040519081526020015b60405180910390f35b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610361565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103e36103de366004612bf3565b610922565b005b6103e36103f3366004612c28565b610969565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b610357610454366004612c54565b6109ad565b6103e3610467366004612c80565b610f2a565b6103e361047a366004612caa565b610f71565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103e36104b4366004612cec565b610fba565b6103e36104c7366004612d29565b611019565b6103e36104da366004612cec565b611071565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103e3610514366004612d54565b6110c0565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6105677f000000000000000000000000000000000000000000000000000000000000000081565b6040519015158152602001610361565b6103e3610585366004612d86565b611119565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103e36105bf366004612d54565b611167565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6105f3600281565b60405161ffff9091168152602001610361565b6103e3610614366004612c28565b6111c0565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103e36106ea366004612d29565b611204565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103e3610724366004612caa565b61125c565b6103e3610737366004612cec565b61129f565b61035761074a366004612d86565b6112f9565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b61081a600681565b6040516103619190612da8565b6103e3610835366004612bf3565b611312565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103e361086f366004612d86565b611356565b6103e3610882366004612c80565b6113a4565b6103e3610895366004612dd0565b6113e7565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103e36108cf366004612cec565b611428565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b61092a611590565b6001600160a01b0316336001600160a01b03161461095b57604051636c01359160e11b815260040160405180910390fd5b61096482611619565b505050565b610971611590565b6001600160a01b0316336001600160a01b0316146109a257604051636c01359160e11b815260040160405180910390fd5b61096483838361165d565b60007f0000000000000000000000000000000000000000000000000000000000000000600203610b635781600f0b600014610aa257604080518082018252600081526020810185905290517fed8e84f30000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163ed8e84f391610a5c9190600190600401612e17565b602060405180830381865afa158015610a79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9d9190612e34565b610b5c565b6040805180820182528481526000602082015290517fed8e84f30000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163ed8e84f391610b1b9190600190600401612e17565b602060405180830381865afa158015610b38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5c9190612e34565b9050610f24565b7f0000000000000000000000000000000000000000000000000000000000000000600303610cd65781600f0b600014610c6f5781600f0b600114610c085760408051606081018252600080825260208201528082018590529051633883e11960e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691633883e11991610a5c9190600190600401612e70565b60408051606081018252600080825260208201869052818301529051633883e11960e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691633883e11991610a5c9190600190600401612e70565b60408051606081018252848152600060208201819052818301529051633883e11960e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691633883e11991610b1b9190600190600401612e70565b7f0000000000000000000000000000000000000000000000000000000000000000600403610ed75781600f0b600014610e695781600f0b600114610dfb5781600f0b600214610d8d57604080516080810182526000808252602082018190528183015260608101859052905163cf701ff760e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163cf701ff791610a5c9190600190600401612eb0565b604080516080810182526000808252602082018190528183018690526060820152905163cf701ff760e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163cf701ff791610a5c9190600190600401612eb0565b604080516080810182526000808252602082018690528183018190526060820152905163cf701ff760e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163cf701ff791610a5c9190600190600401612eb0565b604080516080810182528481526000602082018190528183018190526060820152905163cf701ff760e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163cf701ff791610b1b9190600190600401612eb0565b60405162461bcd60e51b815260206004820152601060248201527f496e636f7272656374206e436f696e730000000000000000000000000000000060448201526064015b60405180910390fd5b92915050565b610f32611590565b6001600160a01b0316336001600160a01b031614610f6357604051636c01359160e11b815260040160405180910390fd5b610f6d8282611745565b5050565b610f79611590565b6001600160a01b0316336001600160a01b031614610faa57604051636c01359160e11b815260040160405180910390fd5b610fb48484611835565b50505050565b610fc2611590565b6001600160a01b0316336001600160a01b031614610ff357604051636c01359160e11b815260040160405180910390fd5b61096461100761100285611475565b611511565b61101361100285611475565b83611879565b611021611590565b6001600160a01b0316336001600160a01b03161461105257604051636c01359160e11b815260040160405180910390fd5b610f6d6001833581109060208501358110906040860135116000611959565b611079611590565b6001600160a01b0316336001600160a01b0316146110aa57604051636c01359160e11b815260040160405180910390fd5b610964836110ba61100285611475565b836119e2565b6110c8611590565b6001600160a01b0316336001600160a01b0316146110f957604051636c01359160e11b815260040160405180910390fd5b610fb461110861100286611475565b61111461100286611475565b611835565b611121611590565b6001600160a01b0316336001600160a01b03161461115257604051636c01359160e11b815260040160405180910390fd5b610f6d61116161100284611475565b826119f8565b61116f611590565b6001600160a01b0316336001600160a01b0316146111a057604051636c01359160e11b815260040160405180910390fd5b610fb46111af61100286611475565b6111bb61100286611475565b611ad9565b6111c8611590565b6001600160a01b0316336001600160a01b0316146111f957604051636c01359160e11b815260040160405180910390fd5b610964838383611879565b61120c611590565b6001600160a01b0316336001600160a01b03161461123d57604051636c01359160e11b815260040160405180910390fd5b610f6d6001833581109060208501358110906040860135116000611b1e565b611264611590565b6001600160a01b0316336001600160a01b03161461129557604051636c01359160e11b815260040160405180910390fd5b610fb48484611ad9565b6112a7611590565b6001600160a01b0316336001600160a01b0316146112d857604051636c01359160e11b815260040160405180910390fd5b6109646112e761100285611475565b6112f361100285611475565b8361165d565b600061130b8361045461100285611475565b9392505050565b61131a611590565b6001600160a01b0316336001600160a01b03161461134b57604051636c01359160e11b815260040160405180910390fd5b6109648383836119e2565b61135e611590565b6001600160a01b0316336001600160a01b03161461138f57604051636c01359160e11b815260040160405180910390fd5b610f6d61139e61100284611475565b82611745565b6113ac611590565b6001600160a01b0316336001600160a01b0316146113dd57604051636c01359160e11b815260040160405180910390fd5b610f6d82826119f8565b6113ef611590565b6001600160a01b0316336001600160a01b03161461142057604051636c01359160e11b815260040160405180910390fd5b610f6d611bbb565b611430611590565b6001600160a01b0316336001600160a01b03161461146157604051636c01359160e11b815260040160405180910390fd5b61096461147061100284611475565b611619565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82111561150d5760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e206160448201527f6e20696e743235360000000000000000000000000000000000000000000000006064820152608401610f1b565b5090565b80600f81900b811461158b5760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f32382062697473000000000000000000000000000000000000000000000000006064820152608401610f1b565b919050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632f7a18816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116149190612efa565b905090565b61165a816000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509250611c8f915050565b50565b6000611667611cda565b90506000611676856001611d6f565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa1580156116c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e69190612e34565b9050600181116116f857505050505050565b6000190160006b033b2e3c9fd0803ce80000006117158684612f15565b61171f9190612f3a565b905061173c87876117348a8a87876001611f0c565b600180612100565b50505050505050565b600061174f611cda565b6040516370a0823160e01b81526001600160a01b0380831660048301529192506000917f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156117bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117df9190612e34565b9050600181116117ef5750505050565b6000190160006b033b2e3c9fd0803ce800000061180c8584612f15565b6118169190612f3a565b905061182e85611827878585612146565b6001611c8f565b5050505050565b610f6d82826000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525092508291506121009050565b6000611883611cda565b90506000611892856000611d6f565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa1580156118de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119029190612e34565b90506001811161191457505050505050565b6000190160006b033b2e3c9fd0803ce80000006119318684612f15565b61193b9190612f3a565b905061173c87876119508a8a87876000611f0c565b60006001612100565b61196884848484600019612240565b6119a86000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061230092505050565b506119b7848484846001612240565b610fb47f000000000000000000000000000000000000000000000000000000000000000060006123c0565b610964826119f184868561260e565b60006128aa565b6000611a02611cda565b90506000611a11846000611d6f565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa158015611a5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a819190612e34565b905060018111611a92575050505050565b6000190160006b033b2e3c9fd0803ce8000000611aaf8684612f15565b611ab99190612f3a565b9050611ad186611aca88858561260e565b60016128aa565b505050505050565b610f6d82826000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052506001935091506121009050565b611b5e6000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061230092505050565b5060008415611b7457611b72600080612906565b175b8315611b8857611b8660016000612906565b175b8215611b9c57611b9a60026000612906565b175b8115611bb057611bae60036000612906565b175b61182e8160006123c0565b611bfb6000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061230092505050565b50611c8d7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000017171760006123c0565b565b611c9882612300565b50610964611ca7846000612906565b82611cb35760006123c0565b7f00000000000000000000000000000000000000000000000000000000000000005b6123c0565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e958b704611d13611590565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156115f0573d6000803e3d6000fd5b600082600f0b600003611dd05781611da7577f0000000000000000000000000000000000000000000000000000000000000000611dc9565b7f00000000000000000000000000000000000000000000000000000000000000005b9050611ee5565b82600f0b600103611e2d5781611e06577f0000000000000000000000000000000000000000000000000000000000000000611dc9565b507f0000000000000000000000000000000000000000000000000000000000000000611ee5565b82600f0b600203611e8a5781611e63577f0000000000000000000000000000000000000000000000000000000000000000611dc9565b507f0000000000000000000000000000000000000000000000000000000000000000611ee5565b82600f0b600303611ee55781611ec0577f0000000000000000000000000000000000000000000000000000000000000000611ee2565b7f00000000000000000000000000000000000000000000000000000000000000005b90505b6001600160a01b038116610f24576040516334769e6f60e21b815260040160405180910390fd5b60607f0000000000000000000000000000000000000000000000000000000000000000156120185781611fa757604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f5b41b90800000000000000000000000000000000000000000000000000000000179052612011565b604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f65b2489b000000000000000000000000000000000000000000000000000000001790525b90506120f7565b8161208b57604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f3df0212400000000000000000000000000000000000000000000000000000000179052612011565b604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167fa6417ed60000000000000000000000000000000000000000000000000000000017905290505b95945050505050565b61210d8583600019612a9d565b61211683612300565b5061212385836001612a9d565b61182e6121308584612906565b8261213c5760006123c0565b611cd58785612906565b60607f0000000000000000000000000000000000000000000000000000000000000000156121d65760405160248101849052600f85900b60448201526064810183905260840160408051601f198184030181529190526020810180516001600160e01b03167ff1dc3cc900000000000000000000000000000000000000000000000000000000179052905061130b565b60405160248101849052600f85900b60448201526064810183905260840160408051601f198184030181529190526020810180516001600160e01b03167f1a4d01d20000000000000000000000000000000000000000000000000000000017905290509392505050565b8415612270576122707f000000000000000000000000000000000000000000000000000000000000000082612aac565b83156122a0576122a07f000000000000000000000000000000000000000000000000000000000000000082612aac565b82156122d0576122d07f000000000000000000000000000000000000000000000000000000000000000082612aac565b811561182e5761182e7f000000000000000000000000000000000000000000000000000000000000000082612aac565b60607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636ce4074a612339611590565b7f0000000000000000000000000000000000000000000000000000000000000000856040518463ffffffff1660e01b815260040161237993929190612f80565b6000604051808303816000875af1158015612398573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f249190810190612fe4565b60006123ca611cda565b9050828218600060015b828111611ad157828116156125df576040517fe75538c7000000000000000000000000000000000000000000000000000000008152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e75538c7906024016040805180830381865afa158015612460573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124849190613091565b50915085811615612530576040517f51e3f1600000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015283811660248301527f000000000000000000000000000000000000000000000000000000000000000016906351e3f16090604401600060405180830381600087803b15801561251357600080fd5b505af1158015612527573d6000803e3d6000fd5b505050506125df565b6040517f0d8f9cee0000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015283811660248301527f00000000000000000000000000000000000000000000000000000000000000001690630d8f9cee906044016020604051808303816000875af11580156125b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125dd91906130cf565b505b7f80000000000000000000000000000000000000000000000000000000000000008114611ad15760011b6123d4565b60607f00000000000000000000000000000000000000000000000000000000000000006002036126ee57612640612b87565b600185600f0b1315612665576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166002811061268a5761268a612ecd565b60200201526040516126a290829085906024016130f1565b60408051601f198184030181529190526020810180516001600160e01b03167f0b4c7e4d00000000000000000000000000000000000000000000000000000000179052915061130b9050565b7f00000000000000000000000000000000000000000000000000000000000000006003036127cc5761271e612ba5565b600285600f0b1315612743576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166003811061276857612768612ecd565b6020020152604051612780908290859060240161310c565b60408051601f198184030181529190526020810180516001600160e01b03167f4515cef300000000000000000000000000000000000000000000000000000000179052915061130b9050565b7f0000000000000000000000000000000000000000000000000000000000000000600403610ed7576127fc612bc3565b600385600f0b1315612821576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166004811061284657612846612ecd565b602002015260405161285e9082908590602401613127565b60408051601f198184030181529190526020810180516001600160e01b03167f029b2f3400000000000000000000000000000000000000000000000000000000179052915061130b9050565b6128b8836000600019612a9d565b6128c182612300565b506128cf8360006001612a9d565b6109647f0000000000000000000000000000000000000000000000000000000000000000826128ff5760006123c0565b611cd58560005b600082600f0b600003612967578161293e577f0000000000000000000000000000000000000000000000000000000000000000612960565b7f00000000000000000000000000000000000000000000000000000000000000005b9050612a7c565b82600f0b6001036129c4578161299d577f0000000000000000000000000000000000000000000000000000000000000000612960565b507f0000000000000000000000000000000000000000000000000000000000000000612a7c565b82600f0b600203612a2157816129fa577f0000000000000000000000000000000000000000000000000000000000000000612960565b507f0000000000000000000000000000000000000000000000000000000000000000612a7c565b82600f0b600303612a7c5781612a57577f0000000000000000000000000000000000000000000000000000000000000000612a79565b7f00000000000000000000000000000000000000000000000000000000000000005b90505b80600003610f24576040516334769e6f60e21b815260040160405180910390fd5b610964612aaa8484611d6f565b825b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166346fb371d612ae3611590565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b0391821660048201527f000000000000000000000000000000000000000000000000000000000000000082166024820152908516604482015260648101849052608401600060405180830381600087803b158015612b7357600080fd5b505af1158015611ad1573d6000803e3d6000fd5b60405180604001604052806002906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b8035600f81900b811461158b57600080fd5b600080600060608486031215612c0857600080fd5b83359250612c1860208501612be1565b9150604084013590509250925092565b600080600060608486031215612c3d57600080fd5b612c4684612be1565b9250612c1860208501612be1565b60008060408385031215612c6757600080fd5b82359150612c7760208401612be1565b90509250929050565b60008060408385031215612c9357600080fd5b612c9c83612be1565b946020939093013593505050565b60008060008060808587031215612cc057600080fd5b612cc985612be1565b9350612cd760208601612be1565b93969395505050506040820135916060013590565b600080600060608486031215612d0157600080fd5b505081359360208301359350604090920135919050565b8060608101831015610f2457600080fd5b60008060808385031215612d3c57600080fd5b612d468484612d18565b946060939093013593505050565b60008060008060808587031215612d6a57600080fd5b5050823594602084013594506040840135936060013592509050565b60008060408385031215612d9957600080fd5b50508035926020909101359150565b6020810160158310612dca57634e487b7160e01b600052602160045260246000fd5b91905290565b60008060808385031215612de357600080fd5b82359150612c778460208501612d18565b8060005b6002811015610fb4578151845260209384019390910190600101612df8565b60608101612e258285612df4565b82151560408301529392505050565b600060208284031215612e4657600080fd5b5051919050565b8060005b6003811015610fb4578151845260209384019390910190600101612e51565b60808101612e7e8285612e4d565b82151560608301529392505050565b8060005b6004811015610fb4578151845260209384019390910190600101612e91565b60a08101612ebe8285612e8d565b82151560808301529392505050565b634e487b7160e01b600052603260045260246000fd5b80516001600160a01b038116811461158b57600080fd5b600060208284031215612f0c57600080fd5b61130b82612ee3565b8082028115828204841417610f2457634e487b7160e01b600052601160045260246000fd5b600082612f5757634e487b7160e01b600052601260045260246000fd5b500490565b60005b83811015612f77578181015183820152602001612f5f565b50506000910152565b60006001600160a01b038086168352808516602084015250606060408301528251806060840152612fb8816080850160208701612f5c565b601f01601f191691909101608001949350505050565b634e487b7160e01b600052604160045260246000fd5b600060208284031215612ff657600080fd5b815167ffffffffffffffff8082111561300e57600080fd5b818401915084601f83011261302257600080fd5b81518181111561303457613034612fce565b604051601f8201601f19908116603f0116810190838211818310171561305c5761305c612fce565b8160405282815287602084870101111561307557600080fd5b613086836020830160208801612f5c565b979650505050505050565b600080604083850312156130a457600080fd5b6130ad83612ee3565b9150602083015161ffff811681146130c457600080fd5b809150509250929050565b6000602082840312156130e157600080fd5b8151801515811461130b57600080fd5b606081016130ff8285612df4565b8260408301529392505050565b6080810161311a8285612e4d565b8260608301529392505050565b60a081016131358285612e8d565b826080830152939250505056fea2646970667358221220c2134ce1a4fa1dea086cfa7ebade5030e55b06a3dc11900b7e6900abee59381764736f6c63430008110033000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f7000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c70000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e4900000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061032b5760003560e01c806382c63066116101b2578063c21ee162116100f9578063e90d1dbc116100a2578063ef14101e1161007c578063ef14101e1461089a578063f1dc3cc9146108c1578063f8f15639146108d4578063fc0c546a146108fb57600080fd5b8063e90d1dbc14610861578063ec026ca714610874578063ecb586a51461088757600080fd5b8063ce30bbdb116100d3578063ce30bbdb14610812578063cf023dd014610827578063d21220a71461083a57600080fd5b8063c21ee1621461079d578063c7c4fe1e146107c4578063caed3787146107eb57600080fd5b8063a50cf2c81161015b578063ae206e2411610135578063ae206e241461073c578063bd90df701461074f578063c12c21c01461077657600080fd5b8063a50cf2c8146106ef578063a6417ed614610716578063ab6548fa1461072957600080fd5b806393a581531161018c57806393a581531461068e5780639e9c1e88146106b55780639fdaea0c146106dc57600080fd5b806382c630661461061957806387427f46146106405780638ba51dfc1461066757600080fd5b80634515cef31161027657806363e73cbb1161021f5780636e1d8271116101f95780636e1d8271146105c457806378aa73a4146105eb57806379bea6641461060657600080fd5b806363e73cbb1461057757806364a89bca1461058a57806365b2489b146105b157600080fd5b80635b41b908116102505780635b41b908146105065780635e8d3f5514610519578063623d85851461054057600080fd5b80634515cef3146104b95780634be97fb0146104cc57806357d78875146104df57600080fd5b80632954018c116102d85780633df02124116102b25780633df021241461046c578063403d4e4a1461047f57806341c84b36146104a657600080fd5b80632954018c1461041f5780632c5788d21461044657806333d2ebf21461045957600080fd5b80631a4d01d2116103095780631a4d01d2146103d05780631af4de83146103e557806325be124e146103f857600080fd5b806301b44c8414610330578063068711631461036a5780630dfe1681146103a9575b600080fd5b6103577f000000000000000000000000000000000000000000000000000000000000000181565b6040519081526020015b60405180910390f35b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610361565b6103917f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b6103e36103de366004612bf3565b610922565b005b6103e36103f3366004612c28565b610969565b6103917f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b6103917f000000000000000000000000cf64698aff7e5f27a11dff868af228653ba53be081565b610357610454366004612c54565b6109ad565b6103e3610467366004612c80565b610f2a565b6103e361047a366004612caa565b610f71565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103e36104b4366004612cec565b610fba565b6103e36104c7366004612d29565b611019565b6103e36104da366004612cec565b611071565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103e3610514366004612d54565b6110c0565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6105677f000000000000000000000000000000000000000000000000000000000000000081565b6040519015158152602001610361565b6103e3610585366004612d86565b611119565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103e36105bf366004612d54565b611167565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6105f3600281565b60405161ffff9091168152602001610361565b6103e3610614366004612c28565b6111c0565b6103917f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e49081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b6103577f000000000000000000000000000000000000000000000000000000000000002081565b6103e36106ea366004612d29565b611204565b6103917f000000000000000000000000523da3a8961e4dd4f6206dbf7e6c749f51796bb381565b6103e3610724366004612caa565b61125c565b6103e3610737366004612cec565b61129f565b61035761074a366004612d86565b6112f9565b6103917f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c781565b6103917f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f781565b6103577f000000000000000000000000000000000000000000000000000000000000000381565b6103577f000000000000000000000000000000000000000000000000000000000000100081565b6103577f000000000000000000000000000000000000000000000000000000000000000081565b61081a600681565b6040516103619190612da8565b6103e3610835366004612bf3565b611312565b6103917f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b6103e361086f366004612d86565b611356565b6103e3610882366004612c80565b6113a4565b6103e3610895366004612dd0565b6113e7565b6103917f000000000000000000000000000000000000000000000000000000000000000081565b6103e36108cf366004612cec565b611428565b6103577f000000000000000000000000000000000000000000000000000000000000001081565b6103917f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e49081565b61092a611590565b6001600160a01b0316336001600160a01b03161461095b57604051636c01359160e11b815260040160405180910390fd5b61096482611619565b505050565b610971611590565b6001600160a01b0316336001600160a01b0316146109a257604051636c01359160e11b815260040160405180910390fd5b61096483838361165d565b60007f0000000000000000000000000000000000000000000000000000000000000003600203610b635781600f0b600014610aa257604080518082018252600081526020810185905290517fed8e84f30000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7169163ed8e84f391610a5c9190600190600401612e17565b602060405180830381865afa158015610a79573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9d9190612e34565b610b5c565b6040805180820182528481526000602082015290517fed8e84f30000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7169163ed8e84f391610b1b9190600190600401612e17565b602060405180830381865afa158015610b38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5c9190612e34565b9050610f24565b7f0000000000000000000000000000000000000000000000000000000000000003600303610cd65781600f0b600014610c6f5781600f0b600114610c085760408051606081018252600080825260208201528082018590529051633883e11960e01b81526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c71691633883e11991610a5c9190600190600401612e70565b60408051606081018252600080825260208201869052818301529051633883e11960e01b81526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c71691633883e11991610a5c9190600190600401612e70565b60408051606081018252848152600060208201819052818301529051633883e11960e01b81526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c71691633883e11991610b1b9190600190600401612e70565b7f0000000000000000000000000000000000000000000000000000000000000003600403610ed75781600f0b600014610e695781600f0b600114610dfb5781600f0b600214610d8d57604080516080810182526000808252602082018190528183015260608101859052905163cf701ff760e01b81526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7169163cf701ff791610a5c9190600190600401612eb0565b604080516080810182526000808252602082018190528183018690526060820152905163cf701ff760e01b81526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7169163cf701ff791610a5c9190600190600401612eb0565b604080516080810182526000808252602082018690528183018190526060820152905163cf701ff760e01b81526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7169163cf701ff791610a5c9190600190600401612eb0565b604080516080810182528481526000602082018190528183018190526060820152905163cf701ff760e01b81526001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7169163cf701ff791610b1b9190600190600401612eb0565b60405162461bcd60e51b815260206004820152601060248201527f496e636f7272656374206e436f696e730000000000000000000000000000000060448201526064015b60405180910390fd5b92915050565b610f32611590565b6001600160a01b0316336001600160a01b031614610f6357604051636c01359160e11b815260040160405180910390fd5b610f6d8282611745565b5050565b610f79611590565b6001600160a01b0316336001600160a01b031614610faa57604051636c01359160e11b815260040160405180910390fd5b610fb48484611835565b50505050565b610fc2611590565b6001600160a01b0316336001600160a01b031614610ff357604051636c01359160e11b815260040160405180910390fd5b61096461100761100285611475565b611511565b61101361100285611475565b83611879565b611021611590565b6001600160a01b0316336001600160a01b03161461105257604051636c01359160e11b815260040160405180910390fd5b610f6d6001833581109060208501358110906040860135116000611959565b611079611590565b6001600160a01b0316336001600160a01b0316146110aa57604051636c01359160e11b815260040160405180910390fd5b610964836110ba61100285611475565b836119e2565b6110c8611590565b6001600160a01b0316336001600160a01b0316146110f957604051636c01359160e11b815260040160405180910390fd5b610fb461110861100286611475565b61111461100286611475565b611835565b611121611590565b6001600160a01b0316336001600160a01b03161461115257604051636c01359160e11b815260040160405180910390fd5b610f6d61116161100284611475565b826119f8565b61116f611590565b6001600160a01b0316336001600160a01b0316146111a057604051636c01359160e11b815260040160405180910390fd5b610fb46111af61100286611475565b6111bb61100286611475565b611ad9565b6111c8611590565b6001600160a01b0316336001600160a01b0316146111f957604051636c01359160e11b815260040160405180910390fd5b610964838383611879565b61120c611590565b6001600160a01b0316336001600160a01b03161461123d57604051636c01359160e11b815260040160405180910390fd5b610f6d6001833581109060208501358110906040860135116000611b1e565b611264611590565b6001600160a01b0316336001600160a01b03161461129557604051636c01359160e11b815260040160405180910390fd5b610fb48484611ad9565b6112a7611590565b6001600160a01b0316336001600160a01b0316146112d857604051636c01359160e11b815260040160405180910390fd5b6109646112e761100285611475565b6112f361100285611475565b8361165d565b600061130b8361045461100285611475565b9392505050565b61131a611590565b6001600160a01b0316336001600160a01b03161461134b57604051636c01359160e11b815260040160405180910390fd5b6109648383836119e2565b61135e611590565b6001600160a01b0316336001600160a01b03161461138f57604051636c01359160e11b815260040160405180910390fd5b610f6d61139e61100284611475565b82611745565b6113ac611590565b6001600160a01b0316336001600160a01b0316146113dd57604051636c01359160e11b815260040160405180910390fd5b610f6d82826119f8565b6113ef611590565b6001600160a01b0316336001600160a01b03161461142057604051636c01359160e11b815260040160405180910390fd5b610f6d611bbb565b611430611590565b6001600160a01b0316336001600160a01b03161461146157604051636c01359160e11b815260040160405180910390fd5b61096461147061100284611475565b611619565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82111561150d5760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e206160448201527f6e20696e743235360000000000000000000000000000000000000000000000006064820152608401610f1b565b5090565b80600f81900b811461158b5760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f32382062697473000000000000000000000000000000000000000000000000006064820152608401610f1b565b919050565b60007f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b0316632f7a18816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116149190612efa565b905090565b61165a816000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509250611c8f915050565b50565b6000611667611cda565b90506000611676856001611d6f565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa1580156116c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e69190612e34565b9050600181116116f857505050505050565b6000190160006b033b2e3c9fd0803ce80000006117158684612f15565b61171f9190612f3a565b905061173c87876117348a8a87876001611f0c565b600180612100565b50505050505050565b600061174f611cda565b6040516370a0823160e01b81526001600160a01b0380831660048301529192506000917f0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e49016906370a0823190602401602060405180830381865afa1580156117bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117df9190612e34565b9050600181116117ef5750505050565b6000190160006b033b2e3c9fd0803ce800000061180c8584612f15565b6118169190612f3a565b905061182e85611827878585612146565b6001611c8f565b5050505050565b610f6d82826000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525092508291506121009050565b6000611883611cda565b90506000611892856000611d6f565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa1580156118de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119029190612e34565b90506001811161191457505050505050565b6000190160006b033b2e3c9fd0803ce80000006119318684612f15565b61193b9190612f3a565b905061173c87876119508a8a87876000611f0c565b60006001612100565b61196884848484600019612240565b6119a86000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061230092505050565b506119b7848484846001612240565b610fb47f000000000000000000000000000000000000000000000000000000000000100060006123c0565b610964826119f184868561260e565b60006128aa565b6000611a02611cda565b90506000611a11846000611d6f565b6040516370a0823160e01b81526001600160a01b0384811660048301529192506000918316906370a0823190602401602060405180830381865afa158015611a5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a819190612e34565b905060018111611a92575050505050565b6000190160006b033b2e3c9fd0803ce8000000611aaf8684612f15565b611ab99190612f3a565b9050611ad186611aca88858561260e565b60016128aa565b505050505050565b610f6d82826000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052506001935091506121009050565b611b5e6000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061230092505050565b5060008415611b7457611b72600080612906565b175b8315611b8857611b8660016000612906565b175b8215611b9c57611b9a60026000612906565b175b8115611bb057611bae60036000612906565b175b61182e8160006123c0565b611bfb6000368080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061230092505050565b50611c8d7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000207f00000000000000000000000000000000000000000000000000000000000000107f000000000000000000000000000000000000000000000000000000000000000117171760006123c0565b565b611c9882612300565b50610964611ca7846000612906565b82611cb35760006123c0565b7f00000000000000000000000000000000000000000000000000000000000010005b6123c0565b60007f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b031663e958b704611d13611590565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156115f0573d6000803e3d6000fd5b600082600f0b600003611dd05781611da7577f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f611dc9565b7f00000000000000000000000000000000000000000000000000000000000000005b9050611ee5565b82600f0b600103611e2d5781611e06577f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48611dc9565b507f0000000000000000000000000000000000000000000000000000000000000000611ee5565b82600f0b600203611e8a5781611e63577f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7611dc9565b507f0000000000000000000000000000000000000000000000000000000000000000611ee5565b82600f0b600303611ee55781611ec0577f0000000000000000000000000000000000000000000000000000000000000000611ee2565b7f00000000000000000000000000000000000000000000000000000000000000005b90505b6001600160a01b038116610f24576040516334769e6f60e21b815260040160405180910390fd5b60607f0000000000000000000000000000000000000000000000000000000000000000156120185781611fa757604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f5b41b90800000000000000000000000000000000000000000000000000000000179052612011565b604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f65b2489b000000000000000000000000000000000000000000000000000000001790525b90506120f7565b8161208b57604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167f3df0212400000000000000000000000000000000000000000000000000000000179052612011565b604051600f87810b602483015286900b6044820152606481018590526084810184905260a40160408051601f198184030181529190526020810180516001600160e01b03167fa6417ed60000000000000000000000000000000000000000000000000000000017905290505b95945050505050565b61210d8583600019612a9d565b61211683612300565b5061212385836001612a9d565b61182e6121308584612906565b8261213c5760006123c0565b611cd58785612906565b60607f0000000000000000000000000000000000000000000000000000000000000000156121d65760405160248101849052600f85900b60448201526064810183905260840160408051601f198184030181529190526020810180516001600160e01b03167ff1dc3cc900000000000000000000000000000000000000000000000000000000179052905061130b565b60405160248101849052600f85900b60448201526064810183905260840160408051601f198184030181529190526020810180516001600160e01b03167f1a4d01d20000000000000000000000000000000000000000000000000000000017905290509392505050565b8415612270576122707f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f82612aac565b83156122a0576122a07f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4882612aac565b82156122d0576122d07f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec782612aac565b811561182e5761182e7f000000000000000000000000000000000000000000000000000000000000000082612aac565b60607f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b0316636ce4074a612339611590565b7f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7856040518463ffffffff1660e01b815260040161237993929190612f80565b6000604051808303816000875af1158015612398573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f249190810190612fe4565b60006123ca611cda565b9050828218600060015b828111611ad157828116156125df576040517fe75538c7000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b03169063e75538c7906024016040805180830381865afa158015612460573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124849190613091565b50915085811615612530576040517f51e3f1600000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015283811660248301527f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f716906351e3f16090604401600060405180830381600087803b15801561251357600080fd5b505af1158015612527573d6000803e3d6000fd5b505050506125df565b6040517f0d8f9cee0000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015283811660248301527f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f71690630d8f9cee906044016020604051808303816000875af11580156125b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125dd91906130cf565b505b7f80000000000000000000000000000000000000000000000000000000000000008114611ad15760011b6123d4565b60607f00000000000000000000000000000000000000000000000000000000000000036002036126ee57612640612b87565b600185600f0b1315612665576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166002811061268a5761268a612ecd565b60200201526040516126a290829085906024016130f1565b60408051601f198184030181529190526020810180516001600160e01b03167f0b4c7e4d00000000000000000000000000000000000000000000000000000000179052915061130b9050565b7f00000000000000000000000000000000000000000000000000000000000000036003036127cc5761271e612ba5565b600285600f0b1315612743576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166003811061276857612768612ecd565b6020020152604051612780908290859060240161310c565b60408051601f198184030181529190526020810180516001600160e01b03167f4515cef300000000000000000000000000000000000000000000000000000000179052915061130b9050565b7f0000000000000000000000000000000000000000000000000000000000000003600403610ed7576127fc612bc3565b600385600f0b1315612821576040516334769e6f60e21b815260040160405180910390fd5b8381866fffffffffffffffffffffffffffffffff166004811061284657612846612ecd565b602002015260405161285e9082908590602401613127565b60408051601f198184030181529190526020810180516001600160e01b03167f029b2f3400000000000000000000000000000000000000000000000000000000179052915061130b9050565b6128b8836000600019612a9d565b6128c182612300565b506128cf8360006001612a9d565b6109647f0000000000000000000000000000000000000000000000000000000000001000826128ff5760006123c0565b611cd58560005b600082600f0b600003612967578161293e577f0000000000000000000000000000000000000000000000000000000000000001612960565b7f00000000000000000000000000000000000000000000000000000000000000005b9050612a7c565b82600f0b6001036129c4578161299d577f0000000000000000000000000000000000000000000000000000000000000010612960565b507f0000000000000000000000000000000000000000000000000000000000000000612a7c565b82600f0b600203612a2157816129fa577f0000000000000000000000000000000000000000000000000000000000000020612960565b507f0000000000000000000000000000000000000000000000000000000000000000612a7c565b82600f0b600303612a7c5781612a57577f0000000000000000000000000000000000000000000000000000000000000000612a79565b7f00000000000000000000000000000000000000000000000000000000000000005b90505b80600003610f24576040516334769e6f60e21b815260040160405180910390fd5b610964612aaa8484611d6f565b825b7f000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f76001600160a01b03166346fb371d612ae3611590565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526001600160a01b0391821660048201527f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c782166024820152908516604482015260648101849052608401600060405180830381600087803b158015612b7357600080fd5b505af1158015611ad1573d6000803e3d6000fd5b60405180604001604052806002906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b8035600f81900b811461158b57600080fd5b600080600060608486031215612c0857600080fd5b83359250612c1860208501612be1565b9150604084013590509250925092565b600080600060608486031215612c3d57600080fd5b612c4684612be1565b9250612c1860208501612be1565b60008060408385031215612c6757600080fd5b82359150612c7760208401612be1565b90509250929050565b60008060408385031215612c9357600080fd5b612c9c83612be1565b946020939093013593505050565b60008060008060808587031215612cc057600080fd5b612cc985612be1565b9350612cd760208601612be1565b93969395505050506040820135916060013590565b600080600060608486031215612d0157600080fd5b505081359360208301359350604090920135919050565b8060608101831015610f2457600080fd5b60008060808385031215612d3c57600080fd5b612d468484612d18565b946060939093013593505050565b60008060008060808587031215612d6a57600080fd5b5050823594602084013594506040840135936060013592509050565b60008060408385031215612d9957600080fd5b50508035926020909101359150565b6020810160158310612dca57634e487b7160e01b600052602160045260246000fd5b91905290565b60008060808385031215612de357600080fd5b82359150612c778460208501612d18565b8060005b6002811015610fb4578151845260209384019390910190600101612df8565b60608101612e258285612df4565b82151560408301529392505050565b600060208284031215612e4657600080fd5b5051919050565b8060005b6003811015610fb4578151845260209384019390910190600101612e51565b60808101612e7e8285612e4d565b82151560608301529392505050565b8060005b6004811015610fb4578151845260209384019390910190600101612e91565b60a08101612ebe8285612e8d565b82151560808301529392505050565b634e487b7160e01b600052603260045260246000fd5b80516001600160a01b038116811461158b57600080fd5b600060208284031215612f0c57600080fd5b61130b82612ee3565b8082028115828204841417610f2457634e487b7160e01b600052601160045260246000fd5b600082612f5757634e487b7160e01b600052601260045260246000fd5b500490565b60005b83811015612f77578181015183820152602001612f5f565b50506000910152565b60006001600160a01b038086168352808516602084015250606060408301528251806060840152612fb8816080850160208701612f5c565b601f01601f191691909101608001949350505050565b634e487b7160e01b600052604160045260246000fd5b600060208284031215612ff657600080fd5b815167ffffffffffffffff8082111561300e57600080fd5b818401915084601f83011261302257600080fd5b81518181111561303457613034612fce565b604051601f8201601f19908116603f0116810190838211818310171561305c5761305c612fce565b8160405282815287602084870101111561307557600080fd5b613086836020830160208801612f5c565b979650505050505050565b600080604083850312156130a457600080fd5b6130ad83612ee3565b9150602083015161ffff811681146130c457600080fd5b809150509250929050565b6000602082840312156130e157600080fd5b8151801515811461130b57600080fd5b606081016130ff8285612df4565b8260408301529392505050565b6080810161311a8285612e4d565b8260608301529392505050565b60a081016131358285612e8d565b826080830152939250505056fea2646970667358221220c2134ce1a4fa1dea086cfa7ebade5030e55b06a3dc11900b7e6900abee59381764736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f7000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c70000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e4900000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _creditManager (address): 0x672461Bfc20DD783444a830Ad4c38b345aB6E2f7
Arg [1] : _curvePool (address): 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7
Arg [2] : _lp_token (address): 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490
Arg [3] : _metapoolBase (address): 0x0000000000000000000000000000000000000000
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000672461bfc20dd783444a830ad4c38b345ab6e2f7
Arg [1] : 000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c7
Arg [2] : 0000000000000000000000006c3f90f043a72fa612cbac8115ee7e52bde6e490
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.