Overview
ETH Balance
ETH Value
$0.00Multichain Info
Latest 25 from a total of 2,195 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Increase | 11191235 | 51 days ago | IN | 0 ETH | 0.00000198 | ||||
| Rebalance | 11191142 | 51 days ago | IN | 0 ETH | 0.00000322 | ||||
| Increase | 11190580 | 51 days ago | IN | 0 ETH | 0.00000179 | ||||
| Rebalance | 11190518 | 51 days ago | IN | 0 ETH | 0.00000291 | ||||
| Increase | 11189199 | 51 days ago | IN | 0 ETH | 0.00000185 | ||||
| Move | 11188956 | 51 days ago | IN | 0 ETH | 0.00000279 | ||||
| Move | 11183748 | 51 days ago | IN | 0 ETH | 0.00000265 | ||||
| Move | 11182636 | 51 days ago | IN | 0 ETH | 0.00000302 | ||||
| Move | 11182418 | 51 days ago | IN | 0 ETH | 0.00000297 | ||||
| Increase | 11181487 | 51 days ago | IN | 0 ETH | 0.00000197 | ||||
| Increase | 11181464 | 51 days ago | IN | 0 ETH | 0.00000214 | ||||
| Deposit | 11181027 | 51 days ago | IN | 0.20569162 ETH | 0.00000247 | ||||
| Increase | 11174926 | 51 days ago | IN | 0 ETH | 0.00000181 | ||||
| Simple Harvest | 11166585 | 51 days ago | IN | 0 ETH | 0.00000208 | ||||
| Simple Harvest | 11166360 | 51 days ago | IN | 0 ETH | 0.00000135 | ||||
| Deposit | 11164469 | 51 days ago | IN | 0 ETH | 0.00000247 | ||||
| Increase | 11163882 | 51 days ago | IN | 0 ETH | 0.00000198 | ||||
| Increase | 11163849 | 51 days ago | IN | 0 ETH | 0.00000202 | ||||
| Exit | 11163712 | 51 days ago | IN | 0 ETH | 0.00000193 | ||||
| Move | 11162753 | 51 days ago | IN | 0 ETH | 0.00000299 | ||||
| Deposit | 11160155 | 51 days ago | IN | 0.00005577 ETH | 0.00000241 | ||||
| Increase | 11146121 | 51 days ago | IN | 0 ETH | 0.00000205 | ||||
| Move | 11145135 | 51 days ago | IN | 0 ETH | 0.00000285 | ||||
| Move | 11145074 | 51 days ago | IN | 0 ETH | 0.00000332 | ||||
| Move | 11145017 | 51 days ago | IN | 0 ETH | 0.00000418 |
Latest 25 internal transactions (View All)
| Parent Transaction Hash | Block | From | To | ||||
|---|---|---|---|---|---|---|---|
| 11191235 | 51 days ago | 0 ETH | |||||
| 11191235 | 51 days ago | 0 ETH | |||||
| 11191235 | 51 days ago | 0 ETH | |||||
| 11191235 | 51 days ago | 0 ETH | |||||
| 11191235 | 51 days ago | 0 ETH | |||||
| 11191235 | 51 days ago | 0 ETH | |||||
| 11191235 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11191142 | 51 days ago | 0 ETH | |||||
| 11190580 | 51 days ago | 0 ETH | |||||
| 11190580 | 51 days ago | 0 ETH |
Cross-Chain Transactions
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { IERC721Enumerable } from
"lib/openzeppelin-contracts/contracts/interfaces/IERC721Enumerable.sol";
import { INonfungiblePositionManager } from
"contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";
import {
IUniswapV3Pool,
IUniswapV3PoolImmutables
} from "contracts/interfaces/external/uniswap/IUniswapV3Pool.sol";
import {
StrategyModule,
SickleFactory,
Sickle
} from "contracts/modules/StrategyModule.sol";
import { ConnectorRegistry } from "contracts/ConnectorRegistry.sol";
import { INftFarmConnector } from "contracts/interfaces/INftFarmConnector.sol";
import { INftLiquidityConnector } from
"contracts/interfaces/INftLiquidityConnector.sol";
import {
INftSettingsRegistry,
NftKey
} from "contracts/interfaces/INftSettingsRegistry.sol";
import { INftTransferLib } from
"contracts/interfaces/libraries/INftTransferLib.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 { INftZapLib } from "contracts/interfaces/libraries/INftZapLib.sol";
import { INftSettingsLib } from
"contracts/interfaces/libraries/INftSettingsLib.sol";
import { NftFarmStrategyEvents } from
"contracts/events/NftFarmStrategyEvents.sol";
import { INftAutomation } from "contracts/interfaces/INftAutomation.sol";
import { NftZapIn } from "contracts/structs/NftZapStructs.sol";
import { Farm } from "contracts/structs/FarmStrategyStructs.sol";
import {
NftPosition,
NftDeposit,
NftIncrease,
NftWithdraw,
NftHarvest,
NftCompound,
NftRebalance,
NftMove,
SimpleNftHarvest
} from "contracts/structs/NftFarmStrategyStructs.sol";
import { NftSettings } from "contracts/structs/NftSettingsStructs.sol";
library NftFarmStrategyFees {
bytes4 constant Deposit = bytes4(keccak256("FarmDepositFee"));
bytes4 constant Harvest = bytes4(keccak256("FarmHarvestFee"));
bytes4 constant Compound = bytes4(keccak256("FarmCompoundFee"));
bytes4 constant Withdraw = bytes4(keccak256("FarmWithdrawFee"));
bytes4 constant HarvestFor = bytes4(keccak256("FarmHarvestForFee"));
bytes4 constant CompoundFor = bytes4(keccak256("FarmCompoundForFee"));
bytes4 constant RebalanceLow = bytes4(keccak256("RebalanceLowFee"));
bytes4 constant RebalanceMid = bytes4(keccak256("RebalanceMidFee"));
bytes4 constant RebalanceHigh = bytes4(keccak256("RebalanceHighFee"));
}
contract NftFarmStrategy is
StrategyModule,
NftFarmStrategyEvents,
INftAutomation
{
uint256 constant REBALANCE_LOW_FEE_BPS = 500; // 0.05%
uint256 constant REBALANCE_MID_FEE_BPS = 3000; // 0.3%
error PleaseUseIncrease();
error PleaseUseDeposit();
error NftSupplyChanged();
error NftSupplyDidntIncrease();
struct Libraries {
INftTransferLib nftTransferLib;
ITransferLib transferLib;
ISwapLib swapLib;
IFeesLib feesLib;
INftZapLib nftZapLib;
INftSettingsLib nftSettingsLib;
}
INftTransferLib public immutable nftTransferLib;
INftZapLib public immutable nftZapLib;
ISwapLib public immutable swapLib;
ITransferLib public immutable transferLib;
IFeesLib public immutable feesLib;
INftSettingsLib public immutable nftSettingsLib;
INftSettingsRegistry public immutable nftSettingsRegistry;
address public immutable strategyAddress;
constructor(
SickleFactory factory,
ConnectorRegistry connectorRegistry,
INftSettingsRegistry nftSettingsRegistry_,
Libraries memory libraries
) StrategyModule(factory, connectorRegistry) {
nftTransferLib = libraries.nftTransferLib;
nftZapLib = libraries.nftZapLib;
swapLib = libraries.swapLib;
transferLib = libraries.transferLib;
feesLib = libraries.feesLib;
nftSettingsLib = libraries.nftSettingsLib;
nftSettingsRegistry = nftSettingsRegistry_;
strategyAddress = address(this);
}
/**
* @notice Deposits tokens into the farm, creating a new NFT position.
* @param params The parameters for the deposit.
* @param settings The automation settings to be applied to the NFT.
* @param sweepTokens The tokens to be swept at the end of the deposit.
* @param approved The address approved to manage automation (used when
* deploying a new Sickle only).
* @param referralCode The referral code for tracking purposes (used when
* deploying a new Sickle only).
*/
function deposit(
NftDeposit calldata params,
NftSettings calldata settings,
address[] calldata sweepTokens,
address approved,
bytes32 referralCode
) external payable {
if (params.increase.zap.addLiquidityParams.tokenId != 0) {
revert PleaseUseIncrease();
}
INftLiquidityConnector liquidityConnector = INftLiquidityConnector(
connectorRegistry.connectorOf(address(params.nft))
);
uint256 initialSupply =
liquidityConnector.totalSupply(address(params.nft));
Sickle sickle = getOrDeploySickle(msg.sender, approved, referralCode);
_transferInTokens(sickle, params.increase);
_zapIn(sickle, params.increase.zap);
uint256 tokenId =
liquidityConnector.getTokenId(address(params.nft), address(sickle));
_depositNft(
sickle,
NftPosition({ farm: params.farm, nft: params.nft, tokenId: tokenId }),
params.increase.extraData
);
_setNftSettings(sickle, params.nft, tokenId, settings);
_sweep(sickle, sweepTokens);
if (
initialSupply >= liquidityConnector.totalSupply(address(params.nft))
) {
revert NftSupplyDidntIncrease();
}
}
/**
* @notice Withdraws from the NFT farm and breaks the NFT position.
* @param position The position details of the NFT to be withdrawn.
* @param params The parameters for the withdrawal.
* @param sweepTokens The tokens to be swept at the end of the withdrawal.
*/
function withdraw(
NftPosition calldata position,
NftWithdraw calldata params,
address[] calldata sweepTokens
) external {
Sickle sickle = getSickle(msg.sender);
bytes4 fee = params.zap.swaps.length > 0
? NftFarmStrategyFees.Withdraw
: bytes4(0);
_withdraw(sickle, position, params, fee);
_sweep(sickle, sweepTokens);
}
/**
* @notice Harvests rewards from the NFT farm.
* @param position The position details of the NFT to be harvested.
* @param params The parameters for the harvest.
*/
function harvest(
NftPosition calldata position,
NftHarvest calldata params
) external {
Sickle sickle = getSickle(msg.sender);
_harvest(sickle, position, params, NftFarmStrategyFees.Harvest);
}
/**
* @notice Compounds the NFT farm.
* @param position The position details of the NFT to be compounded.
* @param params The parameters for the compound.
* @param inPlace Whether to compound in place (without withdrawing).
* @param sweepTokens The tokens to be swept at the end of the compound.
*/
function compound(
NftPosition calldata position,
NftCompound calldata params,
bool inPlace, // Compound without withdrawing
address[] calldata sweepTokens
) external nftSupplyUnchanged(position.nft) {
Sickle sickle = getSickle(msg.sender);
_compound(
sickle,
position,
params,
inPlace,
sweepTokens,
NftFarmStrategyFees.Compound
);
}
/**
* @notice Exits an NFT from the NFT farm (harvests and withdraws).
* @param position The position details of the NFT to be exited.
* @param harvestParams The parameters for the harvest.
* @param withdrawParams The parameters for the withdrawal.
* @param sweepTokens The tokens to be swept at the end of the exit.
*/
function exit(
NftPosition calldata position,
NftHarvest calldata harvestParams,
NftWithdraw calldata withdrawParams,
address[] calldata sweepTokens
) external {
Sickle sickle = getSickle(msg.sender);
_exit(sickle, position, harvestParams, withdrawParams, sweepTokens);
}
/**
* @notice Rebalances the NFT position.
* @param params The parameters for the rebalance.
* @param sweepTokens The tokens to be swept at the end of the rebalance.
*/
function rebalance(
NftRebalance calldata params,
address[] calldata sweepTokens
) external {
Sickle sickle = getSickle(msg.sender);
_rebalance(sickle, params, sweepTokens, NftFarmStrategyFees.Harvest);
}
/**
* @notice Withdraws from the current farm and deposits into a new farm.
* @param params The parameters for the move.
* @param settings The automation settings to be applied to the new NFT.
* @param sweepTokens The tokens to be swept at the end of the move.
*/
function move(
NftMove calldata params,
NftSettings calldata settings,
address[] calldata sweepTokens
) external {
Sickle sickle = getSickle(msg.sender);
_harvest(
sickle, params.position, params.harvest, NftFarmStrategyFees.Harvest
);
_withdraw(
sickle,
params.position,
params.withdraw,
_getRebalanceFee(
params.position.nft, params.pool, params.position.tokenId
)
);
_zapIn(sickle, params.deposit.increase.zap);
uint256 tokenId = INftLiquidityConnector(
connectorRegistry.connectorOf(address(params.position.nft))
).getTokenId(address(params.position.nft), address(sickle));
_depositNft(
sickle,
NftPosition({
farm: params.deposit.farm,
nft: params.deposit.nft,
tokenId: tokenId
}),
params.deposit.increase.extraData
);
_setNftSettings(sickle, params.deposit.nft, tokenId, settings);
_sweep(sickle, sweepTokens);
_emitMoveEvent(
sickle,
params.position,
params.deposit.nft,
params.deposit.farm,
tokenId
);
}
// Required due to stack too deep error
function _emitMoveEvent(
Sickle sickle,
NftPosition calldata positionFrom,
INonfungiblePositionManager nftTo,
Farm calldata farmTo,
uint256 tokenId
) internal {
emit SickleMovedNft(
sickle,
positionFrom.nft,
positionFrom.tokenId,
positionFrom.farm.stakingContract,
positionFrom.farm.poolIndex,
nftTo,
tokenId,
farmTo.stakingContract,
farmTo.poolIndex
);
}
/**
* @notice Increases the NFT position.
* @param position The position details of the NFT to be increased.
* @param harvestParams The parameters for the harvest.
* @param increaseParams The parameters for the increase.
* @param inPlace Whether to increase in place (without withdrawing).
* @param sweepTokens The tokens to be swept at the end of the increase.
*/
function increase(
NftPosition calldata position,
NftHarvest calldata harvestParams,
NftIncrease calldata increaseParams,
bool inPlace, // Increase without withdrawing
address[] calldata sweepTokens
) external payable nftSupplyUnchanged(position.nft) {
if (increaseParams.zap.addLiquidityParams.tokenId == 0) {
revert PleaseUseDeposit();
}
Sickle sickle = getSickle(msg.sender);
if (!inPlace) {
_harvest(
sickle, position, harvestParams, NftFarmStrategyFees.Harvest
);
_withdrawNft(sickle, position, increaseParams.extraData);
}
_transferInTokens(sickle, increaseParams);
_zapIn(sickle, increaseParams.zap);
if (!inPlace) {
_depositNft(sickle, position, increaseParams.extraData);
}
_sweep(sickle, sweepTokens);
emit SickleIncreasedNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
/**
* @notice Decreases the NFT position.
* @param position The position details of the NFT to be decreased.
* @param harvestParams The parameters for the harvest.
* @param withdrawParams The parameters for the withdrawal.
* @param inPlace Whether to decrease in place (without withdrawing).
* @param sweepTokens The tokens to be swept at the end of the decrease.
*/
function decrease(
NftPosition calldata position,
NftHarvest calldata harvestParams,
NftWithdraw calldata withdrawParams,
bool inPlace,
address[] calldata sweepTokens
) external nftSupplyUnchanged(position.nft) {
Sickle sickle = getSickle(msg.sender);
if (!inPlace) {
_harvest(
sickle, position, harvestParams, NftFarmStrategyFees.Harvest
);
_withdrawNft(sickle, position, withdrawParams.extraData);
}
bytes4 fee = withdrawParams.zap.swaps.length > 0
? NftFarmStrategyFees.Withdraw
: bytes4(0);
_zapOut(sickle, withdrawParams, fee);
if (!inPlace) {
_depositNft(sickle, position, withdrawParams.extraData);
}
_sweep(sickle, sweepTokens);
_emitDecreaseEvent(sickle, position);
}
function _emitDecreaseEvent(
Sickle sickle,
NftPosition calldata position
) internal {
emit SickleDecreasedNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
/* Simple actions (non-swap) */
/**
* @notice Deposits an NFT into the farm strategy.
* @param position The position details of the NFT to be deposited.
* @param extraData Additional data required for the deposit (optional).
* @param settings The automation settings to be applied to the NFT.
* @param approved The address approved to manage automation (used when
* deploying a new Sickle only).
* @param referralCode The referral code for tracking purposes (used when
* deploying a new Sickle only).
*/
function simpleDeposit(
NftPosition calldata position,
bytes calldata extraData,
NftSettings calldata settings,
address approved,
bytes32 referralCode
) public {
Sickle sickle = getOrDeploySickle(msg.sender, approved, referralCode);
_transferInNft(sickle, position.nft, position.tokenId);
_depositNft(sickle, position, extraData);
_setNftSettings(sickle, position.nft, position.tokenId, settings);
}
/**
* @notice Harvests rewards from the NFT farm without swapping.
* @param position The position details of the NFT to be harvested.
* @param params The parameters for the harvest.
*/
function simpleHarvest(
NftPosition calldata position,
SimpleNftHarvest calldata params
) external {
Sickle sickle = getSickle(msg.sender);
_simpleHarvest(sickle, position, params);
}
/**
* @notice Withdraws an NFT from the NFT farm.
* @param position The position details of the NFT to be withdrawn.
* @param extraData Additional data required for the withdrawal (optional).
*/
function simpleWithdraw(
NftPosition calldata position,
bytes calldata extraData
) public {
Sickle sickle = getSickle(msg.sender);
_withdrawNft(sickle, position, extraData);
_transferOutNft(sickle, position.nft, position.tokenId);
emit SickleWithdrewNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
/**
* @notice Exits an NFT from the NFT farm without swapping.
* @param position The position details of the NFT to be exited.
* @param harvestParams The parameters for the harvest.
* @param withdrawExtraData Additional data required for the withdrawal
* (optional).
*/
function simpleExit(
NftPosition calldata position,
SimpleNftHarvest calldata harvestParams,
bytes calldata withdrawExtraData
) public {
Sickle sickle = getSickle(msg.sender);
_simpleHarvest(sickle, position, harvestParams);
_withdrawNft(sickle, position, withdrawExtraData);
_transferOutNft(sickle, position.nft, position.tokenId);
emit SickleExitedNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
/* Automation */
/**
* @notice Harvests rewards from the NFT farm.
* Can only be called by the approved address on the Sickle.
* @param position The position details of the NFT to be harvested.
* @param params The parameters for the harvest.
*/
function harvestFor(
Sickle sickle,
NftPosition calldata position,
NftHarvest calldata params
) external override onlyApproved(sickle) {
nftSettingsRegistry.validateHarvestFor(
NftKey({
sickle: sickle,
nftManager: position.nft,
tokenId: position.tokenId
})
);
_harvest(sickle, position, params, NftFarmStrategyFees.HarvestFor);
}
/**
* @notice Compounds the NFT farm.
* Can only be called by the approved address on the Sickle.
* @param position The position details of the NFT to be compounded.
* @param params The parameters for the compound.
* @param inPlace Whether to compound in place.
* @param sweepTokens The tokens to be swept.
*/
function compoundFor(
Sickle sickle,
NftPosition calldata position,
NftCompound calldata params,
bool inPlace,
address[] calldata sweepTokens
) external override onlyApproved(sickle) {
nftSettingsRegistry.validateCompoundFor(
NftKey({
sickle: sickle,
nftManager: position.nft,
tokenId: position.tokenId
})
);
_compound(
sickle,
position,
params,
inPlace,
sweepTokens,
NftFarmStrategyFees.CompoundFor
);
}
/**
* @notice Exits an NFT from the NFT farm.
* Can only be called by the approved address on the Sickle.
* @param position The position details of the NFT to be exited.
* @param harvestParams The parameters for the harvest.
* @param withdrawParams The parameters for the withdrawal.
* @param sweepTokens The tokens to be swept.
*/
function exitFor(
Sickle sickle,
NftPosition calldata position,
NftHarvest calldata harvestParams,
NftWithdraw calldata withdrawParams,
address[] calldata sweepTokens
) external override onlyApproved(sickle) {
nftSettingsRegistry.validateExitFor(
NftKey({
sickle: sickle,
nftManager: position.nft,
tokenId: position.tokenId
})
);
_exit(sickle, position, harvestParams, withdrawParams, sweepTokens);
}
/**
* @notice Rebalances the NFT farm.
* Can only be called by the approved address on the Sickle.
* @param params The parameters for the rebalance.
* @param sweepTokens The tokens to be swept.
*/
function rebalanceFor(
Sickle sickle,
NftRebalance calldata params,
address[] calldata sweepTokens
) external override onlyApproved(sickle) {
nftSettingsRegistry.validateRebalanceFor(
NftKey({
sickle: sickle,
nftManager: params.position.nft,
tokenId: params.position.tokenId
})
);
_rebalance(sickle, params, sweepTokens, NftFarmStrategyFees.HarvestFor);
}
/* Modifiers */
modifier nftSupplyUnchanged(
INonfungiblePositionManager nft
) {
INftLiquidityConnector liquidityConnector =
INftLiquidityConnector(connectorRegistry.connectorOf(address(nft)));
uint256 initialSupply = liquidityConnector.totalSupply(address(nft));
_;
if (initialSupply != liquidityConnector.totalSupply(address(nft))) {
revert NftSupplyChanged();
}
}
/* Private */
function _withdraw(
Sickle sickle,
NftPosition calldata position,
NftWithdraw calldata params,
bytes4 withdrawalFee
) internal {
_withdrawNft(sickle, position, params.extraData);
_zapOut(sickle, params, withdrawalFee);
}
function _harvest(
Sickle sickle,
NftPosition calldata position,
NftHarvest calldata params,
bytes4 fee
) private {
if (params.swaps.length > 0) {
_claimAndSwap(sickle, position, params);
} else {
_claim(sickle, position, params.harvest, fee);
}
if (params.sweepTokens.length > 0) {
_sweep(sickle, params.sweepTokens);
}
emit SickleHarvestedNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
function _simpleHarvest(
Sickle sickle,
NftPosition calldata position,
SimpleNftHarvest calldata params
) private {
_claim(sickle, position, params, NftFarmStrategyFees.Harvest);
_sweep(sickle, params.rewardTokens);
emit SickleHarvestedNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
function _compound(
Sickle sickle,
NftPosition calldata position,
NftCompound calldata params,
bool inPlace,
address[] calldata sweepTokens,
bytes4 fee
) private {
_claim(sickle, position, params.harvest, fee);
if (!inPlace) {
_withdrawNft(sickle, position, params.harvest.extraData);
}
_zapIn(sickle, params.zap);
if (!inPlace) {
_depositNft(sickle, position, params.harvest.extraData);
}
_sweep(sickle, sweepTokens);
emit SickleCompoundedNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
function _exit(
Sickle sickle,
NftPosition calldata position,
NftHarvest calldata harvestParams,
NftWithdraw calldata withdrawParams,
address[] calldata sweepTokens
) private {
_harvest(sickle, position, harvestParams, NftFarmStrategyFees.Harvest);
_withdraw(
sickle, position, withdrawParams, NftFarmStrategyFees.Withdraw
);
_sweep(sickle, sweepTokens);
emit SickleExitedNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
function _rebalance(
Sickle sickle,
NftRebalance calldata params,
address[] calldata sweepTokens,
bytes4 harvestFee
) private {
_harvest(sickle, params.position, params.harvest, harvestFee);
_withdraw(
sickle,
params.position,
params.withdraw,
_getRebalanceFee(
params.position.nft, params.pool, params.position.tokenId
)
);
_zapIn(sickle, params.increase.zap);
_resetNftSettings(sickle, params.position.nft, params.position.tokenId);
uint256 tokenId = INftLiquidityConnector(
connectorRegistry.connectorOf(address(params.position.nft))
).getTokenId(address(params.position.nft), address(sickle));
_depositNft(
sickle,
NftPosition({
farm: params.position.farm,
nft: params.position.nft,
tokenId: tokenId
}),
params.increase.extraData
);
_sweep(sickle, sweepTokens);
emit SickleRebalancedNft(
sickle,
params.position.nft,
params.position.tokenId,
params.position.farm.stakingContract,
params.position.farm.poolIndex
);
}
/* Building blocks */
function _transferInTokens(
Sickle sickle,
NftIncrease calldata params
) private {
bytes4 fee = params.zap.swaps.length > 0
? NftFarmStrategyFees.Deposit
: bytes4(0);
address[] memory targets = new address[](1);
bytes[] memory data = new bytes[](1);
targets[0] = address(transferLib);
data[0] = abi.encodeCall(
ITransferLib.transferTokensFromUser,
(params.tokensIn, params.amountsIn, strategyAddress, fee)
);
sickle.multicall{ value: msg.value }(targets, data);
}
function _transferInNft(
Sickle sickle,
INonfungiblePositionManager nft,
uint256 tokenId
) private {
address[] memory targets = new address[](1);
bytes[] memory data = new bytes[](1);
targets[0] = address(nftTransferLib);
data[0] = abi.encodeCall(
INftTransferLib.transferErc721FromUser, (nft, tokenId)
);
sickle.multicall(targets, data);
}
function _transferOutNft(
Sickle sickle,
INonfungiblePositionManager nft,
uint256 tokenId
) private {
address[] memory targets = new address[](1);
bytes[] memory data = new bytes[](1);
targets[0] = address(nftTransferLib);
data[0] =
abi.encodeCall(INftTransferLib.transferErc721ToUser, (nft, tokenId));
sickle.multicall(targets, data);
}
function _depositNft(
Sickle sickle,
NftPosition memory 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);
emit SickleDepositedNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
function _withdrawNft(
Sickle sickle,
NftPosition calldata position,
bytes calldata extraData
) private {
address[] memory targets = new address[](1);
bytes[] memory data = new bytes[](1);
address farmConnector =
connectorRegistry.connectorOf(position.farm.stakingContract);
targets[0] = farmConnector;
data[0] =
abi.encodeCall(INftFarmConnector.withdrawNft, (position, extraData));
sickle.multicall(targets, data);
emit SickleWithdrewNft(
sickle,
position.nft,
position.tokenId,
position.farm.stakingContract,
position.farm.poolIndex
);
}
// Claim, swap then charge fees on the output
function _claimAndSwap(
Sickle sickle,
NftPosition calldata position,
NftHarvest calldata params
) private {
address farmConnector =
connectorRegistry.connectorOf(position.farm.stakingContract);
address[] memory targets = new address[](3);
bytes[] memory data = new bytes[](3);
targets[0] = farmConnector;
data[0] = abi.encodeCall(
INftFarmConnector.claim,
(
position,
params.harvest.rewardTokens,
params.harvest.amount0Max,
params.harvest.amount1Max,
params.harvest.extraData
)
);
targets[1] = address(swapLib);
data[1] = abi.encodeCall(ISwapLib.swapMultiple, (params.swaps));
targets[2] = address(feesLib);
data[2] = abi.encodeCall(
IFeesLib.chargeFees,
(strategyAddress, NftFarmStrategyFees.Harvest, params.outputTokens)
);
sickle.multicall(targets, data);
}
// Claim then charge fees on the reward tokens
function _claim(
Sickle sickle,
NftPosition calldata position,
SimpleNftHarvest calldata params,
bytes4 fee
) private {
address farmConnector =
connectorRegistry.connectorOf(position.farm.stakingContract);
address[] memory targets = new address[](2);
bytes[] memory data = new bytes[](2);
targets[0] = farmConnector;
data[0] = abi.encodeCall(
INftFarmConnector.claim,
(
position,
params.rewardTokens,
params.amount0Max,
params.amount1Max,
params.extraData
)
);
targets[1] = address(feesLib);
data[1] = abi.encodeCall(
IFeesLib.chargeFees, (strategyAddress, fee, params.rewardTokens)
);
sickle.multicall(targets, data);
}
function _zapIn(Sickle sickle, NftZapIn calldata zap) private {
address[] memory targets = new address[](1);
bytes[] memory data = new bytes[](1);
targets[0] = address(nftZapLib);
data[0] = abi.encodeCall(INftZapLib.zapIn, (zap));
sickle.multicall(targets, data);
}
function _zapOut(
Sickle sickle,
NftWithdraw calldata params,
bytes4 withdrawalFee
) private {
address[] memory targets = new address[](2);
bytes[] memory data = new bytes[](2);
targets[0] = address(nftZapLib);
data[0] = abi.encodeCall(INftZapLib.zapOut, (params.zap));
targets[1] = address(feesLib);
data[1] = abi.encodeCall(
IFeesLib.chargeFees,
(strategyAddress, withdrawalFee, params.tokensOut)
);
sickle.multicall(targets, data);
}
function _setNftSettings(
Sickle sickle,
INonfungiblePositionManager nft,
uint256 tokenId,
NftSettings calldata settings
) private {
address[] memory targets = new address[](1);
bytes[] memory data = new bytes[](1);
targets[0] = address(nftSettingsLib);
data[0] = abi.encodeCall(
INftSettingsLib.setNftSettings,
(nftSettingsRegistry, nft, tokenId, settings)
);
sickle.multicall(targets, data);
}
function _resetNftSettings(
Sickle sickle,
INonfungiblePositionManager nft,
uint256 tokenId
) private {
address[] memory targets = new address[](1);
bytes[] memory data = new bytes[](1);
targets[0] = address(nftSettingsLib);
data[0] = abi.encodeCall(
INftSettingsLib.transferNftSettings,
(nftSettingsRegistry, nft, tokenId)
);
sickle.multicall(targets, data);
}
function _sweep(Sickle sickle, address[] calldata sweepTokens) private {
address[] memory targets = new address[](1);
bytes[] memory data = new bytes[](1);
targets[0] = address(transferLib);
data[0] =
abi.encodeCall(ITransferLib.transferTokensToUser, (sweepTokens));
sickle.multicall(targets, data);
}
function _getRebalanceFee(
INonfungiblePositionManager nft,
IUniswapV3Pool pool,
uint256 tokenId
) internal view returns (bytes4) {
INftLiquidityConnector liquidityConnector =
INftLiquidityConnector(connectorRegistry.connectorOf(address(nft)));
uint24 fee = liquidityConnector.fee(address(pool), tokenId);
if (fee <= REBALANCE_LOW_FEE_BPS) {
return NftFarmStrategyFees.RebalanceLow;
} else if (fee <= REBALANCE_MID_FEE_BPS) {
return NftFarmStrategyFees.RebalanceMid;
} else {
return NftFarmStrategyFees.RebalanceHigh;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { Sickle } from "contracts/Sickle.sol";
struct PositionKey {
Sickle sickle;
address stakingContract;
uint256 poolIndex;
}
enum RewardBehavior {
None,
Harvest,
Compound
}
struct RewardConfig {
RewardBehavior rewardBehavior;
address harvestTokenOut;
}
struct ExitConfig {
uint256 baseTokenIndex;
uint256 quoteTokenIndex;
uint256 triggerPriceLow;
address exitTokenOutLow;
uint256 triggerPriceHigh;
address exitTokenOutHigh;
uint256[] triggerReservesLow;
address[] triggerReservesTokensOut;
uint256 priceImpactBP;
uint256 slippageBP;
}
/**
* Settings for automating an ERC20 position
* @param pool: Uniswap or Aerodrome vAMM/sAMM pair for the position (requires
* ILiquidityConnector connector registered)
* @param router: Router for the pair (requires connector registration)
* @param automateRewards: Whether to automatically harvest or compound rewards
* for this position, regardless of rebalance settings.
* @param rewardConfig: Configuration for reward automation
* Harvest as-is, harvest and convert to a different token, or compound into the
* position.
* @param autoExit: Whether to automatically exit the position when it goes out
* of
* range
* @param exitConfig: Configuration for the above
*/
struct PositionSettings {
address pool;
address router;
bool automateRewards;
RewardConfig rewardConfig;
bool autoExit;
ExitConfig exitConfig;
bytes extraData;
}// 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 {
/// CONSTANTS ///
uint256 constant MAX_FEE = 500; // 5%
/// 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] <= MAX_FEE) {
feeRegistry[feeHashes[i]] = feesArray[i];
} else {
revert FeeAboveMaxLimit();
}
unchecked {
++i;
}
}
emit SickleRegistryEvents.FeesUpdated(feeHashes, feesArray);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { INonfungiblePositionManager } from
"contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";
import { IUniswapV3Pool } from
"contracts/interfaces/external/uniswap/IUniswapV3Pool.sol";
import { Sickle } from "contracts/Sickle.sol";
import {
RewardConfig,
RewardBehavior
} from "contracts/structs/PositionSettingsStructs.sol";
struct NftKey {
Sickle sickle;
INonfungiblePositionManager nftManager;
uint256 tokenId;
}
struct ExitConfig {
int24 triggerTickLow;
int24 triggerTickHigh;
address exitTokenOutLow;
address exitTokenOutHigh;
uint256 priceImpactBP;
uint256 slippageBP;
}
/**
* @notice Settings for automatic rebalancing
* @param tickSpacesBelow: Position width measured in tick spaces below
* Default: 0 (Position doesn't include any tick spaces below current)
* @param tickSpacesAbove: Position width measured in tick spaces above
* Default: 0 (Position doesn't include any tick spaces above current)
* @param bufferTicksBelow: Difference from position tickLower to
* rebalance below. Can be negative (rebalance before position goes under
* range)
* Default: 0 (always rebalance if tick < tickLower)
* @param bufferTicksAbove: Difference from position tickUpper to
* rebalance above. Can be negative (rebalance before position goes above range)
* Default: 0 (always rebalance if tick >= tickUpper)
* @param dustBP: Dust allowance in basis points
* @param priceImpactBP: Price impact allowance in basis points
* @param slippageBP: Slippage allowance in basis points
* @param cutoffTickLow: Stop rebalancing below this tick
* default: MIN_TICK (no stop loss)
* @param cutoffTickHigh: Stop rebalancing above this tick
* default: MAX_TICK (no stop loss)
* @param delayMin: Delay in minutes before rebalancing
* @param rewardConfig: Configuration for handling rewards when rebalancing
*/
struct RebalanceConfig {
uint24 tickSpacesBelow;
uint24 tickSpacesAbove;
int24 bufferTicksBelow;
int24 bufferTicksAbove;
uint256 dustBP;
uint256 priceImpactBP;
uint256 slippageBP;
int24 cutoffTickLow;
int24 cutoffTickHigh;
uint8 delayMin;
RewardConfig rewardConfig;
}
/**
* Settings for automating an NFT position
* @param autoRebalance: Whether to rebalance automatically when position goes
* out of range
* @param rebalanceConfig: Configuration for the above
* @param automateRewards: Whether to automatically harvest or compound rewards
* for this position, regardless of rebalance settings.
* @param rewardConfig: Configuration for reward automation
* Harvest as-is, harvest and convert to a different token, or compound into the
* position.
*/
struct NftSettings {
IUniswapV3Pool pool;
bytes32 poolId;
bool autoRebalance;
RebalanceConfig rebalanceConfig;
bool automateRewards;
RewardConfig rewardConfig;
bool autoExit;
ExitConfig exitConfig;
bytes extraData;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { IUniswapV3Pool } from
"contracts/interfaces/external/uniswap/IUniswapV3Pool.sol";
import { Sickle } from "contracts/Sickle.sol";
import {
NftPosition,
NftRebalance,
NftHarvest,
NftWithdraw,
NftCompound
} from "contracts/structs/NftFarmStrategyStructs.sol";
interface INftAutomation {
function rebalanceFor(
Sickle sickle,
NftRebalance calldata rebalance,
address[] calldata sweepTokens
) external;
function harvestFor(
Sickle sickle,
NftPosition calldata position,
NftHarvest calldata params
) external;
function compoundFor(
Sickle sickle,
NftPosition calldata position,
NftCompound calldata params,
bool inPlace,
address[] memory sweepTokens
) external;
function exitFor(
Sickle sickle,
NftPosition calldata position,
NftHarvest calldata harvestParams,
NftWithdraw calldata withdrawParams,
address[] memory sweepTokens
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { ZapIn, ZapOut } from "contracts/structs/ZapStructs.sol";
interface IZapLib {
function zapIn(
ZapIn memory zap
) external payable;
function zapOut(
ZapOut memory zap
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { Admin } from "contracts/base/Admin.sol";
import { TimelockAdmin } from "contracts/base/TimelockAdmin.sol";
error ConnectorNotRegistered(address target);
error CustomRegistryAlreadyRegistered();
interface ICustomConnectorRegistry {
function connectorOf(
address target
) external view returns (address);
}
contract ConnectorRegistry is Admin, TimelockAdmin {
event ConnectorChanged(address target, address connector);
event CustomRegistryAdded(address registry);
event CustomRegistryRemoved(address registry);
error ConnectorAlreadySet(address target);
error ConnectorNotSet(address target);
error ArrayLengthMismatch();
ICustomConnectorRegistry[] public customRegistries;
mapping(address target => address connector) private connectors_;
constructor(
address admin_,
address timelockAdmin_
) Admin(admin_) TimelockAdmin(timelockAdmin_) { }
/// Admin functions
/// @notice Update connector addresses for a batch of targets.
/// @dev Controls which connector contracts are used for the specified
/// targets.
/// @custom:access Restricted to protocol admin.
function setConnectors(
address[] calldata targets,
address[] calldata connectors
) external onlyAdmin {
if (targets.length != connectors.length) {
revert ArrayLengthMismatch();
}
for (uint256 i; i != targets.length;) {
if (connectors_[targets[i]] != address(0)) {
revert ConnectorAlreadySet(targets[i]);
}
connectors_[targets[i]] = connectors[i];
emit ConnectorChanged(targets[i], connectors[i]);
unchecked {
++i;
}
}
}
function updateConnectors(
address[] calldata targets,
address[] calldata connectors
) external onlyTimelockAdmin {
if (targets.length != connectors.length) {
revert ArrayLengthMismatch();
}
for (uint256 i; i != targets.length;) {
if (connectors_[targets[i]] == address(0)) {
revert ConnectorNotSet(targets[i]);
}
connectors_[targets[i]] = connectors[i];
emit ConnectorChanged(targets[i], connectors[i]);
unchecked {
++i;
}
}
}
/// @notice Append an address to the custom registries list.
/// @custom:access Restricted to protocol admin.
function addCustomRegistry(
ICustomConnectorRegistry registry
) external onlyAdmin {
if (isCustomRegistry(registry)) {
revert CustomRegistryAlreadyRegistered();
}
customRegistries.push(registry);
emit CustomRegistryAdded(address(registry));
}
/// @notice Replace an address in the custom registries list.
/// @custom:access Restricted to protocol admin.
function updateCustomRegistry(
uint256 index,
ICustomConnectorRegistry newRegistry
) external onlyTimelockAdmin {
ICustomConnectorRegistry oldRegistry = customRegistries[index];
emit CustomRegistryRemoved(address(oldRegistry));
customRegistries[index] = newRegistry;
if (address(newRegistry) != address(0)) {
emit CustomRegistryAdded(address(newRegistry));
}
}
/// Public functions
function connectorOf(
address target
) external view returns (address) {
address connector = _getConnector(target);
if (connector != address(0)) {
return connector;
}
revert ConnectorNotRegistered(target);
}
function hasConnector(
address target
) external view returns (bool) {
return _getConnector(target) != address(0);
}
function isCustomRegistry(
ICustomConnectorRegistry registry
) public view returns (bool) {
for (uint256 i; i != customRegistries.length;) {
if (address(customRegistries[i]) == address(registry)) {
return true;
}
unchecked {
++i;
}
}
return false;
}
/// Internal functions
function _getConnector(
address target
) internal view returns (address) {
address connector = connectors_[target];
if (connector != address(0)) {
return connector;
}
uint256 length = customRegistries.length;
for (uint256 i; i != length;) {
if (address(customRegistries[i]) != address(0)) {
(bool success, bytes memory data) = address(customRegistries[i])
.staticcall(
abi.encodeWithSelector(
ICustomConnectorRegistry.connectorOf.selector, target
)
);
if (success && data.length == 32) {
address _connector = abi.decode(data, (address));
if (_connector != address(0)) {
return _connector;
}
}
}
unchecked {
++i;
}
}
return address(0);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.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;
}// 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;
}// 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 of the Sickle contract
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwnerError();
_;
}
/// INITIALIZATION ///
/// @param owner_ Address of the owner of this Sickle contract
function _initializeSickleStorage(
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;
}
}// 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
);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
/// @title TimelockAdmin contract
/// @author vfat.tools
/// @notice Provides an timelockAdministration mechanism allowing restricted
/// functions
abstract contract TimelockAdmin {
/// ERRORS ///
/// @notice Thrown when the caller is not the timelockAdmin
error NotTimelockAdminError();
/// EVENTS ///
/// @notice Emitted when a new timelockAdmin is set
/// @param oldTimelockAdmin Address of the old timelockAdmin
/// @param newTimelockAdmin Address of the new timelockAdmin
event TimelockAdminSet(address oldTimelockAdmin, address newTimelockAdmin);
/// STORAGE ///
/// @notice Address of the current timelockAdmin
address public timelockAdmin;
/// MODIFIERS ///
/// @dev Restricts a function to the timelockAdmin
modifier onlyTimelockAdmin() {
if (msg.sender != timelockAdmin) revert NotTimelockAdminError();
_;
}
/// WRITE FUNCTIONS ///
/// @param timelockAdmin_ Address of the timelockAdmin
constructor(address timelockAdmin_) {
emit TimelockAdminSet(timelockAdmin, timelockAdmin_);
timelockAdmin = timelockAdmin_;
}
/// @notice Sets a new timelockAdmin
/// @dev Can only be called by the current timelockAdmin
/// @param newTimelockAdmin Address of the new timelockAdmin
function setTimelockAdmin(address newTimelockAdmin)
external
onlyTimelockAdmin
{
emit TimelockAdminSet(timelockAdmin, newTimelockAdmin);
timelockAdmin = newTimelockAdmin;
}
}// SPDX-License-Identifier: MIT
// 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;
}
}// 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;
}// 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);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { INonfungiblePositionManager } from
"contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";
import {
INftSettingsRegistry,
NftSettings,
NftKey
} from "contracts/interfaces/INftSettingsRegistry.sol";
interface INftSettingsLib {
error InvalidTokenId();
function transferNftSettings(
INftSettingsRegistry nftSettingsRegistry,
INonfungiblePositionManager nftManager,
uint256 tokenId
) external;
function setNftSettings(
INftSettingsRegistry nftSettingsRegistry,
INonfungiblePositionManager nftManager,
uint256 tokenId,
NftSettings calldata settings
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (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));
}
}// 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;
}// 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();
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
/// @title Admin contract
/// @author vfat.tools
/// @notice Provides an administration mechanism allowing restricted functions
abstract contract Admin {
/// ERRORS ///
/// @notice Thrown when the caller is not the admin
error NotAdminError(); //0xb5c42b3b
/// EVENTS ///
/// @notice Emitted when a new admin is set
/// @param oldAdmin Address of the old admin
/// @param newAdmin Address of the new admin
event AdminSet(address oldAdmin, address newAdmin);
/// STORAGE ///
/// @notice Address of the current admin
address public admin;
/// MODIFIERS ///
/// @dev Restricts a function to the admin
modifier onlyAdmin() {
if (msg.sender != admin) revert NotAdminError();
_;
}
/// WRITE FUNCTIONS ///
/// @param admin_ Address of the admin
constructor(
address admin_
) {
emit AdminSet(address(0), admin_);
admin = admin_;
}
/// @notice Sets a new admin
/// @param newAdmin Address of the new admin
/// @custom:access Restricted to protocol admin.
function setAdmin(
address newAdmin
) external onlyAdmin {
emit AdminSet(admin, newAdmin);
admin = newAdmin;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface ITransferLib {
error ArrayLengthMismatch();
error TokenInRequired();
error AmountInRequired();
error DuplicateTokenIn();
error TokenOutRequired();
error IncompatibleEthTokens();
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;
}// 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);
}// 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 payable;
}// 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;
}// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../token/ERC721/extensions/IERC721Enumerable.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;
function earned(
NftPosition calldata position,
address[] memory rewardTokens
) external view returns (uint256[] memory);
function isStaked(
address user,
NftPosition calldata position
) external view returns (bool);
}// 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;
}// 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
);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {
AddLiquidityParams,
RemoveLiquidityParams,
SwapParams
} from "contracts/structs/LiquidityStructs.sol";
interface ILiquidityConnector {
error InvalidPrice();
function addLiquidity(
AddLiquidityParams memory addLiquidityParams
) external payable;
function removeLiquidity(
RemoveLiquidityParams memory removeLiquidityParams
) external;
function swapExactTokensForTokens(
SwapParams memory swap
) external payable;
function swapExactETHForTokens(
SwapParams memory swap
) external payable;
function getPoolPrice(
address lpToken,
uint256 baseTokenIndex,
uint256 quoteTokenIndex
) external view returns (uint256);
function getReserves(
address lpToken
) external view returns (uint256[] memory reserves);
function getTokens(
address lpToken
) external view returns (address[] memory tokens);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { 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_
) Multicall(sickleRegistry_) {
_disableInitializers();
}
/// @param sickleOwner_ Address of the Sickle owner
function initialize(
address sickleOwner_,
address approved_
) external initializer {
SickleStorage._initializeSickleStorage(sickleOwner_, approved_);
}
/// INTERNALS ///
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;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract DelegateModule {
function _delegateTo(
address to,
bytes memory data
) internal returns (bytes memory) {
(bool success, bytes memory result) = to.delegatecall(data);
if (!success) {
if (result.length == 0) revert();
assembly {
revert(add(32, result), mload(result))
}
}
return result;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
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 {
/// 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_
) {
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;
}
}
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {ERC20} from "../tokens/ERC20.sol";
/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error ETHTransferFailed();
error TransferFromFailed();
error TransferFailed();
error ApproveFailed();
/*//////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
if (!success) revert ETHTransferFailed();
}
/*//////////////////////////////////////////////////////////////
ERC20 OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferFrom(
address token,
address from,
address to,
uint256 amount
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument.
mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
)
}
if (!success) revert TransferFromFailed();
}
function safeTransfer(
address token,
address to,
uint256 amount
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
if (!success) revert TransferFailed();
}
function safeApprove(
address token,
address to,
uint256 amount
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
if (!success) revert ApproveFailed();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import { Sickle } from "contracts/Sickle.sol";
interface INftTransferLib {
/// @dev Transfers the ERC721 NFT with {tokenId} from the user to the Sickle
function transferErc721FromUser(IERC721 nft, uint256 tokenId) external;
/// @dev Transfers the ERC721 NFT with {tokenId} from the Sickle to the user
function transferErc721ToUser(IERC721 nft, uint256 tokenId) external;
/// @dev Transfers the ERC1155 NFT with {tokenId} from the user to Sickle
function transferErc1155FromUser(
IERC1155 nft,
uint256 tokenId,
uint256 amount
) external;
/// @dev Transfers the ERC1155 NFT with {tokenId} from Sickle to the user
function transferErc1155ToUser(
IERC1155 nft,
uint256 tokenId,
uint256 amount
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { NftKey, NftSettings } from "contracts/structs/NftSettingsStructs.sol";
interface INftSettingsRegistry {
error InvalidNftManager();
error AutoHarvestNotSet();
error AutoCompoundNotSet();
error AutoRebalanceNotSet();
error AutoExitNotSet();
error ExitTriggersNotSet();
error InvalidExitTriggers();
error InvalidTokenOut();
error InvalidMinMaxTickRange();
error InvalidSlippageBP();
error InvalidPriceImpactBP();
error InvalidDustBP();
error InvalidMinTickLow();
error InvalidMaxTickHigh();
error InvalidBufferTicksAbove();
error InvalidBufferTicksBelow();
error OnlySickle();
error RebalanceConfigNotSet();
error TickWithinRange();
error TickOutsideStopLossRange();
error SickleNotDeployed();
error InvalidWidth(uint24 actual, uint24 expected);
error TokenIdUnchanged();
event NftSettingsSet(NftKey key, NftSettings settings);
event NftSettingsUnset(NftKey key);
event ConnectionRegistrySet(address connectorRegistry);
function getNftSettings(
NftKey calldata key
) external view returns (NftSettings memory);
function setNftSettings(
NftKey calldata key,
NftSettings calldata settings
) external;
function transferNftSettings(
NftKey calldata oldKey,
NftSettings calldata settings
) external;
function validateRebalanceFor(
NftKey memory key
) external;
function validateExitFor(
NftKey memory key
) external;
function validateHarvestFor(
NftKey memory key
) external;
function validateCompoundFor(
NftKey memory key
) external;
}// 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;
}// 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)));
}
}// 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);
}// 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;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { SwapParams } from "contracts/structs/LiquidityStructs.sol";
import {
NftAddLiquidity,
NftRemoveLiquidity
} from "contracts/structs/NftLiquidityStructs.sol";
struct NftPoolKey {
address poolAddress;
bytes32 poolId;
}
struct NftPoolInfo {
address token0;
address token1;
uint24 fee;
uint24 tickSpacing;
uint160 sqrtPriceX96;
int24 tick;
uint128 liquidity;
uint256 feeGrowthGlobal0X128;
uint256 feeGrowthGlobal1X128;
}
struct NftPositionInfo {
uint128 liquidity;
int24 tickLower;
int24 tickUpper;
}
interface INftLiquidityConnector {
function addLiquidity(
NftAddLiquidity memory addLiquidityParams
) external payable;
function removeLiquidity(
NftRemoveLiquidity memory removeLiquidityParams
) external;
function swapExactTokensForTokens(
SwapParams memory swap
) external payable;
function swapExactETHForTokens(
SwapParams memory swap
) external payable;
function feeGrowthOutside(
address pool,
bytes32 poolId,
int24 tick
)
external
view
returns (uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128);
function fee(
address pool,
uint256 tokenId // Used by UniswapV4
) external view returns (uint24);
function poolInfo(
address pool,
bytes32 poolId
) external view returns (NftPoolInfo memory);
function positionInfo(
address nftManager,
uint256 tokenId
) external view returns (NftPositionInfo memory);
function positionPoolKey(
address poolFactory,
address nftManager,
uint256 tokenId
) external view returns (NftPoolKey memory);
function totalSupply(
address nftManager
) external view returns (uint256);
function getTokenId(
address nftManager,
address owner
) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/proxy/Clones.sol";
import "./Sickle.sol";
import "./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_);
}
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 approved Address approved to manage automation
/// @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 approved Address approved to manage automation
/// @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);
}
}// 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);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
/*//////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
string public name;
string public symbol;
uint8 public immutable decimals;
/*//////////////////////////////////////////////////////////////
ERC20 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256)) public allowance;
/*//////////////////////////////////////////////////////////////
EIP-2612 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 internal immutable INITIAL_CHAIN_ID;
bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name = _name;
symbol = _symbol;
decimals = _decimals;
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
/*//////////////////////////////////////////////////////////////
ERC20 LOGIC
//////////////////////////////////////////////////////////////*/
function approve(address spender, uint256 amount) public virtual returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(address to, uint256 amount) public virtual returns (bool) {
balanceOf[msg.sender] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual returns (bool) {
uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;
balanceOf[from] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
/*//////////////////////////////////////////////////////////////
EIP-2612 LOGIC
//////////////////////////////////////////////////////////////*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
// Unchecked because the only math done is incrementing
// the owner's nonce which cannot realistically overflow.
unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
owner,
spender,
value,
nonces[owner]++,
deadline
)
)
)
),
v,
r,
s
);
require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");
allowance[recoveredAddress][spender] = value;
}
emit Approval(owner, spender, value);
}
function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
}
function computeDomainSeparator() internal view virtual returns (bytes32) {
return
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(name)),
keccak256("1"),
block.chainid,
address(this)
)
);
}
/*//////////////////////////////////////////////////////////////
INTERNAL MINT/BURN LOGIC
//////////////////////////////////////////////////////////////*/
function _mint(address to, uint256 amount) internal virtual {
totalSupply += amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
function _burn(address from, uint256 amount) internal virtual {
balanceOf[from] -= amount;
// Cannot underflow because a user's balance
// will never be larger than the total supply.
unchecked {
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
}// SPDX-License-Identifier: MIT
// 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);
}
}
}// 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++;
}
}
}
}{
"evmVersion": "paris",
"libraries": {},
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": [
"solmate/=lib/solmate/src/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@morpho-blue/=lib/morpho-blue/src/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"morpho-blue/=lib/morpho-blue/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
],
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract SickleFactory","name":"factory","type":"address"},{"internalType":"contract ConnectorRegistry","name":"connectorRegistry","type":"address"},{"internalType":"contract INftSettingsRegistry","name":"nftSettingsRegistry_","type":"address"},{"components":[{"internalType":"contract INftTransferLib","name":"nftTransferLib","type":"address"},{"internalType":"contract ITransferLib","name":"transferLib","type":"address"},{"internalType":"contract ISwapLib","name":"swapLib","type":"address"},{"internalType":"contract IFeesLib","name":"feesLib","type":"address"},{"internalType":"contract INftZapLib","name":"nftZapLib","type":"address"},{"internalType":"contract INftSettingsLib","name":"nftSettingsLib","type":"address"}],"internalType":"struct NftFarmStrategy.Libraries","name":"libraries","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"NftSupplyChanged","type":"error"},{"inputs":[],"name":"NftSupplyDidntIncrease","type":"error"},{"inputs":[],"name":"NotApproved","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"NotOwner","type":"error"},{"inputs":[],"name":"NotRegisteredSickle","type":"error"},{"inputs":[],"name":"PleaseUseDeposit","type":"error"},{"inputs":[],"name":"PleaseUseIncrease","type":"error"},{"inputs":[],"name":"SickleNotDeployed","type":"error"},{"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":"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":"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":"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":"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":[{"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":[{"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"},{"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"}],"internalType":"struct NftCompound","name":"params","type":"tuple"},{"internalType":"bool","name":"inPlace","type":"bool"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"compound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"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":[{"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"},{"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"}],"internalType":"struct NftCompound","name":"params","type":"tuple"},{"internalType":"bool","name":"inPlace","type":"bool"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"compoundFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"connectorRegistry","outputs":[{"internalType":"contract ConnectorRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"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":[{"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"},{"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":"outputTokens","type":"address[]"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"internalType":"struct NftHarvest","name":"harvestParams","type":"tuple"},{"components":[{"components":[{"components":[{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftRemoveLiquidity","name":"removeLiquidityParams","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":"struct NftZapOut","name":"zap","type":"tuple"},{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftWithdraw","name":"withdrawParams","type":"tuple"},{"internalType":"bool","name":"inPlace","type":"bool"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"decrease","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"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"},{"components":[{"internalType":"address[]","name":"tokensIn","type":"address[]"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"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"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftIncrease","name":"increase","type":"tuple"}],"internalType":"struct NftDeposit","name":"params","type":"tuple"},{"components":[{"internalType":"contract IUniswapV3Pool","name":"pool","type":"address"},{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"autoRebalance","type":"bool"},{"components":[{"internalType":"uint24","name":"tickSpacesBelow","type":"uint24"},{"internalType":"uint24","name":"tickSpacesAbove","type":"uint24"},{"internalType":"int24","name":"bufferTicksBelow","type":"int24"},{"internalType":"int24","name":"bufferTicksAbove","type":"int24"},{"internalType":"uint256","name":"dustBP","type":"uint256"},{"internalType":"uint256","name":"priceImpactBP","type":"uint256"},{"internalType":"uint256","name":"slippageBP","type":"uint256"},{"internalType":"int24","name":"cutoffTickLow","type":"int24"},{"internalType":"int24","name":"cutoffTickHigh","type":"int24"},{"internalType":"uint8","name":"delayMin","type":"uint8"},{"components":[{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"}],"internalType":"struct RewardConfig","name":"rewardConfig","type":"tuple"}],"internalType":"struct RebalanceConfig","name":"rebalanceConfig","type":"tuple"},{"internalType":"bool","name":"automateRewards","type":"bool"},{"components":[{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"}],"internalType":"struct RewardConfig","name":"rewardConfig","type":"tuple"},{"internalType":"bool","name":"autoExit","type":"bool"},{"components":[{"internalType":"int24","name":"triggerTickLow","type":"int24"},{"internalType":"int24","name":"triggerTickHigh","type":"int24"},{"internalType":"address","name":"exitTokenOutLow","type":"address"},{"internalType":"address","name":"exitTokenOutHigh","type":"address"},{"internalType":"uint256","name":"priceImpactBP","type":"uint256"},{"internalType":"uint256","name":"slippageBP","type":"uint256"}],"internalType":"struct ExitConfig","name":"exitConfig","type":"tuple"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftSettings","name":"settings","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"},{"internalType":"address","name":"approved","type":"address"},{"internalType":"bytes32","name":"referralCode","type":"bytes32"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"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":[{"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"},{"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":"outputTokens","type":"address[]"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"internalType":"struct NftHarvest","name":"harvestParams","type":"tuple"},{"components":[{"components":[{"components":[{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftRemoveLiquidity","name":"removeLiquidityParams","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":"struct NftZapOut","name":"zap","type":"tuple"},{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftWithdraw","name":"withdrawParams","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"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":[{"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"},{"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":"outputTokens","type":"address[]"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"internalType":"struct NftHarvest","name":"harvestParams","type":"tuple"},{"components":[{"components":[{"components":[{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftRemoveLiquidity","name":"removeLiquidityParams","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":"struct NftZapOut","name":"zap","type":"tuple"},{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftWithdraw","name":"withdrawParams","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"exitFor","outputs":[],"stateMutability":"nonpayable","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":[{"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":[{"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"},{"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":"outputTokens","type":"address[]"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"internalType":"struct NftHarvest","name":"params","type":"tuple"}],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"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":[{"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"},{"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":"outputTokens","type":"address[]"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"internalType":"struct NftHarvest","name":"params","type":"tuple"}],"name":"harvestFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"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":[{"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"},{"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":"outputTokens","type":"address[]"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"internalType":"struct NftHarvest","name":"harvestParams","type":"tuple"},{"components":[{"internalType":"address[]","name":"tokensIn","type":"address[]"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"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"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftIncrease","name":"increaseParams","type":"tuple"},{"internalType":"bool","name":"inPlace","type":"bool"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"increase","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IUniswapV3Pool","name":"pool","type":"address"},{"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":[{"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"},{"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":"outputTokens","type":"address[]"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"internalType":"struct NftHarvest","name":"harvest","type":"tuple"},{"components":[{"components":[{"components":[{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftRemoveLiquidity","name":"removeLiquidityParams","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":"struct NftZapOut","name":"zap","type":"tuple"},{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftWithdraw","name":"withdraw","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"},{"components":[{"internalType":"address[]","name":"tokensIn","type":"address[]"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"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"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftIncrease","name":"increase","type":"tuple"}],"internalType":"struct NftDeposit","name":"deposit","type":"tuple"}],"internalType":"struct NftMove","name":"params","type":"tuple"},{"components":[{"internalType":"contract IUniswapV3Pool","name":"pool","type":"address"},{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"autoRebalance","type":"bool"},{"components":[{"internalType":"uint24","name":"tickSpacesBelow","type":"uint24"},{"internalType":"uint24","name":"tickSpacesAbove","type":"uint24"},{"internalType":"int24","name":"bufferTicksBelow","type":"int24"},{"internalType":"int24","name":"bufferTicksAbove","type":"int24"},{"internalType":"uint256","name":"dustBP","type":"uint256"},{"internalType":"uint256","name":"priceImpactBP","type":"uint256"},{"internalType":"uint256","name":"slippageBP","type":"uint256"},{"internalType":"int24","name":"cutoffTickLow","type":"int24"},{"internalType":"int24","name":"cutoffTickHigh","type":"int24"},{"internalType":"uint8","name":"delayMin","type":"uint8"},{"components":[{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"}],"internalType":"struct RewardConfig","name":"rewardConfig","type":"tuple"}],"internalType":"struct RebalanceConfig","name":"rebalanceConfig","type":"tuple"},{"internalType":"bool","name":"automateRewards","type":"bool"},{"components":[{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"}],"internalType":"struct RewardConfig","name":"rewardConfig","type":"tuple"},{"internalType":"bool","name":"autoExit","type":"bool"},{"components":[{"internalType":"int24","name":"triggerTickLow","type":"int24"},{"internalType":"int24","name":"triggerTickHigh","type":"int24"},{"internalType":"address","name":"exitTokenOutLow","type":"address"},{"internalType":"address","name":"exitTokenOutHigh","type":"address"},{"internalType":"uint256","name":"priceImpactBP","type":"uint256"},{"internalType":"uint256","name":"slippageBP","type":"uint256"}],"internalType":"struct ExitConfig","name":"exitConfig","type":"tuple"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftSettings","name":"settings","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"move","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nftSettingsLib","outputs":[{"internalType":"contract INftSettingsLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftSettingsRegistry","outputs":[{"internalType":"contract INftSettingsRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftTransferLib","outputs":[{"internalType":"contract INftTransferLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftZapLib","outputs":[{"internalType":"contract INftZapLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IUniswapV3Pool","name":"pool","type":"address"},{"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":[{"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"},{"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":"outputTokens","type":"address[]"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"internalType":"struct NftHarvest","name":"harvest","type":"tuple"},{"components":[{"components":[{"components":[{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftRemoveLiquidity","name":"removeLiquidityParams","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":"struct NftZapOut","name":"zap","type":"tuple"},{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftWithdraw","name":"withdraw","type":"tuple"},{"components":[{"internalType":"address[]","name":"tokensIn","type":"address[]"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"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"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftIncrease","name":"increase","type":"tuple"}],"internalType":"struct NftRebalance","name":"params","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"rebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"components":[{"internalType":"contract IUniswapV3Pool","name":"pool","type":"address"},{"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":[{"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"},{"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":"outputTokens","type":"address[]"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"internalType":"struct NftHarvest","name":"harvest","type":"tuple"},{"components":[{"components":[{"components":[{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftRemoveLiquidity","name":"removeLiquidityParams","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":"struct NftZapOut","name":"zap","type":"tuple"},{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftWithdraw","name":"withdraw","type":"tuple"},{"components":[{"internalType":"address[]","name":"tokensIn","type":"address[]"},{"internalType":"uint256[]","name":"amountsIn","type":"uint256[]"},{"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"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftIncrease","name":"increase","type":"tuple"}],"internalType":"struct NftRebalance","name":"params","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"rebalanceFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"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"},{"internalType":"bytes","name":"extraData","type":"bytes"},{"components":[{"internalType":"contract IUniswapV3Pool","name":"pool","type":"address"},{"internalType":"bytes32","name":"poolId","type":"bytes32"},{"internalType":"bool","name":"autoRebalance","type":"bool"},{"components":[{"internalType":"uint24","name":"tickSpacesBelow","type":"uint24"},{"internalType":"uint24","name":"tickSpacesAbove","type":"uint24"},{"internalType":"int24","name":"bufferTicksBelow","type":"int24"},{"internalType":"int24","name":"bufferTicksAbove","type":"int24"},{"internalType":"uint256","name":"dustBP","type":"uint256"},{"internalType":"uint256","name":"priceImpactBP","type":"uint256"},{"internalType":"uint256","name":"slippageBP","type":"uint256"},{"internalType":"int24","name":"cutoffTickLow","type":"int24"},{"internalType":"int24","name":"cutoffTickHigh","type":"int24"},{"internalType":"uint8","name":"delayMin","type":"uint8"},{"components":[{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"}],"internalType":"struct RewardConfig","name":"rewardConfig","type":"tuple"}],"internalType":"struct RebalanceConfig","name":"rebalanceConfig","type":"tuple"},{"internalType":"bool","name":"automateRewards","type":"bool"},{"components":[{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"}],"internalType":"struct RewardConfig","name":"rewardConfig","type":"tuple"},{"internalType":"bool","name":"autoExit","type":"bool"},{"components":[{"internalType":"int24","name":"triggerTickLow","type":"int24"},{"internalType":"int24","name":"triggerTickHigh","type":"int24"},{"internalType":"address","name":"exitTokenOutLow","type":"address"},{"internalType":"address","name":"exitTokenOutHigh","type":"address"},{"internalType":"uint256","name":"priceImpactBP","type":"uint256"},{"internalType":"uint256","name":"slippageBP","type":"uint256"}],"internalType":"struct ExitConfig","name":"exitConfig","type":"tuple"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftSettings","name":"settings","type":"tuple"},{"internalType":"address","name":"approved","type":"address"},{"internalType":"bytes32","name":"referralCode","type":"bytes32"}],"name":"simpleDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"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":"harvestParams","type":"tuple"},{"internalType":"bytes","name":"withdrawExtraData","type":"bytes"}],"name":"simpleExit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"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":"params","type":"tuple"}],"name":"simpleHarvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"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"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"name":"simpleWithdraw","outputs":[],"stateMutability":"nonpayable","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":[{"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":[{"components":[{"components":[{"internalType":"contract INonfungiblePositionManager","name":"nft","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftRemoveLiquidity","name":"removeLiquidityParams","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":"struct NftZapOut","name":"zap","type":"tuple"},{"internalType":"address[]","name":"tokensOut","type":"address[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct NftWithdraw","name":"params","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6101c06040523480156200001257600080fd5b506040516200574f3803806200574f8339810160408190526200003591620000c3565b6001600160a01b03938416608090815292841660a09081528151851660c05292810151841660e052604081015184166101005260208101518416610120526060810151841661014052909101518216610160521661018052306101a052620001d4565b6001600160a01b0381168114620000ae57600080fd5b50565b8051620000be8162000098565b919050565b600080600080848603610120811215620000dc57600080fd5b8551620000e98162000098565b6020870151909550620000fc8162000098565b60408701519094506200010f8162000098565b925060c0605f19820112156200012457600080fd5b5060405160c081016001600160401b03811182821017156200015657634e487b7160e01b600052604160045260246000fd5b6040526200016760608701620000b1565b81526200017760808701620000b1565b60208201526200018a60a08701620000b1565b60408201526200019d60c08701620000b1565b6060820152620001b060e08701620000b1565b6080820152620001c46101008701620000b1565b60a0820152939692955090935050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516153ee62000361600039600081816104ef015281816126560152818161353b015281816139df0152613c780152600081816102ab01528181610f70015281816113ff01528181611a5901528181611f1401528181612db30152613e0801526000818161023b01528181612d5f0152613dbb01526000818161031f0152818161260b015281816139930152613c2c0152600081816103a7015281816120d701526134d801526000818161037301526138e101526000818161058b0152818161255d0152612c050152600081816105570152818161310a01526136530152600081816104bb015281816106de01528181610a0301528181610c5b015281816115ea01528181611b8501528181612309015281816126fb01528181612a3801528181613241015281816137010152613a7801526000818161052301528181610e490152818161121a015281816112d80152818161151a015281816119320152611ded01526153ee6000f3fe6080604052600436106101c25760003560e01c8063659b91b1116100f7578063c45a015511610095578063e0192b2811610064578063e0192b28146105c0578063e5bacdd0146105e0578063f0806a7f146105f3578063f0d847501461061357600080fd5b8063c45a015514610511578063cce5b8c614610545578063d996cef714610579578063ddff9470146105ad57600080fd5b80639448c56a116100d15780639448c56a14610469578063b3fb68d514610489578063b53c86d2146104a9578063bc6b74ab146104dd57600080fd5b8063659b91b1146104095780636e2f91d514610429578063759cb2341461044957600080fd5b806328734381116101645780633faa6e301161013e5780633faa6e30146103615780633fb53a0d14610395578063541bb89e146103c95780635ec5999e146103e957600080fd5b806328734381146102ed5780632af3fa1b1461030d57806338f6f9271461034157600080fd5b80631de7354b116101a05780631de7354b14610229578063237179671461027957806324f450db146102995780632812d614146102cd57600080fd5b8063107acebd146101c75780631c396db6146101e95780631d06722b14610209575b600080fd5b3480156101d357600080fd5b506101e76101e2366004613ef2565b610633565b005b3480156101f557600080fd5b506101e7610204366004613f7e565b6106ac565b34801561021557600080fd5b506101e761022436600461402f565b61092e565b34801561023557600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b34801561028557600080fd5b506101e76102943660046140a3565b61094b565b3480156102a557600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b3480156102d957600080fd5b506101e76102e8366004614126565b610c29565b3480156102f957600080fd5b506101e76103083660046141b2565b610e0a565b34801561031957600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561034d57600080fd5b506101e761035c366004614236565b610e25565b34801561036d57600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b3480156103a157600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b3480156103d557600080fd5b506101e76103e43660046142f5565b611045565b3480156103f557600080fd5b506101e761040436600461402f565b6110ed565b34801561041557600080fd5b506101e7610424366004614348565b611114565b34801561043557600080fd5b506101e76104443660046143a3565b611142565b34801561045557600080fd5b5061025d61046436600461440e565b6111f6565b34801561047557600080fd5b506101e761048436600461442b565b6112b4565b34801561049557600080fd5b5061025d6104a436600461448b565b6114e9565b3480156104b557600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b3480156104e957600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561051d57600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561055157600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561058557600080fd5b5061025d7f000000000000000000000000000000000000000000000000000000000000000081565b6101e76105bb3660046144cc565b611593565b3480156105cc57600080fd5b506101e76105db366004614576565b61190e565b6101e76105ee3660046145bf565b611b53565b3480156105ff57600080fd5b506101e761060e36600461462d565b611dc9565b34801561061f57600080fd5b506101e761062e366004614689565b612001565b600061063e336111f6565b905060008061064d8680614721565b61065b906020810190614741565b90501161066957600061068b565b7fdfa64d371f38074894860654f13f7558a46a9b052e65fd158280c8dd2f07af645b905061069982878784612067565b6106a4828585612084565b505050505050565b6106bc606087016040880161440e565b6040516363cd755760e11b81526001600160a01b0382811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063c79aeaae90602401602060405180830381865afa158015610727573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074b9190614795565b6040516339370aa960e21b81526001600160a01b03848116600483015291925060009183169063e4dc2aa490602401602060405180830381865afa158015610797573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bb91906147b2565b905060006107c8336111f6565b905086610800576107e9818b8b6000805160206153998339815191526121e0565b610800818b6107fb60408c018c6147cb565b6122ac565b60008061080d8a80614721565b61081b906020810190614741565b90501161082957600061084b565b7fdfa64d371f38074894860654f13f7558a46a9b052e65fd158280c8dd2f07af645b9050610858828a8361250a565b876108825761088282610870368e90038e018e614877565b61087d60408d018d6147cb565b6126d6565b61088d828888612084565b610897828c61290d565b50506040516339370aa960e21b81526001600160a01b03848116600483015283169063e4dc2aa4906024015b602060405180830381865afa1580156108e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090491906147b2565b81146109235760405163648873f960e01b815260040160405180910390fd5b505050505050505050565b6000610939336111f6565b905061094681848461297c565b505050565b6000610956336111f6565b9050610981816020870161096d60a08901896148ed565b6000805160206153998339815191526121e0565b6109c5816020870161099660c0890189614903565b6109c06109a960808b0160608c0161440e565b6109b660208c018c61440e565b60808c0135612a14565b612067565b6109f7816109d660e08801886148ed565b6109e49060608101906148ed565b6109f2906040810190614721565b612bb2565b60006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae610a386080890160608a0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610a7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa09190614795565b6001600160a01b031663b943855e610abe6080890160608a0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b0391821660048201529085166024820152604401602060405180830381865afa158015610b0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2e91906147b2565b9050610bbc826040518060600160405280898060e00190610b4f91906148ed565b610b5f9036819003810190614919565b8152602001610b7160e08b018b6148ed565b610b8290606081019060400161440e565b6001600160a01b03168152602001849052610ba060e08a018a6148ed565b610bae9060608101906148ed565b61087d9060608101906147cb565b610be582610bcd60e08901896148ed565b610bde90606081019060400161440e565b8388612d0c565b610bf0828585612084565b6106a48260208801610c0560e08a018a6148ed565b610c1690606081019060400161440e565b610c2360e08b018b6148ed565b85612e8c565b610c39606086016040870161440e565b6040516363cd755760e11b81526001600160a01b0382811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063c79aeaae90602401602060405180830381865afa158015610ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc89190614795565b6040516339370aa960e21b81526001600160a01b03848116600483015291925060009183169063e4dc2aa490602401602060405180830381865afa158015610d14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3891906147b2565b90506000610d45336111f6565b9050610d76818a8a8a8a8a7f1d5b8de553017a3bd388578aeece0183b79c5ca87ec64628b3f76b39487f0231612f34565b506040516339370aa960e21b81526001600160a01b03848116600483015283169063e4dc2aa490602401602060405180830381865afa158015610dbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de191906147b2565b8114610e005760405163648873f960e01b815260040160405180910390fd5b5050505050505050565b6000610e15336111f6565b90506106a4818787878787612ff3565b60405163429b62e560e01b81526001600160a01b03808816600483015287916000917f0000000000000000000000000000000000000000000000000000000000000000169063429b62e590602401602060405180830381865afa158015610e90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb49190614795565b6001600160a01b031603610edb57604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f479190614795565b6001600160a01b031614610f6e5760405163c19f17a960e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663459e268460405180606001604052808a6001600160a01b03168152602001896040016020810190610fca919061440e565b6001600160a01b0316815260200189606001358152506040518263ffffffff1660e01b8152600401610ffc9190614935565b600060405180830381600087803b15801561101657600080fd5b505af115801561102a573d6000803e3d6000fd5b5050505061103c878787878787612ff3565b50505050505050565b6000611050336111f6565b905061105e818585856122ac565b61107c81611072606087016040880161440e565b86606001356130b7565b60608401803590611090906040870161440e565b6001600160a01b039081169083167f976f9aa1da6d0f0e23405b12b4e2b446c12615150624819f4bebe8060fa39f616110cc602089018961440e565b6040516110df919060208b013590614964565b60405180910390a450505050565b60006110f8336111f6565b90506109468184846000805160206153998339815191526121e0565b600061111f336111f6565b905061113c818585856000805160206153998339815191526131ac565b50505050565b600061114d336111f6565b905061115a81868661297c565b611166818685856122ac565b6111848161117a606088016040890161440e565b87606001356130b7565b60608501803590611198906040880161440e565b6001600160a01b039081169083167fc9a3d0888f5ab83eb0fcd2e948c80035fd02319ad2f57c4bc68b1513a0f78ea06111d460208a018a61440e565b6040516111e7919060208c013590614964565b60405180910390a45050505050565b6040516312cfc9b560e31b81526001600160a01b03828116600483015260009182917f0000000000000000000000000000000000000000000000000000000000000000169063967e4da890602401602060405180830381865afa158015611261573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112859190614795565b90506001600160a01b0381166112ae57604051633098a45560e01b815260040160405180910390fd5b92915050565b60405163429b62e560e01b81526001600160a01b03808516600483015284916000917f0000000000000000000000000000000000000000000000000000000000000000169063429b62e590602401602060405180830381865afa15801561131f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113439190614795565b6001600160a01b03160361136a57604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d69190614795565b6001600160a01b0316146113fd5760405163c19f17a960e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bca9ca736040518060600160405280876001600160a01b03168152602001866040016020810190611459919061440e565b6001600160a01b0316815260200186606001358152506040518263ffffffff1660e01b815260040161148b9190614935565b600060405180830381600087803b1580156114a557600080fd5b505af11580156114b9573d6000803e3d6000fd5b5050505061113c8484847f139f6e665188bd3327a590d2d1c9d8d09b55289c07e19fef103ceab100ea09796121e0565b60405163de0d95ed60e01b81526001600160a01b0384811660048301528381166024830152604482018390526000917f00000000000000000000000000000000000000000000000000000000000000009091169063de0d95ed906064016020604051808303816000875af1158015611565573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115899190614795565b90505b9392505050565b6115a060608701876148ed565b6115ae906040810190614721565b6115bc90602081019061497d565b60200135156115de576040516379bb579b60e11b815260040160405180910390fd5b60006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae61161f60608a0160408b0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611663573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116879190614795565b905060006001600160a01b03821663e4dc2aa46116aa60608b0160408c0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156116ee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171291906147b2565b905060006117213386866114e9565b90506117398161173460608c018c6148ed565b613437565b61174a816109e460608c018c6148ed565b60006001600160a01b03841663b943855e61176b60608d0160408e0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b0391821660048201529085166024820152604401602060405180830381865afa1580156117b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117db91906147b2565b90506118368260405180606001604052808d6000018036038101906118009190614919565b81526020018d6040016020810190611818919061440e565b6001600160a01b03168152602001849052610bae60608e018e6148ed565b6118518261184a60608d0160408e0161440e565b838c612d0c565b61185c828989612084565b6001600160a01b03841663e4dc2aa461187b60608d0160408e0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156118bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e391906147b2565b831061190257604051638480c32560e01b815260040160405180910390fd5b50505050505050505050565b60405163429b62e560e01b81526001600160a01b03808616600483015285916000917f0000000000000000000000000000000000000000000000000000000000000000169063429b62e590602401602060405180830381865afa158015611979573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199d9190614795565b6001600160a01b0316036119c457604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a309190614795565b6001600160a01b031614611a575760405163c19f17a960e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638bb96a906040518060600160405280886001600160a01b03168152602001876020016040016020810190611ab6919061440e565b6001600160a01b0316815260808801356020909101526040516001600160e01b031960e084901b168152611aed9190600401614935565b600060405180830381600087803b158015611b0757600080fd5b505af1158015611b1b573d6000803e3d6000fd5b50505050611b4c858585857f139f6e665188bd3327a590d2d1c9d8d09b55289c07e19fef103ceab100ea09796131ac565b5050505050565b611b63606087016040880161440e565b6040516363cd755760e11b81526001600160a01b0382811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063c79aeaae90602401602060405180830381865afa158015611bce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bf29190614795565b6040516339370aa960e21b81526001600160a01b03848116600483015291925060009183169063e4dc2aa490602401602060405180830381865afa158015611c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c6291906147b2565b9050611c716040880188614721565b611c7f90602081019061497d565b60200135600003611ca35760405163059707b960e41b815260040160405180910390fd5b6000611cae336111f6565b905086611ce157611ccf818b8b6000805160206153998339815191526121e0565b611ce1818b6107fb60608c018c6147cb565b611ceb8189613437565b611cfc816109f260408b018b614721565b86611d2157611d2181611d14368d90038d018d614877565b61087d60608c018c6147cb565b611d2c818787612084565b60608a01803590611d409060408d0161440e565b6001600160a01b039081169083167fb00138e527e12645ad7a5a8d608b107cf2fcd3525d2b5d09973ed652f87b4f39611d7c60208f018f61440e565b8e60000160200135604051611d92929190614964565b60405180910390a4506040516339370aa960e21b81526001600160a01b03848116600483015283169063e4dc2aa4906024016108c3565b60405163429b62e560e01b81526001600160a01b03808816600483015287916000917f0000000000000000000000000000000000000000000000000000000000000000169063429b62e590602401602060405180830381865afa158015611e34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e589190614795565b6001600160a01b031603611e7f57604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eeb9190614795565b6001600160a01b031614611f125760405163c19f17a960e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f1cf418260405180606001604052808a6001600160a01b03168152602001896040016020810190611f6e919061440e565b6001600160a01b0316815260200189606001358152506040518263ffffffff1660e01b8152600401611fa09190614935565b600060405180830381600087803b158015611fba57600080fd5b505af1158015611fce573d6000803e3d6000fd5b5050505061103c8787878787877f6b277b6f647b7a0d8000e4fc1460639f589d3e1262b3f1a2f378cce0a5da40bb612f34565b600061200e3384846114e9565b905061202e8161202460608a0160408b0161440e565b8960600135613600565b61204881612041368a90038a018a614877565b88886126d6565b61103c8161205c60608a0160408b0161440e565b896060013587612d0c565b61207984846107fb60408601866147cb565b61113c84838361250a565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816120be5790505090507f00000000000000000000000000000000000000000000000000000000000000008260008151811061210957612109614994565b60200260200101906001600160a01b031690816001600160a01b031681525050838360405160240161213c9291906149f3565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b1790528151829060009061217957612179614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038616906363fb0b96906121b29085908590600401614a07565b600060405180830381600087803b1580156121cc57600080fd5b505af1158015610923573d6000803e3d6000fd5b60006121ef6020840184614741565b90501115612207576122028484846136f5565b61221c565b61221c848461221685806148ed565b84613a6c565b600061222b6060840184614741565b9050111561224957612249846122446060850185614741565b612084565b6060830180359061225d906040860161440e565b6001600160a01b039081169086167fbf9d03ac543e8f596c6f4af5ab5e75f366a57d2d6c28d2ff9c024bd3f88e8771612299602088018861440e565b6040516110df919060208a013590614964565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816122e657905050905060006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae61233b602089018961440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561237f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a39190614795565b905080836000815181106123b9576123b9614994565b60200260200101906001600160a01b031690816001600160a01b0316815250508585856040516024016123ee93929190614b42565b60408051601f198184030181529190526020810180516001600160e01b0316631423e67960e11b1790528251839060009061242b5761242b614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038816906363fb0b96906124649086908690600401614a07565b600060405180830381600087803b15801561247e57600080fd5b505af1158015612492573d6000803e3d6000fd5b50505060608701803591506124aa906040890161440e565b6001600160a01b039081169089167f976f9aa1da6d0f0e23405b12b4e2b446c12615150624819f4bebe8060fa39f616124e660208b018b61440e565b6040516124f9919060208d013590614964565b60405180910390a450505050505050565b6040805160028082526060820183526000926020830190803683375050604080516002808252606082019092529293506000929150602082015b60608152602001906001900390816125445790505090507f00000000000000000000000000000000000000000000000000000000000000008260008151811061258f5761258f614994565b6001600160a01b03909216602092830291909101909101526125b18480614721565b6040516024016125c19190614ce6565b60408051601f198184030181529190526020810180516001600160e01b0316630505281960e11b179052815182906000906125fe576125fe614994565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000008260018151811061263d5761263d614994565b6001600160a01b039092166020928302919091018201527f000000000000000000000000000000000000000000000000000000000000000090849061268490870187614741565b6040516024016126979493929190614df6565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b17905281518290600190811061217957612179614994565b8251516040516363cd755760e11b81526001600160a01b0391821660048201526000917f0000000000000000000000000000000000000000000000000000000000000000169063c79aeaae90602401602060405180830381865afa158015612742573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127669190614795565b604080516001808252818301909252919250600091906020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816127a457905050905082826000815181106127cf576127cf614994565b60200260200101906001600160a01b031690816001600160a01b03168152505085858560405160240161280493929190614e2b565b60408051601f198184030181529190526020810180516001600160e01b03166001624236cd60e11b03191790528151829060009061284457612844614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038816906363fb0b969061287d9085908590600401614a07565b600060405180830381600087803b15801561289757600080fd5b505af11580156128ab573d6000803e3d6000fd5b50505050856040015186602001516001600160a01b0316886001600160a01b03167f53375fafff3a4a00460af1c1347b8f0dd0d35cce6b2bd5661346bc8ad1d37a008960000151600001518a60000151602001516040516124f9929190614964565b60608101803590612921906040840161440e565b6001600160a01b039081169084167f3d988581b5d3b2ed8c77b357af36f383c9a6d036a423cb9f82be3b03211cfd1461295d602086018661440e565b6040516129709190602088013590614964565b60405180910390a45050565b612996838383600080516020615399833981519152613a6c565b6129a4836122448380614741565b606082018035906129b8906040850161440e565b6001600160a01b039081169085167fbf9d03ac543e8f596c6f4af5ab5e75f366a57d2d6c28d2ff9c024bd3f88e87716129f4602087018761440e565b604051612a079190602089013590614964565b60405180910390a4505050565b6040516363cd755760e11b81526001600160a01b03848116600483015260009182917f0000000000000000000000000000000000000000000000000000000000000000169063c79aeaae90602401602060405180830381865afa158015612a7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa39190614795565b90506000816001600160a01b0316639e6eda1886866040518363ffffffff1660e01b8152600401612ad5929190614964565b602060405180830381865afa158015612af2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b169190614e84565b90506101f48162ffffff1611612b50577fcb922c4d36cde61b3660729b33f36eff74a31440cf3e852d4467b4bd6045011c9250505061158c565b610bb88162ffffff1611612b88577fc552bcd88e8785f8a0d9f9c5b9dc4e198659e68e9f6645642142b2900cde564d9250505061158c565b7fa7e26cbd23588e6e87ee40cb01079e973bf8a0910c2edb6bc11ba3240a81480b9250505061158c565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081612bec5790505090507f000000000000000000000000000000000000000000000000000000000000000082600081518110612c3757612c37614994565b60200260200101906001600160a01b031690816001600160a01b03168152505082604051602401612c689190614f09565b60408051601f198184030181529190526020810180516001600160e01b0316633d74119b60e21b17905281518290600090612ca557612ca5614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038516906363fb0b9690612cde9085908590600401614a07565b600060405180830381600087803b158015612cf857600080fd5b505af1158015610e00573d6000803e3d6000fd5b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081612d465790505090507f000000000000000000000000000000000000000000000000000000000000000082600081518110612d9157612d91614994565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000000000000000000000000000000000000000000000858585604051602401612de894939291906151b2565b60408051601f198184030181529190526020810180516001600160e01b0316636505c9ff60e11b17905281518290600090612e2557612e25614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038716906363fb0b9690612e5e9085908590600401614a07565b600060405180830381600087803b158015612e7857600080fd5b505af1158015611902573d6000803e3d6000fd5b60608401803590612ea0906040870161440e565b6001600160a01b039081169087167f8181f528787b6f5d64998fce6130134048cf712961e4d1554465276932df54cc612edc602089018961440e565b6020808a01359089908890612ef3908b018b61440e565b604080516001600160a01b039687168152602080820196909652938616908401526060830191909152909216608083015287013560a082015260c0016111e7565b612f43878761221688806148ed565b83612f6557612f658787612f5788806148ed565b6107fb9060608101906147cb565b612f76876109f26020880188614721565b83612f9857612f9887612f8e36899003890189614877565b610bae88806148ed565b612fa3878484612084565b60608601803590612fb7906040890161440e565b6001600160a01b039081169089167f504180eddec0aa4ed3bb8edcf99b13013e1d8ae52be37f0f4f38d14ccf0c99a56124e660208b018b61440e565b61300d8686866000805160206153998339815191526121e0565b6130398686857fdfa64d371f38074894860654f13f7558a46a9b052e65fd158280c8dd2f07af64612067565b613044868383612084565b60608501803590613058906040880161440e565b6001600160a01b039081169088167fc9a3d0888f5ab83eb0fcd2e948c80035fd02319ad2f57c4bc68b1513a0f78ea061309460208a018a61440e565b6040516130a7919060208c013590614964565b60405180910390a4505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816130f15790505090507f00000000000000000000000000000000000000000000000000000000000000008260008151811061313c5761313c614994565b60200260200101906001600160a01b031690816001600160a01b031681525050838360405160240161316f929190614964565b60408051601f198184030181529190526020810180516001600160e01b0316631df6a96160e31b1790528151829060009061217957612179614994565b6131c785602086016131c160a08801886148ed565b846121e0565b61320685602086016131dc60c0880188614903565b6109c06131ef60808a0160608b0161440e565b6131fc60208b018b61440e565b60808b0135612a14565b613217856109e460e08701876148ed565b6132358561322b608087016060880161440e565b6080870135613d68565b60006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae613276608088016060890161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156132ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132de9190614795565b6001600160a01b031663b943855e6132fc608088016060890161440e565b6040516001600160e01b031960e084901b1681526001600160a01b0391821660048201529089166024820152604401602060405180830381865afa158015613348573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336c91906147b2565b90506133c7866040518060600160405280886020016000018036038101906133949190614919565b81526020016133a960808a0160608b0161440e565b6001600160a01b03168152602001849052610bae60e08901896148ed565b6133d2868585612084565b608085018035906133e6906060880161440e565b6001600160a01b039081169088167f550ef6ca72911d6a82dfa1fade2d87ed10c69661f1bf04376add792b5d1e543761342560408a0160208b0161440e565b604080516130a792918c013590614964565b6000806134476040840184614721565b6134519080614741565b90501161345f576000613481565b7fab273376f9efdd920b41b30b3f02b3dee877874951e3c14bf87bc60060efebcc5b604080516001808252818301909252919250600091906020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816134bf5790505090507f00000000000000000000000000000000000000000000000000000000000000008260008151811061350a5761350a614994565b6001600160a01b039092166020928302919091019091015261352c8480614741565b6135396020870187614741565b7f0000000000000000000000000000000000000000000000000000000000000000876040516024016135709695949392919061529b565b60408051601f198184030181529190526020810180516001600160e01b03166312f5760360e01b179052815182906000906135ad576135ad614994565b6020026020010181905250846001600160a01b03166363fb0b963484846040518463ffffffff1660e01b81526004016135e7929190614a07565b6000604051808303818588803b158015612e7857600080fd5b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b606081526020019060019003908161363a5790505090507f00000000000000000000000000000000000000000000000000000000000000008260008151811061368557613685614994565b60200260200101906001600160a01b031690816001600160a01b03168152505083836040516024016136b8929190614964565b60408051601f198184030181529190526020810180516001600160e01b03166306c530b960e41b1790528151829060009061217957612179614994565b60006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae613733602086018661440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015613777573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379b9190614795565b6040805160038082526080820190925291925060009190602082016060803683375050604080516003808252608082019092529293506000929150602082015b60608152602001906001900390816137db579050509050828260008151811061380657613806614994565b6001600160a01b03909216602092830291909101909101528461382985806148ed565b6138339080614741565b61383d87806148ed565b61384e90604081019060200161530d565b61385888806148ed565b61386990606081019060400161530d565b61387389806148ed565b6138819060608101906147cb565b6040516024016138979796959493929190615328565b60408051601f198184030181529190526020810180516001600160e01b0316636f4621e360e01b179052815182906000906138d4576138d4614994565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000008260018151811061391357613913614994565b6001600160a01b0390921660209283029190910182015261393690850185614741565b604051602401613947929190615384565b60408051601f198184030181529190526020810180516001600160e01b03166357e72eb360e01b17905281518290600190811061398657613986614994565b60200260200101819052507f0000000000000000000000000000000000000000000000000000000000000000826002815181106139c5576139c5614994565b6001600160a01b03909216602092830291909101909101527f0000000000000000000000000000000000000000000000000000000000000000600080516020615399833981519152613a1a6040870187614741565b604051602401613a2d9493929190614df6565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b179052815182906002908110612e2557612e25614994565b60006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae613aaa602087018761440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015613aee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b129190614795565b60408051600280825260608201835292935060009290916020830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081613b515790505090508282600081518110613b7c57613b7c614994565b6001600160a01b039092166020928302919091019091015285613b9f8680614741565b613baf6040890160208a0161530d565b613bbf60608a0160408b0161530d565b613bcc60608b018b6147cb565b604051602401613be29796959493929190615328565b60408051601f198184030181529190526020810180516001600160e01b0316636f4621e360e01b17905281518290600090613c1f57613c1f614994565b60200260200101819052507f000000000000000000000000000000000000000000000000000000000000000082600181518110613c5e57613c5e614994565b6001600160a01b03909216602092830291909101909101527f000000000000000000000000000000000000000000000000000000000000000084613ca28780614741565b604051602401613cb59493929190614df6565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b179052815182906001908110613cf457613cf4614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038816906363fb0b9690613d2d9085908590600401614a07565b600060405180830381600087803b158015613d4757600080fd5b505af1158015613d5b573d6000803e3d6000fd5b5050505050505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081613da25790505090507f000000000000000000000000000000000000000000000000000000000000000082600081518110613ded57613ded614994565b6001600160a01b0392831660209182029290920101526040517f00000000000000000000000000000000000000000000000000000000000000008216602482015290851660448201526064810184905260840160408051601f198184030181529190526020810180516001600160e01b0316631f5cecd560e01b1790528151829060009061217957612179614994565b600060808284031215613e8f57600080fd5b50919050565b600060608284031215613e8f57600080fd5b60008083601f840112613eb957600080fd5b5081356001600160401b03811115613ed057600080fd5b6020830191508360208260051b8501011115613eeb57600080fd5b9250929050565b60008060008060c08587031215613f0857600080fd5b613f128686613e7d565b935060808501356001600160401b0380821115613f2e57600080fd5b613f3a88838901613e95565b945060a0870135915080821115613f5057600080fd5b50613f5d87828801613ea7565b95989497509550505050565b80358015158114613f7957600080fd5b919050565b6000806000806000806101008789031215613f9857600080fd5b613fa28888613e7d565b955060808701356001600160401b0380821115613fbe57600080fd5b613fca8a838b01613e7d565b965060a0890135915080821115613fe057600080fd5b613fec8a838b01613e95565b9550613ffa60c08a01613f69565b945060e089013591508082111561401057600080fd5b5061401d89828a01613ea7565b979a9699509497509295939492505050565b60008060a0838503121561404257600080fd5b61404c8484613e7d565b915060808301356001600160401b0381111561406757600080fd5b61407385828601613e7d565b9150509250929050565b60006101008284031215613e8f57600080fd5b60006103408284031215613e8f57600080fd5b600080600080606085870312156140b957600080fd5b84356001600160401b03808211156140d057600080fd5b6140dc8883890161407d565b955060208701359150808211156140f257600080fd5b6140fe88838901614090565b94506040870135915080821115613f5057600080fd5b600060408284031215613e8f57600080fd5b600080600080600060e0868803121561413e57600080fd5b6141488787613e7d565b945060808601356001600160401b038082111561416457600080fd5b61417089838a01614114565b955061417e60a08901613f69565b945060c088013591508082111561419457600080fd5b506141a188828901613ea7565b969995985093965092949392505050565b600080600080600060e086880312156141ca57600080fd5b6141d48787613e7d565b945060808601356001600160401b03808211156141f057600080fd5b6141fc89838a01613e7d565b955060a088013591508082111561421257600080fd5b61417e89838a01613e95565b6001600160a01b038116811461423357600080fd5b50565b600080600080600080610100878903121561425057600080fd5b863561425b8161421e565b955061426a8860208901613e7d565b945060a08701356001600160401b038082111561428657600080fd5b6142928a838b01613e7d565b955060c08901359150808211156142a857600080fd5b613ffa8a838b01613e95565b60008083601f8401126142c657600080fd5b5081356001600160401b038111156142dd57600080fd5b602083019150836020828501011115613eeb57600080fd5b600080600060a0848603121561430a57600080fd5b6143148585613e7d565b925060808401356001600160401b0381111561432f57600080fd5b61433b868287016142b4565b9497909650939450505050565b60008060006040848603121561435d57600080fd5b83356001600160401b038082111561437457600080fd5b6143808783880161407d565b9450602086013591508082111561439657600080fd5b5061433b86828701613ea7565b60008060008060c085870312156143b957600080fd5b6143c38686613e7d565b935060808501356001600160401b03808211156143df57600080fd5b6143eb88838901613e7d565b945060a087013591508082111561440157600080fd5b50613f5d878288016142b4565b60006020828403121561442057600080fd5b813561158c8161421e565b600080600060c0848603121561444057600080fd5b833561444b8161421e565b925061445a8560208601613e7d565b915060a08401356001600160401b0381111561447557600080fd5b61448186828701613e7d565b9150509250925092565b6000806000606084860312156144a057600080fd5b83356144ab8161421e565b925060208401356144bb8161421e565b929592945050506040919091013590565b60008060008060008060a087890312156144e557600080fd5b86356001600160401b03808211156144fc57600080fd5b6145088a838b01613e7d565b9750602089013591508082111561451e57600080fd5b61452a8a838b01614090565b9650604089013591508082111561454057600080fd5b5061454d89828a01613ea7565b90955093505060608701356145618161421e565b80925050608087013590509295509295509295565b6000806000806060858703121561458c57600080fd5b84356145978161421e565b935060208501356001600160401b03808211156145b357600080fd5b6140fe8883890161407d565b60008060008060008061010087890312156145d957600080fd5b6145e38888613e7d565b955060808701356001600160401b03808211156145ff57600080fd5b61460b8a838b01613e7d565b965060a089013591508082111561462157600080fd5b613fec8a838b01613e7d565b600080600080600080610100878903121561464757600080fd5b86356146528161421e565b95506146618860208901613e7d565b945060a08701356001600160401b038082111561467d57600080fd5b613fec8a838b01614114565b60008060008060008061010087890312156146a357600080fd5b6146ad8888613e7d565b955060808701356001600160401b03808211156146c957600080fd5b6146d58a838b016142b4565b909750955060a08901359150808211156146ee57600080fd5b506146fb89828a01614090565b93505060c087013561470c8161421e565b8092505060e087013590509295509295509295565b60008235603e1983360301811261473757600080fd5b9190910192915050565b6000808335601e1984360301811261475857600080fd5b8301803591506001600160401b0382111561477257600080fd5b6020019150600581901b3603821315613eeb57600080fd5b8035613f798161421e565b6000602082840312156147a757600080fd5b815161158c8161421e565b6000602082840312156147c457600080fd5b5051919050565b6000808335601e198436030181126147e257600080fd5b8301803591506001600160401b038211156147fc57600080fd5b602001915036819003821315613eeb57600080fd5b60006040828403121561482357600080fd5b604051604081018181106001600160401b038211171561485357634e487b7160e01b600052604160045260246000fd5b60405290508082356148648161421e565b8152602092830135920191909152919050565b60006080828403121561488957600080fd5b604051606081018181106001600160401b03821117156148b957634e487b7160e01b600052604160045260246000fd5b6040526148c68484614811565b815260408301356148d68161421e565b602082015260609290920135604083015250919050565b60008235607e1983360301811261473757600080fd5b60008235605e1983360301811261473757600080fd5b60006040828403121561492b57600080fd5b61158c8383614811565b81516001600160a01b039081168252602080840151909116908201526040918201519181019190915260600190565b6001600160a01b03929092168252602082015260400190565b6000823561017e1983360301811261473757600080fd5b634e487b7160e01b600052603260045260246000fd5b8183526000602080850194508260005b858110156149e85781356149cd8161421e565b6001600160a01b0316875295820195908201906001016149ba565b509495945050505050565b6020815260006115896020830184866149aa565b604080825283519082018190526000906020906060840190828701845b82811015614a495781516001600160a01b031684529284019290840190600101614a24565b50505083810382850152845180825282820190600581901b8301840187850160005b83811015614ac857601f19808785030186528251805180865260005b81811015614aa2578281018b01518782018c01528a01614a87565b5060008682018b015296890196601f019091169093018701925090860190600101614a6b565b50909998505050505050505050565b8035614ae28161421e565b6001600160a01b03908116835260208281013590840152604082013590614b088261421e565b166040830152606090810135910152565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b614b4c8185614ad7565b60a060808201526000614b6360a083018486614b19565b95945050505050565b80356001600160801b0381168114613f7957600080fd5b6000808335601e19843603018112614b9a57600080fd5b83016020810192503590506001600160401b03811115614bb957600080fd5b803603821315613eeb57600080fd5b6000808335601e19843603018112614bdf57600080fd5b83016020810192503590506001600160401b03811115614bfe57600080fd5b8060051b3603821315613eeb57600080fd5b60008235609e19833603018112614c2657600080fd5b90910192915050565b81835260006020808501808196508560051b810191508460005b87811015614cd9578284038952614c608288614c10565b60a08135614c6d8161421e565b6001600160a01b03908116875282880135888801526040808401359088015260609081840135614c9c8161421e565b16908701526080614caf83820184614b83565b93508282890152614cc38389018583614b19565b9c89019c97505050928601925050600101614c49565b5091979650505050505050565b602081526000823560fe19843603018112614d0057600080fd5b6040602084015283018035614d148161421e565b6001600160a01b0316606084015260208101356080840152614d3860408201614b6c565b6001600160801b03811660a085015250606081013560c0840152608081013560e0840152614d6860a08201614b6c565b610100614d7f818601836001600160801b03169052565b614d8b60c08401614b6c565b6001600160801b0381166101208701529150614daa60e0840184614b83565b935091508061014086015250614dc561016085018383614b19565b915050614dd56020850185614bc8565b848303601f19016040860152614dec838284614c2f565b9695505050505050565b6001600160a01b03851681526001600160e01b031984166020820152606060408201819052600090614dec90830184866149aa565b6000845160018060a01b038082511684526020820151602085015280602088015116604085015250506040850151606083015260a06080830152614b6360a083018486614b19565b62ffffff8116811461423357600080fd5b600060208284031215614e9657600080fd5b815161158c81614e73565b8035613f7981614e73565b8035614eb78161421e565b6001600160a01b039081168352602082013590614ed38261421e565b1660208301526040810135614ee781614e73565b62ffffff81166040840152505050565b8035600281900b8114613f7957600080fd5b602081526000614f198384614bc8565b60406020850152614f2e606085018284614c2f565b915050602084013561017e19853603018112614f4957600080fd5b838203601f190160408501528401610180614f7483614f678461478a565b6001600160a01b03169052565b60208201356020840152614f8e6040840160408401614eac565b614f9a60a08301614ef7565b614fa960a085018260020b9052565b50614fb660c08301614ef7565b614fc560c085018260020b9052565b5060e0828101359084015261010080830135908401526101208083013590840152610140808301359084015261016061500081840184614b83565b935082828601526150148386018583614b19565b98975050505050505050565b803560ff81168114613f7957600080fd5b80356003811061504057600080fd5b825260208101356150508161421e565b6001600160a01b03166020929092019190915250565b61507c8261507383614ea1565b62ffffff169052565b61508860208201614ea1565b62ffffff16602083015261509e60408201614ef7565b6150ad604084018260020b9052565b506150ba60608201614ef7565b6150c9606084018260020b9052565b506080810135608083015260a081013560a083015260c081013560c08301526150f460e08201614ef7565b61510360e084018260020b9052565b50610100615112818301614ef7565b6151208285018260020b9052565b5050610120615130818301615020565b60ff1690830152610140610946818401838301615031565b61515181614ef7565b60020b825261516260208201614ef7565b60020b602083015260408101356151788161421e565b6001600160a01b0390811660408401526060820135906151978261421e565b1660608301526080818101359083015260a090810135910152565b6001600160a01b038581168252841660208201526040810183905260806060820152600082356151e18161421e565b6001600160a01b03166080830152602083013560a083015261520560408401613f69565b151560c083015261521c60e0830160608501615066565b6152296101e08401613f69565b6102606152398185018315159052565b61524b61028085016102008701615031565b6152586102408601613f69565b8015156102c086015291506152736102e08501828701615148565b5050615283610320840184614b83565b6103406103a08501526150146103c085018284614b19565b6080815260006152af60808301888a6149aa565b82810360208401528581526001600160fb1b038611156152ce57600080fd5b8560051b808860208401376001600160a01b039590951660408401526001600160e01b0319939093166060909201919091525001602001949350505050565b60006020828403121561531f57600080fd5b61158c82614b6c565b6000610100615337838b614ad7565b80608084015261534a818401898b6149aa565b6001600160801b0388811660a0860152871660c085015283810360e08501529050615376818587614b19565b9a9950505050505050505050565b602081526000611589602083018486614c2f56fee400534da780c9d64ef8b5f03c074ff47537b6a4aa2a3e5d5455cb37b5406aa3a264697066735822122067a332bee99042132b736fb845a282e9761d6f6ad086b4a75f0067173885a13c64736f6c63430008130033000000000000000000000000233d9067677dcf1a161954d45b4c965b9d567168000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c99000000000000000000000000372e7761997858be1ee3c492dfa01091282c5083000000000000000000000000188f3b2b1c40e3bc77bc0993c6c951ce4030c9430000000000000000000000000626bd067ff557ae86ee5c7ce44281adbf10298b0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d000000000000000000000000a697ca262c8338fce02f5e6a0484fcb3ae0bc8d80000000000000000000000000f592f2ee1779fa7d81a8482f4cc6d216a0fe04f
Deployed Bytecode
0x6080604052600436106101c25760003560e01c8063659b91b1116100f7578063c45a015511610095578063e0192b2811610064578063e0192b28146105c0578063e5bacdd0146105e0578063f0806a7f146105f3578063f0d847501461061357600080fd5b8063c45a015514610511578063cce5b8c614610545578063d996cef714610579578063ddff9470146105ad57600080fd5b80639448c56a116100d15780639448c56a14610469578063b3fb68d514610489578063b53c86d2146104a9578063bc6b74ab146104dd57600080fd5b8063659b91b1146104095780636e2f91d514610429578063759cb2341461044957600080fd5b806328734381116101645780633faa6e301161013e5780633faa6e30146103615780633fb53a0d14610395578063541bb89e146103c95780635ec5999e146103e957600080fd5b806328734381146102ed5780632af3fa1b1461030d57806338f6f9271461034157600080fd5b80631de7354b116101a05780631de7354b14610229578063237179671461027957806324f450db146102995780632812d614146102cd57600080fd5b8063107acebd146101c75780631c396db6146101e95780631d06722b14610209575b600080fd5b3480156101d357600080fd5b506101e76101e2366004613ef2565b610633565b005b3480156101f557600080fd5b506101e7610204366004613f7e565b6106ac565b34801561021557600080fd5b506101e761022436600461402f565b61092e565b34801561023557600080fd5b5061025d7f0000000000000000000000000f592f2ee1779fa7d81a8482f4cc6d216a0fe04f81565b6040516001600160a01b03909116815260200160405180910390f35b34801561028557600080fd5b506101e76102943660046140a3565b61094b565b3480156102a557600080fd5b5061025d7f000000000000000000000000372e7761997858be1ee3c492dfa01091282c508381565b3480156102d957600080fd5b506101e76102e8366004614126565b610c29565b3480156102f957600080fd5b506101e76103083660046141b2565b610e0a565b34801561031957600080fd5b5061025d7f00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d81565b34801561034d57600080fd5b506101e761035c366004614236565b610e25565b34801561036d57600080fd5b5061025d7f0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a81565b3480156103a157600080fd5b5061025d7f0000000000000000000000000626bd067ff557ae86ee5c7ce44281adbf10298b81565b3480156103d557600080fd5b506101e76103e43660046142f5565b611045565b3480156103f557600080fd5b506101e761040436600461402f565b6110ed565b34801561041557600080fd5b506101e7610424366004614348565b611114565b34801561043557600080fd5b506101e76104443660046143a3565b611142565b34801561045557600080fd5b5061025d61046436600461440e565b6111f6565b34801561047557600080fd5b506101e761048436600461442b565b6112b4565b34801561049557600080fd5b5061025d6104a436600461448b565b6114e9565b3480156104b557600080fd5b5061025d7f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c9981565b3480156104e957600080fd5b5061025d7f000000000000000000000000588be0d1422b81e0c7c1349d124b047909098b1981565b34801561051d57600080fd5b5061025d7f000000000000000000000000233d9067677dcf1a161954d45b4c965b9d56716881565b34801561055157600080fd5b5061025d7f000000000000000000000000188f3b2b1c40e3bc77bc0993c6c951ce4030c94381565b34801561058557600080fd5b5061025d7f000000000000000000000000a697ca262c8338fce02f5e6a0484fcb3ae0bc8d881565b6101e76105bb3660046144cc565b611593565b3480156105cc57600080fd5b506101e76105db366004614576565b61190e565b6101e76105ee3660046145bf565b611b53565b3480156105ff57600080fd5b506101e761060e36600461462d565b611dc9565b34801561061f57600080fd5b506101e761062e366004614689565b612001565b600061063e336111f6565b905060008061064d8680614721565b61065b906020810190614741565b90501161066957600061068b565b7fdfa64d371f38074894860654f13f7558a46a9b052e65fd158280c8dd2f07af645b905061069982878784612067565b6106a4828585612084565b505050505050565b6106bc606087016040880161440e565b6040516363cd755760e11b81526001600160a01b0382811660048301526000917f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c999091169063c79aeaae90602401602060405180830381865afa158015610727573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074b9190614795565b6040516339370aa960e21b81526001600160a01b03848116600483015291925060009183169063e4dc2aa490602401602060405180830381865afa158015610797573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bb91906147b2565b905060006107c8336111f6565b905086610800576107e9818b8b6000805160206153998339815191526121e0565b610800818b6107fb60408c018c6147cb565b6122ac565b60008061080d8a80614721565b61081b906020810190614741565b90501161082957600061084b565b7fdfa64d371f38074894860654f13f7558a46a9b052e65fd158280c8dd2f07af645b9050610858828a8361250a565b876108825761088282610870368e90038e018e614877565b61087d60408d018d6147cb565b6126d6565b61088d828888612084565b610897828c61290d565b50506040516339370aa960e21b81526001600160a01b03848116600483015283169063e4dc2aa4906024015b602060405180830381865afa1580156108e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090491906147b2565b81146109235760405163648873f960e01b815260040160405180910390fd5b505050505050505050565b6000610939336111f6565b905061094681848461297c565b505050565b6000610956336111f6565b9050610981816020870161096d60a08901896148ed565b6000805160206153998339815191526121e0565b6109c5816020870161099660c0890189614903565b6109c06109a960808b0160608c0161440e565b6109b660208c018c61440e565b60808c0135612a14565b612067565b6109f7816109d660e08801886148ed565b6109e49060608101906148ed565b6109f2906040810190614721565b612bb2565b60006001600160a01b037f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c991663c79aeaae610a386080890160608a0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610a7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa09190614795565b6001600160a01b031663b943855e610abe6080890160608a0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b0391821660048201529085166024820152604401602060405180830381865afa158015610b0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2e91906147b2565b9050610bbc826040518060600160405280898060e00190610b4f91906148ed565b610b5f9036819003810190614919565b8152602001610b7160e08b018b6148ed565b610b8290606081019060400161440e565b6001600160a01b03168152602001849052610ba060e08a018a6148ed565b610bae9060608101906148ed565b61087d9060608101906147cb565b610be582610bcd60e08901896148ed565b610bde90606081019060400161440e565b8388612d0c565b610bf0828585612084565b6106a48260208801610c0560e08a018a6148ed565b610c1690606081019060400161440e565b610c2360e08b018b6148ed565b85612e8c565b610c39606086016040870161440e565b6040516363cd755760e11b81526001600160a01b0382811660048301526000917f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c999091169063c79aeaae90602401602060405180830381865afa158015610ca4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc89190614795565b6040516339370aa960e21b81526001600160a01b03848116600483015291925060009183169063e4dc2aa490602401602060405180830381865afa158015610d14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3891906147b2565b90506000610d45336111f6565b9050610d76818a8a8a8a8a7f1d5b8de553017a3bd388578aeece0183b79c5ca87ec64628b3f76b39487f0231612f34565b506040516339370aa960e21b81526001600160a01b03848116600483015283169063e4dc2aa490602401602060405180830381865afa158015610dbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de191906147b2565b8114610e005760405163648873f960e01b815260040160405180910390fd5b5050505050505050565b6000610e15336111f6565b90506106a4818787878787612ff3565b60405163429b62e560e01b81526001600160a01b03808816600483015287916000917f000000000000000000000000233d9067677dcf1a161954d45b4c965b9d567168169063429b62e590602401602060405180830381865afa158015610e90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb49190614795565b6001600160a01b031603610edb57604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f479190614795565b6001600160a01b031614610f6e5760405163c19f17a960e01b815260040160405180910390fd5b7f000000000000000000000000372e7761997858be1ee3c492dfa01091282c50836001600160a01b031663459e268460405180606001604052808a6001600160a01b03168152602001896040016020810190610fca919061440e565b6001600160a01b0316815260200189606001358152506040518263ffffffff1660e01b8152600401610ffc9190614935565b600060405180830381600087803b15801561101657600080fd5b505af115801561102a573d6000803e3d6000fd5b5050505061103c878787878787612ff3565b50505050505050565b6000611050336111f6565b905061105e818585856122ac565b61107c81611072606087016040880161440e565b86606001356130b7565b60608401803590611090906040870161440e565b6001600160a01b039081169083167f976f9aa1da6d0f0e23405b12b4e2b446c12615150624819f4bebe8060fa39f616110cc602089018961440e565b6040516110df919060208b013590614964565b60405180910390a450505050565b60006110f8336111f6565b90506109468184846000805160206153998339815191526121e0565b600061111f336111f6565b905061113c818585856000805160206153998339815191526131ac565b50505050565b600061114d336111f6565b905061115a81868661297c565b611166818685856122ac565b6111848161117a606088016040890161440e565b87606001356130b7565b60608501803590611198906040880161440e565b6001600160a01b039081169083167fc9a3d0888f5ab83eb0fcd2e948c80035fd02319ad2f57c4bc68b1513a0f78ea06111d460208a018a61440e565b6040516111e7919060208c013590614964565b60405180910390a45050505050565b6040516312cfc9b560e31b81526001600160a01b03828116600483015260009182917f000000000000000000000000233d9067677dcf1a161954d45b4c965b9d567168169063967e4da890602401602060405180830381865afa158015611261573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112859190614795565b90506001600160a01b0381166112ae57604051633098a45560e01b815260040160405180910390fd5b92915050565b60405163429b62e560e01b81526001600160a01b03808516600483015284916000917f000000000000000000000000233d9067677dcf1a161954d45b4c965b9d567168169063429b62e590602401602060405180830381865afa15801561131f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113439190614795565b6001600160a01b03160361136a57604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113d69190614795565b6001600160a01b0316146113fd5760405163c19f17a960e01b815260040160405180910390fd5b7f000000000000000000000000372e7761997858be1ee3c492dfa01091282c50836001600160a01b031663bca9ca736040518060600160405280876001600160a01b03168152602001866040016020810190611459919061440e565b6001600160a01b0316815260200186606001358152506040518263ffffffff1660e01b815260040161148b9190614935565b600060405180830381600087803b1580156114a557600080fd5b505af11580156114b9573d6000803e3d6000fd5b5050505061113c8484847f139f6e665188bd3327a590d2d1c9d8d09b55289c07e19fef103ceab100ea09796121e0565b60405163de0d95ed60e01b81526001600160a01b0384811660048301528381166024830152604482018390526000917f000000000000000000000000233d9067677dcf1a161954d45b4c965b9d5671689091169063de0d95ed906064016020604051808303816000875af1158015611565573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115899190614795565b90505b9392505050565b6115a060608701876148ed565b6115ae906040810190614721565b6115bc90602081019061497d565b60200135156115de576040516379bb579b60e11b815260040160405180910390fd5b60006001600160a01b037f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c991663c79aeaae61161f60608a0160408b0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611663573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116879190614795565b905060006001600160a01b03821663e4dc2aa46116aa60608b0160408c0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156116ee573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171291906147b2565b905060006117213386866114e9565b90506117398161173460608c018c6148ed565b613437565b61174a816109e460608c018c6148ed565b60006001600160a01b03841663b943855e61176b60608d0160408e0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b0391821660048201529085166024820152604401602060405180830381865afa1580156117b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117db91906147b2565b90506118368260405180606001604052808d6000018036038101906118009190614919565b81526020018d6040016020810190611818919061440e565b6001600160a01b03168152602001849052610bae60608e018e6148ed565b6118518261184a60608d0160408e0161440e565b838c612d0c565b61185c828989612084565b6001600160a01b03841663e4dc2aa461187b60608d0160408e0161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156118bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e391906147b2565b831061190257604051638480c32560e01b815260040160405180910390fd5b50505050505050505050565b60405163429b62e560e01b81526001600160a01b03808616600483015285916000917f000000000000000000000000233d9067677dcf1a161954d45b4c965b9d567168169063429b62e590602401602060405180830381865afa158015611979573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199d9190614795565b6001600160a01b0316036119c457604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a309190614795565b6001600160a01b031614611a575760405163c19f17a960e01b815260040160405180910390fd5b7f000000000000000000000000372e7761997858be1ee3c492dfa01091282c50836001600160a01b0316638bb96a906040518060600160405280886001600160a01b03168152602001876020016040016020810190611ab6919061440e565b6001600160a01b0316815260808801356020909101526040516001600160e01b031960e084901b168152611aed9190600401614935565b600060405180830381600087803b158015611b0757600080fd5b505af1158015611b1b573d6000803e3d6000fd5b50505050611b4c858585857f139f6e665188bd3327a590d2d1c9d8d09b55289c07e19fef103ceab100ea09796131ac565b5050505050565b611b63606087016040880161440e565b6040516363cd755760e11b81526001600160a01b0382811660048301526000917f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c999091169063c79aeaae90602401602060405180830381865afa158015611bce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bf29190614795565b6040516339370aa960e21b81526001600160a01b03848116600483015291925060009183169063e4dc2aa490602401602060405180830381865afa158015611c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c6291906147b2565b9050611c716040880188614721565b611c7f90602081019061497d565b60200135600003611ca35760405163059707b960e41b815260040160405180910390fd5b6000611cae336111f6565b905086611ce157611ccf818b8b6000805160206153998339815191526121e0565b611ce1818b6107fb60608c018c6147cb565b611ceb8189613437565b611cfc816109f260408b018b614721565b86611d2157611d2181611d14368d90038d018d614877565b61087d60608c018c6147cb565b611d2c818787612084565b60608a01803590611d409060408d0161440e565b6001600160a01b039081169083167fb00138e527e12645ad7a5a8d608b107cf2fcd3525d2b5d09973ed652f87b4f39611d7c60208f018f61440e565b8e60000160200135604051611d92929190614964565b60405180910390a4506040516339370aa960e21b81526001600160a01b03848116600483015283169063e4dc2aa4906024016108c3565b60405163429b62e560e01b81526001600160a01b03808816600483015287916000917f000000000000000000000000233d9067677dcf1a161954d45b4c965b9d567168169063429b62e590602401602060405180830381865afa158015611e34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e589190614795565b6001600160a01b031603611e7f57604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eeb9190614795565b6001600160a01b031614611f125760405163c19f17a960e01b815260040160405180910390fd5b7f000000000000000000000000372e7761997858be1ee3c492dfa01091282c50836001600160a01b031663f1cf418260405180606001604052808a6001600160a01b03168152602001896040016020810190611f6e919061440e565b6001600160a01b0316815260200189606001358152506040518263ffffffff1660e01b8152600401611fa09190614935565b600060405180830381600087803b158015611fba57600080fd5b505af1158015611fce573d6000803e3d6000fd5b5050505061103c8787878787877f6b277b6f647b7a0d8000e4fc1460639f589d3e1262b3f1a2f378cce0a5da40bb612f34565b600061200e3384846114e9565b905061202e8161202460608a0160408b0161440e565b8960600135613600565b61204881612041368a90038a018a614877565b88886126d6565b61103c8161205c60608a0160408b0161440e565b896060013587612d0c565b61207984846107fb60408601866147cb565b61113c84838361250a565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816120be5790505090507f0000000000000000000000000626bd067ff557ae86ee5c7ce44281adbf10298b8260008151811061210957612109614994565b60200260200101906001600160a01b031690816001600160a01b031681525050838360405160240161213c9291906149f3565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b1790528151829060009061217957612179614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038616906363fb0b96906121b29085908590600401614a07565b600060405180830381600087803b1580156121cc57600080fd5b505af1158015610923573d6000803e3d6000fd5b60006121ef6020840184614741565b90501115612207576122028484846136f5565b61221c565b61221c848461221685806148ed565b84613a6c565b600061222b6060840184614741565b9050111561224957612249846122446060850185614741565b612084565b6060830180359061225d906040860161440e565b6001600160a01b039081169086167fbf9d03ac543e8f596c6f4af5ab5e75f366a57d2d6c28d2ff9c024bd3f88e8771612299602088018861440e565b6040516110df919060208a013590614964565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816122e657905050905060006001600160a01b037f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c991663c79aeaae61233b602089018961440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561237f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a39190614795565b905080836000815181106123b9576123b9614994565b60200260200101906001600160a01b031690816001600160a01b0316815250508585856040516024016123ee93929190614b42565b60408051601f198184030181529190526020810180516001600160e01b0316631423e67960e11b1790528251839060009061242b5761242b614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038816906363fb0b96906124649086908690600401614a07565b600060405180830381600087803b15801561247e57600080fd5b505af1158015612492573d6000803e3d6000fd5b50505060608701803591506124aa906040890161440e565b6001600160a01b039081169089167f976f9aa1da6d0f0e23405b12b4e2b446c12615150624819f4bebe8060fa39f616124e660208b018b61440e565b6040516124f9919060208d013590614964565b60405180910390a450505050505050565b6040805160028082526060820183526000926020830190803683375050604080516002808252606082019092529293506000929150602082015b60608152602001906001900390816125445790505090507f000000000000000000000000a697ca262c8338fce02f5e6a0484fcb3ae0bc8d88260008151811061258f5761258f614994565b6001600160a01b03909216602092830291909101909101526125b18480614721565b6040516024016125c19190614ce6565b60408051601f198184030181529190526020810180516001600160e01b0316630505281960e11b179052815182906000906125fe576125fe614994565b60200260200101819052507f00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d8260018151811061263d5761263d614994565b6001600160a01b039092166020928302919091018201527f000000000000000000000000588be0d1422b81e0c7c1349d124b047909098b1990849061268490870187614741565b6040516024016126979493929190614df6565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b17905281518290600190811061217957612179614994565b8251516040516363cd755760e11b81526001600160a01b0391821660048201526000917f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c99169063c79aeaae90602401602060405180830381865afa158015612742573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127669190614795565b604080516001808252818301909252919250600091906020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816127a457905050905082826000815181106127cf576127cf614994565b60200260200101906001600160a01b031690816001600160a01b03168152505085858560405160240161280493929190614e2b565b60408051601f198184030181529190526020810180516001600160e01b03166001624236cd60e11b03191790528151829060009061284457612844614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038816906363fb0b969061287d9085908590600401614a07565b600060405180830381600087803b15801561289757600080fd5b505af11580156128ab573d6000803e3d6000fd5b50505050856040015186602001516001600160a01b0316886001600160a01b03167f53375fafff3a4a00460af1c1347b8f0dd0d35cce6b2bd5661346bc8ad1d37a008960000151600001518a60000151602001516040516124f9929190614964565b60608101803590612921906040840161440e565b6001600160a01b039081169084167f3d988581b5d3b2ed8c77b357af36f383c9a6d036a423cb9f82be3b03211cfd1461295d602086018661440e565b6040516129709190602088013590614964565b60405180910390a45050565b612996838383600080516020615399833981519152613a6c565b6129a4836122448380614741565b606082018035906129b8906040850161440e565b6001600160a01b039081169085167fbf9d03ac543e8f596c6f4af5ab5e75f366a57d2d6c28d2ff9c024bd3f88e87716129f4602087018761440e565b604051612a079190602089013590614964565b60405180910390a4505050565b6040516363cd755760e11b81526001600160a01b03848116600483015260009182917f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c99169063c79aeaae90602401602060405180830381865afa158015612a7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa39190614795565b90506000816001600160a01b0316639e6eda1886866040518363ffffffff1660e01b8152600401612ad5929190614964565b602060405180830381865afa158015612af2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b169190614e84565b90506101f48162ffffff1611612b50577fcb922c4d36cde61b3660729b33f36eff74a31440cf3e852d4467b4bd6045011c9250505061158c565b610bb88162ffffff1611612b88577fc552bcd88e8785f8a0d9f9c5b9dc4e198659e68e9f6645642142b2900cde564d9250505061158c565b7fa7e26cbd23588e6e87ee40cb01079e973bf8a0910c2edb6bc11ba3240a81480b9250505061158c565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081612bec5790505090507f000000000000000000000000a697ca262c8338fce02f5e6a0484fcb3ae0bc8d882600081518110612c3757612c37614994565b60200260200101906001600160a01b031690816001600160a01b03168152505082604051602401612c689190614f09565b60408051601f198184030181529190526020810180516001600160e01b0316633d74119b60e21b17905281518290600090612ca557612ca5614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038516906363fb0b9690612cde9085908590600401614a07565b600060405180830381600087803b158015612cf857600080fd5b505af1158015610e00573d6000803e3d6000fd5b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081612d465790505090507f0000000000000000000000000f592f2ee1779fa7d81a8482f4cc6d216a0fe04f82600081518110612d9157612d91614994565b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000372e7761997858be1ee3c492dfa01091282c5083858585604051602401612de894939291906151b2565b60408051601f198184030181529190526020810180516001600160e01b0316636505c9ff60e11b17905281518290600090612e2557612e25614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038716906363fb0b9690612e5e9085908590600401614a07565b600060405180830381600087803b158015612e7857600080fd5b505af1158015611902573d6000803e3d6000fd5b60608401803590612ea0906040870161440e565b6001600160a01b039081169087167f8181f528787b6f5d64998fce6130134048cf712961e4d1554465276932df54cc612edc602089018961440e565b6020808a01359089908890612ef3908b018b61440e565b604080516001600160a01b039687168152602080820196909652938616908401526060830191909152909216608083015287013560a082015260c0016111e7565b612f43878761221688806148ed565b83612f6557612f658787612f5788806148ed565b6107fb9060608101906147cb565b612f76876109f26020880188614721565b83612f9857612f9887612f8e36899003890189614877565b610bae88806148ed565b612fa3878484612084565b60608601803590612fb7906040890161440e565b6001600160a01b039081169089167f504180eddec0aa4ed3bb8edcf99b13013e1d8ae52be37f0f4f38d14ccf0c99a56124e660208b018b61440e565b61300d8686866000805160206153998339815191526121e0565b6130398686857fdfa64d371f38074894860654f13f7558a46a9b052e65fd158280c8dd2f07af64612067565b613044868383612084565b60608501803590613058906040880161440e565b6001600160a01b039081169088167fc9a3d0888f5ab83eb0fcd2e948c80035fd02319ad2f57c4bc68b1513a0f78ea061309460208a018a61440e565b6040516130a7919060208c013590614964565b60405180910390a4505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816130f15790505090507f000000000000000000000000188f3b2b1c40e3bc77bc0993c6c951ce4030c9438260008151811061313c5761313c614994565b60200260200101906001600160a01b031690816001600160a01b031681525050838360405160240161316f929190614964565b60408051601f198184030181529190526020810180516001600160e01b0316631df6a96160e31b1790528151829060009061217957612179614994565b6131c785602086016131c160a08801886148ed565b846121e0565b61320685602086016131dc60c0880188614903565b6109c06131ef60808a0160608b0161440e565b6131fc60208b018b61440e565b60808b0135612a14565b613217856109e460e08701876148ed565b6132358561322b608087016060880161440e565b6080870135613d68565b60006001600160a01b037f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c991663c79aeaae613276608088016060890161440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156132ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132de9190614795565b6001600160a01b031663b943855e6132fc608088016060890161440e565b6040516001600160e01b031960e084901b1681526001600160a01b0391821660048201529089166024820152604401602060405180830381865afa158015613348573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336c91906147b2565b90506133c7866040518060600160405280886020016000018036038101906133949190614919565b81526020016133a960808a0160608b0161440e565b6001600160a01b03168152602001849052610bae60e08901896148ed565b6133d2868585612084565b608085018035906133e6906060880161440e565b6001600160a01b039081169088167f550ef6ca72911d6a82dfa1fade2d87ed10c69661f1bf04376add792b5d1e543761342560408a0160208b0161440e565b604080516130a792918c013590614964565b6000806134476040840184614721565b6134519080614741565b90501161345f576000613481565b7fab273376f9efdd920b41b30b3f02b3dee877874951e3c14bf87bc60060efebcc5b604080516001808252818301909252919250600091906020808301908036833750506040805160018082528183019092529293506000929150602082015b60608152602001906001900390816134bf5790505090507f0000000000000000000000000626bd067ff557ae86ee5c7ce44281adbf10298b8260008151811061350a5761350a614994565b6001600160a01b039092166020928302919091019091015261352c8480614741565b6135396020870187614741565b7f000000000000000000000000588be0d1422b81e0c7c1349d124b047909098b19876040516024016135709695949392919061529b565b60408051601f198184030181529190526020810180516001600160e01b03166312f5760360e01b179052815182906000906135ad576135ad614994565b6020026020010181905250846001600160a01b03166363fb0b963484846040518463ffffffff1660e01b81526004016135e7929190614a07565b6000604051808303818588803b158015612e7857600080fd5b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b606081526020019060019003908161363a5790505090507f000000000000000000000000188f3b2b1c40e3bc77bc0993c6c951ce4030c9438260008151811061368557613685614994565b60200260200101906001600160a01b031690816001600160a01b03168152505083836040516024016136b8929190614964565b60408051601f198184030181529190526020810180516001600160e01b03166306c530b960e41b1790528151829060009061217957612179614994565b60006001600160a01b037f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c991663c79aeaae613733602086018661440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015613777573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379b9190614795565b6040805160038082526080820190925291925060009190602082016060803683375050604080516003808252608082019092529293506000929150602082015b60608152602001906001900390816137db579050509050828260008151811061380657613806614994565b6001600160a01b03909216602092830291909101909101528461382985806148ed565b6138339080614741565b61383d87806148ed565b61384e90604081019060200161530d565b61385888806148ed565b61386990606081019060400161530d565b61387389806148ed565b6138819060608101906147cb565b6040516024016138979796959493929190615328565b60408051601f198184030181529190526020810180516001600160e01b0316636f4621e360e01b179052815182906000906138d4576138d4614994565b60200260200101819052507f0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a8260018151811061391357613913614994565b6001600160a01b0390921660209283029190910182015261393690850185614741565b604051602401613947929190615384565b60408051601f198184030181529190526020810180516001600160e01b03166357e72eb360e01b17905281518290600190811061398657613986614994565b60200260200101819052507f00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d826002815181106139c5576139c5614994565b6001600160a01b03909216602092830291909101909101527f000000000000000000000000588be0d1422b81e0c7c1349d124b047909098b19600080516020615399833981519152613a1a6040870187614741565b604051602401613a2d9493929190614df6565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b179052815182906002908110612e2557612e25614994565b60006001600160a01b037f000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c991663c79aeaae613aaa602087018761440e565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015613aee573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b129190614795565b60408051600280825260608201835292935060009290916020830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081613b515790505090508282600081518110613b7c57613b7c614994565b6001600160a01b039092166020928302919091019091015285613b9f8680614741565b613baf6040890160208a0161530d565b613bbf60608a0160408b0161530d565b613bcc60608b018b6147cb565b604051602401613be29796959493929190615328565b60408051601f198184030181529190526020810180516001600160e01b0316636f4621e360e01b17905281518290600090613c1f57613c1f614994565b60200260200101819052507f00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d82600181518110613c5e57613c5e614994565b6001600160a01b03909216602092830291909101909101527f000000000000000000000000588be0d1422b81e0c7c1349d124b047909098b1984613ca28780614741565b604051602401613cb59493929190614df6565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b179052815182906001908110613cf457613cf4614994565b60209081029190910101526040516331fd85cb60e11b81526001600160a01b038816906363fb0b9690613d2d9085908590600401614a07565b600060405180830381600087803b158015613d4757600080fd5b505af1158015613d5b573d6000803e3d6000fd5b5050505050505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602082015b6060815260200190600190039081613da25790505090507f0000000000000000000000000f592f2ee1779fa7d81a8482f4cc6d216a0fe04f82600081518110613ded57613ded614994565b6001600160a01b0392831660209182029290920101526040517f000000000000000000000000372e7761997858be1ee3c492dfa01091282c50838216602482015290851660448201526064810184905260840160408051601f198184030181529190526020810180516001600160e01b0316631f5cecd560e01b1790528151829060009061217957612179614994565b600060808284031215613e8f57600080fd5b50919050565b600060608284031215613e8f57600080fd5b60008083601f840112613eb957600080fd5b5081356001600160401b03811115613ed057600080fd5b6020830191508360208260051b8501011115613eeb57600080fd5b9250929050565b60008060008060c08587031215613f0857600080fd5b613f128686613e7d565b935060808501356001600160401b0380821115613f2e57600080fd5b613f3a88838901613e95565b945060a0870135915080821115613f5057600080fd5b50613f5d87828801613ea7565b95989497509550505050565b80358015158114613f7957600080fd5b919050565b6000806000806000806101008789031215613f9857600080fd5b613fa28888613e7d565b955060808701356001600160401b0380821115613fbe57600080fd5b613fca8a838b01613e7d565b965060a0890135915080821115613fe057600080fd5b613fec8a838b01613e95565b9550613ffa60c08a01613f69565b945060e089013591508082111561401057600080fd5b5061401d89828a01613ea7565b979a9699509497509295939492505050565b60008060a0838503121561404257600080fd5b61404c8484613e7d565b915060808301356001600160401b0381111561406757600080fd5b61407385828601613e7d565b9150509250929050565b60006101008284031215613e8f57600080fd5b60006103408284031215613e8f57600080fd5b600080600080606085870312156140b957600080fd5b84356001600160401b03808211156140d057600080fd5b6140dc8883890161407d565b955060208701359150808211156140f257600080fd5b6140fe88838901614090565b94506040870135915080821115613f5057600080fd5b600060408284031215613e8f57600080fd5b600080600080600060e0868803121561413e57600080fd5b6141488787613e7d565b945060808601356001600160401b038082111561416457600080fd5b61417089838a01614114565b955061417e60a08901613f69565b945060c088013591508082111561419457600080fd5b506141a188828901613ea7565b969995985093965092949392505050565b600080600080600060e086880312156141ca57600080fd5b6141d48787613e7d565b945060808601356001600160401b03808211156141f057600080fd5b6141fc89838a01613e7d565b955060a088013591508082111561421257600080fd5b61417e89838a01613e95565b6001600160a01b038116811461423357600080fd5b50565b600080600080600080610100878903121561425057600080fd5b863561425b8161421e565b955061426a8860208901613e7d565b945060a08701356001600160401b038082111561428657600080fd5b6142928a838b01613e7d565b955060c08901359150808211156142a857600080fd5b613ffa8a838b01613e95565b60008083601f8401126142c657600080fd5b5081356001600160401b038111156142dd57600080fd5b602083019150836020828501011115613eeb57600080fd5b600080600060a0848603121561430a57600080fd5b6143148585613e7d565b925060808401356001600160401b0381111561432f57600080fd5b61433b868287016142b4565b9497909650939450505050565b60008060006040848603121561435d57600080fd5b83356001600160401b038082111561437457600080fd5b6143808783880161407d565b9450602086013591508082111561439657600080fd5b5061433b86828701613ea7565b60008060008060c085870312156143b957600080fd5b6143c38686613e7d565b935060808501356001600160401b03808211156143df57600080fd5b6143eb88838901613e7d565b945060a087013591508082111561440157600080fd5b50613f5d878288016142b4565b60006020828403121561442057600080fd5b813561158c8161421e565b600080600060c0848603121561444057600080fd5b833561444b8161421e565b925061445a8560208601613e7d565b915060a08401356001600160401b0381111561447557600080fd5b61448186828701613e7d565b9150509250925092565b6000806000606084860312156144a057600080fd5b83356144ab8161421e565b925060208401356144bb8161421e565b929592945050506040919091013590565b60008060008060008060a087890312156144e557600080fd5b86356001600160401b03808211156144fc57600080fd5b6145088a838b01613e7d565b9750602089013591508082111561451e57600080fd5b61452a8a838b01614090565b9650604089013591508082111561454057600080fd5b5061454d89828a01613ea7565b90955093505060608701356145618161421e565b80925050608087013590509295509295509295565b6000806000806060858703121561458c57600080fd5b84356145978161421e565b935060208501356001600160401b03808211156145b357600080fd5b6140fe8883890161407d565b60008060008060008061010087890312156145d957600080fd5b6145e38888613e7d565b955060808701356001600160401b03808211156145ff57600080fd5b61460b8a838b01613e7d565b965060a089013591508082111561462157600080fd5b613fec8a838b01613e7d565b600080600080600080610100878903121561464757600080fd5b86356146528161421e565b95506146618860208901613e7d565b945060a08701356001600160401b038082111561467d57600080fd5b613fec8a838b01614114565b60008060008060008061010087890312156146a357600080fd5b6146ad8888613e7d565b955060808701356001600160401b03808211156146c957600080fd5b6146d58a838b016142b4565b909750955060a08901359150808211156146ee57600080fd5b506146fb89828a01614090565b93505060c087013561470c8161421e565b8092505060e087013590509295509295509295565b60008235603e1983360301811261473757600080fd5b9190910192915050565b6000808335601e1984360301811261475857600080fd5b8301803591506001600160401b0382111561477257600080fd5b6020019150600581901b3603821315613eeb57600080fd5b8035613f798161421e565b6000602082840312156147a757600080fd5b815161158c8161421e565b6000602082840312156147c457600080fd5b5051919050565b6000808335601e198436030181126147e257600080fd5b8301803591506001600160401b038211156147fc57600080fd5b602001915036819003821315613eeb57600080fd5b60006040828403121561482357600080fd5b604051604081018181106001600160401b038211171561485357634e487b7160e01b600052604160045260246000fd5b60405290508082356148648161421e565b8152602092830135920191909152919050565b60006080828403121561488957600080fd5b604051606081018181106001600160401b03821117156148b957634e487b7160e01b600052604160045260246000fd5b6040526148c68484614811565b815260408301356148d68161421e565b602082015260609290920135604083015250919050565b60008235607e1983360301811261473757600080fd5b60008235605e1983360301811261473757600080fd5b60006040828403121561492b57600080fd5b61158c8383614811565b81516001600160a01b039081168252602080840151909116908201526040918201519181019190915260600190565b6001600160a01b03929092168252602082015260400190565b6000823561017e1983360301811261473757600080fd5b634e487b7160e01b600052603260045260246000fd5b8183526000602080850194508260005b858110156149e85781356149cd8161421e565b6001600160a01b0316875295820195908201906001016149ba565b509495945050505050565b6020815260006115896020830184866149aa565b604080825283519082018190526000906020906060840190828701845b82811015614a495781516001600160a01b031684529284019290840190600101614a24565b50505083810382850152845180825282820190600581901b8301840187850160005b83811015614ac857601f19808785030186528251805180865260005b81811015614aa2578281018b01518782018c01528a01614a87565b5060008682018b015296890196601f019091169093018701925090860190600101614a6b565b50909998505050505050505050565b8035614ae28161421e565b6001600160a01b03908116835260208281013590840152604082013590614b088261421e565b166040830152606090810135910152565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b614b4c8185614ad7565b60a060808201526000614b6360a083018486614b19565b95945050505050565b80356001600160801b0381168114613f7957600080fd5b6000808335601e19843603018112614b9a57600080fd5b83016020810192503590506001600160401b03811115614bb957600080fd5b803603821315613eeb57600080fd5b6000808335601e19843603018112614bdf57600080fd5b83016020810192503590506001600160401b03811115614bfe57600080fd5b8060051b3603821315613eeb57600080fd5b60008235609e19833603018112614c2657600080fd5b90910192915050565b81835260006020808501808196508560051b810191508460005b87811015614cd9578284038952614c608288614c10565b60a08135614c6d8161421e565b6001600160a01b03908116875282880135888801526040808401359088015260609081840135614c9c8161421e565b16908701526080614caf83820184614b83565b93508282890152614cc38389018583614b19565b9c89019c97505050928601925050600101614c49565b5091979650505050505050565b602081526000823560fe19843603018112614d0057600080fd5b6040602084015283018035614d148161421e565b6001600160a01b0316606084015260208101356080840152614d3860408201614b6c565b6001600160801b03811660a085015250606081013560c0840152608081013560e0840152614d6860a08201614b6c565b610100614d7f818601836001600160801b03169052565b614d8b60c08401614b6c565b6001600160801b0381166101208701529150614daa60e0840184614b83565b935091508061014086015250614dc561016085018383614b19565b915050614dd56020850185614bc8565b848303601f19016040860152614dec838284614c2f565b9695505050505050565b6001600160a01b03851681526001600160e01b031984166020820152606060408201819052600090614dec90830184866149aa565b6000845160018060a01b038082511684526020820151602085015280602088015116604085015250506040850151606083015260a06080830152614b6360a083018486614b19565b62ffffff8116811461423357600080fd5b600060208284031215614e9657600080fd5b815161158c81614e73565b8035613f7981614e73565b8035614eb78161421e565b6001600160a01b039081168352602082013590614ed38261421e565b1660208301526040810135614ee781614e73565b62ffffff81166040840152505050565b8035600281900b8114613f7957600080fd5b602081526000614f198384614bc8565b60406020850152614f2e606085018284614c2f565b915050602084013561017e19853603018112614f4957600080fd5b838203601f190160408501528401610180614f7483614f678461478a565b6001600160a01b03169052565b60208201356020840152614f8e6040840160408401614eac565b614f9a60a08301614ef7565b614fa960a085018260020b9052565b50614fb660c08301614ef7565b614fc560c085018260020b9052565b5060e0828101359084015261010080830135908401526101208083013590840152610140808301359084015261016061500081840184614b83565b935082828601526150148386018583614b19565b98975050505050505050565b803560ff81168114613f7957600080fd5b80356003811061504057600080fd5b825260208101356150508161421e565b6001600160a01b03166020929092019190915250565b61507c8261507383614ea1565b62ffffff169052565b61508860208201614ea1565b62ffffff16602083015261509e60408201614ef7565b6150ad604084018260020b9052565b506150ba60608201614ef7565b6150c9606084018260020b9052565b506080810135608083015260a081013560a083015260c081013560c08301526150f460e08201614ef7565b61510360e084018260020b9052565b50610100615112818301614ef7565b6151208285018260020b9052565b5050610120615130818301615020565b60ff1690830152610140610946818401838301615031565b61515181614ef7565b60020b825261516260208201614ef7565b60020b602083015260408101356151788161421e565b6001600160a01b0390811660408401526060820135906151978261421e565b1660608301526080818101359083015260a090810135910152565b6001600160a01b038581168252841660208201526040810183905260806060820152600082356151e18161421e565b6001600160a01b03166080830152602083013560a083015261520560408401613f69565b151560c083015261521c60e0830160608501615066565b6152296101e08401613f69565b6102606152398185018315159052565b61524b61028085016102008701615031565b6152586102408601613f69565b8015156102c086015291506152736102e08501828701615148565b5050615283610320840184614b83565b6103406103a08501526150146103c085018284614b19565b6080815260006152af60808301888a6149aa565b82810360208401528581526001600160fb1b038611156152ce57600080fd5b8560051b808860208401376001600160a01b039590951660408401526001600160e01b0319939093166060909201919091525001602001949350505050565b60006020828403121561531f57600080fd5b61158c82614b6c565b6000610100615337838b614ad7565b80608084015261534a818401898b6149aa565b6001600160801b0388811660a0860152871660c085015283810360e08501529050615376818587614b19565b9a9950505050505050505050565b602081526000611589602083018486614c2f56fee400534da780c9d64ef8b5f03c074ff47537b6a4aa2a3e5d5455cb37b5406aa3a264697066735822122067a332bee99042132b736fb845a282e9761d6f6ad086b4a75f0067173885a13c64736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000233d9067677dcf1a161954d45b4c965b9d567168000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c99000000000000000000000000372e7761997858be1ee3c492dfa01091282c5083000000000000000000000000188f3b2b1c40e3bc77bc0993c6c951ce4030c9430000000000000000000000000626bd067ff557ae86ee5c7ce44281adbf10298b0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d000000000000000000000000a697ca262c8338fce02f5e6a0484fcb3ae0bc8d80000000000000000000000000f592f2ee1779fa7d81a8482f4cc6d216a0fe04f
-----Decoded View---------------
Arg [0] : factory (address): 0x233D9067677dCf1a161954D45B4C965B9d567168
Arg [1] : connectorRegistry (address): 0xc6013E57a0811C7111A8fB07ACd2E248D9489C99
Arg [2] : nftSettingsRegistry_ (address): 0x372e7761997858BE1ee3c492DFa01091282c5083
Arg [3] : libraries (tuple):
Arg [1] : nftTransferLib (address): 0x188f3B2B1C40e3Bc77BC0993C6C951ce4030c943
Arg [2] : transferLib (address): 0x0626Bd067fF557AE86Ee5c7CE44281aDbf10298B
Arg [3] : swapLib (address): 0x9Fad68008C8361436545a206c90AF1Cc480F710A
Arg [4] : feesLib (address): 0x46292986Df2FEE3a048Dd6753918e62e93806C2d
Arg [5] : nftZapLib (address): 0xA697cA262C8338fcE02F5E6A0484FcB3aE0BC8D8
Arg [6] : nftSettingsLib (address): 0x0f592f2Ee1779Fa7d81a8482f4CC6D216a0FE04f
-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 000000000000000000000000233d9067677dcf1a161954d45b4c965b9d567168
Arg [1] : 000000000000000000000000c6013e57a0811c7111a8fb07acd2e248d9489c99
Arg [2] : 000000000000000000000000372e7761997858be1ee3c492dfa01091282c5083
Arg [3] : 000000000000000000000000188f3b2b1c40e3bc77bc0993c6c951ce4030c943
Arg [4] : 0000000000000000000000000626bd067ff557ae86ee5c7ce44281adbf10298b
Arg [5] : 0000000000000000000000009fad68008c8361436545a206c90af1cc480f710a
Arg [6] : 00000000000000000000000046292986df2fee3a048dd6753918e62e93806c2d
Arg [7] : 000000000000000000000000a697ca262c8338fce02f5e6a0484fcb3ae0bc8d8
Arg [8] : 0000000000000000000000000f592f2ee1779fa7d81a8482f4cc6d216a0fe04f
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.