Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
IchiVaultRegistry
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import { ICustomConnectorRegistry } from "contracts/ConnectorRegistry.sol"; import { IchiConnector } from "contracts/connectors/IchiConnector.sol"; import { IICHIVault } from "contracts/interfaces/external/swapx/IIchiVault.sol"; interface IICHIVaultFactory { function genKey( address deployer, address token0, address token1, bool allowToken0, bool allowToken1 ) external pure returns (bytes32 key); function getICHIVault( bytes32 vaultKey ) external view returns (address); } contract IchiVaultRegistry is ICustomConnectorRegistry { IchiConnector public immutable ichiConnector; IICHIVaultFactory public immutable ichiVaultFactory; constructor(IchiConnector ichiConnector_, IICHIVaultFactory vaultFactory_) { ichiConnector = ichiConnector_; ichiVaultFactory = vaultFactory_; } function connectorOf( address target ) external view override returns (address) { bytes memory data = abi.encodeWithSelector(IICHIVault.ichiVaultFactory.selector); (bool success, bytes memory returnData) = target.staticcall(data); if (success && returnData.length == 32) { address result = abi.decode(returnData, (address)); if (result == address(ichiVaultFactory)) { bytes32 key = ichiVaultFactory.genKey( IICHIVault(target).owner(), IICHIVault(target).token0(), IICHIVault(target).token1(), IICHIVault(target).allowToken0(), IICHIVault(target).allowToken1() ); address ichiVault = ichiVaultFactory.getICHIVault(key); if (ichiVault == target) { return address(ichiConnector); } else { return address(0); } } else { return address(0); } } else { return address(0); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import { Admin } from "contracts/base/Admin.sol"; import { TimelockAdmin } from "contracts/base/TimelockAdmin.sol"; error ConnectorNotRegistered(address target); interface ICustomConnectorRegistry { function connectorOf(address target) external view returns (address); } contract ConnectorRegistry is Admin, TimelockAdmin { event ConnectorChanged(address target, address connector); event CustomRegistryAdded(address registry); event CustomRegistryRemoved(address registry); error ConnectorAlreadySet(address target); error ConnectorNotSet(address target); ICustomConnectorRegistry[] public customRegistries; mapping(ICustomConnectorRegistry => bool) public isCustomRegistry; mapping(address target => address connector) private connectors_; constructor( address admin_, address timelockAdmin_ ) Admin(admin_) TimelockAdmin(timelockAdmin_) { } /// @notice Update connector addresses for a batch of targets. /// @dev Controls which connector contracts are used for the specified /// targets. /// @custom:access Restricted to protocol admin. function setConnectors( address[] calldata targets, address[] calldata connectors ) external onlyAdmin { for (uint256 i; i != targets.length;) { if (connectors_[targets[i]] != address(0)) { revert ConnectorAlreadySet(targets[i]); } connectors_[targets[i]] = connectors[i]; emit ConnectorChanged(targets[i], connectors[i]); unchecked { ++i; } } } function updateConnectors( address[] calldata targets, address[] calldata connectors ) external onlyTimelockAdmin { for (uint256 i; i != targets.length;) { if (connectors_[targets[i]] == address(0)) { revert ConnectorNotSet(targets[i]); } connectors_[targets[i]] = connectors[i]; emit ConnectorChanged(targets[i], connectors[i]); unchecked { ++i; } } } /// @notice Append an address to the custom registries list. /// @custom:access Restricted to protocol admin. function addCustomRegistry(ICustomConnectorRegistry registry) external onlyAdmin { customRegistries.push(registry); isCustomRegistry[registry] = true; emit CustomRegistryAdded(address(registry)); } /// @notice Replace an address in the custom registries list. /// @custom:access Restricted to protocol admin. function updateCustomRegistry( uint256 index, ICustomConnectorRegistry newRegistry ) external onlyTimelockAdmin { address oldRegistry = address(customRegistries[index]); isCustomRegistry[customRegistries[index]] = false; emit CustomRegistryRemoved(oldRegistry); customRegistries[index] = newRegistry; isCustomRegistry[newRegistry] = true; if (address(newRegistry) != address(0)) { emit CustomRegistryAdded(address(newRegistry)); } } function connectorOf(address target) external view returns (address) { address connector = connectors_[target]; if (connector != address(0)) { return connector; } uint256 length = customRegistries.length; for (uint256 i; i != length;) { if (address(customRegistries[i]) != address(0)) { try customRegistries[i].connectorOf(target) returns ( address _connector ) { if (_connector != address(0)) { return _connector; } } catch { // Ignore } } unchecked { ++i; } } revert ConnectorNotRegistered(target); } function hasConnector(address target) external view returns (bool) { if (connectors_[target] != address(0)) { return true; } uint256 length = customRegistries.length; for (uint256 i; i != length;) { if (address(customRegistries[i]) != address(0)) { try customRegistries[i].connectorOf(target) returns ( address _connector ) { if (_connector != address(0)) { return true; } } catch { // Ignore } unchecked { ++i; } } } return false; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IICHIVault } from "contracts/interfaces/external/swapx/IIchiVault.sol"; import { ILiquidityConnector, AddLiquidityParams, RemoveLiquidityParams, SwapParams, GetAmountOutParams } from "contracts/interfaces/ILiquidityConnector.sol"; contract IchiConnector is ILiquidityConnector { error NotSupported(); error PoolTokensNotAllowed(); function addLiquidity( AddLiquidityParams memory addLiquidityParams ) external payable override { if ( IICHIVault(addLiquidityParams.lpToken).allowToken0() && !IICHIVault(addLiquidityParams.lpToken).allowToken1() ) { IICHIVault(addLiquidityParams.lpToken).deposit( addLiquidityParams.desiredAmounts[0], 0, address(this) ); } else if ( !IICHIVault(addLiquidityParams.lpToken).allowToken0() && IICHIVault(addLiquidityParams.lpToken).allowToken1() ) { IICHIVault(addLiquidityParams.lpToken).deposit( 0, addLiquidityParams.desiredAmounts[1], address(this) ); } else if ( IICHIVault(addLiquidityParams.lpToken).allowToken0() && IICHIVault(addLiquidityParams.lpToken).allowToken1() ) { IICHIVault(addLiquidityParams.lpToken).deposit( addLiquidityParams.desiredAmounts[0], addLiquidityParams.desiredAmounts[1], address(this) ); } else { revert PoolTokensNotAllowed(); } } function removeLiquidity( RemoveLiquidityParams memory removeLiquidityParams ) external override { IICHIVault(removeLiquidityParams.lpToken).withdraw( removeLiquidityParams.lpAmountIn, address(this) ); } function swapExactTokensForTokens( SwapParams memory ) external payable override { revert NotSupported(); } function getAmountOut( GetAmountOutParams memory ) external pure returns (uint256) { revert NotSupported(); } }
// SPDX-License-Identifier: Unlicense pragma solidity >=0.8.4; interface IICHIVault { function ichiVaultFactory() external view returns (address); function balanceOf( address ) external view returns (uint256); function pool() external view returns (address); function owner() external view returns (address); function token0() external view returns (address); function allowToken0() external view returns (bool); function token1() external view returns (address); function allowToken1() external view returns (bool); function fee() external view returns (uint24); function tickSpacing() external view returns (int24); function ammFeeRecipient() external view returns (address); function affiliate() external view returns (address); function baseLower() external view returns (int24); function baseUpper() external view returns (int24); function limitLower() external view returns (int24); function limitUpper() external view returns (int24); /// @notice NFT ID of the base position. If 0, the base position is not /// initialized. function basePositionId() external view returns (uint256); /// @notice NFT ID of the limit position. If 0, the limit position is not /// initialized. function limitPositionId() external view returns (uint256); function deposit0Max() external view returns (uint256); function deposit1Max() external view returns (uint256); function hysteresis() external view returns (uint256); function twapPeriod() external view returns (uint32); function auxTwapPeriod() external view returns (uint32); function getTotalAmounts() external view returns (uint256, uint256); function getBasePosition() external view returns (uint128, uint256, uint256); function getLimitPosition() external view returns (uint128, uint256, uint256); function deposit(uint256, uint256, address) external returns (uint256); function withdraw(uint256, address) external returns (uint256, uint256); function currentTick() external view returns (int24); function resetAllowances() external; function rebalance( int24 _baseLower, int24 _baseUpper, int24 _limitLower, int24 _limitUpper, int256 swapQuantity ) external; function collectFees() external returns (uint256 fees0, uint256 fees1); function setDepositMax( uint256 _deposit0Max, uint256 _deposit1Max ) external; function setHysteresis( uint256 _hysteresis ) external; function setAmmFeeRecipient( address _ammFeeRecipient ) external; function setAffiliate( address _affiliate ) external; function setTwapPeriod( uint32 newTwapPeriod ) external; function setAuxTwapPeriod( uint32 newAuxTwapPeriod ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; /// @title Admin contract /// @author vfat.tools /// @notice Provides an administration mechanism allowing restricted functions abstract contract Admin { /// ERRORS /// /// @notice Thrown when the caller is not the admin error NotAdminError(); //0xb5c42b3b /// EVENTS /// /// @notice Emitted when a new admin is set /// @param oldAdmin Address of the old admin /// @param newAdmin Address of the new admin event AdminSet(address oldAdmin, address newAdmin); /// STORAGE /// /// @notice Address of the current admin address public admin; /// MODIFIERS /// /// @dev Restricts a function to the admin modifier onlyAdmin() { if (msg.sender != admin) revert NotAdminError(); _; } /// WRITE FUNCTIONS /// /// @param admin_ Address of the admin constructor(address admin_) { emit AdminSet(admin, admin_); admin = admin_; } /// @notice Sets a new admin /// @param newAdmin Address of the new admin /// @custom:access Restricted to protocol admin. function setAdmin(address newAdmin) external onlyAdmin { emit AdminSet(admin, newAdmin); admin = newAdmin; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; /// @title TimelockAdmin contract /// @author vfat.tools /// @notice Provides an timelockAdministration mechanism allowing restricted /// functions abstract contract TimelockAdmin { /// ERRORS /// /// @notice Thrown when the caller is not the timelockAdmin error NotTimelockAdminError(); /// EVENTS /// /// @notice Emitted when a new timelockAdmin is set /// @param oldTimelockAdmin Address of the old timelockAdmin /// @param newTimelockAdmin Address of the new timelockAdmin event TimelockAdminSet(address oldTimelockAdmin, address newTimelockAdmin); /// STORAGE /// /// @notice Address of the current timelockAdmin address public timelockAdmin; /// MODIFIERS /// /// @dev Restricts a function to the timelockAdmin modifier onlyTimelockAdmin() { if (msg.sender != timelockAdmin) revert NotTimelockAdminError(); _; } /// WRITE FUNCTIONS /// /// @param timelockAdmin_ Address of the timelockAdmin constructor(address timelockAdmin_) { emit TimelockAdminSet(timelockAdmin, timelockAdmin_); timelockAdmin = timelockAdmin_; } /// @notice Sets a new timelockAdmin /// @dev Can only be called by the current timelockAdmin /// @param newTimelockAdmin Address of the new timelockAdmin function setTimelockAdmin(address newTimelockAdmin) external onlyTimelockAdmin { emit TimelockAdminSet(timelockAdmin, newTimelockAdmin); timelockAdmin = newTimelockAdmin; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { AddLiquidityParams, RemoveLiquidityParams, SwapParams, GetAmountOutParams } from "contracts/structs/LiquidityStructs.sol"; interface ILiquidityConnector { function addLiquidity( AddLiquidityParams memory addLiquidityParams ) external payable; function removeLiquidity( RemoveLiquidityParams memory removeLiquidityParams ) external; function swapExactTokensForTokens( SwapParams memory swap ) external payable; function getAmountOut( GetAmountOutParams memory getAmountOutParams ) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; struct AddLiquidityParams { address router; address lpToken; address[] tokens; uint256[] desiredAmounts; uint256[] minAmounts; bytes extraData; } struct RemoveLiquidityParams { address router; address lpToken; address[] tokens; uint256 lpAmountIn; uint256[] minAmountsOut; bytes extraData; } struct SwapParams { address router; uint256 amountIn; uint256 minAmountOut; address tokenIn; bytes extraData; } struct GetAmountOutParams { address router; address lpToken; address tokenIn; address tokenOut; uint256 amountIn; }
{ "remappings": [ "solmate/=lib/solmate/src/", "@openzeppelin/=lib/openzeppelin-contracts/", "@uniswap/v3-periphery/=lib/v3-periphery/", "@uniswap/v3-core/=lib/v3-core/", "@morpho-blue/=lib/morpho-blue/src/", "ds-test/=lib/solmate/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "morpho-blue/=lib/morpho-blue/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IchiConnector","name":"ichiConnector_","type":"address"},{"internalType":"contract IICHIVaultFactory","name":"vaultFactory_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"connectorOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ichiConnector","outputs":[{"internalType":"contract IchiConnector","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ichiVaultFactory","outputs":[{"internalType":"contract IICHIVaultFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60c060405234801561001057600080fd5b5060405161072338038061072383398101604081905261002f9161005e565b6001600160a01b039182166080521660a052610098565b6001600160a01b038116811461005b57600080fd5b50565b6000806040838503121561007157600080fd5b825161007c81610046565b602084015190925061008d81610046565b809150509250929050565b60805160a05161064c6100d76000396000818160a10152818161017d015281816101b8015261047b015260008181604b0152610504015261064c6000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806363cb3f9914610046578063c79aeaae14610089578063dd81fa631461009c575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b61006d61009736600461056b565b6100c3565b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b60408051600481526024810182526020810180516001600160e01b031663dd81fa6360e01b179052905160009190829081906001600160a01b0386169061010b90859061058f565b600060405180830381855afa9150503d8060008114610146576040519150601f19603f3d011682016040523d82523d6000602084013e61014b565b606091505b509150915081801561015e575080516020145b156105485760008180602001905181019061017991906105be565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b03160361053c5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630d4a4e52886001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610223573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024791906105be565b896001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610285573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a991906105be565b8a6001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061030b91906105be565b8b6001600160a01b0316637f7a1eec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610349573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036d91906105db565b8c6001600160a01b03166337e41b406040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cf91906105db565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015293909116604483015215156064820152901515608482015260a401602060405180830381865afa158015610433573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045791906105fd565b604051635030961560e01b8152600481018290529091506000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635030961590602401602060405180830381865afa1580156104c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e691906105be565b9050876001600160a01b0316816001600160a01b03160361052e57507f0000000000000000000000000000000000000000000000000000000000000000979650505050505050565b506000979650505050505050565b50600095945050505050565b506000949350505050565b6001600160a01b038116811461056857600080fd5b50565b60006020828403121561057d57600080fd5b813561058881610553565b9392505050565b6000825160005b818110156105b05760208186018101518583015201610596565b506000920191825250919050565b6000602082840312156105d057600080fd5b815161058881610553565b6000602082840312156105ed57600080fd5b8151801515811461058857600080fd5b60006020828403121561060f57600080fd5b505191905056fea26469706673582212208796bef35c2feecc4079fe5e0e7afb9f2940596b8a06aa56131e4d31509f866064736f6c63430008130033000000000000000000000000955198c750a160b1f8c5976a0af7ce6c6013682d00000000000000000000000034513e8a327987bb44acf5a925a7f3b4092d8b5f
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100415760003560e01c806363cb3f9914610046578063c79aeaae14610089578063dd81fa631461009c575b600080fd5b61006d7f000000000000000000000000955198c750a160b1f8c5976a0af7ce6c6013682d81565b6040516001600160a01b03909116815260200160405180910390f35b61006d61009736600461056b565b6100c3565b61006d7f00000000000000000000000034513e8a327987bb44acf5a925a7f3b4092d8b5f81565b60408051600481526024810182526020810180516001600160e01b031663dd81fa6360e01b179052905160009190829081906001600160a01b0386169061010b90859061058f565b600060405180830381855afa9150503d8060008114610146576040519150601f19603f3d011682016040523d82523d6000602084013e61014b565b606091505b509150915081801561015e575080516020145b156105485760008180602001905181019061017991906105be565b90507f00000000000000000000000034513e8a327987bb44acf5a925a7f3b4092d8b5f6001600160a01b0316816001600160a01b03160361053c5760007f00000000000000000000000034513e8a327987bb44acf5a925a7f3b4092d8b5f6001600160a01b0316630d4a4e52886001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610223573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024791906105be565b896001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610285573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102a991906105be565b8a6001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061030b91906105be565b8b6001600160a01b0316637f7a1eec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610349573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036d91906105db565b8c6001600160a01b03166337e41b406040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103cf91906105db565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015293909116604483015215156064820152901515608482015260a401602060405180830381865afa158015610433573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045791906105fd565b604051635030961560e01b8152600481018290529091506000906001600160a01b037f00000000000000000000000034513e8a327987bb44acf5a925a7f3b4092d8b5f1690635030961590602401602060405180830381865afa1580156104c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e691906105be565b9050876001600160a01b0316816001600160a01b03160361052e57507f000000000000000000000000955198c750a160b1f8c5976a0af7ce6c6013682d979650505050505050565b506000979650505050505050565b50600095945050505050565b506000949350505050565b6001600160a01b038116811461056857600080fd5b50565b60006020828403121561057d57600080fd5b813561058881610553565b9392505050565b6000825160005b818110156105b05760208186018101518583015201610596565b506000920191825250919050565b6000602082840312156105d057600080fd5b815161058881610553565b6000602082840312156105ed57600080fd5b8151801515811461058857600080fd5b60006020828403121561060f57600080fd5b505191905056fea26469706673582212208796bef35c2feecc4079fe5e0e7afb9f2940596b8a06aa56131e4d31509f866064736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000955198c750a160b1f8c5976a0af7ce6c6013682d00000000000000000000000034513e8a327987bb44acf5a925a7f3b4092d8b5f
-----Decoded View---------------
Arg [0] : ichiConnector_ (address): 0x955198C750A160b1f8C5976A0AF7cE6C6013682D
Arg [1] : vaultFactory_ (address): 0x34513e8A327987Bb44acF5A925a7f3b4092d8b5F
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000955198c750a160b1f8c5976a0af7ce6c6013682d
Arg [1] : 00000000000000000000000034513e8a327987bb44acf5a925a7f3b4092d8b5f
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.