S Price: $0.625521 (-8.02%)

Contract

0x85378fA1d0707897D948Ba322B5EB43254e4d7c2

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Harvest Multiple43692732025-01-18 8:14:3836 hrs ago1737188078IN
0x85378fA1...254e4d7c2
0 S0.0653373655
Harvest Multiple40264762025-01-15 17:38:304 days ago1736962710IN
0x85378fA1...254e4d7c2
0 S0.0170913233.01

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MultiFarmStrategy

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 42 : MultiFarmStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { INonfungiblePositionManager } from
    "contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";

import { IFarmConnector } from "contracts/interfaces/IFarmConnector.sol";
import { INftFarmConnector } from "contracts/interfaces/INftFarmConnector.sol";
import { Farm } from "contracts/structs/FarmStrategyStructs.sol";
import {
    NftPosition,
    SimpleNftHarvest
} from "contracts/structs/NftFarmStrategyStructs.sol";
import {
    StrategyModule,
    SickleFactory,
    Sickle
} from "contracts/modules/StrategyModule.sol";
import { ConnectorRegistry } from "contracts/ConnectorRegistry.sol";
import { IZapLib } from "contracts/interfaces/libraries/IZapLib.sol";
import { INftZapLib } from "contracts/interfaces/libraries/INftZapLib.sol";
import { IFeesLib } from "contracts/interfaces/libraries/IFeesLib.sol";
import { ITransferLib } from "contracts/interfaces/libraries/ITransferLib.sol";
import { ISwapLib } from "contracts/interfaces/libraries/ISwapLib.sol";
import { FarmStrategyEvents } from "contracts/events/FarmStrategyEvents.sol";
import { NftFarmStrategyEvents } from
    "contracts/events/NftFarmStrategyEvents.sol";
import {
    ClaimParams,
    NftClaimParams,
    MultiCompoundParams,
    NftMultiCompoundParams,
    MultiHarvestParams
} from "contracts/structs/MultiFarmStrategyStructs.sol";

library MultiFarmStrategyFees {
    bytes4 constant Harvest = bytes4(keccak256("FarmHarvestFee"));
    bytes4 constant Compound = bytes4(keccak256("FarmCompoundFee"));
}

contract MultiFarmStrategy is
    StrategyModule,
    FarmStrategyEvents,
    NftFarmStrategyEvents
{
    struct Libraries {
        ITransferLib transferLib;
        ISwapLib swapLib;
        IFeesLib feesLib;
        IZapLib zapLib;
        INftZapLib nftZapLib;
    }

    ITransferLib public immutable transferLib;
    ISwapLib public immutable swapLib;
    IFeesLib public immutable feesLib;
    IZapLib public immutable zapLib;
    INftZapLib public immutable nftZapLib;
    address public immutable strategyAddress;

    constructor(
        SickleFactory factory,
        ConnectorRegistry connectorRegistry,
        Libraries memory libraries
    ) StrategyModule(factory, connectorRegistry) {
        strategyAddress = address(this);
        transferLib = libraries.transferLib;
        swapLib = libraries.swapLib;
        feesLib = libraries.feesLib;
        zapLib = libraries.zapLib;
        nftZapLib = libraries.nftZapLib;
    }

    /* External Functions */

    /**
     * @notice Compound multiple ERC20 and/or NFT farms into a single ERC20 farm
     * @param params The parameters for the compound operation
     * @param sweepTokens The tokens to sweep after the compound operation
     */
    function compoundMultiple(
        MultiCompoundParams calldata params,
        address[] memory sweepTokens
    ) external {
        Sickle sickle = getSickle(msg.sender);

        _harvest_erc20_positions(sickle, params.claims);
        _harvest_nft_positions(sickle, params.nftClaims);

        address[] memory targets = new address[](4);
        bytes[] memory data = new bytes[](4);

        targets[0] = address(feesLib);
        data[0] = abi.encodeCall(
            IFeesLib.chargeFees,
            (
                strategyAddress,
                MultiFarmStrategyFees.Compound,
                params.rewardTokens
            )
        );

        targets[1] = address(zapLib);
        data[1] = abi.encodeCall(IZapLib.zapIn, (params.zap));

        address depositFarmConnector =
            connectorRegistry.connectorOf(params.depositFarm.stakingContract);
        targets[2] = depositFarmConnector;
        data[2] = abi.encodeCall(
            IFarmConnector.deposit,
            (
                params.depositFarm,
                params.zap.addLiquidityParams.lpToken,
                params.depositExtraData
            )
        );

        targets[3] = address(transferLib);
        data[3] =
            abi.encodeCall(ITransferLib.transferTokensToUser, (sweepTokens));

        sickle.multicall(targets, data);

        _emit_compound_events(
            sickle, params.depositFarm, params.claims, params.nftClaims
        );
    }

    /**
     * @notice Compound multiple ERC20 and/or NFT farms into a single NFT farm
     * @param params The parameters for the compound operation
     * @param sweepTokens The tokens to sweep after the compound operation
     */
    function nftCompoundMultiple(
        NftMultiCompoundParams calldata params,
        address[] calldata sweepTokens
    ) external {
        Sickle sickle = getSickle(msg.sender);

        _harvest_erc20_positions(sickle, params.claims);
        _harvest_nft_positions(sickle, params.nftClaims);

        if (!params.compoundInPlace) {
            _withdraw_nft(
                sickle, params.depositPosition, params.depositExtraData
            );
        }

        address[] memory targets = new address[](3);
        bytes[] memory data = new bytes[](3);

        targets[0] = address(feesLib);
        data[0] = abi.encodeCall(
            IFeesLib.chargeFees,
            (
                strategyAddress,
                MultiFarmStrategyFees.Compound,
                params.rewardTokens
            )
        );

        targets[1] = address(nftZapLib);
        data[1] = abi.encodeCall(INftZapLib.zapIn, (params.zap));

        targets[2] = address(transferLib);
        data[2] =
            abi.encodeCall(ITransferLib.transferTokensToUser, (sweepTokens));

        sickle.multicall(targets, data);

        if (!params.compoundInPlace) {
            _deposit_nft(
                sickle, params.depositPosition, params.depositExtraData
            );
        }

        _emit_compound_events(
            sickle, params.depositPosition.farm, params.claims, params.nftClaims
        );
    }

    /**
     * @notice Harvest multiple ERC20 and/or NFT farms
     * @param params The parameters for the harvest operation
     * @param sweepTokens The tokens to sweep after the harvest operation
     */
    function harvestMultiple(
        MultiHarvestParams calldata params,
        address[] memory sweepTokens
    ) public {
        Sickle sickle = getSickle(msg.sender);

        _harvest_erc20_positions(sickle, params.claims);
        _harvest_nft_positions(sickle, params.nftClaims);

        address[] memory targets = new address[](3);
        bytes[] memory data = new bytes[](3);

        targets[0] = address(swapLib);
        data[0] = abi.encodeCall(ISwapLib.swapMultiple, (params.swaps));

        targets[1] = address(feesLib);
        data[1] = abi.encodeCall(
            IFeesLib.chargeFees,
            (strategyAddress, MultiFarmStrategyFees.Harvest, params.tokensOut)
        );

        targets[2] = address(transferLib);
        data[2] =
            abi.encodeCall(ITransferLib.transferTokensToUser, (sweepTokens));

        sickle.multicall(targets, data);

        _emit_harvest_events(sickle, params.claims, params.nftClaims);
    }

    /* Private Functions */

    function _harvest_erc20_positions(
        Sickle sickle,
        ClaimParams[] calldata params
    ) private {
        uint256 arrayLength = params.length;
        address[] memory targets = new address[](arrayLength);
        bytes[] memory data = new bytes[](arrayLength);

        for (uint256 i; i < arrayLength; i++) {
            ClaimParams calldata claim = params[i];
            address farmConnector =
                connectorRegistry.connectorOf(claim.claimFarm.stakingContract);

            targets[i] = farmConnector;
            data[i] = abi.encodeCall(
                IFarmConnector.claim, (claim.claimFarm, claim.claimExtraData)
            );
        }

        sickle.multicall(targets, data);
    }

    function _harvest_nft_positions(
        Sickle sickle,
        NftClaimParams[] calldata params
    ) private {
        uint256 arrayLength = params.length;
        address[] memory targets = new address[](arrayLength);
        bytes[] memory data = new bytes[](arrayLength);

        for (uint256 i; i < arrayLength; i++) {
            NftClaimParams calldata claim = params[i];
            address farmConnector = connectorRegistry.connectorOf(
                claim.position.farm.stakingContract
            );

            targets[i] = farmConnector;
            data[i] = abi.encodeCall(
                INftFarmConnector.claim,
                (
                    claim.position,
                    claim.harvest.rewardTokens,
                    claim.harvest.amount0Max,
                    claim.harvest.amount1Max,
                    claim.harvest.extraData
                )
            );
        }

        sickle.multicall(targets, data);
    }

    function _withdraw_nft(
        Sickle sickle,
        NftPosition calldata position,
        bytes calldata extraData
    ) private {
        address farmConnector =
            connectorRegistry.connectorOf(position.farm.stakingContract);

        address[] memory targets = new address[](1);
        bytes[] memory data = new bytes[](1);

        targets[0] = farmConnector;
        data[0] =
            abi.encodeCall(INftFarmConnector.withdrawNft, (position, extraData));

        sickle.multicall(targets, data);
    }

    function _deposit_nft(
        Sickle sickle,
        NftPosition calldata position,
        bytes calldata extraData
    ) private {
        address farmConnector =
            connectorRegistry.connectorOf(position.farm.stakingContract);

        address[] memory targets = new address[](1);
        bytes[] memory data = new bytes[](1);

        targets[0] = farmConnector;
        data[0] = abi.encodeCall(
            INftFarmConnector.depositExistingNft, (position, extraData)
        );

        sickle.multicall(targets, data);
    }

    function _emit_harvest_events(
        Sickle sickle,
        ClaimParams[] calldata claims,
        NftClaimParams[] calldata nftClaims
    ) private {
        for (uint256 i = 0; i < claims.length; i++) {
            emit SickleHarvested(
                sickle,
                claims[i].claimFarm.stakingContract,
                claims[i].claimFarm.poolIndex
            );
        }

        for (uint256 i = 0; i < nftClaims.length; i++) {
            emit SickleHarvestedNft(
                sickle,
                nftClaims[i].position.nft,
                nftClaims[i].position.tokenId,
                nftClaims[i].position.farm.stakingContract,
                nftClaims[i].position.farm.poolIndex
            );
        }
    }

    function _emit_compound_events(
        Sickle sickle,
        Farm calldata depositFarm,
        ClaimParams[] calldata claims,
        NftClaimParams[] calldata nftClaims
    ) private {
        for (uint256 i = 0; i < claims.length; i++) {
            emit SickleCompounded(
                sickle,
                claims[i].claimFarm.stakingContract,
                claims[i].claimFarm.poolIndex,
                depositFarm.stakingContract,
                depositFarm.poolIndex
            );
        }

        for (uint256 i = 0; i < nftClaims.length; i++) {
            emit SickleCompoundedNft(
                sickle,
                nftClaims[i].position.nft,
                nftClaims[i].position.tokenId,
                depositFarm.stakingContract,
                depositFarm.poolIndex
            );
        }
    }
}

File 2 of 42 : INonfungiblePositionManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { IERC721Enumerable } from
    "openzeppelin-contracts/contracts/interfaces/IERC721Enumerable.sol";

interface INonfungiblePositionManager is IERC721Enumerable {
    struct IncreaseLiquidityParams {
        uint256 tokenId;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    struct MintParams {
        address token0;
        address token1;
        uint24 fee;
        int24 tickLower;
        int24 tickUpper;
        uint256 amount0Desired;
        uint256 amount1Desired;
        uint256 amount0Min;
        uint256 amount1Min;
        address recipient;
        uint256 deadline;
    }

    struct DecreaseLiquidityParams {
        uint256 tokenId;
        uint128 liquidity;
        uint256 amount0Min;
        uint256 amount1Min;
        uint256 deadline;
    }

    struct CollectParams {
        uint256 tokenId;
        address recipient;
        uint128 amount0Max;
        uint128 amount1Max;
    }

    function increaseLiquidity(IncreaseLiquidityParams memory params)
        external
        payable
        returns (uint256 amount0, uint256 amount1, uint256 liquidity);

    function decreaseLiquidity(DecreaseLiquidityParams calldata params)
        external
        payable
        returns (uint256 amount0, uint256 amount1);

    function mint(MintParams memory params)
        external
        payable
        returns (uint256 tokenId, uint256 amount0, uint256 amount1);

    function collect(CollectParams calldata params)
        external
        payable
        returns (uint256 amount0, uint256 amount1);

    function burn(uint256 tokenId) external payable;

    function positions(uint256 tokenId)
        external
        view
        returns (
            uint96 nonce,
            address operator,
            address token0,
            address token1,
            uint24 fee,
            int24 tickLower,
            int24 tickUpper,
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );
}

File 3 of 42 : IFarmConnector.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { Farm } from "contracts/structs/FarmStrategyStructs.sol";

interface IFarmConnector {
    function deposit(
        Farm calldata farm,
        address token,
        bytes memory extraData
    ) external payable;

    function withdraw(
        Farm calldata farm,
        uint256 amount,
        bytes memory extraData
    ) external;

    function claim(Farm calldata farm, bytes memory extraData) external;
}

File 4 of 42 : INftFarmConnector.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { INonfungiblePositionManager } from
    "contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";
import { Farm } from "contracts/structs/FarmStrategyStructs.sol";
import { NftPosition } from "contracts/structs/NftFarmStrategyStructs.sol";

interface INftFarmConnector {
    function depositExistingNft(
        NftPosition calldata position,
        bytes calldata extraData
    ) external payable;

    function withdrawNft(
        NftPosition calldata position,
        bytes calldata extraData
    ) external payable;
    // Payable in case an NFT is withdrawn to be increased with ETH

    function claim(
        NftPosition calldata position,
        address[] memory rewardTokens,
        uint128 maxAmount0, // For collecting
        uint128 maxAmount1,
        bytes calldata extraData
    ) external payable;
}

File 5 of 42 : FarmStrategyStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { ZapIn, ZapOut } from "contracts/libraries/ZapLib.sol";
import { SwapParams } from "contracts/structs/LiquidityStructs.sol";

struct Farm {
    address stakingContract;
    uint256 poolIndex;
}

struct DepositParams {
    Farm farm;
    address[] tokensIn;
    uint256[] amountsIn;
    ZapIn zap;
    bytes extraData;
}

struct WithdrawParams {
    bytes extraData;
    ZapOut zap;
    address[] tokensOut;
}

struct HarvestParams {
    SwapParams[] swaps;
    bytes extraData;
    address[] tokensOut;
}

struct CompoundParams {
    Farm claimFarm;
    bytes claimExtraData;
    address[] rewardTokens;
    ZapIn zap;
    Farm depositFarm;
    bytes depositExtraData;
}

struct SimpleDepositParams {
    Farm farm;
    address lpToken;
    uint256 amountIn;
    bytes extraData;
}

struct SimpleHarvestParams {
    address[] rewardTokens;
    bytes extraData;
}

struct SimpleWithdrawParams {
    address lpToken;
    uint256 amountOut;
    bytes extraData;
}

File 6 of 42 : NftFarmStrategyStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { IUniswapV3Pool } from
    "contracts/interfaces/external/uniswap/IUniswapV3Pool.sol";
import { INonfungiblePositionManager } from
    "contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";
import { NftZapIn, NftZapOut } from "contracts/structs/NftZapStructs.sol";
import { SwapParams } from "contracts/structs/LiquidityStructs.sol";
import { Farm } from "contracts/structs/FarmStrategyStructs.sol";

struct NftPosition {
    Farm farm;
    INonfungiblePositionManager nft;
    uint256 tokenId;
}

struct NftIncrease {
    address[] tokensIn;
    uint256[] amountsIn;
    NftZapIn zap;
    bytes extraData;
}

struct NftDeposit {
    Farm farm;
    INonfungiblePositionManager nft;
    NftIncrease increase;
}

struct NftWithdraw {
    NftZapOut zap;
    address[] tokensOut;
    bytes extraData;
}

struct SimpleNftHarvest {
    address[] rewardTokens;
    uint128 amount0Max;
    uint128 amount1Max;
    bytes extraData;
}

struct NftHarvest {
    SimpleNftHarvest harvest;
    SwapParams[] swaps;
    address[] outputTokens;
    address[] sweepTokens;
}

struct NftCompound {
    SimpleNftHarvest harvest;
    NftZapIn zap;
}

struct NftRebalance {
    IUniswapV3Pool pool;
    NftPosition position;
    NftHarvest harvest;
    NftWithdraw withdraw;
    NftIncrease increase;
}

struct NftMove {
    IUniswapV3Pool pool;
    NftPosition position;
    NftHarvest harvest;
    NftWithdraw withdraw;
    NftDeposit deposit;
}

File 7 of 42 : StrategyModule.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { SickleFactory, Sickle } from "contracts/SickleFactory.sol";
import { ConnectorRegistry } from "contracts/ConnectorRegistry.sol";
import { AccessControlModule } from "contracts/modules/AccessControlModule.sol";

contract StrategyModule is AccessControlModule {
    ConnectorRegistry public immutable connectorRegistry;

    constructor(
        SickleFactory factory,
        ConnectorRegistry connectorRegistry_
    ) AccessControlModule(factory) {
        connectorRegistry = connectorRegistry_;
    }

    function getSickle(address owner) public view returns (Sickle) {
        Sickle sickle = Sickle(payable(factory.sickles(owner)));
        if (address(sickle) == address(0)) {
            revert SickleNotDeployed();
        }
        return sickle;
    }

    function getOrDeploySickle(
        address owner,
        address approved,
        bytes32 referralCode
    ) public returns (Sickle) {
        return
            Sickle(payable(factory.getOrDeploy(owner, approved, referralCode)));
    }
}

File 8 of 42 : ConnectorRegistry.sol
// 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;
    }
}

File 9 of 42 : IZapLib.sol
// 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;
}

File 10 of 42 : INftZapLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { NftZapIn, NftZapOut } from "contracts/structs/NftZapStructs.sol";

interface INftZapLib {
    function zapIn(
        NftZapIn memory zap
    ) external payable;

    function zapOut(
        NftZapOut memory zap
    ) external;
}

File 11 of 42 : IFeesLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Sickle } from "contracts/Sickle.sol";

interface IFeesLib {
    event FeeCharged(
        address strategy, bytes4 feeDescriptor, uint256 amount, address token
    );
    event TransactionCostCharged(address recipient, uint256 amount);

    function chargeFee(
        address strategy,
        bytes4 feeDescriptor,
        address feeToken,
        uint256 feeBasis
    ) external payable returns (uint256 remainder);

    function chargeFees(
        address strategy,
        bytes4 feeDescriptor,
        address[] memory feeTokens
    ) external payable;

    function getBalance(
        Sickle sickle,
        address token
    ) external view returns (uint256);
}

File 12 of 42 : ITransferLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface ITransferLib {
    error ArrayLengthMismatch();
    error TokenInRequired();
    error AmountInRequired();
    error TwoTokenMaximum();
    error SameTokenIn();
    error TokenOutRequired();

    function transferTokenToUser(
        address token
    ) external payable;

    function transferTokensToUser(
        address[] memory tokens
    ) external payable;

    function transferTokenFromUser(
        address tokenIn,
        uint256 amountIn,
        address strategy,
        bytes4 feeSelector
    ) external payable;

    function transferTokensFromUser(
        address[] memory tokensIn,
        uint256[] memory amountsIn,
        address strategy,
        bytes4 feeSelector
    ) external payable;
}

File 13 of 42 : ISwapLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { SwapParams } from "contracts/structs/LiquidityStructs.sol";

interface ISwapLib {
    function swap(
        SwapParams memory swap
    ) external payable;

    function swapMultiple(
        SwapParams[] memory swaps
    ) external;
}

File 14 of 42 : FarmStrategyEvents.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Sickle } from "contracts/Sickle.sol";

abstract contract FarmStrategyEvents {
    event SickleDeposited(
        Sickle indexed sickle,
        address indexed stakingContract,
        uint256 indexed poolIndex
    );

    event SickleHarvested(
        Sickle indexed sickle,
        address indexed stakingContract,
        uint256 indexed poolIndex
    );

    event SickleCompounded(
        Sickle indexed sickle,
        address indexed claimStakingContract,
        uint256 claimPoolIndex,
        address indexed depositStakingContract,
        uint256 depositPoolIndex
    );

    event SickleWithdrawn(
        Sickle indexed sickle,
        address indexed stakingContract,
        uint256 indexed poolIndex
    );

    event SickleExited(
        Sickle indexed sickle,
        address indexed stakingContract,
        uint256 indexed poolIndex
    );
}

File 15 of 42 : NftFarmStrategyEvents.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { INonfungiblePositionManager } from
    "contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";

import { Sickle } from "contracts/Sickle.sol";

abstract contract NftFarmStrategyEvents {
    event SickleDepositedNft(
        Sickle indexed sickle,
        INonfungiblePositionManager indexed nft,
        uint256 indexed tokenId,
        address stakingContract,
        uint256 poolIndex
    );

    event SickleIncreasedNft(
        Sickle indexed sickle,
        INonfungiblePositionManager indexed nft,
        uint256 indexed tokenId,
        address stakingContract,
        uint256 poolIndex
    );

    event SickleHarvestedNft(
        Sickle indexed sickle,
        INonfungiblePositionManager indexed nft,
        uint256 indexed tokenId,
        address stakingContract,
        uint256 poolIndex
    );

    event SickleCompoundedNft(
        Sickle indexed sickle,
        INonfungiblePositionManager indexed nft,
        uint256 indexed tokenId,
        address stakingContract,
        uint256 poolIndex
    );

    event SickleWithdrewNft(
        Sickle indexed sickle,
        INonfungiblePositionManager indexed nft,
        uint256 indexed tokenId,
        address stakingContract,
        uint256 poolIndex
    );

    event SickleDecreasedNft(
        Sickle indexed sickle,
        INonfungiblePositionManager indexed nft,
        uint256 indexed tokenId,
        address stakingContract,
        uint256 poolIndex
    );

    event SickleExitedNft(
        Sickle indexed sickle,
        INonfungiblePositionManager indexed nft,
        uint256 indexed tokenId,
        address stakingContract,
        uint256 poolIndex
    );

    event SickleRebalancedNft(
        Sickle indexed sickle,
        INonfungiblePositionManager indexed nft,
        uint256 indexed tokenId,
        address stakingContract,
        uint256 poolIndex
    );

    event SickleMovedNft(
        Sickle indexed sickle,
        INonfungiblePositionManager indexed fromNft,
        uint256 indexed fromTokenId,
        address fromStakingContract,
        uint256 fromPoolIndex,
        INonfungiblePositionManager toNft,
        uint256 toTokenId,
        address toStakingContract,
        uint256 toPoolIndex
    );
}

File 16 of 42 : MultiFarmStrategyStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Farm } from "contracts/structs/FarmStrategyStructs.sol";
import { ZapIn } from "contracts/structs/ZapStructs.sol";
import {
    NftPosition,
    SimpleNftHarvest
} from "contracts/structs/NftFarmStrategyStructs.sol";
import { SwapParams } from "contracts/structs/LiquidityStructs.sol";
import { NftZapIn } from "contracts/structs/NftZapStructs.sol";

struct ClaimParams {
    Farm claimFarm;
    bytes claimExtraData;
}

struct NftClaimParams {
    NftPosition position;
    SimpleNftHarvest harvest;
}

struct MultiCompoundParams {
    ClaimParams[] claims;
    NftClaimParams[] nftClaims;
    address[] rewardTokens;
    ZapIn zap;
    Farm depositFarm;
    bytes depositExtraData;
}

struct NftMultiCompoundParams {
    ClaimParams[] claims;
    NftClaimParams[] nftClaims;
    address[] rewardTokens;
    NftZapIn zap;
    NftPosition depositPosition;
    bytes depositExtraData;
    bool compoundInPlace;
}

struct MultiHarvestParams {
    ClaimParams[] claims;
    NftClaimParams[] nftClaims;
    SwapParams[] swaps;
    address[] tokensOut;
}

File 17 of 42 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../token/ERC721/extensions/IERC721Enumerable.sol";

File 18 of 42 : ZapLib.sol
// 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 {
    SwapParams,
    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++;
            }
        }
    }
}

File 19 of 42 : LiquidityStructs.sol
// 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;
}

File 20 of 42 : IUniswapV3Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods
/// will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the
    /// IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);

    /// @notice The first of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token0() external view returns (address);

    /// @notice The second of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token1() external view returns (address);

    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
    /// @return The fee
    function fee() external view returns (uint24);

    /// @notice The pool tick spacing
    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and
    /// always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick,
    /// i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always
    /// positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);

    /// @notice The maximum amount of position liquidity that can use any tick
    /// in the range
    /// @dev This parameter is enforced per tick to prevent liquidity from
    /// overflowing a uint128 at any point, and
    /// also prevents out-of-range liquidity from being used to prevent adding
    /// in-range liquidity to a pool
    /// @return The max amount of liquidity per tick
    function maxLiquidityPerTick() external view returns (uint128);
}

/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any
/// frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is
    /// exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a
    /// sqrt(token1/token0) Q64.96 value
    /// @return tick The current tick of the pool, i.e. according to the last
    /// tick transition that was run.
    /// This value may not always be equal to
    /// SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// @return observationIndex The index of the last oracle observation that
    /// was written,
    /// @return observationCardinality The current maximum number of
    /// observations stored in the pool,
    /// @return observationCardinalityNext The next maximum number of
    /// observations, to be updated when the observation.
    /// @return feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted
    /// 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap
    /// fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit
    /// of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal0X128() external view returns (uint256);

    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit
    /// of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal1X128() external view returns (uint256);

    /// @notice The amounts of token0 and token1 that are owed to the protocol
    /// @dev Protocol fees will never exceed uint128 max in either token
    function protocolFees()
        external
        view
        returns (uint128 token0, uint128 token1);

    /// @notice The currently in range liquidity available to the pool
    /// @dev This value has no relationship to the total liquidity across all
    /// ticks
    /// @return The liquidity at the current price of the pool
    function liquidity() external view returns (uint128);

    /// @notice Look up information about a specific tick in the pool
    /// @param tick The tick to look up
    /// @return liquidityGross the total amount of position liquidity that uses
    /// the pool either as tick lower or
    /// tick upper
    /// @return liquidityNet how much liquidity changes when the pool price
    /// crosses the tick,
    /// @return feeGrowthOutside0X128 the fee growth on the other side of the
    /// tick from the current tick in token0,
    /// @return feeGrowthOutside1X128 the fee growth on the other side of the
    /// tick from the current tick in token1,
    /// @return tickCumulativeOutside the cumulative tick value on the other
    /// side of the tick from the current tick
    /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity
    /// on the other side of the tick from the current tick,
    /// @return secondsOutside the seconds spent on the other side of the tick
    /// from the current tick,
    /// @return initialized Set to true if the tick is initialized, i.e.
    /// liquidityGross is greater than 0, otherwise equal to false.
    /// Outside values can only be used if the tick is initialized, i.e. if
    /// liquidityGross is greater than 0.
    /// In addition, these values are only relative and must be used only in
    /// comparison to previous snapshots for
    /// a specific position.
    function ticks(int24 tick)
        external
        view
        returns (
            uint128 liquidityGross,
            int128 liquidityNet,
            uint256 feeGrowthOutside0X128,
            uint256 feeGrowthOutside1X128,
            int56 tickCumulativeOutside,
            uint160 secondsPerLiquidityOutsideX128,
            uint32 secondsOutside,
            bool initialized
        );

    /// @notice Returns 256 packed tick initialized boolean values. See
    /// TickBitmap for more information
    function tickBitmap(int16 wordPosition) external view returns (uint256);

    /// @notice Returns the information about a position by the position's key
    /// @param key The position's key is a hash of a preimage composed by the
    /// owner, tickLower and tickUpper
    /// @return liquidity The amount of liquidity in the position,
    /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick
    /// range as of the last mint/burn/poke,
    /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick
    /// range as of the last mint/burn/poke,
    /// @return tokensOwed0 the computed amount of token0 owed to the position
    /// as of the last mint/burn/poke,
    /// @return tokensOwed1 the computed amount of token1 owed to the position
    /// as of the last mint/burn/poke
    function positions(bytes32 key)
        external
        view
        returns (
            uint128 liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    /// @notice Returns data about a specific observation index
    /// @param index The element of the observations array to fetch
    /// @dev You most likely want to use #observe() instead of this method to
    /// get an observation as of some amount of time
    /// ago, rather than at a specific index in the array.
    /// @return blockTimestamp The timestamp of the observation,
    /// @return tickCumulative the tick multiplied by seconds elapsed for the
    /// life of the pool as of the observation timestamp,
    /// @return secondsPerLiquidityCumulativeX128 the seconds per in range
    /// liquidity for the life of the pool as of the observation timestamp,
    /// @return initialized whether the observation has been initialized and the
    /// values are safe to use
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );
}

interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState {
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;
}

File 21 of 42 : NftZapStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { SwapParams } from "contracts/structs/LiquidityStructs.sol";
import {
    NftAddLiquidity,
    NftRemoveLiquidity
} from "contracts/structs/NftLiquidityStructs.sol";

struct NftZapIn {
    SwapParams[] swaps;
    NftAddLiquidity addLiquidityParams;
}

struct NftZapOut {
    NftRemoveLiquidity removeLiquidityParams;
    SwapParams[] swaps;
}

File 22 of 42 : SickleFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Clones } from "@openzeppelin/contracts/proxy/Clones.sol";
import { SickleRegistry } from "contracts/SickleRegistry.sol";
import { Sickle } from "contracts/Sickle.sol";
import { Admin } from "contracts/base/Admin.sol";

/// @title SickleFactory contract
/// @author vfat.tools
/// @notice Factory deploying new Sickle contracts
contract SickleFactory is Admin {
    /// EVENTS ///

    /// @notice Emitted when a new Sickle contract is deployed
    /// @param admin Address receiving the admin rights of the Sickle contract
    /// @param sickle Address of the newly deployed Sickle contract
    event Deploy(address indexed admin, address sickle);

    /// @notice Thrown when the caller is not whitelisted
    /// @param caller Address of the non-whitelisted caller
    error CallerNotWhitelisted(address caller); // 0x252c8273

    /// @notice Thrown when the factory is not active and a deploy is attempted
    error NotActive(); // 0x80cb55e2

    /// @notice Thrown when a Sickle contract is already deployed for a user
    error SickleAlreadyDeployed(); //0xf6782ef1

    /// STORAGE ///

    mapping(address => address) private _sickles;
    mapping(address => address) private _admins;
    mapping(address => bytes32) public _referralCodes;

    /// @notice Address of the SickleRegistry contract
    SickleRegistry public immutable registry;

    /// @notice Address of the Sickle implementation contract
    address public immutable implementation;

    /// @notice Address of the previous SickleFactory contract (if applicable)
    SickleFactory public immutable previousFactory;

    /// @notice Whether the factory is active (can deploy new Sickle contracts)
    bool public isActive = true;

    /// WRITE FUNCTIONS ///

    /// @param admin_ Address of the admin
    /// @param sickleRegistry_ Address of the SickleRegistry contract
    /// @param sickleImplementation_ Address of the Sickle implementation
    /// contract
    /// @param previousFactory_ Address of the previous SickleFactory contract
    /// if applicable
    constructor(
        address admin_,
        address sickleRegistry_,
        address sickleImplementation_,
        address previousFactory_
    ) Admin(admin_) {
        registry = SickleRegistry(sickleRegistry_);
        implementation = sickleImplementation_;
        previousFactory = SickleFactory(previousFactory_);
    }

    /// @notice Update the isActive flag.
    /// @dev Effectively pauses and unpauses new Sickle deployments.
    /// @custom:access Restricted to protocol admin.
    function setActive(bool active) external onlyAdmin {
        isActive = active;
    }

    function _deploy(
        address admin,
        address approved,
        bytes32 referralCode
    ) internal returns (address sickle) {
        sickle = Clones.cloneDeterministic(
            implementation, keccak256(abi.encode(admin))
        );
        Sickle(payable(sickle)).initialize(admin, approved);
        _sickles[admin] = sickle;
        _admins[sickle] = admin;
        if (referralCode != bytes32(0)) {
            _referralCodes[sickle] = referralCode;
        }
        emit Deploy(admin, sickle);
    }

    function _getSickle(address admin) internal returns (address sickle) {
        sickle = _sickles[admin];
        if (sickle != address(0)) {
            return sickle;
        }
        if (address(previousFactory) != address(0)) {
            sickle = previousFactory.sickles(admin);
            if (sickle != address(0)) {
                _sickles[admin] = sickle;
                _admins[sickle] = admin;
                _referralCodes[sickle] = previousFactory.referralCodes(sickle);
                return sickle;
            }
        }
    }

    /// @notice Predict the address of a Sickle contract for a specific user
    /// @param admin Address receiving the admin rights of the Sickle contract
    /// @return sickle Address of the predicted Sickle contract
    function predict(address admin) external view returns (address) {
        bytes32 salt = keccak256(abi.encode(admin));
        return Clones.predictDeterministicAddress(implementation, salt);
    }

    /// @notice Returns the Sickle contract for a specific user
    /// @param admin Address that owns the Sickle contract
    /// @return sickle Address of the Sickle contract
    function sickles(address admin) external view returns (address sickle) {
        sickle = _sickles[admin];
        if (sickle == address(0) && address(previousFactory) != address(0)) {
            sickle = previousFactory.sickles(admin);
        }
    }

    /// @notice Returns the admin for a specific Sickle contract
    /// @param sickle Address of the Sickle contract
    /// @return admin Address that owns the Sickle contract
    function admins(address sickle) external view returns (address admin) {
        admin = _admins[sickle];
        if (admin == address(0) && address(previousFactory) != address(0)) {
            admin = previousFactory.admins(sickle);
        }
    }

    /// @notice Returns the referral code for a specific Sickle contract
    /// @param sickle Address of the Sickle contract
    /// @return referralCode Referral code for the user
    function referralCodes(address sickle)
        external
        view
        returns (bytes32 referralCode)
    {
        referralCode = _referralCodes[sickle];
        if (
            referralCode == bytes32(0) && address(previousFactory) != address(0)
        ) {
            referralCode = previousFactory.referralCodes(sickle);
        }
    }

    /// @notice Deploys a new Sickle contract for a specific user, or returns
    /// the existing one if it exists
    /// @param admin Address receiving the admin rights of the Sickle contract
    /// @param referralCode Referral code for the user
    /// @return sickle Address of the deployed Sickle contract
    function getOrDeploy(
        address admin,
        address approved,
        bytes32 referralCode
    ) external returns (address sickle) {
        if (!isActive) {
            revert NotActive();
        }
        if (!registry.isWhitelistedCaller(msg.sender)) {
            revert CallerNotWhitelisted(msg.sender);
        }
        if ((sickle = _getSickle(admin)) != address(0)) {
            return sickle;
        }
        return _deploy(admin, approved, referralCode);
    }

    /// @notice Deploys a new Sickle contract for a specific user
    /// @dev Sickle contracts are deployed with create2, the address of the
    /// admin is used as a salt, so all the Sickle addresses can be pre-computed
    /// and only 1 Sickle will exist per address
    /// @param referralCode Referral code for the user
    /// @return sickle Address of the deployed Sickle contract
    function deploy(
        address approved,
        bytes32 referralCode
    ) external returns (address sickle) {
        if (!isActive) {
            revert NotActive();
        }
        if (_getSickle(msg.sender) != address(0)) {
            revert SickleAlreadyDeployed();
        }
        return _deploy(msg.sender, approved, referralCode);
    }
}

File 23 of 42 : AccessControlModule.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Sickle } from "contracts/Sickle.sol";
import { SickleFactory } from "contracts/SickleFactory.sol";

contract AccessControlModule {
    SickleFactory public immutable factory;

    error NotOwner(address sender); // 30cd7471
    error NotApproved();
    error SickleNotDeployed();
    error NotRegisteredSickle();

    constructor(SickleFactory factory_) {
        factory = factory_;
    }

    modifier onlyRegisteredSickle() {
        if (factory.admins(address(this)) == address(0)) {
            revert NotRegisteredSickle();
        }

        _;
    }

    // @dev allow access only to the sickle's owner or addresses approved by him
    // to use only for functions such as claiming rewards or compounding rewards
    modifier onlyApproved(Sickle sickle) {
        // Here we check if the Sickle was really deployed, this gives use the
        // guarantee that the contract that we are going to call is genuine
        if (factory.admins(address(sickle)) == address(0)) {
            revert SickleNotDeployed();
        }

        if (sickle.approved() != msg.sender) revert NotApproved();

        _;
    }
}

File 24 of 42 : Admin.sol
// 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;
    }
}

File 25 of 42 : TimelockAdmin.sol
// 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;
    }
}

File 26 of 42 : ZapStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {
    SwapParams,
    AddLiquidityParams,
    RemoveLiquidityParams
} from "contracts/structs/LiquidityStructs.sol";

struct ZapIn {
    SwapParams[] swaps;
    AddLiquidityParams addLiquidityParams;
}

struct ZapOut {
    RemoveLiquidityParams removeLiquidityParams;
    SwapParams[] swaps;
}

File 27 of 42 : Sickle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { SickleStorage } from "contracts/base/SickleStorage.sol";
import { Multicall } from "contracts/base/Multicall.sol";
import { SickleRegistry } from "contracts/SickleRegistry.sol";

/// @title Sickle contract
/// @author vfat.tools
/// @notice Sickle facilitates farming and interactions with Masterchef
/// contracts
/// @dev Base contract inheriting from all the other "manager" contracts
contract Sickle is SickleStorage, Multicall {
    /// @notice Function to receive ETH
    receive() external payable { }

    /// @param sickleRegistry_ Address of the SickleRegistry contract
    constructor(
        SickleRegistry sickleRegistry_
    ) initializer Multicall(sickleRegistry_) {
        _Sickle_initialize(address(0), address(0));
    }

    /// @param sickleOwner_ Address of the Sickle owner
    function initialize(
        address sickleOwner_,
        address approved_
    ) external initializer {
        _Sickle_initialize(sickleOwner_, approved_);
    }

    /// INTERNALS ///

    function _Sickle_initialize(
        address sickleOwner_,
        address approved_
    ) internal {
        SickleStorage._SickleStorage_initialize(sickleOwner_, approved_);
    }

    function onERC721Received(
        address, // operator
        address, // from
        uint256, // tokenId
        bytes calldata // data
    ) external pure returns (bytes4) {
        return this.onERC721Received.selector;
    }

    function onERC1155Received(
        address, // operator
        address, // from
        uint256, // id
        uint256, // value
        bytes calldata // data
    ) external pure returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address, // operator
        address, // from
        uint256[] calldata, // ids
        uint256[] calldata, // values
        bytes calldata // data
    ) external pure returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

File 28 of 42 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 29 of 42 : IERC20.sol
// 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);
}

File 30 of 42 : SafeTransferLib.sol
// 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();
    }
}

File 31 of 42 : ILiquidityConnector.sol
// 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);
}

File 32 of 42 : DelegateModule.sol
// 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;
    }
}

File 33 of 42 : NftLiquidityStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { INonfungiblePositionManager } from
    "contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";

struct Pool {
    address token0;
    address token1;
    uint24 fee;
}

struct NftAddLiquidity {
    INonfungiblePositionManager nft;
    uint256 tokenId;
    Pool pool;
    int24 tickLower;
    int24 tickUpper;
    uint256 amount0Desired;
    uint256 amount1Desired;
    uint256 amount0Min;
    uint256 amount1Min;
    bytes extraData;
}

struct NftRemoveLiquidity {
    INonfungiblePositionManager nft;
    uint256 tokenId;
    uint128 liquidity;
    uint256 amount0Min; // For decreasing
    uint256 amount1Min;
    uint128 amount0Max; // For collecting
    uint128 amount1Max;
    bytes extraData;
}

File 34 of 42 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create(0, 0x09, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create2(0, 0x09, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(add(ptr, 0x38), deployer)
            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
            mstore(add(ptr, 0x14), implementation)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
            mstore(add(ptr, 0x58), salt)
            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
            predicted := keccak256(add(ptr, 0x43), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 35 of 42 : SickleRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Admin } from "contracts/base/Admin.sol";

library SickleRegistryEvents {
    event CollectorChanged(address newCollector);
    event FeesUpdated(bytes32[] feeHashes, uint256[] feesInBP);
    event ReferralCodeCreated(bytes32 indexed code, address indexed referrer);

    // Multicall caller and target whitelist status changes
    event CallerStatusChanged(address caller, bool isWhitelisted);
    event TargetStatusChanged(address target, bool isWhitelisted);
}

/// @title SickleRegistry contract
/// @author vfat.tools
/// @notice Manages the whitelisted contracts and the collector address
contract SickleRegistry is Admin {
    /// ERRORS ///

    error ArrayLengthMismatch(); // 0xa24a13a6
    error FeeAboveMaxLimit(); // 0xd6cf7b5e
    error InvalidReferralCode(); // 0xe55b4629

    /// STORAGE ///

    /// @notice Address of the fee collector
    address public collector;

    /// @notice Tracks the contracts that can be called through Sickle multicall
    /// @return True if the contract is a whitelisted target
    mapping(address => bool) public isWhitelistedTarget;

    /// @notice Tracks the contracts that can call Sickle multicall
    /// @return True if the contract is a whitelisted caller
    mapping(address => bool) public isWhitelistedCaller;

    /// @notice Keeps track of the referrers and their associated code
    mapping(bytes32 => address) public referralCodes;

    /// @notice Mapping for fee hashes (hash of the strategy contract addresses
    /// and the function selectors) and their associated fees
    /// @return The fee in basis points to apply to the transaction amount
    mapping(bytes32 => uint256) public feeRegistry;

    /// WRITE FUNCTIONS ///

    /// @param admin_ Address of the admin
    /// @param collector_ Address of the collector
    constructor(address admin_, address collector_) Admin(admin_) {
        collector = collector_;
    }

    /// @notice Updates the whitelist status for multiple multicall targets
    /// @param targets Addresses of the contracts to update
    /// @param isApproved New status for the contracts
    /// @custom:access Restricted to protocol admin.
    function setWhitelistedTargets(
        address[] calldata targets,
        bool isApproved
    ) external onlyAdmin {
        for (uint256 i; i < targets.length;) {
            isWhitelistedTarget[targets[i]] = isApproved;
            emit SickleRegistryEvents.TargetStatusChanged(
                targets[i], isApproved
            );

            unchecked {
                ++i;
            }
        }
    }

    /// @notice Updates the fee collector address
    /// @param newCollector Address of the new fee collector
    /// @custom:access Restricted to protocol admin.
    function updateCollector(address newCollector) external onlyAdmin {
        collector = newCollector;
        emit SickleRegistryEvents.CollectorChanged(newCollector);
    }

    /// @notice Update the whitelist status for multiple multicall callers
    /// @param callers Addresses of the callers
    /// @param isApproved New status for the caller
    /// @custom:access Restricted to protocol admin.
    function setWhitelistedCallers(
        address[] calldata callers,
        bool isApproved
    ) external onlyAdmin {
        for (uint256 i; i < callers.length;) {
            isWhitelistedCaller[callers[i]] = isApproved;
            emit SickleRegistryEvents.CallerStatusChanged(
                callers[i], isApproved
            );

            unchecked {
                ++i;
            }
        }
    }

    /// @notice Associates a referral code to the address of the caller
    function setReferralCode(bytes32 referralCode) external {
        if (referralCodes[referralCode] != address(0)) {
            revert InvalidReferralCode();
        }

        referralCodes[referralCode] = msg.sender;
        emit SickleRegistryEvents.ReferralCodeCreated(referralCode, msg.sender);
    }

    /// @notice Update the fees for multiple strategy functions
    /// @param feeHashes Array of fee hashes
    /// @param feesArray Array of fees to apply (in basis points)
    /// @custom:access Restricted to protocol admin.
    function setFees(
        bytes32[] calldata feeHashes,
        uint256[] calldata feesArray
    ) external onlyAdmin {
        if (feeHashes.length != feesArray.length) {
            revert ArrayLengthMismatch();
        }

        for (uint256 i = 0; i < feeHashes.length;) {
            if (feesArray[i] <= 500) {
                // maximum fee of 5%
                feeRegistry[feeHashes[i]] = feesArray[i];
            } else {
                revert FeeAboveMaxLimit();
            }
            unchecked {
                ++i;
            }
        }

        emit SickleRegistryEvents.FeesUpdated(feeHashes, feesArray);
    }
}

File 36 of 42 : SickleStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Initializable } from
    "@openzeppelin/contracts/proxy/utils/Initializable.sol";

library SickleStorageEvents {
    event ApprovedAddressChanged(address newApproved);
}

/// @title SickleStorage contract
/// @author vfat.tools
/// @notice Base storage of the Sickle contract
/// @dev This contract needs to be inherited by stub contracts meant to be used
/// with `delegatecall`
abstract contract SickleStorage is Initializable {
    /// ERRORS ///

    /// @notice Thrown when the caller is not the owner of the Sickle contract
    error NotOwnerError(); // 0x74a21527

    /// @notice Thrown when the caller is not a strategy contract or the
    /// Flashloan Stub
    error NotStrategyError(); // 0x4581ba62

    /// STORAGE ///

    /// @notice Address of the owner
    address public owner;

    /// @notice An address that can be set by the owner of the Sickle contract
    /// in order to trigger specific functions.
    address public approved;

    /// MODIFIERS ///

    /// @dev Restricts a function call to the owner, however if the admin was
    /// not set yet,
    /// the modifier will not restrict the call, this allows the SickleFactory
    /// to perform
    /// some calls on the user's behalf before passing the admin rights to them
    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwnerError();
        _;
    }

    /// INITIALIZATION ///

    /// @param owner_ Address of the owner of this Sickle contract
    function _SickleStorage_initialize(
        address owner_,
        address approved_
    ) internal onlyInitializing {
        owner = owner_;
        approved = approved_;
    }

    /// WRITE FUNCTIONS ///

    /// @notice Sets the approved address of this Sickle
    /// @param newApproved Address meant to be approved by the owner
    function setApproved(address newApproved) external onlyOwner {
        approved = newApproved;
        emit SickleStorageEvents.ApprovedAddressChanged(newApproved);
    }

    /// @notice Checks if `caller` is either the owner of the Sickle contract
    /// or was approved by them
    /// @param caller Address to check
    /// @return True if `caller` is either the owner of the Sickle contract
    function isOwnerOrApproved(address caller) public view returns (bool) {
        return caller == owner || caller == approved;
    }
}

File 37 of 42 : Multicall.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { SickleStorage } from "contracts/base/SickleStorage.sol";
import { SickleRegistry } from "contracts/SickleRegistry.sol";

/// @title Multicall contract
/// @author vfat.tools
/// @notice Enables calling multiple methods in a single call to the contract
abstract contract Multicall is SickleStorage {
    /// ERRORS ///

    error MulticallParamsMismatchError(); // 0xc1e637c9

    /// @notice Thrown when the target contract is not whitelisted
    /// @param target Address of the non-whitelisted target
    error TargetNotWhitelisted(address target); // 0x47ccabe7

    /// @notice Thrown when the caller is not whitelisted
    /// @param caller Address of the non-whitelisted caller
    error CallerNotWhitelisted(address caller); // 0x252c8273

    /// STORAGE ///

    /// @notice Address of the SickleRegistry contract
    /// @dev Needs to be immutable so that it's accessible for Sickle proxies
    SickleRegistry public immutable registry;

    /// INITIALIZATION ///

    /// @param registry_ Address of the SickleRegistry contract
    constructor(SickleRegistry registry_) initializer {
        registry = registry_;
    }

    /// WRITE FUNCTIONS ///

    /// @notice Batch multiple calls together (calls or delegatecalls)
    /// @param targets Array of targets to call
    /// @param data Array of data to pass with the calls
    function multicall(
        address[] calldata targets,
        bytes[] calldata data
    ) external payable {
        if (targets.length != data.length) {
            revert MulticallParamsMismatchError();
        }

        if (!registry.isWhitelistedCaller(msg.sender)) {
            revert CallerNotWhitelisted(msg.sender);
        }

        for (uint256 i = 0; i != data.length;) {
            if (targets[i] == address(0)) {
                unchecked {
                    ++i;
                }
                continue; // No-op
            }

            if (targets[i] != address(this)) {
                if (!registry.isWhitelistedTarget(targets[i])) {
                    revert TargetNotWhitelisted(targets[i]);
                }
            }

            (bool success, bytes memory result) =
                targets[i].delegatecall(data[i]);

            if (!success) {
                if (result.length == 0) revert();
                assembly {
                    revert(add(32, result), mload(result))
                }
            }
            unchecked {
                ++i;
            }
        }
    }
}

File 38 of 42 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 39 of 42 : ERC20.sol
// 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);
    }
}

File 40 of 42 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/Address.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 41 of 42 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 42 of 42 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

Settings
{
  "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

Contract ABI

[{"inputs":[{"internalType":"contract SickleFactory","name":"factory","type":"address"},{"internalType":"contract ConnectorRegistry","name":"connectorRegistry","type":"address"},{"components":[{"internalType":"contract ITransferLib","name":"transferLib","type":"address"},{"internalType":"contract ISwapLib","name":"swapLib","type":"address"},{"internalType":"contract IFeesLib","name":"feesLib","type":"address"},{"internalType":"contract IZapLib","name":"zapLib","type":"address"},{"internalType":"contract INftZapLib","name":"nftZapLib","type":"address"}],"internalType":"struct MultiFarmStrategy.Libraries","name":"libraries","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"NotApproved","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"NotOwner","type":"error"},{"inputs":[],"name":"NotRegisteredSickle","type":"error"},{"inputs":[],"name":"SickleNotDeployed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"address","name":"claimStakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"claimPoolIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"depositStakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositPoolIndex","type":"uint256"}],"name":"SickleCompounded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleCompoundedNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleDecreasedNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleDeposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleDepositedNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleExited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleExitedNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleHarvested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleHarvestedNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleIncreasedNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"contract INonfungiblePositionManager","name":"fromNft","type":"address"},{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"fromStakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"fromPoolIndex","type":"uint256"},{"indexed":false,"internalType":"contract INonfungiblePositionManager","name":"toNft","type":"address"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"toStakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"toPoolIndex","type":"uint256"}],"name":"SickleMovedNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleRebalancedNft","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract Sickle","name":"sickle","type":"address"},{"indexed":true,"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"stakingContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolIndex","type":"uint256"}],"name":"SickleWithdrewNft","type":"event"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"address","name":"stakingContract","type":"address"},{"internalType":"uint256","name":"poolIndex","type":"uint256"}],"internalType":"struct Farm","name":"claimFarm","type":"tuple"},{"internalType":"bytes","name":"claimExtraData","type":"bytes"}],"internalType":"struct ClaimParams[]","name":"claims","type":"tuple[]"},{"components":[{"components":[{"components":[{"internalType":"address","name":"stakingContract","type":"address"},{"internalType":"uint256","name":"poolIndex","type":"uint256"}],"internalType":"struct Farm","name":"farm","type":"tuple"},{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NftPosition","name":"position","type":"tuple"},{"components":[{"internalType":"address[]","name":"rewardTokens","type":"address[]"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct SimpleNftHarvest","name":"harvest","type":"tuple"}],"internalType":"struct NftClaimParams[]","name":"nftClaims","type":"tuple[]"},{"internalType":"address[]","name":"rewardTokens","type":"address[]"},{"components":[{"components":[{"internalType":"address","name":"router","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"address","name":"tokenIn","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"},{"components":[{"internalType":"address","name":"stakingContract","type":"address"},{"internalType":"uint256","name":"poolIndex","type":"uint256"}],"internalType":"struct Farm","name":"depositFarm","type":"tuple"},{"internalType":"bytes","name":"depositExtraData","type":"bytes"}],"internalType":"struct MultiCompoundParams","name":"params","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"compoundMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"connectorRegistry","outputs":[{"internalType":"contract ConnectorRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"contract SickleFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feesLib","outputs":[{"internalType":"contract IFeesLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"approved","type":"address"},{"internalType":"bytes32","name":"referralCode","type":"bytes32"}],"name":"getOrDeploySickle","outputs":[{"internalType":"contract Sickle","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getSickle","outputs":[{"internalType":"contract Sickle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"address","name":"stakingContract","type":"address"},{"internalType":"uint256","name":"poolIndex","type":"uint256"}],"internalType":"struct Farm","name":"claimFarm","type":"tuple"},{"internalType":"bytes","name":"claimExtraData","type":"bytes"}],"internalType":"struct ClaimParams[]","name":"claims","type":"tuple[]"},{"components":[{"components":[{"components":[{"internalType":"address","name":"stakingContract","type":"address"},{"internalType":"uint256","name":"poolIndex","type":"uint256"}],"internalType":"struct Farm","name":"farm","type":"tuple"},{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NftPosition","name":"position","type":"tuple"},{"components":[{"internalType":"address[]","name":"rewardTokens","type":"address[]"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct SimpleNftHarvest","name":"harvest","type":"tuple"}],"internalType":"struct NftClaimParams[]","name":"nftClaims","type":"tuple[]"},{"components":[{"internalType":"address","name":"router","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct SwapParams[]","name":"swaps","type":"tuple[]"},{"internalType":"address[]","name":"tokensOut","type":"address[]"}],"internalType":"struct MultiHarvestParams","name":"params","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"harvestMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"address","name":"stakingContract","type":"address"},{"internalType":"uint256","name":"poolIndex","type":"uint256"}],"internalType":"struct Farm","name":"claimFarm","type":"tuple"},{"internalType":"bytes","name":"claimExtraData","type":"bytes"}],"internalType":"struct ClaimParams[]","name":"claims","type":"tuple[]"},{"components":[{"components":[{"components":[{"internalType":"address","name":"stakingContract","type":"address"},{"internalType":"uint256","name":"poolIndex","type":"uint256"}],"internalType":"struct Farm","name":"farm","type":"tuple"},{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NftPosition","name":"position","type":"tuple"},{"components":[{"internalType":"address[]","name":"rewardTokens","type":"address[]"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct SimpleNftHarvest","name":"harvest","type":"tuple"}],"internalType":"struct NftClaimParams[]","name":"nftClaims","type":"tuple[]"},{"internalType":"address[]","name":"rewardTokens","type":"address[]"},{"components":[{"components":[{"internalType":"address","name":"router","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minAmountOut","type":"uint256"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct SwapParams[]","name":"swaps","type":"tuple[]"},{"components":[{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"}],"internalType":"struct Pool","name":"pool","type":"tuple"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftAddLiquidity","name":"addLiquidityParams","type":"tuple"}],"internalType":"struct NftZapIn","name":"zap","type":"tuple"},{"components":[{"components":[{"internalType":"address","name":"stakingContract","type":"address"},{"internalType":"uint256","name":"poolIndex","type":"uint256"}],"internalType":"struct Farm","name":"farm","type":"tuple"},{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NftPosition","name":"depositPosition","type":"tuple"},{"internalType":"bytes","name":"depositExtraData","type":"bytes"},{"internalType":"bool","name":"compoundInPlace","type":"bool"}],"internalType":"struct NftMultiCompoundParams","name":"params","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"nftCompoundMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nftZapLib","outputs":[{"internalType":"contract INftZapLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategyAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapLib","outputs":[{"internalType":"contract ISwapLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferLib","outputs":[{"internalType":"contract ITransferLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"zapLib","outputs":[{"internalType":"contract IZapLib","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101806040523480156200001257600080fd5b5060405162002abc38038062002abc8339810160408190526200003591620000af565b6001600160a01b03928316608090815291831660a05230610160528051831660c0526020810151831660e052604081015183166101005260608101518316610120520151166101405262000199565b6001600160a01b03811681146200009a57600080fd5b50565b8051620000aa8162000084565b919050565b600080600083850360e0811215620000c657600080fd5b8451620000d38162000084565b6020860151909450620000e68162000084565b925060a0603f1982011215620000fb57600080fd5b5060405160a081016001600160401b03811182821017156200012d57634e487b7160e01b600052604160045260246000fd5b806040525062000140604086016200009d565b815262000150606086016200009d565b602082015262000163608086016200009d565b60408201526200017660a086016200009d565b60608201526200018960c086016200009d565b6080820152809150509250925092565b60805160a05160c05160e0516101005161012051610140516101605161283962000283600039600081816101df01528181610412015281816106c20152610d2f01526000818161022d0152610dd9015260008181610267015261076c01526000818160ee015281816103c6015281816106760152610ce30152600081816101310152610314015260008181610158015281816104be015281816109900152610e8c0152600081816101b801528181610829015281816110b60152818161133b0152818161189b0152611a9001526000818161020601528181610aef0152610bba01526128396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063b3fb68d51161008c578063c45a015511610066578063c45a015514610201578063d996cef714610228578063def739531461024f578063ee360f241461026257600080fd5b8063b3fb68d5146101a0578063b53c86d2146101b3578063bc6b74ab146101da57600080fd5b806320822a27146100d45780632af3fa1b146100e95780633faa6e301461012c5780633fb53a0d14610153578063597457061461017a578063759cb2341461018d575b600080fd5b6100e76100e2366004611ce8565b610289565b005b6101107f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b6101107f000000000000000000000000000000000000000000000000000000000000000081565b6101107f000000000000000000000000000000000000000000000000000000000000000081565b6100e7610188366004611d54565b6105f5565b61011061019b366004611d93565b610acb565b6101106101ae366004611db7565b610b89565b6101107f000000000000000000000000000000000000000000000000000000000000000081565b6101107f000000000000000000000000000000000000000000000000000000000000000081565b6101107f000000000000000000000000000000000000000000000000000000000000000081565b6101107f000000000000000000000000000000000000000000000000000000000000000081565b6100e761025d366004611df8565b610c31565b6101107f000000000000000000000000000000000000000000000000000000000000000081565b600061029433610acb565b90506102a9816102a48580611e9b565b610fdf565b6102bf816102ba6020860186611e9b565b611264565b60408051600380825260808201909252600091602082016060803683375050604080516003808252608082019092529293506000929150602082015b60608152602001906001900390816102fb5790505090507f00000000000000000000000000000000000000000000000000000000000000008260008151811061034657610346611eec565b6001600160a01b039092166020928302919091019091015261036b6040860186611e9b565b60405160240161037c929190611f90565b60408051601f198184030181529190526020810180516001600160e01b03166357e72eb360e01b179052815182906000906103b9576103b9611eec565b60200260200101819052507f0000000000000000000000000000000000000000000000000000000000000000826001815181106103f8576103f8611eec565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000000000000000000000000000000000000000000007fe400534da780c9d64ef8b5f03c074ff47537b6a4aa2a3e5d5455cb37b5406aa361045f6060880188611e9b565b6040516024016104729493929190612098565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b1790528151829060019081106104b1576104b1611eec565b60200260200101819052507f0000000000000000000000000000000000000000000000000000000000000000826002815181106104f0576104f0611eec565b60200260200101906001600160a01b031690816001600160a01b031681525050836040516024016105219190612110565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b17905281518290600290811061056057610560611eec565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038416906363fb0b96906105999085908590600401612123565b600060405180830381600087803b1580156105b357600080fd5b505af11580156105c7573d6000803e3d6000fd5b506105ee92508591506105dc90508780611e9b565b6105e960208a018a611e9b565b6114e5565b5050505050565b600061060033610acb565b9050610610816102a48580611e9b565b610621816102ba6020860186611e9b565b60408051600480825260a0820190925260009160208201608080368337505060408051600480825260a082019092529293506000929150602082015b606081526020019060019003908161065d5790505090507f0000000000000000000000000000000000000000000000000000000000000000826000815181106106a8576106a8611eec565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000000000000000000000000000000000000000000007f1d5b8de553017a3bd388578aeece0183b79c5ca87ec64628b3f76b39487f023161070f6040880188611e9b565b6040516024016107229493929190612098565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b1790528151829060009061075f5761075f611eec565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000008260018151811061079e5761079e611eec565b6001600160a01b03909216602092830291909101909101526107c360608601866121c5565b6040516024016107d39190612314565b60408051601f198184030181529190526020810180516001600160e01b031663cd5f81a960e01b17905281518290600190811061081257610812611eec565b602090810291909101015260006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae61085e60a0890160808a01611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156108a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c6919061241d565b905080836002815181106108dc576108dc611eec565b6001600160a01b03909216602092830291909101909101526080860161090560608801886121c5565b61091390602081019061243a565b610924906040810190602001611d93565b61093160c0890189612450565b60405160240161094494939291906124b8565b60408051601f198184030181529190526020810180516001600160e01b0316636ec4f1e960e11b17905282518390600290811061098357610983611eec565b60200260200101819052507f0000000000000000000000000000000000000000000000000000000000000000836003815181106109c2576109c2611eec565b60200260200101906001600160a01b031690816001600160a01b031681525050846040516024016109f39190612110565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b179052825183906003908110610a3257610a32611eec565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038516906363fb0b9690610a6b9086908690600401612123565b600060405180830381600087803b158015610a8557600080fd5b505af1158015610a99573d6000803e3d6000fd5b50610ac392508691505060808801610ab18980611e9b565b610abe60208c018c611e9b565b6116ce565b505050505050565b6040516312cfc9b560e31b81526001600160a01b03828116600483015260009182917f0000000000000000000000000000000000000000000000000000000000000000169063967e4da890602401602060405180830381865afa158015610b36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5a919061241d565b90506001600160a01b038116610b8357604051633098a45560e01b815260040160405180910390fd5b92915050565b60405163de0d95ed60e01b81526001600160a01b0384811660048301528381166024830152604482018390526000917f00000000000000000000000000000000000000000000000000000000000000009091169063de0d95ed906064016020604051808303816000875af1158015610c05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c29919061241d565b949350505050565b6000610c3c33610acb565b9050610c4c816102a48680611e9b565b610c5d816102ba6020870187611e9b565b610c6f610140850161012086016124ea565b610c8e57610c8e8160808601610c89610100880188612450565b61188f565b60408051600380825260808201909252600091602082016060803683375050604080516003808252608082019092529293506000929150602082015b6060815260200190600190039081610cca5790505090507f000000000000000000000000000000000000000000000000000000000000000082600081518110610d1557610d15611eec565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000000000000000000000000000000000000000000007f1d5b8de553017a3bd388578aeece0183b79c5ca87ec64628b3f76b39487f0231610d7c6040890189611e9b565b604051602401610d8f9493929190612098565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b17905281518290600090610dcc57610dcc611eec565b60200260200101819052507f000000000000000000000000000000000000000000000000000000000000000082600181518110610e0b57610e0b611eec565b6001600160a01b0390921660209283029190910190910152610e3060608701876121c5565b604051602401610e40919061256e565b60408051601f198184030181529190526020810180516001600160e01b0316633d74119b60e21b179052815182906001908110610e7f57610e7f611eec565b60200260200101819052507f000000000000000000000000000000000000000000000000000000000000000082600281518110610ebe57610ebe611eec565b60200260200101906001600160a01b031690816001600160a01b0316815250508484604051602401610ef1929190612685565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b179052815182906002908110610f3057610f30611eec565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038416906363fb0b9690610f699085908590600401612123565b600060405180830381600087803b158015610f8357600080fd5b505af1158015610f97573d6000803e3d6000fd5b50610fae92505050610140870161012088016124ea565b610fcd57610fcd8360808801610fc86101008a018a612450565b611a84565b610ac38360808801610ab18980611e9b565b8060008167ffffffffffffffff811115610ffb57610ffb611c08565b604051908082528060200260200182016040528015611024578160200160208202803683370190505b50905060008267ffffffffffffffff81111561104257611042611c08565b60405190808252806020026020018201604052801561107557816020015b60608152602001906001900390816110605790505b50905060005b838110156111fb573686868381811061109657611096611eec565b90506020028101906110a89190612699565b905060006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae6110e86020850185611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561112c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611150919061241d565b90508085848151811061116557611165611eec565b6001600160a01b03909216602092830291909101909101528161118b6040820182612450565b60405160240161119d939291906126af565b60408051601f198184030181529190526020810180516001600160e01b0316638bddf18760e01b17905284518590859081106111db576111db611eec565b6020026020010181905250505080806111f3906126d9565b91505061107b565b506040516331fd85cb60e11b81526001600160a01b038716906363fb0b969061122a9085908590600401612123565b600060405180830381600087803b15801561124457600080fd5b505af1158015611258573d6000803e3d6000fd5b50505050505050505050565b8060008167ffffffffffffffff81111561128057611280611c08565b6040519080825280602002602001820160405280156112a9578160200160208202803683370190505b50905060008267ffffffffffffffff8111156112c7576112c7611c08565b6040519080825280602002602001820160405280156112fa57816020015b60608152602001906001900390816112e55790505b50905060005b838110156111fb573686868381811061131b5761131b611eec565b905060200281019061132d9190612700565b905060006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae61136d6020850185611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156113b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d5919061241d565b9050808584815181106113ea576113ea611eec565b6001600160a01b0390921660209283029190910190910152816114106080820182612716565b61141a9080611e9b565b6114276080860186612716565b61143890604081019060200161272c565b6114456080870187612716565b61145690606081019060400161272c565b6114636080880188612716565b611471906060810190612450565b6040516024016114879796959493929190612786565b60408051601f198184030181529190526020810180516001600160e01b0316636f4621e360e01b17905284518590859081106114c5576114c5611eec565b6020026020010181905250505080806114dd906126d9565b915050611300565b60005b8381101561159b5784848281811061150257611502611eec565b90506020028101906115149190612699565b6020013585858381811061152a5761152a611eec565b905060200281019061153c9190612699565b61154a906020810190611d93565b6001600160a01b0316876001600160a01b03167f37da49704c95bce31298d9d965163d5953283973279e35728e6666bd9abe1e7a60405160405180910390a480611593816126d9565b9150506114e8565b5060005b81811015610ac3578282828181106115b9576115b9611eec565b90506020028101906115cb9190612700565b606001358383838181106115e1576115e1611eec565b90506020028101906115f39190612700565b611604906060810190604001611d93565b6001600160a01b0316876001600160a01b03167fbf9d03ac543e8f596c6f4af5ab5e75f366a57d2d6c28d2ff9c024bd3f88e877186868681811061164a5761164a611eec565b905060200281019061165c9190612700565b61166a906020810190611d93565b87878781811061167c5761167c611eec565b905060200281019061168e9190612700565b6040516116b4929160200135906001600160a01b03929092168252602082015260400190565b60405180910390a4806116c6816126d9565b91505061159f565b60005b838110156117ab576116e66020870187611d93565b6001600160a01b031685858381811061170157611701611eec565b90506020028101906117139190612699565b611721906020810190611d93565b6001600160a01b0316886001600160a01b03167f052db0f97f7329c6cb05c89ccab89a2ad3acd05ac8d5678a6c1d46c309afbad188888681811061176757611767611eec565b90506020028101906117799190612699565b6040805160209283013581528c830135928101929092520160405180910390a4806117a3816126d9565b9150506116d1565b5060005b81811015611886578282828181106117c9576117c9611eec565b90506020028101906117db9190612700565b606001358383838181106117f1576117f1611eec565b90506020028101906118039190612700565b611814906060810190604001611d93565b6001600160a01b039081169089167f504180eddec0aa4ed3bb8edcf99b13013e1d8ae52be37f0f4f38d14ccf0c99a561185060208b018b611d93565b604080516001600160a01b0390921682526020808d0135908301520160405180910390a48061187e816126d9565b9150506117af565b50505050505050565b60006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae6118cd6020870187611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611911573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611935919061241d565b604080516001808252818301909252919250600091906020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081611973579050509050828260008151811061199e5761199e611eec565b60200260200101906001600160a01b031690816001600160a01b0316815250508585856040516024016119d3939291906127e2565b60408051601f198184030181529190526020810180516001600160e01b0316631423e67960e11b17905281518290600090611a1057611a10611eec565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038816906363fb0b9690611a499085908590600401612123565b600060405180830381600087803b158015611a6357600080fd5b505af1158015611a77573d6000803e3d6000fd5b5050505050505050505050565b60006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae611ac26020870187611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611b06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2a919061241d565b604080516001808252818301909252919250600091906020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081611b685790505090508282600081518110611b9357611b93611eec565b60200260200101906001600160a01b031690816001600160a01b031681525050858585604051602401611bc8939291906127e2565b60408051601f198184030181529190526020810180516001600160e01b03166001624236cd60e11b031917905281518290600090611a1057611a10611eec565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611c3357600080fd5b50565b8035611c4181611c1e565b919050565b600082601f830112611c5757600080fd5b8135602067ffffffffffffffff80831115611c7457611c74611c08565b8260051b604051601f19603f83011681018181108482111715611c9957611c99611c08565b604052938452858101830193838101925087851115611cb757600080fd5b83870191505b84821015611cdd57611cce82611c36565b83529183019190830190611cbd565b979650505050505050565b60008060408385031215611cfb57600080fd5b823567ffffffffffffffff80821115611d1357600080fd5b9084019060808287031215611d2757600080fd5b90925060208401359080821115611d3d57600080fd5b50611d4a85828601611c46565b9150509250929050565b60008060408385031215611d6757600080fd5b823567ffffffffffffffff80821115611d7f57600080fd5b9084019060e08287031215611d2757600080fd5b600060208284031215611da557600080fd5b8135611db081611c1e565b9392505050565b600080600060608486031215611dcc57600080fd5b8335611dd781611c1e565b92506020840135611de781611c1e565b929592945050506040919091013590565b600080600060408486031215611e0d57600080fd5b833567ffffffffffffffff80821115611e2557600080fd5b908501906101408288031215611e3a57600080fd5b90935060208501359080821115611e5057600080fd5b818601915086601f830112611e6457600080fd5b813581811115611e7357600080fd5b8760208260051b8501011115611e8857600080fd5b6020830194508093505050509250925092565b6000808335601e19843603018112611eb257600080fd5b83018035915067ffffffffffffffff821115611ecd57600080fd5b6020019150600581901b3603821315611ee557600080fd5b9250929050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611f1957600080fd5b830160208101925035905067ffffffffffffffff811115611f3957600080fd5b803603821315611ee557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008235609e19833603018112611f8757600080fd5b90910192915050565b60208082528181018390526000906040808401600586901b8501820187855b8881101561204157878303603f19018452611fca828b611f71565b60a08135611fd781611c1e565b6001600160a01b039081168652828901358987015287830135888701526060908184013561200481611c1e565b1690860152608061201783820184611f02565b9350828288015261202b8388018583611f48565b978a019796505050928701925050600101611faf565b509098975050505050505050565b8183526000602080850194508260005b8581101561208d57813561207281611c1e565b6001600160a01b03168752958201959082019060010161205f565b509495945050505050565b6001600160a01b03851681526001600160e01b0319841660208201526060604082018190526000906120cd908301848661204f565b9695505050505050565b600081518084526020808501945080840160005b8381101561208d5781516001600160a01b0316875295820195908201906001016120eb565b602081526000611db060208301846120d7565b60408152600061213660408301856120d7565b6020838203818501528185518084528284019150828160051b8501018388016000805b848110156121b557601f198089860301875283518051808752845b8181101561218f578281018b01518882018c01528a01612174565b508681018a0185905297890197601f019091169094018701935091860191600101612159565b50919a9950505050505050505050565b60008235603e198336030181126121db57600080fd5b9190910192915050565b6000808335601e198436030181126121fc57600080fd5b830160208101925035905067ffffffffffffffff81111561221c57600080fd5b8060051b3603821315611ee557600080fd5b818352600060208085019450848460051b86018460005b878110156122d557838303895261225c8288611f71565b60a0813561226981611c1e565b6001600160a01b0390811686528288013588870152604080840135908701526060908184013561229881611c1e565b169086015260806122ab83820184611f02565b935082828801526122bf8388018583611f48565b9c89019c96505050928601925050600101612245565b5090979650505050505050565b81835260006001600160fb1b038311156122fb57600080fd5b8260051b80836020870137939093016020019392505050565b60208152600061232483846121e5565b6040602085015261233960608501828461222e565b915050602084013560be1985360301811261235357600080fd5b838203601f190160408501528401803561236c81611c1e565b6001600160a01b03908116835260208201359061238882611c1e565b16602083015261239b60408201826121e5565b60c060408501526123b060c08501828461204f565b9150506123c060608301836121e5565b84830360608601526123d38382846122e2565b925050506123e460808301836121e5565b84830360808601526123f78382846122e2565b9250505061240860a0830183611f02565b925083820360a0850152611cdd828483611f48565b60006020828403121561242f57600080fd5b8151611db081611c1e565b6000823560be198336030181126121db57600080fd5b6000808335601e1984360301811261246757600080fd5b83018035915067ffffffffffffffff82111561248257600080fd5b602001915036819003821315611ee557600080fd5b80356124a281611c1e565b6001600160a01b03168252602090810135910152565b6124c28186612497565b6001600160a01b03841660408201526080606082018190526000906120cd9083018486611f48565b6000602082840312156124fc57600080fd5b81358015158114611db057600080fd5b803561251781611c1e565b6001600160a01b03908116835260208201359061253382611c1e565b166020830152604081013562ffffff811680821461255057600080fd5b80604085015250505050565b8035600281900b8114611c4157600080fd5b60208152600061257e83846121e5565b6040602085015261259360608501828461222e565b915050602084013561017e198536030181126125ae57600080fd5b838203601f1901604085015284016101806125d9836125cc84611c36565b6001600160a01b03169052565b602082013560208401526125f3604084016040840161250c565b6125ff60a0830161255c565b61260e60a085018260020b9052565b5061261b60c0830161255c565b61262a60c085018260020b9052565b5060e0828101359084015261010080830135908401526101208083013590840152610140808301359084015261016061266581840184611f02565b935082828601526126798386018583611f48565b98975050505050505050565b602081526000610c2960208301848661204f565b60008235605e198336030181126121db57600080fd5b6126b98185612497565b6060604082015260006126d0606083018486611f48565b95945050505050565b6000600182016126f957634e487b7160e01b600052601160045260246000fd5b5060010190565b60008235609e198336030181126121db57600080fd5b60008235607e198336030181126121db57600080fd5b60006020828403121561273e57600080fd5b81356001600160801b0381168114611db057600080fd5b61275f8282612497565b604081013561276d81611c1e565b6001600160a01b03166040830152606090810135910152565b6000610100612795838b612755565b8060808401526127a8818401898b61204f565b6001600160801b0388811660a0860152871660c085015283810360e085015290506127d4818587611f48565b9a9950505050505050505050565b6127ec8185612755565b60a0608082015260006126d060a083018486611f4856fea26469706673582212204428162358c1f19ba742bd2aab88a0c54e9aa511a477715958a2e82ea62599ec64736f6c6343000813003300000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf0000000000000000000000003575aa02ae85d8cd2aae6dcaa5d8750cfc9622e6000000000000000000000000a77d2dde3847a92d57b847b59a270cdfe67f2823000000000000000000000000b01e431542bafbac3fc95057961c92ed8e06e08d00000000000000000000000060d3345c2d2fd62dbed55cf2178bdcff69d1769800000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063b3fb68d51161008c578063c45a015511610066578063c45a015514610201578063d996cef714610228578063def739531461024f578063ee360f241461026257600080fd5b8063b3fb68d5146101a0578063b53c86d2146101b3578063bc6b74ab146101da57600080fd5b806320822a27146100d45780632af3fa1b146100e95780633faa6e301461012c5780633fb53a0d14610153578063597457061461017a578063759cb2341461018d575b600080fd5b6100e76100e2366004611ce8565b610289565b005b6101107f00000000000000000000000060d3345c2d2fd62dbed55cf2178bdcff69d1769881565b6040516001600160a01b03909116815260200160405180910390f35b6101107f000000000000000000000000b01e431542bafbac3fc95057961c92ed8e06e08d81565b6101107f000000000000000000000000a77d2dde3847a92d57b847b59a270cdfe67f282381565b6100e7610188366004611d54565b6105f5565b61011061019b366004611d93565b610acb565b6101106101ae366004611db7565b610b89565b6101107f0000000000000000000000003575aa02ae85d8cd2aae6dcaa5d8750cfc9622e681565b6101107f00000000000000000000000085378fa1d0707897d948ba322b5eb43254e4d7c281565b6101107f00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf81565b6101107f0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a81565b6100e761025d366004611df8565b610c31565b6101107f00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d81565b600061029433610acb565b90506102a9816102a48580611e9b565b610fdf565b6102bf816102ba6020860186611e9b565b611264565b60408051600380825260808201909252600091602082016060803683375050604080516003808252608082019092529293506000929150602082015b60608152602001906001900390816102fb5790505090507f000000000000000000000000b01e431542bafbac3fc95057961c92ed8e06e08d8260008151811061034657610346611eec565b6001600160a01b039092166020928302919091019091015261036b6040860186611e9b565b60405160240161037c929190611f90565b60408051601f198184030181529190526020810180516001600160e01b03166357e72eb360e01b179052815182906000906103b9576103b9611eec565b60200260200101819052507f00000000000000000000000060d3345c2d2fd62dbed55cf2178bdcff69d17698826001815181106103f8576103f8611eec565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000085378fa1d0707897d948ba322b5eb43254e4d7c27fe400534da780c9d64ef8b5f03c074ff47537b6a4aa2a3e5d5455cb37b5406aa361045f6060880188611e9b565b6040516024016104729493929190612098565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b1790528151829060019081106104b1576104b1611eec565b60200260200101819052507f000000000000000000000000a77d2dde3847a92d57b847b59a270cdfe67f2823826002815181106104f0576104f0611eec565b60200260200101906001600160a01b031690816001600160a01b031681525050836040516024016105219190612110565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b17905281518290600290811061056057610560611eec565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038416906363fb0b96906105999085908590600401612123565b600060405180830381600087803b1580156105b357600080fd5b505af11580156105c7573d6000803e3d6000fd5b506105ee92508591506105dc90508780611e9b565b6105e960208a018a611e9b565b6114e5565b5050505050565b600061060033610acb565b9050610610816102a48580611e9b565b610621816102ba6020860186611e9b565b60408051600480825260a0820190925260009160208201608080368337505060408051600480825260a082019092529293506000929150602082015b606081526020019060019003908161065d5790505090507f00000000000000000000000060d3345c2d2fd62dbed55cf2178bdcff69d17698826000815181106106a8576106a8611eec565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000085378fa1d0707897d948ba322b5eb43254e4d7c27f1d5b8de553017a3bd388578aeece0183b79c5ca87ec64628b3f76b39487f023161070f6040880188611e9b565b6040516024016107229493929190612098565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b1790528151829060009061075f5761075f611eec565b60200260200101819052507f00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d8260018151811061079e5761079e611eec565b6001600160a01b03909216602092830291909101909101526107c360608601866121c5565b6040516024016107d39190612314565b60408051601f198184030181529190526020810180516001600160e01b031663cd5f81a960e01b17905281518290600190811061081257610812611eec565b602090810291909101015260006001600160a01b037f0000000000000000000000003575aa02ae85d8cd2aae6dcaa5d8750cfc9622e61663c79aeaae61085e60a0890160808a01611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156108a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c6919061241d565b905080836002815181106108dc576108dc611eec565b6001600160a01b03909216602092830291909101909101526080860161090560608801886121c5565b61091390602081019061243a565b610924906040810190602001611d93565b61093160c0890189612450565b60405160240161094494939291906124b8565b60408051601f198184030181529190526020810180516001600160e01b0316636ec4f1e960e11b17905282518390600290811061098357610983611eec565b60200260200101819052507f000000000000000000000000a77d2dde3847a92d57b847b59a270cdfe67f2823836003815181106109c2576109c2611eec565b60200260200101906001600160a01b031690816001600160a01b031681525050846040516024016109f39190612110565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b179052825183906003908110610a3257610a32611eec565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038516906363fb0b9690610a6b9086908690600401612123565b600060405180830381600087803b158015610a8557600080fd5b505af1158015610a99573d6000803e3d6000fd5b50610ac392508691505060808801610ab18980611e9b565b610abe60208c018c611e9b565b6116ce565b505050505050565b6040516312cfc9b560e31b81526001600160a01b03828116600483015260009182917f00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf169063967e4da890602401602060405180830381865afa158015610b36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5a919061241d565b90506001600160a01b038116610b8357604051633098a45560e01b815260040160405180910390fd5b92915050565b60405163de0d95ed60e01b81526001600160a01b0384811660048301528381166024830152604482018390526000917f00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf9091169063de0d95ed906064016020604051808303816000875af1158015610c05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c29919061241d565b949350505050565b6000610c3c33610acb565b9050610c4c816102a48680611e9b565b610c5d816102ba6020870187611e9b565b610c6f610140850161012086016124ea565b610c8e57610c8e8160808601610c89610100880188612450565b61188f565b60408051600380825260808201909252600091602082016060803683375050604080516003808252608082019092529293506000929150602082015b6060815260200190600190039081610cca5790505090507f00000000000000000000000060d3345c2d2fd62dbed55cf2178bdcff69d1769882600081518110610d1557610d15611eec565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000085378fa1d0707897d948ba322b5eb43254e4d7c27f1d5b8de553017a3bd388578aeece0183b79c5ca87ec64628b3f76b39487f0231610d7c6040890189611e9b565b604051602401610d8f9493929190612098565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b17905281518290600090610dcc57610dcc611eec565b60200260200101819052507f0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a82600181518110610e0b57610e0b611eec565b6001600160a01b0390921660209283029190910190910152610e3060608701876121c5565b604051602401610e40919061256e565b60408051601f198184030181529190526020810180516001600160e01b0316633d74119b60e21b179052815182906001908110610e7f57610e7f611eec565b60200260200101819052507f000000000000000000000000a77d2dde3847a92d57b847b59a270cdfe67f282382600281518110610ebe57610ebe611eec565b60200260200101906001600160a01b031690816001600160a01b0316815250508484604051602401610ef1929190612685565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b179052815182906002908110610f3057610f30611eec565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038416906363fb0b9690610f699085908590600401612123565b600060405180830381600087803b158015610f8357600080fd5b505af1158015610f97573d6000803e3d6000fd5b50610fae92505050610140870161012088016124ea565b610fcd57610fcd8360808801610fc86101008a018a612450565b611a84565b610ac38360808801610ab18980611e9b565b8060008167ffffffffffffffff811115610ffb57610ffb611c08565b604051908082528060200260200182016040528015611024578160200160208202803683370190505b50905060008267ffffffffffffffff81111561104257611042611c08565b60405190808252806020026020018201604052801561107557816020015b60608152602001906001900390816110605790505b50905060005b838110156111fb573686868381811061109657611096611eec565b90506020028101906110a89190612699565b905060006001600160a01b037f0000000000000000000000003575aa02ae85d8cd2aae6dcaa5d8750cfc9622e61663c79aeaae6110e86020850185611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561112c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611150919061241d565b90508085848151811061116557611165611eec565b6001600160a01b03909216602092830291909101909101528161118b6040820182612450565b60405160240161119d939291906126af565b60408051601f198184030181529190526020810180516001600160e01b0316638bddf18760e01b17905284518590859081106111db576111db611eec565b6020026020010181905250505080806111f3906126d9565b91505061107b565b506040516331fd85cb60e11b81526001600160a01b038716906363fb0b969061122a9085908590600401612123565b600060405180830381600087803b15801561124457600080fd5b505af1158015611258573d6000803e3d6000fd5b50505050505050505050565b8060008167ffffffffffffffff81111561128057611280611c08565b6040519080825280602002602001820160405280156112a9578160200160208202803683370190505b50905060008267ffffffffffffffff8111156112c7576112c7611c08565b6040519080825280602002602001820160405280156112fa57816020015b60608152602001906001900390816112e55790505b50905060005b838110156111fb573686868381811061131b5761131b611eec565b905060200281019061132d9190612700565b905060006001600160a01b037f0000000000000000000000003575aa02ae85d8cd2aae6dcaa5d8750cfc9622e61663c79aeaae61136d6020850185611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156113b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d5919061241d565b9050808584815181106113ea576113ea611eec565b6001600160a01b0390921660209283029190910190910152816114106080820182612716565b61141a9080611e9b565b6114276080860186612716565b61143890604081019060200161272c565b6114456080870187612716565b61145690606081019060400161272c565b6114636080880188612716565b611471906060810190612450565b6040516024016114879796959493929190612786565b60408051601f198184030181529190526020810180516001600160e01b0316636f4621e360e01b17905284518590859081106114c5576114c5611eec565b6020026020010181905250505080806114dd906126d9565b915050611300565b60005b8381101561159b5784848281811061150257611502611eec565b90506020028101906115149190612699565b6020013585858381811061152a5761152a611eec565b905060200281019061153c9190612699565b61154a906020810190611d93565b6001600160a01b0316876001600160a01b03167f37da49704c95bce31298d9d965163d5953283973279e35728e6666bd9abe1e7a60405160405180910390a480611593816126d9565b9150506114e8565b5060005b81811015610ac3578282828181106115b9576115b9611eec565b90506020028101906115cb9190612700565b606001358383838181106115e1576115e1611eec565b90506020028101906115f39190612700565b611604906060810190604001611d93565b6001600160a01b0316876001600160a01b03167fbf9d03ac543e8f596c6f4af5ab5e75f366a57d2d6c28d2ff9c024bd3f88e877186868681811061164a5761164a611eec565b905060200281019061165c9190612700565b61166a906020810190611d93565b87878781811061167c5761167c611eec565b905060200281019061168e9190612700565b6040516116b4929160200135906001600160a01b03929092168252602082015260400190565b60405180910390a4806116c6816126d9565b91505061159f565b60005b838110156117ab576116e66020870187611d93565b6001600160a01b031685858381811061170157611701611eec565b90506020028101906117139190612699565b611721906020810190611d93565b6001600160a01b0316886001600160a01b03167f052db0f97f7329c6cb05c89ccab89a2ad3acd05ac8d5678a6c1d46c309afbad188888681811061176757611767611eec565b90506020028101906117799190612699565b6040805160209283013581528c830135928101929092520160405180910390a4806117a3816126d9565b9150506116d1565b5060005b81811015611886578282828181106117c9576117c9611eec565b90506020028101906117db9190612700565b606001358383838181106117f1576117f1611eec565b90506020028101906118039190612700565b611814906060810190604001611d93565b6001600160a01b039081169089167f504180eddec0aa4ed3bb8edcf99b13013e1d8ae52be37f0f4f38d14ccf0c99a561185060208b018b611d93565b604080516001600160a01b0390921682526020808d0135908301520160405180910390a48061187e816126d9565b9150506117af565b50505050505050565b60006001600160a01b037f0000000000000000000000003575aa02ae85d8cd2aae6dcaa5d8750cfc9622e61663c79aeaae6118cd6020870187611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611911573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611935919061241d565b604080516001808252818301909252919250600091906020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081611973579050509050828260008151811061199e5761199e611eec565b60200260200101906001600160a01b031690816001600160a01b0316815250508585856040516024016119d3939291906127e2565b60408051601f198184030181529190526020810180516001600160e01b0316631423e67960e11b17905281518290600090611a1057611a10611eec565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038816906363fb0b9690611a499085908590600401612123565b600060405180830381600087803b158015611a6357600080fd5b505af1158015611a77573d6000803e3d6000fd5b5050505050505050505050565b60006001600160a01b037f0000000000000000000000003575aa02ae85d8cd2aae6dcaa5d8750cfc9622e61663c79aeaae611ac26020870187611d93565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611b06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2a919061241d565b604080516001808252818301909252919250600091906020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081611b685790505090508282600081518110611b9357611b93611eec565b60200260200101906001600160a01b031690816001600160a01b031681525050858585604051602401611bc8939291906127e2565b60408051601f198184030181529190526020810180516001600160e01b03166001624236cd60e11b031917905281518290600090611a1057611a10611eec565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611c3357600080fd5b50565b8035611c4181611c1e565b919050565b600082601f830112611c5757600080fd5b8135602067ffffffffffffffff80831115611c7457611c74611c08565b8260051b604051601f19603f83011681018181108482111715611c9957611c99611c08565b604052938452858101830193838101925087851115611cb757600080fd5b83870191505b84821015611cdd57611cce82611c36565b83529183019190830190611cbd565b979650505050505050565b60008060408385031215611cfb57600080fd5b823567ffffffffffffffff80821115611d1357600080fd5b9084019060808287031215611d2757600080fd5b90925060208401359080821115611d3d57600080fd5b50611d4a85828601611c46565b9150509250929050565b60008060408385031215611d6757600080fd5b823567ffffffffffffffff80821115611d7f57600080fd5b9084019060e08287031215611d2757600080fd5b600060208284031215611da557600080fd5b8135611db081611c1e565b9392505050565b600080600060608486031215611dcc57600080fd5b8335611dd781611c1e565b92506020840135611de781611c1e565b929592945050506040919091013590565b600080600060408486031215611e0d57600080fd5b833567ffffffffffffffff80821115611e2557600080fd5b908501906101408288031215611e3a57600080fd5b90935060208501359080821115611e5057600080fd5b818601915086601f830112611e6457600080fd5b813581811115611e7357600080fd5b8760208260051b8501011115611e8857600080fd5b6020830194508093505050509250925092565b6000808335601e19843603018112611eb257600080fd5b83018035915067ffffffffffffffff821115611ecd57600080fd5b6020019150600581901b3603821315611ee557600080fd5b9250929050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112611f1957600080fd5b830160208101925035905067ffffffffffffffff811115611f3957600080fd5b803603821315611ee557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008235609e19833603018112611f8757600080fd5b90910192915050565b60208082528181018390526000906040808401600586901b8501820187855b8881101561204157878303603f19018452611fca828b611f71565b60a08135611fd781611c1e565b6001600160a01b039081168652828901358987015287830135888701526060908184013561200481611c1e565b1690860152608061201783820184611f02565b9350828288015261202b8388018583611f48565b978a019796505050928701925050600101611faf565b509098975050505050505050565b8183526000602080850194508260005b8581101561208d57813561207281611c1e565b6001600160a01b03168752958201959082019060010161205f565b509495945050505050565b6001600160a01b03851681526001600160e01b0319841660208201526060604082018190526000906120cd908301848661204f565b9695505050505050565b600081518084526020808501945080840160005b8381101561208d5781516001600160a01b0316875295820195908201906001016120eb565b602081526000611db060208301846120d7565b60408152600061213660408301856120d7565b6020838203818501528185518084528284019150828160051b8501018388016000805b848110156121b557601f198089860301875283518051808752845b8181101561218f578281018b01518882018c01528a01612174565b508681018a0185905297890197601f019091169094018701935091860191600101612159565b50919a9950505050505050505050565b60008235603e198336030181126121db57600080fd5b9190910192915050565b6000808335601e198436030181126121fc57600080fd5b830160208101925035905067ffffffffffffffff81111561221c57600080fd5b8060051b3603821315611ee557600080fd5b818352600060208085019450848460051b86018460005b878110156122d557838303895261225c8288611f71565b60a0813561226981611c1e565b6001600160a01b0390811686528288013588870152604080840135908701526060908184013561229881611c1e565b169086015260806122ab83820184611f02565b935082828801526122bf8388018583611f48565b9c89019c96505050928601925050600101612245565b5090979650505050505050565b81835260006001600160fb1b038311156122fb57600080fd5b8260051b80836020870137939093016020019392505050565b60208152600061232483846121e5565b6040602085015261233960608501828461222e565b915050602084013560be1985360301811261235357600080fd5b838203601f190160408501528401803561236c81611c1e565b6001600160a01b03908116835260208201359061238882611c1e565b16602083015261239b60408201826121e5565b60c060408501526123b060c08501828461204f565b9150506123c060608301836121e5565b84830360608601526123d38382846122e2565b925050506123e460808301836121e5565b84830360808601526123f78382846122e2565b9250505061240860a0830183611f02565b925083820360a0850152611cdd828483611f48565b60006020828403121561242f57600080fd5b8151611db081611c1e565b6000823560be198336030181126121db57600080fd5b6000808335601e1984360301811261246757600080fd5b83018035915067ffffffffffffffff82111561248257600080fd5b602001915036819003821315611ee557600080fd5b80356124a281611c1e565b6001600160a01b03168252602090810135910152565b6124c28186612497565b6001600160a01b03841660408201526080606082018190526000906120cd9083018486611f48565b6000602082840312156124fc57600080fd5b81358015158114611db057600080fd5b803561251781611c1e565b6001600160a01b03908116835260208201359061253382611c1e565b166020830152604081013562ffffff811680821461255057600080fd5b80604085015250505050565b8035600281900b8114611c4157600080fd5b60208152600061257e83846121e5565b6040602085015261259360608501828461222e565b915050602084013561017e198536030181126125ae57600080fd5b838203601f1901604085015284016101806125d9836125cc84611c36565b6001600160a01b03169052565b602082013560208401526125f3604084016040840161250c565b6125ff60a0830161255c565b61260e60a085018260020b9052565b5061261b60c0830161255c565b61262a60c085018260020b9052565b5060e0828101359084015261010080830135908401526101208083013590840152610140808301359084015261016061266581840184611f02565b935082828601526126798386018583611f48565b98975050505050505050565b602081526000610c2960208301848661204f565b60008235605e198336030181126121db57600080fd5b6126b98185612497565b6060604082015260006126d0606083018486611f48565b95945050505050565b6000600182016126f957634e487b7160e01b600052601160045260246000fd5b5060010190565b60008235609e198336030181126121db57600080fd5b60008235607e198336030181126121db57600080fd5b60006020828403121561273e57600080fd5b81356001600160801b0381168114611db057600080fd5b61275f8282612497565b604081013561276d81611c1e565b6001600160a01b03166040830152606090810135910152565b6000610100612795838b612755565b8060808401526127a8818401898b61204f565b6001600160801b0388811660a0860152871660c085015283810360e085015290506127d4818587611f48565b9a9950505050505050505050565b6127ec8185612755565b60a0608082015260006126d060a083018486611f4856fea26469706673582212204428162358c1f19ba742bd2aab88a0c54e9aa511a477715958a2e82ea62599ec64736f6c63430008130033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf0000000000000000000000003575aa02ae85d8cd2aae6dcaa5d8750cfc9622e6000000000000000000000000a77d2dde3847a92d57b847b59a270cdfe67f2823000000000000000000000000b01e431542bafbac3fc95057961c92ed8e06e08d00000000000000000000000060d3345c2d2fd62dbed55cf2178bdcff69d1769800000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a

-----Decoded View---------------
Arg [0] : factory (address): 0x53d9780DbD3831E3A797Fd215be4131636cD5FDf
Arg [1] : connectorRegistry (address): 0x3575Aa02Ae85D8Cd2AaE6DCaA5D8750cFc9622e6
Arg [2] : libraries (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf
Arg [1] : 0000000000000000000000003575aa02ae85d8cd2aae6dcaa5d8750cfc9622e6
Arg [2] : 000000000000000000000000a77d2dde3847a92d57b847b59a270cdfe67f2823
Arg [3] : 000000000000000000000000b01e431542bafbac3fc95057961c92ed8e06e08d
Arg [4] : 00000000000000000000000060d3345c2d2fd62dbed55cf2178bdcff69d17698
Arg [5] : 00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d
Arg [6] : 0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a


Block Transaction Gas Used Reward
view all blocks produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.