Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00Multichain Info
N/A
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
ZapLib
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 { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SafeTransferLib } from "solmate/utils/SafeTransferLib.sol"; import { AddLiquidityParams } from "contracts/structs/LiquidityStructs.sol"; import { ILiquidityConnector } from "contracts/interfaces/ILiquidityConnector.sol"; import { ConnectorRegistry } from "contracts/ConnectorRegistry.sol"; import { DelegateModule } from "contracts/modules/DelegateModule.sol"; import { ZapIn, ZapOut } from "contracts/structs/ZapStructs.sol"; import { IZapLib } from "contracts/interfaces/libraries/IZapLib.sol"; import { ISwapLib } from "contracts/interfaces/libraries/ISwapLib.sol"; contract ZapLib is DelegateModule, IZapLib { error LiquidityAmountError(); // 0x4d0ab6b4 ISwapLib public immutable swapLib; ConnectorRegistry public immutable connectorRegistry; constructor(ConnectorRegistry connectorRegistry_, ISwapLib swapLib_) { connectorRegistry = connectorRegistry_; swapLib = swapLib_; } function zapIn( ZapIn memory zap ) external payable { uint256 swapDataLength = zap.swaps.length; for (uint256 i; i < swapDataLength;) { _delegateTo( address(swapLib), abi.encodeCall(ISwapLib.swap, (zap.swaps[i])) ); unchecked { i++; } } if (zap.addLiquidityParams.lpToken == address(0)) { return; } bool atLeastOneNonZero = false; AddLiquidityParams memory addLiquidityParams = zap.addLiquidityParams; uint256 addLiquidityParamsTokensLength = addLiquidityParams.tokens.length; for (uint256 i; i < addLiquidityParamsTokensLength; i++) { if (addLiquidityParams.tokens[i] == address(0)) { continue; } if (addLiquidityParams.desiredAmounts[i] == 0) { addLiquidityParams.desiredAmounts[i] = IERC20( addLiquidityParams.tokens[i] ).balanceOf(address(this)); } if (addLiquidityParams.desiredAmounts[i] > 0) { atLeastOneNonZero = true; // In case there is USDT or similar dust approval, revoke it SafeTransferLib.safeApprove( addLiquidityParams.tokens[i], addLiquidityParams.router, 0 ); SafeTransferLib.safeApprove( addLiquidityParams.tokens[i], addLiquidityParams.router, addLiquidityParams.desiredAmounts[i] ); } } if (!atLeastOneNonZero) { revert LiquidityAmountError(); } address routerConnector = connectorRegistry.connectorOf(addLiquidityParams.router); _delegateTo( routerConnector, abi.encodeCall( ILiquidityConnector.addLiquidity, (addLiquidityParams) ) ); for (uint256 i; i < addLiquidityParamsTokensLength;) { if (addLiquidityParams.tokens[i] != address(0)) { // Revoke any dust approval in case the amount was estimated SafeTransferLib.safeApprove( addLiquidityParams.tokens[i], addLiquidityParams.router, 0 ); } unchecked { i++; } } } function zapOut( ZapOut memory zap ) external { if (zap.removeLiquidityParams.lpToken != address(0)) { if (zap.removeLiquidityParams.lpAmountIn > 0) { SafeTransferLib.safeApprove( zap.removeLiquidityParams.lpToken, zap.removeLiquidityParams.router, zap.removeLiquidityParams.lpAmountIn ); } address routerConnector = connectorRegistry.connectorOf(zap.removeLiquidityParams.router); _delegateTo( address(routerConnector), abi.encodeCall( ILiquidityConnector.removeLiquidity, zap.removeLiquidityParams ) ); } uint256 swapDataLength = zap.swaps.length; for (uint256 i; i < swapDataLength;) { _delegateTo( address(swapLib), abi.encodeCall(ISwapLib.swap, (zap.swaps[i])) ); unchecked { i++; } } } }
// 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: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ error ETHTransferFailed(); error TransferFromFailed(); error TransferFailed(); error ApproveFailed(); /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } if (!success) revert ETHTransferFailed(); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( address token, address from, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument. mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) ) } if (!success) revert TransferFromFailed(); } function safeTransfer( address token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } if (!success) revert TransferFailed(); } function safeApprove( address token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. success := and( // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data. or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())), // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. // Counterintuitively, this call must be positioned second to the or() call in the // surrounding and() call or else returndatasize() will be zero during the computation. call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) ) } if (!success) revert ApproveFailed(); } }
// 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; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { AddLiquidityParams, RemoveLiquidityParams } from "contracts/structs/LiquidityStructs.sol"; interface ILiquidityConnector { error InvalidPrice(); function addLiquidity( AddLiquidityParams memory addLiquidityParams ) external payable; function removeLiquidity( RemoveLiquidityParams memory removeLiquidityParams ) external; function getPoolPrice( address lpToken, uint256 baseTokenIndex, uint256 quoteTokenIndex ) external view returns (uint256); function getReserves( address lpToken ) external view returns (uint256[] memory reserves); function getTokens( address lpToken ) external view returns (address[] memory tokens); }
// 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); error CustomRegistryAlreadyRegistered(); 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); error ArrayLengthMismatch(); ICustomConnectorRegistry[] public customRegistries; mapping(address target => address connector) private connectors_; constructor( address admin_, address timelockAdmin_ ) Admin(admin_) TimelockAdmin(timelockAdmin_) { } /// Admin functions /// @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 { if (targets.length != connectors.length) { revert ArrayLengthMismatch(); } 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 { if (targets.length != connectors.length) { revert ArrayLengthMismatch(); } 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 { if (isCustomRegistry(registry)) { revert CustomRegistryAlreadyRegistered(); } customRegistries.push(registry); 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 { ICustomConnectorRegistry oldRegistry = customRegistries[index]; emit CustomRegistryRemoved(address(oldRegistry)); customRegistries[index] = newRegistry; if (address(newRegistry) != address(0)) { emit CustomRegistryAdded(address(newRegistry)); } } /// Public functions function connectorOf( address target ) external view returns (address) { address connector = _getConnector(target); if (connector != address(0)) { return connector; } revert ConnectorNotRegistered(target); } function hasConnector( address target ) external view returns (bool) { return _getConnector(target) != address(0); } function isCustomRegistry( ICustomConnectorRegistry registry ) public view returns (bool) { for (uint256 i; i != customRegistries.length;) { if (address(customRegistries[i]) == address(registry)) { return true; } unchecked { ++i; } } return false; } /// Internal functions function _getConnector( address target ) internal 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)) { (bool success, bytes memory data) = address(customRegistries[i]) .staticcall( abi.encodeWithSelector( ICustomConnectorRegistry.connectorOf.selector, target ) ); if (success && data.length == 32) { address _connector = abi.decode(data, (address)); if (_connector != address(0)) { return _connector; } } } unchecked { ++i; } } return address(0); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract DelegateModule { function _delegateTo( address to, bytes memory data ) internal returns (bytes memory) { (bool success, bytes memory result) = to.delegatecall(data); if (!success) { if (result.length == 0) revert(); assembly { revert(add(32, result), mload(result)) } } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { SwapParams } from "contracts/structs/SwapStructs.sol"; import { AddLiquidityParams, RemoveLiquidityParams } from "contracts/structs/LiquidityStructs.sol"; struct ZapIn { SwapParams[] swaps; AddLiquidityParams addLiquidityParams; } struct ZapOut { RemoveLiquidityParams removeLiquidityParams; SwapParams[] swaps; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { ZapIn, ZapOut } from "contracts/structs/ZapStructs.sol"; interface IZapLib { function zapIn( ZapIn memory zap ) external payable; function zapOut( ZapOut memory zap ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { SwapParams } from "contracts/structs/SwapStructs.sol"; interface ISwapLib { function swap( SwapParams memory swap ) external payable; function swapMultiple( SwapParams[] memory swaps ) external payable; }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
// 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(address(0), 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; struct SwapParams { address tokenApproval; address router; uint256 amountIn; uint256 desiredAmountOut; uint256 minAmountOut; address tokenIn; address tokenOut; bytes extraData; }
{ "remappings": [ "solmate/=lib/solmate/src/", "@openzeppelin/=lib/openzeppelin-contracts/", "@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 }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract ConnectorRegistry","name":"connectorRegistry_","type":"address"},{"internalType":"contract ISwapLib","name":"swapLib_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApproveFailed","type":"error"},{"inputs":[],"name":"LiquidityAmountError","type":"error"},{"inputs":[],"name":"connectorRegistry","outputs":[{"internalType":"contract ConnectorRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapLib","outputs":[{"internalType":"contract ISwapLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"address","name":"tokenApproval","type":"address"},{"internalType":"address","name":"router","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"desiredAmountOut","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct SwapParams[]","name":"swaps","type":"tuple[]"},{"components":[{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"lpToken","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"desiredAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"minAmounts","type":"uint256[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct AddLiquidityParams","name":"addLiquidityParams","type":"tuple"}],"internalType":"struct ZapIn","name":"zap","type":"tuple"}],"name":"zapIn","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"lpToken","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256","name":"lpAmountIn","type":"uint256"},{"internalType":"uint256[]","name":"minAmountsOut","type":"uint256[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct RemoveLiquidityParams","name":"removeLiquidityParams","type":"tuple"},{"components":[{"internalType":"address","name":"tokenApproval","type":"address"},{"internalType":"address","name":"router","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"desiredAmountOut","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct SwapParams[]","name":"swaps","type":"tuple[]"}],"internalType":"struct ZapOut","name":"zap","type":"tuple"}],"name":"zapOut","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60c060405234801561001057600080fd5b5060405161112038038061112083398101604081905261002f9161005e565b6001600160a01b0391821660a05216608052610098565b6001600160a01b038116811461005b57600080fd5b50565b6000806040838503121561007157600080fd5b825161007c81610046565b602084015190925061008d81610046565b809150509250929050565b60805160a0516110496100d76000396000818160bb015281816103c70152610556015260008181605601528181610110015261062401526110496000f3fe60806040526004361061003f5760003560e01c80633faa6e30146100445780635bdcfb0d14610094578063b53c86d2146100a9578063f3defcd5146100dd575b600080fd5b34801561005057600080fd5b506100787f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b6100a76100a2366004610aae565b6100fd565b005b3480156100b557600080fd5b506100787f000000000000000000000000000000000000000000000000000000000000000081565b3480156100e957600080fd5b506100a76100f8366004610bfb565b6104f9565b80515160005b818110156101955761018c7f00000000000000000000000000000000000000000000000000000000000000008460000151838151811061014557610145610d2c565b602002602001015160405160240161015d9190610d92565b60408051601f198184030181529190526020810180516001600160e01b031663c472d3e160e01b179052610667565b50600101610103565b5060208083015101516001600160a01b03166101af575050565b602082015160408101515160009190825b818110156103845760006001600160a01b0316836040015182815181106101e9576101e9610d2c565b60200260200101516001600160a01b03160315610372578260600151818151811061021657610216610d2c565b60200260200101516000036102d2578260400151818151811061023b5761023b610d2c565b60209081029190910101516040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561028b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102af9190610e1d565b836060015182815181106102c5576102c5610d2c565b6020026020010181815250505b6000836060015182815181106102ea576102ea610d2c565b6020026020010151111561037257600193506103298360400151828151811061031557610315610d2c565b6020026020010151846000015160006106ec565b6103728360400151828151811061034257610342610d2c565b602002602001015184600001518560600151848151811061036557610365610d2c565b60200260200101516106ec565b8061037c81610e36565b9150506101c0565b50826103a357604051631342adad60e21b815260040160405180910390fd5b81516040516363cd755760e11b81526001600160a01b0391821660048201526000917f0000000000000000000000000000000000000000000000000000000000000000169063c79aeaae90602401602060405180830381865afa15801561040e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104329190610e5d565b905061047881846040516024016104499190610ef5565b60408051601f198184030181529190526020810180516001600160e01b031663fb986deb60e01b179052610667565b5060005b828110156104f05760006001600160a01b0316846040015182815181106104a5576104a5610d2c565b60200260200101516001600160a01b0316146104e8576104e8846040015182815181106104d4576104d4610d2c565b6020026020010151856000015160006106ec565b60010161047c565b50505050505050565b8051602001516001600160a01b03161561060e57805160600151156105315780516020810151815160609092015161053192906106ec565b8051516040516363cd755760e11b81526001600160a01b0391821660048201526000917f0000000000000000000000000000000000000000000000000000000000000000169063c79aeaae90602401602060405180830381865afa15801561059d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c19190610e5d565b905061060b8183600001516040516024016105dc9190610f93565b60408051601f198184030181529190526020810180516001600160e01b031663010741f760e61b179052610667565b50505b60208101515160005b81811015610662576106597f00000000000000000000000000000000000000000000000000000000000000008460200151838151811061014557610145610d2c565b50600101610617565b505050565b6060600080846001600160a01b0316846040516106849190610ff7565b600060405180830381855af49150503d80600081146106bf576040519150601f19603f3d011682016040523d82523d6000602084013e6106c4565b606091505b5091509150816106e45780516000036106dc57600080fd5b805181602001fd5b949350505050565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061074357604051633e3f8f7360e01b815260040160405180910390fd5b50505050565b634e487b7160e01b600052604160045260246000fd5b604051610100810167ffffffffffffffff8111828210171561078357610783610749565b60405290565b6040805190810167ffffffffffffffff8111828210171561078357610783610749565b60405160c0810167ffffffffffffffff8111828210171561078357610783610749565b604051601f8201601f1916810167ffffffffffffffff811182821017156107f8576107f8610749565b604052919050565b600067ffffffffffffffff82111561081a5761081a610749565b5060051b60200190565b6001600160a01b038116811461083957600080fd5b50565b803561084781610824565b919050565b600082601f83011261085d57600080fd5b813567ffffffffffffffff81111561087757610877610749565b61088a601f8201601f19166020016107cf565b81815284602083860101111561089f57600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f8301126108cd57600080fd5b813560206108e26108dd83610800565b6107cf565b82815260059290921b8401810191818101908684111561090157600080fd5b8286015b848110156109e457803567ffffffffffffffff808211156109265760008081fd5b90880190610100828b03601f19018113156109415760008081fd5b61094961075f565b61095488850161083c565b8152604061096381860161083c565b89830152606080860135828401526080915081860135818401525060a0808601358284015260c0915061099782870161083c565b9083015260e06109a886820161083c565b838301529285013592848411156109c157600091508182fd5b6109cf8e8b8689010161084c565b90830152508652505050918301918301610905565b509695505050505050565b600082601f830112610a0057600080fd5b81356020610a106108dd83610800565b82815260059290921b84018101918181019086841115610a2f57600080fd5b8286015b848110156109e4578035610a4681610824565b8352918301918301610a33565b600082601f830112610a6457600080fd5b81356020610a746108dd83610800565b82815260059290921b84018101918181019086841115610a9357600080fd5b8286015b848110156109e45780358352918301918301610a97565b600060208284031215610ac057600080fd5b813567ffffffffffffffff80821115610ad857600080fd5b9083019060408286031215610aec57600080fd5b610af4610789565b823582811115610b0357600080fd5b610b0f878286016108bc565b825250602083013582811115610b2457600080fd5b929092019160c08387031215610b3957600080fd5b610b416107ac565b610b4a8461083c565b8152610b586020850161083c565b6020820152604084013583811115610b6f57600080fd5b610b7b888287016109ef565b604083015250606084013583811115610b9357600080fd5b610b9f88828701610a53565b606083015250608084013583811115610bb757600080fd5b610bc388828701610a53565b60808301525060a084013583811115610bdb57600080fd5b610be78882870161084c565b60a083015250602082015295945050505050565b600060208284031215610c0d57600080fd5b813567ffffffffffffffff80821115610c2557600080fd5b9083019060408286031215610c3957600080fd5b610c41610789565b823582811115610c5057600080fd5b830160c08188031215610c6257600080fd5b610c6a6107ac565b610c738261083c565b8152610c816020830161083c565b6020820152604082013584811115610c9857600080fd5b610ca4898285016109ef565b60408301525060608201356060820152608082013584811115610cc657600080fd5b610cd289828501610a53565b60808301525060a082013584811115610cea57600080fd5b610cf68982850161084c565b60a083015250825250602083013582811115610d1157600080fd5b610d1d878286016108bc565b60208301525095945050505050565b634e487b7160e01b600052603260045260246000fd5b60005b83811015610d5d578181015183820152602001610d45565b50506000910152565b60008151808452610d7e816020860160208601610d42565b601f01601f19169290920160200192915050565b60208152600060018060a01b03808451166020840152806020850151166040840152506040830151606083015260608301516080830152608083015160a083015260a0830151610ded60c08401826001600160a01b03169052565b5060c08301516001600160a01b03811660e08401525060e0830151610100838101526106e4610120840182610d66565b600060208284031215610e2f57600080fd5b5051919050565b600060018201610e5657634e487b7160e01b600052601160045260246000fd5b5060010190565b600060208284031215610e6f57600080fd5b8151610e7a81610824565b9392505050565b600081518084526020808501945080840160005b83811015610eba5781516001600160a01b031687529582019590820190600101610e95565b509495945050505050565b600081518084526020808501945080840160005b83811015610eba57815187529582019590820190600101610ed9565b60208152600060018060a01b0380845116602084015280602085015116604084015250604083015160c06060840152610f3160e0840182610e81565b90506060840151601f1980858403016080860152610f4f8383610ec5565b925060808601519150808584030160a0860152610f6c8383610ec5565b925060a08601519150808584030160c086015250610f8a8282610d66565b95945050505050565b60208152600060018060a01b0380845116602084015280602085015116604084015250604083015160c06060840152610fcf60e0840182610e81565b9050606084015160808401526080840151601f19808584030160a0860152610f6c8383610ec5565b60008251611009818460208701610d42565b919091019291505056fea264697066735822122015d749f5d4e939f06b7884bdc1a7077e3ef0285e4a9cbdeed21b8a1d2e84942664736f6c63430008130033000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c9900000000000000000000000023eb5ce64769b969b58f008154d396957a7ade3b
Deployed Bytecode
0x60806040526004361061003f5760003560e01c80633faa6e30146100445780635bdcfb0d14610094578063b53c86d2146100a9578063f3defcd5146100dd575b600080fd5b34801561005057600080fd5b506100787f00000000000000000000000023eb5ce64769b969b58f008154d396957a7ade3b81565b6040516001600160a01b03909116815260200160405180910390f35b6100a76100a2366004610aae565b6100fd565b005b3480156100b557600080fd5b506100787f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c9981565b3480156100e957600080fd5b506100a76100f8366004610bfb565b6104f9565b80515160005b818110156101955761018c7f00000000000000000000000023eb5ce64769b969b58f008154d396957a7ade3b8460000151838151811061014557610145610d2c565b602002602001015160405160240161015d9190610d92565b60408051601f198184030181529190526020810180516001600160e01b031663c472d3e160e01b179052610667565b50600101610103565b5060208083015101516001600160a01b03166101af575050565b602082015160408101515160009190825b818110156103845760006001600160a01b0316836040015182815181106101e9576101e9610d2c565b60200260200101516001600160a01b03160315610372578260600151818151811061021657610216610d2c565b60200260200101516000036102d2578260400151818151811061023b5761023b610d2c565b60209081029190910101516040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561028b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102af9190610e1d565b836060015182815181106102c5576102c5610d2c565b6020026020010181815250505b6000836060015182815181106102ea576102ea610d2c565b6020026020010151111561037257600193506103298360400151828151811061031557610315610d2c565b6020026020010151846000015160006106ec565b6103728360400151828151811061034257610342610d2c565b602002602001015184600001518560600151848151811061036557610365610d2c565b60200260200101516106ec565b8061037c81610e36565b9150506101c0565b50826103a357604051631342adad60e21b815260040160405180910390fd5b81516040516363cd755760e11b81526001600160a01b0391821660048201526000917f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c99169063c79aeaae90602401602060405180830381865afa15801561040e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104329190610e5d565b905061047881846040516024016104499190610ef5565b60408051601f198184030181529190526020810180516001600160e01b031663fb986deb60e01b179052610667565b5060005b828110156104f05760006001600160a01b0316846040015182815181106104a5576104a5610d2c565b60200260200101516001600160a01b0316146104e8576104e8846040015182815181106104d4576104d4610d2c565b6020026020010151856000015160006106ec565b60010161047c565b50505050505050565b8051602001516001600160a01b03161561060e57805160600151156105315780516020810151815160609092015161053192906106ec565b8051516040516363cd755760e11b81526001600160a01b0391821660048201526000917f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c99169063c79aeaae90602401602060405180830381865afa15801561059d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c19190610e5d565b905061060b8183600001516040516024016105dc9190610f93565b60408051601f198184030181529190526020810180516001600160e01b031663010741f760e61b179052610667565b50505b60208101515160005b81811015610662576106597f00000000000000000000000023eb5ce64769b969b58f008154d396957a7ade3b8460200151838151811061014557610145610d2c565b50600101610617565b505050565b6060600080846001600160a01b0316846040516106849190610ff7565b600060405180830381855af49150503d80600081146106bf576040519150601f19603f3d011682016040523d82523d6000602084013e6106c4565b606091505b5091509150816106e45780516000036106dc57600080fd5b805181602001fd5b949350505050565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d116001600051141617169150508061074357604051633e3f8f7360e01b815260040160405180910390fd5b50505050565b634e487b7160e01b600052604160045260246000fd5b604051610100810167ffffffffffffffff8111828210171561078357610783610749565b60405290565b6040805190810167ffffffffffffffff8111828210171561078357610783610749565b60405160c0810167ffffffffffffffff8111828210171561078357610783610749565b604051601f8201601f1916810167ffffffffffffffff811182821017156107f8576107f8610749565b604052919050565b600067ffffffffffffffff82111561081a5761081a610749565b5060051b60200190565b6001600160a01b038116811461083957600080fd5b50565b803561084781610824565b919050565b600082601f83011261085d57600080fd5b813567ffffffffffffffff81111561087757610877610749565b61088a601f8201601f19166020016107cf565b81815284602083860101111561089f57600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f8301126108cd57600080fd5b813560206108e26108dd83610800565b6107cf565b82815260059290921b8401810191818101908684111561090157600080fd5b8286015b848110156109e457803567ffffffffffffffff808211156109265760008081fd5b90880190610100828b03601f19018113156109415760008081fd5b61094961075f565b61095488850161083c565b8152604061096381860161083c565b89830152606080860135828401526080915081860135818401525060a0808601358284015260c0915061099782870161083c565b9083015260e06109a886820161083c565b838301529285013592848411156109c157600091508182fd5b6109cf8e8b8689010161084c565b90830152508652505050918301918301610905565b509695505050505050565b600082601f830112610a0057600080fd5b81356020610a106108dd83610800565b82815260059290921b84018101918181019086841115610a2f57600080fd5b8286015b848110156109e4578035610a4681610824565b8352918301918301610a33565b600082601f830112610a6457600080fd5b81356020610a746108dd83610800565b82815260059290921b84018101918181019086841115610a9357600080fd5b8286015b848110156109e45780358352918301918301610a97565b600060208284031215610ac057600080fd5b813567ffffffffffffffff80821115610ad857600080fd5b9083019060408286031215610aec57600080fd5b610af4610789565b823582811115610b0357600080fd5b610b0f878286016108bc565b825250602083013582811115610b2457600080fd5b929092019160c08387031215610b3957600080fd5b610b416107ac565b610b4a8461083c565b8152610b586020850161083c565b6020820152604084013583811115610b6f57600080fd5b610b7b888287016109ef565b604083015250606084013583811115610b9357600080fd5b610b9f88828701610a53565b606083015250608084013583811115610bb757600080fd5b610bc388828701610a53565b60808301525060a084013583811115610bdb57600080fd5b610be78882870161084c565b60a083015250602082015295945050505050565b600060208284031215610c0d57600080fd5b813567ffffffffffffffff80821115610c2557600080fd5b9083019060408286031215610c3957600080fd5b610c41610789565b823582811115610c5057600080fd5b830160c08188031215610c6257600080fd5b610c6a6107ac565b610c738261083c565b8152610c816020830161083c565b6020820152604082013584811115610c9857600080fd5b610ca4898285016109ef565b60408301525060608201356060820152608082013584811115610cc657600080fd5b610cd289828501610a53565b60808301525060a082013584811115610cea57600080fd5b610cf68982850161084c565b60a083015250825250602083013582811115610d1157600080fd5b610d1d878286016108bc565b60208301525095945050505050565b634e487b7160e01b600052603260045260246000fd5b60005b83811015610d5d578181015183820152602001610d45565b50506000910152565b60008151808452610d7e816020860160208601610d42565b601f01601f19169290920160200192915050565b60208152600060018060a01b03808451166020840152806020850151166040840152506040830151606083015260608301516080830152608083015160a083015260a0830151610ded60c08401826001600160a01b03169052565b5060c08301516001600160a01b03811660e08401525060e0830151610100838101526106e4610120840182610d66565b600060208284031215610e2f57600080fd5b5051919050565b600060018201610e5657634e487b7160e01b600052601160045260246000fd5b5060010190565b600060208284031215610e6f57600080fd5b8151610e7a81610824565b9392505050565b600081518084526020808501945080840160005b83811015610eba5781516001600160a01b031687529582019590820190600101610e95565b509495945050505050565b600081518084526020808501945080840160005b83811015610eba57815187529582019590820190600101610ed9565b60208152600060018060a01b0380845116602084015280602085015116604084015250604083015160c06060840152610f3160e0840182610e81565b90506060840151601f1980858403016080860152610f4f8383610ec5565b925060808601519150808584030160a0860152610f6c8383610ec5565b925060a08601519150808584030160c086015250610f8a8282610d66565b95945050505050565b60208152600060018060a01b0380845116602084015280602085015116604084015250604083015160c06060840152610fcf60e0840182610e81565b9050606084015160808401526080840151601f19808584030160a0860152610f6c8383610ec5565b60008251611009818460208701610d42565b919091019291505056fea264697066735822122015d749f5d4e939f06b7884bdc1a7077e3ef0285e4a9cbdeed21b8a1d2e84942664736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c9900000000000000000000000023eb5ce64769b969b58f008154d396957a7ade3b
-----Decoded View---------------
Arg [0] : connectorRegistry_ (address): 0xc6013E57a0811C7111A8fB07ACd2E248D9489C99
Arg [1] : swapLib_ (address): 0x23eb5CE64769b969b58f008154d396957A7aDE3b
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c99
Arg [1] : 00000000000000000000000023eb5ce64769b969b58f008154d396957a7ade3b
Loading...
Loading
Loading...
Loading

Loading...
Loading
Loading...
Loading
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.