Source Code
Latest 25 from a total of 8,595 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Rebalance | 286659385 | 407 days ago | IN | 0 ETH | 0.0000758 | ||||
| Rebalance | 286371075 | 407 days ago | IN | 0 ETH | 0.00002225 | ||||
| Rebalance | 286367749 | 407 days ago | IN | 0 ETH | 0.00002555 | ||||
| Rebalance | 286337164 | 407 days ago | IN | 0 ETH | 0.0000289 | ||||
| Rebalance | 285912035 | 409 days ago | IN | 0 ETH | 0.00002575 | ||||
| Rebalance | 285749492 | 409 days ago | IN | 0 ETH | 0.00005562 | ||||
| Rebalance | 285562212 | 410 days ago | IN | 0 ETH | 0.00005423 | ||||
| Rebalance | 285547523 | 410 days ago | IN | 0 ETH | 0.00002103 | ||||
| Rebalance | 285442537 | 410 days ago | IN | 0 ETH | 0.00003018 | ||||
| Rebalance | 284132568 | 414 days ago | IN | 0 ETH | 0.00005475 | ||||
| Rebalance | 283849091 | 415 days ago | IN | 0 ETH | 0.00010934 | ||||
| Rebalance | 283754166 | 415 days ago | IN | 0 ETH | 0.00003622 | ||||
| Rebalance | 283750401 | 415 days ago | IN | 0 ETH | 0.00006906 | ||||
| Rebalance | 283567759 | 416 days ago | IN | 0 ETH | 0.00006403 | ||||
| Rebalance | 283422446 | 416 days ago | IN | 0 ETH | 0.00005162 | ||||
| Rebalance | 283361024 | 416 days ago | IN | 0 ETH | 0.00117666 | ||||
| Rebalance | 282583951 | 418 days ago | IN | 0 ETH | 0.00002024 | ||||
| Rebalance | 282194773 | 420 days ago | IN | 0 ETH | 0.00001874 | ||||
| Rebalance | 282031055 | 420 days ago | IN | 0 ETH | 0.00002393 | ||||
| Rebalance | 281468858 | 422 days ago | IN | 0 ETH | 0.00035124 | ||||
| Rebalance | 281386839 | 422 days ago | IN | 0 ETH | 0.00004602 | ||||
| Rebalance | 281308257 | 422 days ago | IN | 0 ETH | 0.00055865 | ||||
| Rebalance | 281282176 | 422 days ago | IN | 0 ETH | 0.00017337 | ||||
| Rebalance | 280972627 | 423 days ago | IN | 0 ETH | 0.00003577 | ||||
| Rebalance | 280893288 | 423 days ago | IN | 0 ETH | 0.00002663 |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
RebalanceStrategy
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {
RebalanceConfig,
NftKey,
NftInfo,
NftSettings,
INftSettingsRegistry,
RewardBehavior
} from "contracts/interfaces/INftSettingsRegistry.sol";
import { NftSettingsRegistry } from "contracts/NftSettingsRegistry.sol";
import { IFarmConnector } from "contracts/interfaces/IFarmConnector.sol";
import {
IUniswapV3Pool,
IUniswapV3PoolState,
IUniswapV3PoolImmutables
} from "contracts/interfaces/external/uniswap/IUniswapV3Pool.sol";
import { INonfungiblePositionManager } from
"contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";
import { StrategyModule } from "contracts/modules/StrategyModule.sol";
import { ZapLib } from "contracts/libraries/ZapLib.sol";
import { FeesLib } from "contracts/libraries/FeesLib.sol";
import { TransferLib } from "contracts/libraries/TransferLib.sol";
import { NftSettingsLib } from "contracts/libraries/NftSettingsLib.sol";
import { SickleFactory } from "contracts/SickleFactory.sol";
import { ConnectorRegistry } from "contracts/ConnectorRegistry.sol";
import { Sickle } from "contracts/Sickle.sol";
import {
IRebalanceable,
RebalanceParams
} from "contracts/interfaces/IRebalanceable.sol";
import {
DepositParams,
HarvestParams,
WithdrawParams
} from "contracts/structs/FarmStrategyStructs.sol";
library RebalanceStrategyFees {
bytes4 constant Harvest = bytes4(keccak256("RebalanceHarvestFee"));
bytes4 constant HarvestFor = bytes4(keccak256("RebalanceHarvestForFee"));
bytes4 constant RebalanceLow = bytes4(keccak256("RebalanceLowFee"));
bytes4 constant RebalanceMid = bytes4(keccak256("RebalanceMidFee"));
bytes4 constant RebalanceHigh = bytes4(keccak256("RebalanceHighFee"));
}
interface IPreviousRebalanceRegistry {
struct OldRebalanceConfig {
int24 tickLow;
int24 tickHigh;
uint256 slippageBP;
int24 minTickLow;
int24 maxTickHigh;
uint8 delayMin;
}
function getRebalanceConfig(NftKey memory key)
external
returns (OldRebalanceConfig memory);
}
contract RebalanceStrategy is
NftSettingsRegistry,
StrategyModule,
IRebalanceable
{
error TokenOutRequired();
error RebalanceConfigNotSet();
error TickWithinRange();
error TickOutsideStopLossRange();
error NftSupplyChanged();
struct Libraries {
ZapLib zapLib;
FeesLib feesLib;
TransferLib transferLib;
NftSettingsLib nftSettingsLib;
}
ZapLib public immutable zapLib;
FeesLib public immutable feesLib;
TransferLib public immutable transferLib;
NftSettingsLib public immutable nftSettingsLib;
address public immutable strategyAddress;
constructor(
SickleFactory factory,
ConnectorRegistry connectorRegistry,
Libraries memory libraries
) StrategyModule(factory, connectorRegistry) NftSettingsRegistry() {
strategyAddress = address(this);
zapLib = libraries.zapLib;
feesLib = libraries.feesLib;
transferLib = libraries.transferLib;
nftSettingsLib = libraries.nftSettingsLib;
}
/* External functions */
function setNftSettings(
INonfungiblePositionManager nftManager,
uint256 tokenId,
NftSettings calldata settings
) external {
Sickle sickle = getSickle(msg.sender);
NftKey memory key = NftKey(sickle, nftManager, tokenId);
_set_nft_settings(key, settings);
}
function migrateNftSettings(
IPreviousRebalanceRegistry previousRebalanceRegistry,
INonfungiblePositionManager nftManager,
uint256[] memory tokenIds
) external {
Sickle sickle = getSickle(msg.sender);
uint256 tokenLength = tokenIds.length;
for (uint256 i; i < tokenLength; i++) {
NftKey memory key = NftKey(sickle, nftManager, tokenIds[i]);
IPreviousRebalanceRegistry.OldRebalanceConfig memory oldConfig =
previousRebalanceRegistry.getRebalanceConfig(key);
(,,,,, int24 tickLower, int24 tickUpper,,,,,) =
nftManager.positions(key.tokenId);
int24 diffToRebalanceBelowTick = tickLower - oldConfig.tickLow;
int24 diffToRebalanceAboveTick = oldConfig.tickHigh - tickUpper;
if (diffToRebalanceBelowTick < 0) {
diffToRebalanceBelowTick = 0;
}
if (diffToRebalanceAboveTick < 0) {
diffToRebalanceAboveTick = 0;
}
RebalanceConfig memory newConfig = RebalanceConfig(
uint24(diffToRebalanceBelowTick),
uint24(diffToRebalanceAboveTick),
oldConfig.slippageBP,
oldConfig.minTickLow,
oldConfig.maxTickHigh,
oldConfig.delayMin
);
NftSettings memory settings = NftSettings(
true, RewardBehavior.Compound, address(0), newConfig
);
_set_nft_settings(key, settings);
}
}
function unsetNftSettings(
INonfungiblePositionManager nftManager,
uint256 tokenId
) external {
Sickle sickle = getSickle(msg.sender);
NftKey memory key = NftKey(sickle, nftManager, tokenId);
_unset_nft_settings(key);
}
function rebalanceFor(
Sickle sickle,
RebalanceParams calldata params,
address[] calldata sweepTokens
) external onlyApproved(sickle) {
if (params.withdrawParams.tokensOut.length == 0) {
revert TokenOutRequired();
}
_validate_rebalance_config(sickle, params.nftInfo);
uint256 nftTotalSupply = params.nftInfo.nftManager.totalSupply();
address[] memory targets = new address[](9);
bytes[] memory data = new bytes[](9);
targets[0] = connectorRegistry.connectorOf(
params.harvestParams.stakingContractAddress
);
data[0] = abi.encodeCall(
IFarmConnector.claim,
(
params.harvestParams.stakingContractAddress,
params.harvestParams.extraData
)
);
targets[1] = address(feesLib);
data[1] = abi.encodeCall(
FeesLib.chargeFees,
(
strategyAddress,
RebalanceStrategyFees.HarvestFor,
params.harvestParams.tokensOut
)
);
targets[2] = connectorRegistry.connectorOf(
params.withdrawParams.stakingContractAddress
);
data[2] = abi.encodeCall(
IFarmConnector.withdraw,
(
params.withdrawParams.stakingContractAddress,
params.withdrawParams.zapData.removeLiquidityData.lpAmountIn,
params.withdrawParams.extraData
)
);
targets[3] = address(zapLib);
data[3] = abi.encodeCall(ZapLib.zapOut, (params.withdrawParams.zapData));
targets[4] = address(feesLib);
data[4] = abi.encodeCall(
FeesLib.chargeFees,
(
strategyAddress,
_get_rebalance_fee(params.nftInfo.pool),
params.withdrawParams.tokensOut
)
);
targets[5] = address(zapLib);
data[5] = abi.encodeCall(ZapLib.zapIn, (params.depositParams.zapData));
targets[6] = address(nftSettingsLib);
data[6] = abi.encodeCall(
NftSettingsLib.resetNftSettings,
(INftSettingsRegistry(strategyAddress), params.nftInfo)
);
targets[7] = connectorRegistry.connectorOf(
params.depositParams.stakingContractAddress
);
data[7] = abi.encodeCall(
IFarmConnector.deposit,
(
params.depositParams.stakingContractAddress,
params.depositParams.zapData.addLiquidityData.lpToken,
params.depositParams.extraData
)
);
if (sweepTokens.length > 0) {
targets[8] = address(transferLib);
data[8] =
abi.encodeCall(TransferLib.transferTokensToUser, (sweepTokens));
}
sickle.multicall(targets, data);
if (nftTotalSupply != params.nftInfo.nftManager.totalSupply()) {
revert NftSupplyChanged();
}
}
function rebalance(
IUniswapV3Pool pool,
HarvestParams calldata harvestParams,
WithdrawParams calldata withdrawParams,
DepositParams calldata depositParams,
address[] memory sweepTokens
) external {
if (withdrawParams.tokensOut.length == 0) {
revert TokenOutRequired();
}
Sickle sickle = getSickle(msg.sender);
address[] memory targets = new address[](8);
bytes[] memory data = new bytes[](8);
targets[0] =
connectorRegistry.connectorOf(harvestParams.stakingContractAddress);
data[0] = abi.encodeCall(
IFarmConnector.claim,
(harvestParams.stakingContractAddress, harvestParams.extraData)
);
targets[1] = address(feesLib);
data[1] = abi.encodeCall(
FeesLib.chargeFees,
(
strategyAddress,
RebalanceStrategyFees.Harvest,
harvestParams.tokensOut
)
);
targets[2] =
connectorRegistry.connectorOf(withdrawParams.stakingContractAddress);
data[2] = abi.encodeCall(
IFarmConnector.withdraw,
(
withdrawParams.stakingContractAddress,
withdrawParams.zapData.removeLiquidityData.lpAmountIn,
withdrawParams.extraData
)
);
targets[3] = address(zapLib);
data[3] = abi.encodeCall(ZapLib.zapOut, (withdrawParams.zapData));
targets[4] = address(feesLib);
data[4] = abi.encodeCall(
FeesLib.chargeFees,
(
strategyAddress,
_get_rebalance_fee(pool),
withdrawParams.tokensOut
)
);
targets[5] = address(zapLib);
data[5] = abi.encodeCall(ZapLib.zapIn, (depositParams.zapData));
targets[6] =
connectorRegistry.connectorOf(depositParams.stakingContractAddress);
data[6] = abi.encodeCall(
IFarmConnector.deposit,
(
depositParams.stakingContractAddress,
depositParams.zapData.addLiquidityData.lpToken,
depositParams.extraData
)
);
if (sweepTokens.length > 0) {
targets[7] = address(transferLib);
data[7] =
abi.encodeCall(TransferLib.transferTokensToUser, (sweepTokens));
}
sickle.multicall(targets, data);
}
/* Internal functions */
// Tick is the 2nd field in slot0, the rest can vary
function _get_curent_tick(IUniswapV3Pool pool) internal returns (int24) {
(, bytes memory result) =
address(pool).call(abi.encodeCall(IUniswapV3PoolState.slot0, ()));
int24 tick;
assembly {
tick := mload(add(add(result, 32), 32))
}
return tick;
}
function _get_rebalance_fee(IUniswapV3Pool pool)
internal
view
returns (bytes4)
{
uint24 fee = IUniswapV3PoolImmutables(pool).fee();
if (fee <= 500) {
return RebalanceStrategyFees.RebalanceLow;
} else if (fee <= 3000) {
return RebalanceStrategyFees.RebalanceMid;
} else {
return RebalanceStrategyFees.RebalanceHigh;
}
}
function _validate_rebalance_config(
Sickle sickle,
NftInfo calldata nftInfo
) private {
RebalanceConfig memory config = getNftSettings(
NftKey(sickle, nftInfo.nftManager, nftInfo.tokenId)
).rebalanceConfig;
if (config.stopLossTickLow == 0 && config.stopLossTickHigh == 0) {
revert RebalanceConfigNotSet();
}
(,,,,, int24 tickLower, int24 tickUpper,,,,,) =
nftInfo.nftManager.positions(nftInfo.tokenId);
int24 tick = _get_curent_tick(nftInfo.pool);
if (
tick >= tickLower - int24(config.diffToRebalanceBelowTick)
&& tick < tickUpper + int24(config.diffToRebalanceAboveTick)
) {
revert TickWithinRange();
}
if (tick <= config.stopLossTickLow || tick >= config.stopLossTickHigh) {
revert TickOutsideStopLossRange();
}
}
}// 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 { Sickle } from "contracts/Sickle.sol";
struct NftKey {
Sickle sickle;
INonfungiblePositionManager nftManager;
uint256 tokenId;
}
/**
* @notice Settings for automatic rebalancing
* @param diffToRebalanceBelowTick: Difference from position tickLower to
* rebalance below
* Default: 0 (always rebalance if tick < tickLower)
* @param diffToRebalanceAboveTick: Difference from position tickUpper to
* rebalance above
* Default: 0 (always rebalance if tick >= tickUpper)
* @param slippageBP: Slippage in basis points
* Used for price impact as well
* @param stopLossTickLow: stop rebalancing below this tick
* default: MIN_TICK (no stop loss)
* @param stopLossTickHigh: stop rebalancing above this tick
* default: MAX_TICK (no stop loss)
* @param delayMin: delay in minutes before rebalancing
*/
struct RebalanceConfig {
uint24 diffToRebalanceBelowTick;
uint24 diffToRebalanceAboveTick;
uint256 slippageBP;
int24 stopLossTickLow;
int24 stopLossTickHigh;
uint8 delayMin;
}
enum RewardBehavior {
Compound,
Harvest
}
struct NftSettings {
bool autoRebalance;
RewardBehavior rewardBehavior;
address harvestTokenOut;
RebalanceConfig rebalanceConfig;
}
struct NftInfo {
IUniswapV3Pool pool;
INonfungiblePositionManager nftManager;
uint256 tokenId;
}
interface INftSettingsRegistry {
function getNftSettings(NftKey calldata key)
external
view
returns (NftSettings memory);
function resetNftSettings(
NftKey calldata oldKey,
NftKey calldata newKey,
NftSettings calldata settings
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { Sickle } from "contracts/Sickle.sol";
import {
INftSettingsRegistry,
NftKey,
NftSettings,
RebalanceConfig,
RewardBehavior
} from "contracts/interfaces/INftSettingsRegistry.sol";
abstract contract NftSettingsRegistry is INftSettingsRegistry {
error CompoundOrHarvestNotSet();
error CompoundAndHarvestBothSet();
error AutoRebalanceNotSet();
error InvalidTokenOut();
error InvalidMinMaxTickRange();
error InvalidSlippageBP();
error InvalidMinTickLow();
error InvalidMaxTickHigh();
error OnlySickle();
event NftSettingsSet(NftKey key, NftSettings settings);
event NftSettingsUnset(NftKey key);
uint256 constant MAX_SLIPPAGE_BP = 500;
int24 constant MAX_TICK = 887_272;
int24 constant MIN_TICK = -MAX_TICK;
mapping(bytes32 => NftSettings) settingsMap;
function getNftSettings(NftKey memory key)
public
view
returns (NftSettings memory)
{
return settingsMap[keccak256(abi.encode(key))];
}
function _set_nft_settings(
NftKey memory key,
NftSettings memory settings
) internal checkConfigValues(settings) {
settingsMap[keccak256(abi.encode(key))] = settings;
emit NftSettingsSet(key, settings);
}
function _unset_nft_settings(NftKey memory key) internal {
delete settingsMap[keccak256(abi.encode(key))];
emit NftSettingsUnset(key);
}
function resetNftSettings(
NftKey calldata oldKey,
NftKey calldata newKey,
NftSettings calldata settings
) external {
Sickle sickle = Sickle(payable(msg.sender));
if (oldKey.sickle != sickle || newKey.sickle != sickle) {
revert OnlySickle();
}
_unset_nft_settings(oldKey);
_set_nft_settings(newKey, settings);
}
function _check_rebalance_config(RebalanceConfig memory config)
internal
pure
{
if (
config.stopLossTickLow < MIN_TICK
|| config.stopLossTickLow > MAX_TICK
) {
revert InvalidMinTickLow();
}
if (
config.stopLossTickHigh < MIN_TICK
|| config.stopLossTickHigh > MAX_TICK
) {
revert InvalidMaxTickHigh();
}
if (config.stopLossTickLow >= config.stopLossTickHigh) {
revert InvalidMinMaxTickRange();
}
if (config.slippageBP > MAX_SLIPPAGE_BP) {
revert InvalidSlippageBP();
}
}
modifier checkConfigValues(NftSettings memory settings) {
if (settings.autoRebalance) {
_check_rebalance_config(settings.rebalanceConfig);
} else {
if (
settings.rebalanceConfig.stopLossTickLow != 0
|| settings.rebalanceConfig.stopLossTickHigh != 0
) {
revert AutoRebalanceNotSet();
}
}
if (
settings.rewardBehavior != RewardBehavior.Harvest
&& settings.harvestTokenOut != address(0)
) {
revert InvalidTokenOut();
}
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IFarmConnector {
function deposit(
address target,
address token,
bytes memory extraData
) external payable;
function withdraw(
address target,
uint256 amount,
bytes memory extraData
) external;
function claim(address target, bytes memory extraData) 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.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;
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
pragma solidity ^0.8.17;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeTransferLib } from "solmate/utils/SafeTransferLib.sol";
import {
ILiquidityConnector,
SwapData,
AddLiquidityData,
RemoveLiquidityData
} from "contracts/interfaces/ILiquidityConnector.sol";
import { SwapLib } from "contracts/libraries/SwapLib.sol";
import { ConnectorRegistry } from "contracts/ConnectorRegistry.sol";
import { DelegateModule } from "contracts/modules/DelegateModule.sol";
struct ZapInData {
SwapData[] swaps;
AddLiquidityData addLiquidityData;
}
struct ZapOutData {
RemoveLiquidityData removeLiquidityData;
SwapData[] swaps;
}
contract ZapLib is DelegateModule {
error LiquidityAmountError(); // 0x4d0ab6b4
SwapLib public immutable swapLib;
ConnectorRegistry public immutable connectorRegistry;
constructor(ConnectorRegistry connectorRegistry_, SwapLib swapLib_) {
connectorRegistry = connectorRegistry_;
swapLib = swapLib_;
}
function zapIn(ZapInData memory zapData) external payable {
uint256 swapDataLength = zapData.swaps.length;
for (uint256 i; i < swapDataLength;) {
_delegateTo(
address(swapLib),
abi.encodeCall(SwapLib.swap, (zapData.swaps[i]))
);
unchecked {
i++;
}
}
if (zapData.addLiquidityData.lpToken == address(0)) {
return;
}
bool atLeastOneNonZero = false;
AddLiquidityData memory addLiquidityData = zapData.addLiquidityData;
uint256 addLiquidityDataTokensLength = addLiquidityData.tokens.length;
for (uint256 i; i < addLiquidityDataTokensLength; i++) {
if (addLiquidityData.tokens[i] == address(0)) {
continue;
}
if (addLiquidityData.desiredAmounts[i] == 0) {
addLiquidityData.desiredAmounts[i] =
IERC20(addLiquidityData.tokens[i]).balanceOf(address(this));
}
if (addLiquidityData.desiredAmounts[i] > 0) {
atLeastOneNonZero = true;
// In case there is USDT or similar dust approval, revoke it
SafeTransferLib.safeApprove(
addLiquidityData.tokens[i], addLiquidityData.router, 0
);
SafeTransferLib.safeApprove(
addLiquidityData.tokens[i],
addLiquidityData.router,
addLiquidityData.desiredAmounts[i]
);
}
}
if (!atLeastOneNonZero) {
revert LiquidityAmountError();
}
address routerConnector =
connectorRegistry.connectorOf(addLiquidityData.router);
_delegateTo(
routerConnector,
abi.encodeCall(ILiquidityConnector.addLiquidity, (addLiquidityData))
);
for (uint256 i; i < addLiquidityDataTokensLength;) {
if (addLiquidityData.tokens[i] != address(0)) {
// Revoke any dust approval in case the amount was estimated
SafeTransferLib.safeApprove(
addLiquidityData.tokens[i], addLiquidityData.router, 0
);
}
unchecked {
i++;
}
}
}
function zapOut(ZapOutData memory zapData) external {
if (zapData.removeLiquidityData.lpToken != address(0)) {
if (zapData.removeLiquidityData.lpAmountIn > 0) {
SafeTransferLib.safeApprove(
zapData.removeLiquidityData.lpToken,
zapData.removeLiquidityData.router,
zapData.removeLiquidityData.lpAmountIn
);
}
address routerConnector = connectorRegistry.connectorOf(
zapData.removeLiquidityData.router
);
_delegateTo(
address(routerConnector),
abi.encodeCall(
ILiquidityConnector.removeLiquidity,
zapData.removeLiquidityData
)
);
}
uint256 swapDataLength = zapData.swaps.length;
for (uint256 i; i < swapDataLength;) {
_delegateTo(
address(swapLib),
abi.encodeCall(SwapLib.swap, (zapData.swaps[i]))
);
unchecked {
i++;
}
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { SafeTransferLib } from "solmate/utils/SafeTransferLib.sol";
import { WETH } from "solmate/tokens/WETH.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Sickle } from "contracts/Sickle.sol";
import { SickleRegistry } from "contracts/SickleRegistry.sol";
contract FeesLib {
event FeeCharged(
address strategy, bytes4 feeDescriptor, uint256 amount, address token
);
event TransactionCostCharged(address recipient, uint256 amount);
/// @notice Fees library version
uint256 public constant VERSION = 1;
/// @notice Sickle registry address
SickleRegistry public immutable registry;
/// @notice WETH9 token address
WETH public immutable weth;
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
constructor(SickleRegistry registry_, WETH weth_) {
registry = registry_;
weth = weth_;
}
/**
* @notice Strategy contract charges fee to user depending on the type of
* action and sends funds to the collector address
* @param strategy Address of the strategy contract
* @param feeDescriptor Descriptor of the fee to be charged
* @param feeToken Address of the token from which an amount will be
* @param feeBasis Amount to be charged (zero if on full amount)
* charged (zero address if native token)
*/
function chargeFee(
address strategy,
bytes4 feeDescriptor,
address feeToken,
uint256 feeBasis
) public payable returns (uint256 remainder) {
uint256 fee = registry.feeRegistry(
keccak256(abi.encodePacked(strategy, feeDescriptor))
);
if (feeBasis == 0) {
if (feeToken == ETH) {
uint256 wethBalance = weth.balanceOf(address(this));
if (wethBalance > 0) {
weth.withdraw(wethBalance);
}
feeBasis = address(this).balance;
} else {
feeBasis = IERC20(feeToken).balanceOf(address(this));
}
}
if (fee == 0) {
return feeBasis;
}
uint256 amountToCharge = feeBasis * fee / 10_000;
if (feeToken == 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) {
SafeTransferLib.safeTransferETH(
registry.collector(), amountToCharge
);
} else {
SafeTransferLib.safeTransfer(
feeToken, registry.collector(), amountToCharge
);
}
emit FeeCharged(strategy, feeDescriptor, amountToCharge, feeToken);
return feeBasis - amountToCharge;
}
function chargeFees(
address strategy,
bytes4 feeDescriptor,
address[] memory feeTokens
) external {
for (uint256 i = 0; i < feeTokens.length;) {
chargeFee(strategy, feeDescriptor, feeTokens[i], 0);
unchecked {
i++;
}
}
}
function getBalance(
Sickle sickle,
address token
) public view returns (uint256) {
if (token == ETH) {
return weth.balanceOf(address(sickle));
}
return IERC20(token).balanceOf(address(sickle));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { MsgValueModule } from "contracts/modules/MsgValueModule.sol";
import { WETH } from "lib/solmate/src/tokens/WETH.sol";
import { Sickle } from "contracts/Sickle.sol";
import { SafeTransferLib } from "lib/solmate/src/utils/SafeTransferLib.sol";
import { IERC20 } from
"lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol";
import { FeesLib } from "contracts/libraries/FeesLib.sol";
import { DelegateModule } from "contracts/modules/DelegateModule.sol";
contract TransferLib is MsgValueModule, DelegateModule {
error ArrayLengthMismatch();
error TokenInRequired();
address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
WETH public immutable weth;
FeesLib public immutable feesLib;
constructor(FeesLib feseLib_, WETH weth_) {
feesLib = feseLib_;
weth = weth_;
}
/// @dev Transfers the balance of {token} from the contract to the
/// sickle owner
/// @param token Address of the token to transfer
function transferTokenToUser(address token) public payable {
address recipient = Sickle(payable(address(this))).owner();
if (token == address(0)) {
return;
}
if (token == ETH) {
uint256 wethBalance = weth.balanceOf(address(this));
if (wethBalance > 0) {
weth.withdraw(wethBalance);
}
if (address(this).balance > 0) {
SafeTransferLib.safeTransferETH(
recipient, address(this).balance
);
}
} else {
uint256 balance = IERC20(token).balanceOf(address(this));
if (balance > 0) {
SafeTransferLib.safeTransfer(token, recipient, balance);
}
}
}
/// @dev Transfers all balances of {tokens} and/or ETH from the contract
/// to the sickle owner
/// @param tokens An array of token addresses
function transferTokensToUser(address[] memory tokens) external payable {
for (uint256 i = 0; i != tokens.length;) {
transferTokenToUser(tokens[i]);
unchecked {
i++;
}
}
}
/// @dev Transfers {amountIn} of {tokenIn} from the user to the Sickle
/// contract, charging the fees and converting the amount to WETH if
/// necessary
/// @param tokenIn Address of the token to transfer
/// @param amountIn Amount of the token to transfer
/// @param strategy Address of the caller strategy
/// @param feeSelector Selector of the caller function
function transferTokenFromUser(
address tokenIn,
uint256 amountIn,
address strategy,
bytes4 feeSelector
) public payable {
_checkMsgValue(amountIn, tokenIn == ETH);
_transferTokenFromUser(tokenIn, amountIn, strategy, feeSelector);
}
/// @dev Transfers {amountIn} of {tokenIn} from the user to the Sickle
/// contract, charging the fees and converting the amount to WETH if
/// necessary
/// @param tokensIn Addresses of the tokens to transfer
/// @param amountsIn Amounts of the tokens to transfer
/// @param strategy Address of the caller strategy
/// @param feeSelector Selector of the caller function
function transferTokensFromUser(
address[] memory tokensIn,
uint256[] memory amountsIn,
address strategy,
bytes4 feeSelector
) external payable {
if (tokensIn.length != amountsIn.length) {
revert ArrayLengthMismatch();
}
if (tokensIn.length == 0) {
revert TokenInRequired();
}
bool hasEth = false;
for (uint256 i = 0; i < tokensIn.length; i++) {
if (tokensIn[i] == ETH) {
_checkMsgValue(amountsIn[i], true);
hasEth = true;
}
_transferTokenFromUser(
tokensIn[i], amountsIn[i], strategy, feeSelector
);
}
if (!hasEth) {
// Revert if ETH was sent but not used
_checkMsgValue(0, false);
}
}
/* Internal functions */
function _transferTokenFromUser(
address tokenIn,
uint256 amountIn,
address strategy,
bytes4 feeSelector
) internal {
if (tokenIn != ETH) {
SafeTransferLib.safeTransferFrom(
tokenIn,
Sickle(payable(address(this))).owner(),
address(this),
amountIn
);
}
bytes memory result = _delegateTo(
address(feesLib),
abi.encodeCall(
FeesLib.chargeFee, (strategy, feeSelector, tokenIn, 0)
)
);
uint256 remainder = abi.decode(result, (uint256));
if (tokenIn == ETH) {
weth.deposit{ value: remainder }();
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import {
INftSettingsRegistry,
RebalanceConfig,
NftSettings,
NftKey,
NftInfo
} from "contracts/interfaces/INftSettingsRegistry.sol";
import { INonfungiblePositionManager } from
"contracts/interfaces/external/uniswap/INonfungiblePositionManager.sol";
import { Sickle } from "contracts/Sickle.sol";
contract NftSettingsLib {
error TokenIdUnchanged();
function resetNftSettings(
INftSettingsRegistry rebalanceRegistry,
NftInfo calldata nftInfo
) external {
NftKey memory key = NftKey(
Sickle(payable(address(this))), nftInfo.nftManager, nftInfo.tokenId
);
NftSettings memory settings = rebalanceRegistry.getNftSettings(key);
INonfungiblePositionManager nftManager =
INonfungiblePositionManager(key.nftManager);
uint256 newTokenId = nftManager.tokenOfOwnerByIndex(
address(this), nftManager.balanceOf(address(this)) - 1
);
if (newTokenId == key.tokenId) {
revert TokenIdUnchanged();
}
NftKey memory newKey = NftKey(key.sickle, key.nftManager, newTokenId);
rebalanceRegistry.resetNftSettings(key, newKey, settings);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { Clones } from "@openzeppelin/contracts/proxy/Clones.sol";
import { SickleRegistry } from "contracts/SickleRegistry.sol";
import { Sickle } from "contracts/Sickle.sol";
import { Admin } from "contracts/base/Admin.sol";
/// @title SickleFactory contract
/// @author vfat.tools
/// @notice Factory deploying new Sickle contracts
contract SickleFactory is Admin {
/// EVENTS ///
/// @notice Emitted when a new Sickle contract is deployed
/// @param admin Address receiving the admin rights of the Sickle contract
/// @param sickle Address of the newly deployed Sickle contract
event Deploy(address indexed admin, address sickle);
/// @notice Thrown when the caller is not whitelisted
/// @param caller Address of the non-whitelisted caller
error CallerNotWhitelisted(address caller); // 0x252c8273
/// @notice Thrown when the factory is not active and a deploy is attempted
error NotActive(); // 0x80cb55e2
/// @notice Thrown when a Sickle contract is already deployed for a user
error SickleAlreadyDeployed(); //0xf6782ef1
/// STORAGE ///
mapping(address => address) private _sickles;
mapping(address => address) private _admins;
mapping(address => bytes32) public _referralCodes;
/// @notice Address of the SickleRegistry contract
SickleRegistry public immutable registry;
/// @notice Address of the Sickle implementation contract
address public immutable implementation;
/// @notice Address of the previous SickleFactory contract (if applicable)
SickleFactory public immutable previousFactory;
/// @notice Whether the factory is active (can deploy new Sickle contracts)
bool public isActive = true;
/// WRITE FUNCTIONS ///
/// @param admin_ Address of the admin
/// @param sickleRegistry_ Address of the SickleRegistry contract
/// @param sickleImplementation_ Address of the Sickle implementation
/// contract
/// @param previousFactory_ Address of the previous SickleFactory contract
/// if applicable
constructor(
address admin_,
address sickleRegistry_,
address sickleImplementation_,
address previousFactory_
) Admin(admin_) {
registry = SickleRegistry(sickleRegistry_);
implementation = sickleImplementation_;
previousFactory = SickleFactory(previousFactory_);
}
/// @notice Update the isActive flag.
/// @dev Effectively pauses and unpauses new Sickle deployments.
/// @custom:access Restricted to protocol admin.
function setActive(bool active) external onlyAdmin {
isActive = active;
}
function _deploy(
address admin,
address approved,
bytes32 referralCode
) internal returns (address sickle) {
sickle = Clones.cloneDeterministic(
implementation, keccak256(abi.encode(admin))
);
Sickle(payable(sickle)).initialize(admin, approved);
_sickles[admin] = sickle;
_admins[sickle] = admin;
if (referralCode != bytes32(0)) {
_referralCodes[sickle] = referralCode;
}
emit Deploy(admin, sickle);
}
function _getSickle(address admin) internal returns (address sickle) {
sickle = _sickles[admin];
if (sickle != address(0)) {
return sickle;
}
if (address(previousFactory) != address(0)) {
sickle = previousFactory.sickles(admin);
if (sickle != address(0)) {
_sickles[admin] = sickle;
_admins[sickle] = admin;
_referralCodes[sickle] = previousFactory.referralCodes(sickle);
return sickle;
}
}
}
/// @notice Predict the address of a Sickle contract for a specific user
/// @param admin Address receiving the admin rights of the Sickle contract
/// @return sickle Address of the predicted Sickle contract
function predict(address admin) external view returns (address) {
bytes32 salt = keccak256(abi.encode(admin));
return Clones.predictDeterministicAddress(implementation, salt);
}
/// @notice Returns the Sickle contract for a specific user
/// @param admin Address that owns the Sickle contract
/// @return sickle Address of the Sickle contract
function sickles(address admin) external view returns (address sickle) {
sickle = _sickles[admin];
if (sickle == address(0) && address(previousFactory) != address(0)) {
sickle = previousFactory.sickles(admin);
}
}
/// @notice Returns the admin for a specific Sickle contract
/// @param sickle Address of the Sickle contract
/// @return admin Address that owns the Sickle contract
function admins(address sickle) external view returns (address admin) {
admin = _admins[sickle];
if (admin == address(0) && address(previousFactory) != address(0)) {
admin = previousFactory.admins(sickle);
}
}
/// @notice Returns the referral code for a specific Sickle contract
/// @param sickle Address of the Sickle contract
/// @return referralCode Referral code for the user
function referralCodes(address sickle)
external
view
returns (bytes32 referralCode)
{
referralCode = _referralCodes[sickle];
if (
referralCode == bytes32(0) && address(previousFactory) != address(0)
) {
referralCode = previousFactory.referralCodes(sickle);
}
}
/// @notice Deploys a new Sickle contract for a specific user, or returns
/// the existing one if it exists
/// @param admin Address receiving the admin rights of the Sickle contract
/// @param referralCode Referral code for the user
/// @return sickle Address of the deployed Sickle contract
function getOrDeploy(
address admin,
address approved,
bytes32 referralCode
) external returns (address sickle) {
if (!isActive) {
revert NotActive();
}
if (!registry.isWhitelistedCaller(msg.sender)) {
revert CallerNotWhitelisted(msg.sender);
}
if ((sickle = _getSickle(admin)) != address(0)) {
return sickle;
}
return _deploy(admin, approved, referralCode);
}
/// @notice Deploys a new Sickle contract for a specific user
/// @dev Sickle contracts are deployed with create2, the address of the
/// admin is used as a salt, so all the Sickle addresses can be pre-computed
/// and only 1 Sickle will exist per address
/// @param referralCode Referral code for the user
/// @return sickle Address of the deployed Sickle contract
function deploy(
address approved,
bytes32 referralCode
) external returns (address sickle) {
if (!isActive) {
revert NotActive();
}
if (_getSickle(msg.sender) != address(0)) {
revert SickleAlreadyDeployed();
}
return _deploy(msg.sender, approved, referralCode);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { Admin } from "contracts/base/Admin.sol";
import { TimelockAdmin } from "contracts/base/TimelockAdmin.sol";
error ConnectorNotRegistered(address target);
interface ICustomConnectorRegistry {
function connectorOf(address target) external view returns (address);
}
contract ConnectorRegistry is Admin, TimelockAdmin {
event ConnectorChanged(address target, address connector);
event CustomRegistryAdded(address registry);
event CustomRegistryRemoved(address registry);
error ConnectorAlreadySet(address target);
error ConnectorNotSet(address target);
ICustomConnectorRegistry[] public customRegistries;
mapping(ICustomConnectorRegistry => bool) public isCustomRegistry;
mapping(address target => address connector) private connectors_;
constructor(
address admin_,
address timelockAdmin_
) Admin(admin_) TimelockAdmin(timelockAdmin_) { }
/// @notice Update connector addresses for a batch of targets.
/// @dev Controls which connector contracts are used for the specified
/// targets.
/// @custom:access Restricted to protocol admin.
function setConnectors(
address[] calldata targets,
address[] calldata connectors
) external onlyAdmin {
for (uint256 i; i != targets.length;) {
if (connectors_[targets[i]] != address(0)) {
revert ConnectorAlreadySet(targets[i]);
}
connectors_[targets[i]] = connectors[i];
emit ConnectorChanged(targets[i], connectors[i]);
unchecked {
++i;
}
}
}
function updateConnectors(
address[] calldata targets,
address[] calldata connectors
) external onlyTimelockAdmin {
for (uint256 i; i != targets.length;) {
if (connectors_[targets[i]] == address(0)) {
revert ConnectorNotSet(targets[i]);
}
connectors_[targets[i]] = connectors[i];
emit ConnectorChanged(targets[i], connectors[i]);
unchecked {
++i;
}
}
}
/// @notice Append an address to the custom registries list.
/// @custom:access Restricted to protocol admin.
function addCustomRegistry(ICustomConnectorRegistry registry)
external
onlyAdmin
{
customRegistries.push(registry);
isCustomRegistry[registry] = true;
emit CustomRegistryAdded(address(registry));
}
/// @notice Replace an address in the custom registries list.
/// @custom:access Restricted to protocol admin.
function updateCustomRegistry(
uint256 index,
ICustomConnectorRegistry newRegistry
) external onlyTimelockAdmin {
address oldRegistry = address(customRegistries[index]);
isCustomRegistry[customRegistries[index]] = false;
emit CustomRegistryRemoved(oldRegistry);
customRegistries[index] = newRegistry;
isCustomRegistry[newRegistry] = true;
if (address(newRegistry) != address(0)) {
emit CustomRegistryAdded(address(newRegistry));
}
}
function connectorOf(address target) external view returns (address) {
address connector = connectors_[target];
if (connector != address(0)) {
return connector;
}
uint256 length = customRegistries.length;
for (uint256 i; i != length;) {
if (address(customRegistries[i]) != address(0)) {
try customRegistries[i].connectorOf(target) returns (
address _connector
) {
if (_connector != address(0)) {
return _connector;
}
} catch {
// Ignore
}
}
unchecked {
++i;
}
}
revert ConnectorNotRegistered(target);
}
function hasConnector(address target) external view returns (bool) {
if (connectors_[target] != address(0)) {
return true;
}
uint256 length = customRegistries.length;
for (uint256 i; i != length;) {
if (address(customRegistries[i]) != address(0)) {
try customRegistries[i].connectorOf(target) returns (
address _connector
) {
if (_connector != address(0)) {
return true;
}
} catch {
// Ignore
}
unchecked {
++i;
}
}
}
return false;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { SickleStorage } from "contracts/base/SickleStorage.sol";
import { Multicall } from "contracts/base/Multicall.sol";
import { SickleRegistry } from "contracts/SickleRegistry.sol";
/// @title Sickle contract
/// @author vfat.tools
/// @notice Sickle facilitates farming and interactions with MasterChef
/// contracts
/// @dev Base contract inheriting from all the other "manager" contracts
contract Sickle is SickleStorage, Multicall {
/// @notice Function to receive ETH
receive() external payable { }
/// @param sickleRegistry_ Address of the SickleRegistry contract
constructor(SickleRegistry sickleRegistry_)
initializer
Multicall(sickleRegistry_)
{
_Sickle_initialize(address(0), address(0));
}
/// @param sickleOwner_ Address of the Sickle owner
function initialize(
address sickleOwner_,
address approved_
) external initializer {
_Sickle_initialize(sickleOwner_, approved_);
}
/// INTERNALS ///
function _Sickle_initialize(
address sickleOwner_,
address approved_
) internal {
SickleStorage._SickleStorage_initialize(sickleOwner_, approved_);
}
function onERC721Received(
address, // operator
address, // from
uint256, // tokenId
bytes calldata // data
) external pure returns (bytes4) {
return this.onERC721Received.selector;
}
function onERC1155Received(
address, // operator
address, // from
uint256, // id
uint256, // value
bytes calldata // data
) external pure returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address, // operator
address, // from
uint256[] calldata, // ids
uint256[] calldata, // values
bytes calldata // data
) external pure returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { Sickle } from "contracts/Sickle.sol";
import {
DepositParams,
HarvestParams,
WithdrawParams
} from "contracts/structs/FarmStrategyStructs.sol";
import { NftInfo } from "contracts/interfaces/INftSettingsRegistry.sol";
struct RebalanceParams {
NftInfo nftInfo;
HarvestParams harvestParams;
WithdrawParams withdrawParams;
DepositParams depositParams;
}
interface IRebalanceable {
function rebalanceFor(
Sickle sickle,
RebalanceParams calldata params,
address[] calldata sweepTokens
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { ZapInData, ZapOutData } from "contracts/libraries/ZapLib.sol";
import { SwapData } from "contracts/interfaces/ILiquidityConnector.sol";
struct DepositParams {
address stakingContractAddress;
address[] tokensIn;
uint256[] amountsIn;
ZapInData zapData;
bytes extraData;
}
struct WithdrawParams {
address stakingContractAddress;
bytes extraData;
ZapOutData zapData;
address[] tokensOut;
}
struct HarvestParams {
address stakingContractAddress;
SwapData[] swaps;
bytes extraData;
address[] tokensOut;
}
struct CompoundParams {
address claimContractAddress;
bytes claimExtraData;
address[] rewardTokens;
ZapInData zapData;
address depositContractAddress;
bytes depositExtraData;
}// 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.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
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {ERC20} from "../tokens/ERC20.sol";
/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error ETHTransferFailed();
error TransferFromFailed();
error TransferFailed();
error ApproveFailed();
/*//////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
if (!success) revert ETHTransferFailed();
}
/*//////////////////////////////////////////////////////////////
ERC20 OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferFrom(
address token,
address from,
address to,
uint256 amount
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument.
mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
)
}
if (!success) revert TransferFromFailed();
}
function safeTransfer(
address token,
address to,
uint256 amount
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
if (!success) revert TransferFailed();
}
function safeApprove(
address token,
address to,
uint256 amount
) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
if (!success) revert ApproveFailed();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
struct AddLiquidityData {
address router;
address lpToken;
address[] tokens;
uint256[] desiredAmounts;
uint256[] minAmounts;
bytes extraData;
}
struct RemoveLiquidityData {
address router;
address lpToken;
address[] tokens;
uint256 lpAmountIn;
uint256[] minAmountsOut;
bytes extraData;
}
struct SwapData {
address router;
uint256 amountIn;
uint256 minAmountOut;
address tokenIn;
bytes extraData;
}
interface ILiquidityConnector {
function addLiquidity(AddLiquidityData memory addLiquidityData)
external
payable;
function removeLiquidity(RemoveLiquidityData memory removeLiquidityData)
external;
function swapExactTokensForTokens(SwapData memory swapData)
external
payable;
}// 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 { DelegateModule } from "contracts/modules/DelegateModule.sol";
import { ConnectorRegistry } from "contracts/ConnectorRegistry.sol";
import {
ILiquidityConnector,
SwapData
} from "contracts/interfaces/ILiquidityConnector.sol";
contract SwapLib is DelegateModule {
error SwapAmountZero();
ConnectorRegistry immutable connectorRegistry;
constructor(ConnectorRegistry connectorRegistry_) {
connectorRegistry = connectorRegistry_;
}
function swap(SwapData memory swapData) external payable {
_swap(swapData);
}
function swapMultiple(SwapData[] memory swapData) external {
uint256 swapDataLength = swapData.length;
for (uint256 i; i < swapDataLength;) {
_swap(swapData[i]);
unchecked {
i++;
}
}
}
/* Internal Functions */
function _swap(SwapData memory swapData) internal {
address tokenIn = swapData.tokenIn;
if (swapData.amountIn == 0) {
swapData.amountIn = IERC20(tokenIn).balanceOf(address(this));
}
if (swapData.amountIn == 0) {
revert SwapAmountZero();
}
// In case there is USDT dust approval, revoke it
SafeTransferLib.safeApprove(tokenIn, swapData.router, 0);
SafeTransferLib.safeApprove(tokenIn, swapData.router, swapData.amountIn);
address connectorAddress =
connectorRegistry.connectorOf(swapData.router);
ILiquidityConnector routerConnector =
ILiquidityConnector(connectorAddress);
_delegateTo(
address(routerConnector),
abi.encodeCall(routerConnector.swapExactTokensForTokens, swapData)
);
// Revoke any approval after swap in case the swap amount was estimated
SafeTransferLib.safeApprove(tokenIn, swapData.router, 0);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract DelegateModule {
function _delegateTo(
address to,
bytes memory data
) internal returns (bytes memory) {
(bool success, bytes memory result) = to.delegatecall(data);
if (!success) {
if (result.length == 0) revert();
assembly {
revert(add(32, result), mload(result))
}
}
return result;
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {ERC20} from "./ERC20.sol";
import {SafeTransferLib} from "../utils/SafeTransferLib.sol";
/// @notice Minimalist and modern Wrapped Ether implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/WETH.sol)
/// @author Inspired by WETH9 (https://github.com/dapphub/ds-weth/blob/master/src/weth9.sol)
contract WETH is ERC20("Wrapped Ether", "WETH", 18) {
using SafeTransferLib for address;
event Deposit(address indexed from, uint256 amount);
event Withdrawal(address indexed to, uint256 amount);
function deposit() public payable virtual {
_mint(msg.sender, msg.value);
emit Deposit(msg.sender, msg.value);
}
function withdraw(uint256 amount) public virtual {
_burn(msg.sender, amount);
emit Withdrawal(msg.sender, amount);
msg.sender.safeTransferETH(amount);
}
receive() external payable virtual {
deposit();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { Admin } from "contracts/base/Admin.sol";
library SickleRegistryEvents {
event CollectorChanged(address newCollector);
event FeesUpdated(bytes32[] feeHashes, uint256[] feesInBP);
event ReferralCodeCreated(bytes32 indexed code, address indexed referrer);
// Multicall caller and target whitelist status changes
event CallerStatusChanged(address caller, bool isWhitelisted);
event TargetStatusChanged(address target, bool isWhitelisted);
}
/// @title SickleRegistry contract
/// @author vfat.tools
/// @notice Manages the whitelisted contracts and the collector address
contract SickleRegistry is Admin {
/// ERRORS ///
error ArrayLengthMismatch(); // 0xa24a13a6
error FeeAboveMaxLimit(); // 0xd6cf7b5e
error InvalidReferralCode(); // 0xe55b4629
/// STORAGE ///
/// @notice Address of the fee collector
address public collector;
/// @notice Tracks the contracts that can be called through Sickle multicall
/// @return True if the contract is a whitelisted target
mapping(address => bool) public isWhitelistedTarget;
/// @notice Tracks the contracts that can call Sickle multicall
/// @return True if the contract is a whitelisted caller
mapping(address => bool) public isWhitelistedCaller;
/// @notice Keeps track of the referrers and their associated code
mapping(bytes32 => address) public referralCodes;
/// @notice Mapping for fee hashes (hash of the strategy contract addresses
/// and the function selectors) and their associated fees
/// @return The fee in basis points to apply to the transaction amount
mapping(bytes32 => uint256) public feeRegistry;
/// WRITE FUNCTIONS ///
/// @param admin_ Address of the admin
/// @param collector_ Address of the collector
constructor(address admin_, address collector_) Admin(admin_) {
collector = collector_;
}
/// @notice Updates the whitelist status for multiple multicall targets
/// @param targets Addresses of the contracts to update
/// @param isApproved New status for the contracts
/// @custom:access Restricted to protocol admin.
function setWhitelistedTargets(
address[] calldata targets,
bool isApproved
) external onlyAdmin {
for (uint256 i; i < targets.length;) {
isWhitelistedTarget[targets[i]] = isApproved;
emit SickleRegistryEvents.TargetStatusChanged(
targets[i], isApproved
);
unchecked {
++i;
}
}
}
/// @notice Updates the fee collector address
/// @param newCollector Address of the new fee collector
/// @custom:access Restricted to protocol admin.
function updateCollector(address newCollector) external onlyAdmin {
collector = newCollector;
emit SickleRegistryEvents.CollectorChanged(newCollector);
}
/// @notice Update the whitelist status for multiple multicall callers
/// @param callers Addresses of the callers
/// @param isApproved New status for the caller
/// @custom:access Restricted to protocol admin.
function setWhitelistedCallers(
address[] calldata callers,
bool isApproved
) external onlyAdmin {
for (uint256 i; i < callers.length;) {
isWhitelistedCaller[callers[i]] = isApproved;
emit SickleRegistryEvents.CallerStatusChanged(
callers[i], isApproved
);
unchecked {
++i;
}
}
}
/// @notice Associates a referral code to the address of the caller
function setReferralCode(bytes32 referralCode) external {
if (referralCodes[referralCode] != address(0)) {
revert InvalidReferralCode();
}
referralCodes[referralCode] = msg.sender;
emit SickleRegistryEvents.ReferralCodeCreated(referralCode, msg.sender);
}
/// @notice Update the fees for multiple strategy functions
/// @param feeHashes Array of fee hashes
/// @param feesArray Array of fees to apply (in basis points)
/// @custom:access Restricted to protocol admin.
function setFees(
bytes32[] calldata feeHashes,
uint256[] calldata feesArray
) external onlyAdmin {
if (feeHashes.length != feesArray.length) {
revert ArrayLengthMismatch();
}
for (uint256 i = 0; i < feeHashes.length;) {
if (feesArray[i] <= 500) {
// maximum fee of 5%
feeRegistry[feeHashes[i]] = feesArray[i];
} else {
revert FeeAboveMaxLimit();
}
unchecked {
++i;
}
}
emit SickleRegistryEvents.FeesUpdated(feeHashes, feesArray);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract MsgValueModule {
error IncorrectMsgValue();
function _checkMsgValue(uint256 inputAmount, bool isNative) internal {
if (
// Input is native token but user sent incorrect amount
(isNative && inputAmount != msg.value)
// Input is ERC20 but user sent native token as well
|| (!isNative && msg.value > 0)
) {
revert IncorrectMsgValue();
}
}
}// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/Clones.sol)
pragma solidity ^0.8.0;
/**
* @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
* deploying minimal proxy contracts, also known as "clones".
*
* > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
* > a minimal bytecode implementation that delegates all calls to a known, fixed address.
*
* The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
* (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
* deterministic method.
*
* _Available since v3.4._
*/
library Clones {
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create opcode, which should never revert.
*/
function clone(address implementation) internal returns (address instance) {
/// @solidity memory-safe-assembly
assembly {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create(0, 0x09, 0x37)
}
require(instance != address(0), "ERC1167: create failed");
}
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create2 opcode and a `salt` to deterministically deploy
* the clone. Using the same `implementation` and `salt` multiple time will revert, since
* the clones cannot be deployed twice at the same address.
*/
function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
/// @solidity memory-safe-assembly
assembly {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create2(0, 0x09, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt,
address deployer
) internal pure returns (address predicted) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(add(ptr, 0x38), deployer)
mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
mstore(add(ptr, 0x14), implementation)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
mstore(add(ptr, 0x58), salt)
mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
predicted := keccak256(add(ptr, 0x43), 0x55)
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(address implementation, bytes32 salt)
internal
view
returns (address predicted)
{
return predictDeterministicAddress(implementation, salt, address(this));
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
/// @title Admin contract
/// @author vfat.tools
/// @notice Provides an administration mechanism allowing restricted functions
abstract contract Admin {
/// ERRORS ///
/// @notice Thrown when the caller is not the admin
error NotAdminError(); //0xb5c42b3b
/// EVENTS ///
/// @notice Emitted when a new admin is set
/// @param oldAdmin Address of the old admin
/// @param newAdmin Address of the new admin
event AdminSet(address oldAdmin, address newAdmin);
/// STORAGE ///
/// @notice Address of the current admin
address public admin;
/// MODIFIERS ///
/// @dev Restricts a function to the admin
modifier onlyAdmin() {
if (msg.sender != admin) revert NotAdminError();
_;
}
/// WRITE FUNCTIONS ///
/// @param admin_ Address of the admin
constructor(address admin_) {
emit AdminSet(admin, admin_);
admin = admin_;
}
/// @notice Sets a new admin
/// @param newAdmin Address of the new admin
/// @custom:access Restricted to protocol admin.
function setAdmin(address newAdmin) external onlyAdmin {
emit AdminSet(admin, newAdmin);
admin = newAdmin;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
/// @title TimelockAdmin contract
/// @author vfat.tools
/// @notice Provides an timelockAdministration mechanism allowing restricted
/// functions
abstract contract TimelockAdmin {
/// ERRORS ///
/// @notice Thrown when the caller is not the timelockAdmin
error NotTimelockAdminError();
/// EVENTS ///
/// @notice Emitted when a new timelockAdmin is set
/// @param oldTimelockAdmin Address of the old timelockAdmin
/// @param newTimelockAdmin Address of the new timelockAdmin
event TimelockAdminSet(address oldTimelockAdmin, address newTimelockAdmin);
/// STORAGE ///
/// @notice Address of the current timelockAdmin
address public timelockAdmin;
/// MODIFIERS ///
/// @dev Restricts a function to the timelockAdmin
modifier onlyTimelockAdmin() {
if (msg.sender != timelockAdmin) revert NotTimelockAdminError();
_;
}
/// WRITE FUNCTIONS ///
/// @param timelockAdmin_ Address of the timelockAdmin
constructor(address timelockAdmin_) {
emit TimelockAdminSet(timelockAdmin, timelockAdmin_);
timelockAdmin = timelockAdmin_;
}
/// @notice Sets a new timelockAdmin
/// @dev Can only be called by the current timelockAdmin
/// @param newTimelockAdmin Address of the new timelockAdmin
function setTimelockAdmin(address newTimelockAdmin)
external
onlyTimelockAdmin
{
emit TimelockAdminSet(timelockAdmin, newTimelockAdmin);
timelockAdmin = newTimelockAdmin;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { Initializable } from
"@openzeppelin/contracts/proxy/utils/Initializable.sol";
library SickleStorageEvents {
event ApprovedAddressChanged(address newApproved);
}
/// @title SickleStorage contract
/// @author vfat.tools
/// @notice Base storage of the Sickle contract
/// @dev This contract needs to be inherited by stub contracts meant to be used
/// with `delegatecall`
abstract contract SickleStorage is Initializable {
/// ERRORS ///
/// @notice Thrown when the caller is not the owner of the Sickle contract
error NotOwnerError(); // 0x74a21527
/// @notice Thrown when the caller is not a strategy contract or the
/// Flashloan Stub
error NotStrategyError(); // 0x4581ba62
/// STORAGE ///
/// @notice Address of the owner
address public owner;
/// @notice An address that can be set by the owner of the Sickle contract
/// in order to trigger specific functions.
address public approved;
/// MODIFIERS ///
/// @dev Restricts a function call to the owner, however if the admin was
/// not set yet,
/// the modifier will not restrict the call, this allows the SickleFactory
/// to perform
/// some calls on the user's behalf before passing the admin rights to them
modifier onlyOwner() {
if (msg.sender != owner) revert NotOwnerError();
_;
}
/// INITIALIZATION ///
/// @param owner_ Address of the owner of this Sickle contract
function _SickleStorage_initialize(
address owner_,
address approved_
) internal onlyInitializing {
owner = owner_;
approved = approved_;
}
/// WRITE FUNCTIONS ///
/// @notice Sets the approved address of this Sickle
/// @param newApproved Address meant to be approved by the owner
function setApproved(address newApproved) external onlyOwner {
approved = newApproved;
emit SickleStorageEvents.ApprovedAddressChanged(newApproved);
}
/// @notice Checks if `caller` is either the owner of the Sickle contract
/// or was approved by them
/// @param caller Address to check
/// @return True if `caller` is either the owner of the Sickle contract
function isOwnerOrApproved(address caller) public view returns (bool) {
return caller == owner || caller == approved;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { SickleStorage } from "contracts/base/SickleStorage.sol";
import { SickleRegistry } from "contracts/SickleRegistry.sol";
/// @title Multicall contract
/// @author vfat.tools
/// @notice Enables calling multiple methods in a single call to the contract
abstract contract Multicall is SickleStorage {
/// ERRORS ///
error MulticallParamsMismatchError(); // 0xc1e637c9
/// @notice Thrown when the target contract is not whitelisted
/// @param target Address of the non-whitelisted target
error TargetNotWhitelisted(address target); // 0x47ccabe7
/// @notice Thrown when the caller is not whitelisted
/// @param caller Address of the non-whitelisted caller
error CallerNotWhitelisted(address caller); // 0x252c8273
/// STORAGE ///
/// @notice Address of the SickleRegistry contract
/// @dev Needs to be immutable so that it's accessible for Sickle proxies
SickleRegistry public immutable registry;
/// INITIALIZATION ///
/// @param registry_ Address of the SickleRegistry contract
constructor(SickleRegistry registry_) initializer {
registry = registry_;
}
/// WRITE FUNCTIONS ///
/// @notice Batch multiple calls together (calls or delegatecalls)
/// @param targets Array of targets to call
/// @param data Array of data to pass with the calls
function multicall(
address[] calldata targets,
bytes[] calldata data
) external payable {
if (targets.length != data.length) {
revert MulticallParamsMismatchError();
}
if (!registry.isWhitelistedCaller(msg.sender)) {
revert CallerNotWhitelisted(msg.sender);
}
for (uint256 i = 0; i != data.length;) {
if (targets[i] == address(0)) {
unchecked {
++i;
}
continue; // No-op
}
if (targets[i] != address(this)) {
if (!registry.isWhitelistedTarget(targets[i])) {
revert TargetNotWhitelisted(targets[i]);
}
}
(bool success, bytes memory result) =
targets[i].delegatecall(data[i]);
if (!success) {
if (result.length == 0) revert();
assembly {
revert(add(32, result), mload(result))
}
}
unchecked {
++i;
}
}
}
}// 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: 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.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
// 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
// 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
// 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);
}{
"remappings": [
"solmate/=lib/solmate/src/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@uniswap/v3-periphery/=lib/v3-periphery/",
"@uniswap/v3-core/=lib/v3-core/",
"@morpho-blue/=lib/morpho-blue/src/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"morpho-blue/=lib/morpho-blue/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract SickleFactory","name":"factory","type":"address"},{"internalType":"contract ConnectorRegistry","name":"connectorRegistry","type":"address"},{"components":[{"internalType":"contract ZapLib","name":"zapLib","type":"address"},{"internalType":"contract FeesLib","name":"feesLib","type":"address"},{"internalType":"contract TransferLib","name":"transferLib","type":"address"},{"internalType":"contract NftSettingsLib","name":"nftSettingsLib","type":"address"}],"internalType":"struct RebalanceStrategy.Libraries","name":"libraries","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AutoRebalanceNotSet","type":"error"},{"inputs":[],"name":"CompoundAndHarvestBothSet","type":"error"},{"inputs":[],"name":"CompoundOrHarvestNotSet","type":"error"},{"inputs":[],"name":"InvalidMaxTickHigh","type":"error"},{"inputs":[],"name":"InvalidMinMaxTickRange","type":"error"},{"inputs":[],"name":"InvalidMinTickLow","type":"error"},{"inputs":[],"name":"InvalidSlippageBP","type":"error"},{"inputs":[],"name":"InvalidTokenOut","type":"error"},{"inputs":[],"name":"NftSupplyChanged","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":"OnlySickle","type":"error"},{"inputs":[],"name":"RebalanceConfigNotSet","type":"error"},{"inputs":[],"name":"SickleNotDeployed","type":"error"},{"inputs":[],"name":"TickOutsideStopLossRange","type":"error"},{"inputs":[],"name":"TickWithinRange","type":"error"},{"inputs":[],"name":"TokenOutRequired","type":"error"},{"anonymous":false,"inputs":[{"components":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"internalType":"contract INonfungiblePositionManager","name":"nftManager","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"indexed":false,"internalType":"struct NftKey","name":"key","type":"tuple"},{"components":[{"internalType":"bool","name":"autoRebalance","type":"bool"},{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"},{"components":[{"internalType":"uint24","name":"diffToRebalanceBelowTick","type":"uint24"},{"internalType":"uint24","name":"diffToRebalanceAboveTick","type":"uint24"},{"internalType":"uint256","name":"slippageBP","type":"uint256"},{"internalType":"int24","name":"stopLossTickLow","type":"int24"},{"internalType":"int24","name":"stopLossTickHigh","type":"int24"},{"internalType":"uint8","name":"delayMin","type":"uint8"}],"internalType":"struct RebalanceConfig","name":"rebalanceConfig","type":"tuple"}],"indexed":false,"internalType":"struct NftSettings","name":"settings","type":"tuple"}],"name":"NftSettingsSet","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"internalType":"contract INonfungiblePositionManager","name":"nftManager","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"indexed":false,"internalType":"struct NftKey","name":"key","type":"tuple"}],"name":"NftSettingsUnset","type":"event"},{"inputs":[],"name":"connectorRegistry","outputs":[{"internalType":"contract ConnectorRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"contract SickleFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feesLib","outputs":[{"internalType":"contract FeesLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"internalType":"contract INonfungiblePositionManager","name":"nftManager","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NftKey","name":"key","type":"tuple"}],"name":"getNftSettings","outputs":[{"components":[{"internalType":"bool","name":"autoRebalance","type":"bool"},{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"},{"components":[{"internalType":"uint24","name":"diffToRebalanceBelowTick","type":"uint24"},{"internalType":"uint24","name":"diffToRebalanceAboveTick","type":"uint24"},{"internalType":"uint256","name":"slippageBP","type":"uint256"},{"internalType":"int24","name":"stopLossTickLow","type":"int24"},{"internalType":"int24","name":"stopLossTickHigh","type":"int24"},{"internalType":"uint8","name":"delayMin","type":"uint8"}],"internalType":"struct RebalanceConfig","name":"rebalanceConfig","type":"tuple"}],"internalType":"struct NftSettings","name":"","type":"tuple"}],"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":[{"internalType":"contract IPreviousRebalanceRegistry","name":"previousRebalanceRegistry","type":"address"},{"internalType":"contract INonfungiblePositionManager","name":"nftManager","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"migrateNftSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nftSettingsLib","outputs":[{"internalType":"contract NftSettingsLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IUniswapV3Pool","name":"pool","type":"address"},{"components":[{"internalType":"address","name":"stakingContractAddress","type":"address"},{"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 SwapData[]","name":"swaps","type":"tuple[]"},{"internalType":"bytes","name":"extraData","type":"bytes"},{"internalType":"address[]","name":"tokensOut","type":"address[]"}],"internalType":"struct HarvestParams","name":"harvestParams","type":"tuple"},{"components":[{"internalType":"address","name":"stakingContractAddress","type":"address"},{"internalType":"bytes","name":"extraData","type":"bytes"},{"components":[{"components":[{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"lpToken","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256","name":"lpAmountIn","type":"uint256"},{"internalType":"uint256[]","name":"minAmountsOut","type":"uint256[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct RemoveLiquidityData","name":"removeLiquidityData","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 SwapData[]","name":"swaps","type":"tuple[]"}],"internalType":"struct ZapOutData","name":"zapData","type":"tuple"},{"internalType":"address[]","name":"tokensOut","type":"address[]"}],"internalType":"struct WithdrawParams","name":"withdrawParams","type":"tuple"},{"components":[{"internalType":"address","name":"stakingContractAddress","type":"address"},{"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 SwapData[]","name":"swaps","type":"tuple[]"},{"components":[{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"lpToken","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"desiredAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"minAmounts","type":"uint256[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct AddLiquidityData","name":"addLiquidityData","type":"tuple"}],"internalType":"struct ZapInData","name":"zapData","type":"tuple"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct DepositParams","name":"depositParams","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"rebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"components":[{"components":[{"internalType":"contract IUniswapV3Pool","name":"pool","type":"address"},{"internalType":"contract INonfungiblePositionManager","name":"nftManager","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NftInfo","name":"nftInfo","type":"tuple"},{"components":[{"internalType":"address","name":"stakingContractAddress","type":"address"},{"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 SwapData[]","name":"swaps","type":"tuple[]"},{"internalType":"bytes","name":"extraData","type":"bytes"},{"internalType":"address[]","name":"tokensOut","type":"address[]"}],"internalType":"struct HarvestParams","name":"harvestParams","type":"tuple"},{"components":[{"internalType":"address","name":"stakingContractAddress","type":"address"},{"internalType":"bytes","name":"extraData","type":"bytes"},{"components":[{"components":[{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"lpToken","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256","name":"lpAmountIn","type":"uint256"},{"internalType":"uint256[]","name":"minAmountsOut","type":"uint256[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct RemoveLiquidityData","name":"removeLiquidityData","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 SwapData[]","name":"swaps","type":"tuple[]"}],"internalType":"struct ZapOutData","name":"zapData","type":"tuple"},{"internalType":"address[]","name":"tokensOut","type":"address[]"}],"internalType":"struct WithdrawParams","name":"withdrawParams","type":"tuple"},{"components":[{"internalType":"address","name":"stakingContractAddress","type":"address"},{"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 SwapData[]","name":"swaps","type":"tuple[]"},{"components":[{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"lpToken","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"desiredAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"minAmounts","type":"uint256[]"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct AddLiquidityData","name":"addLiquidityData","type":"tuple"}],"internalType":"struct ZapInData","name":"zapData","type":"tuple"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct DepositParams","name":"depositParams","type":"tuple"}],"internalType":"struct RebalanceParams","name":"params","type":"tuple"},{"internalType":"address[]","name":"sweepTokens","type":"address[]"}],"name":"rebalanceFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"internalType":"contract INonfungiblePositionManager","name":"nftManager","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NftKey","name":"oldKey","type":"tuple"},{"components":[{"internalType":"contract Sickle","name":"sickle","type":"address"},{"internalType":"contract INonfungiblePositionManager","name":"nftManager","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct NftKey","name":"newKey","type":"tuple"},{"components":[{"internalType":"bool","name":"autoRebalance","type":"bool"},{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"},{"components":[{"internalType":"uint24","name":"diffToRebalanceBelowTick","type":"uint24"},{"internalType":"uint24","name":"diffToRebalanceAboveTick","type":"uint24"},{"internalType":"uint256","name":"slippageBP","type":"uint256"},{"internalType":"int24","name":"stopLossTickLow","type":"int24"},{"internalType":"int24","name":"stopLossTickHigh","type":"int24"},{"internalType":"uint8","name":"delayMin","type":"uint8"}],"internalType":"struct RebalanceConfig","name":"rebalanceConfig","type":"tuple"}],"internalType":"struct NftSettings","name":"settings","type":"tuple"}],"name":"resetNftSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract INonfungiblePositionManager","name":"nftManager","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"bool","name":"autoRebalance","type":"bool"},{"internalType":"enum RewardBehavior","name":"rewardBehavior","type":"uint8"},{"internalType":"address","name":"harvestTokenOut","type":"address"},{"components":[{"internalType":"uint24","name":"diffToRebalanceBelowTick","type":"uint24"},{"internalType":"uint24","name":"diffToRebalanceAboveTick","type":"uint24"},{"internalType":"uint256","name":"slippageBP","type":"uint256"},{"internalType":"int24","name":"stopLossTickLow","type":"int24"},{"internalType":"int24","name":"stopLossTickHigh","type":"int24"},{"internalType":"uint8","name":"delayMin","type":"uint8"}],"internalType":"struct RebalanceConfig","name":"rebalanceConfig","type":"tuple"}],"internalType":"struct NftSettings","name":"settings","type":"tuple"}],"name":"setNftSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"strategyAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferLib","outputs":[{"internalType":"contract TransferLib","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract INonfungiblePositionManager","name":"nftManager","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"unsetNftSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"zapLib","outputs":[{"internalType":"contract ZapLib","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6101606040523480156200001257600080fd5b5060405162003a9b38038062003a9b8339810160408190526200003591620000a4565b6001600160a01b0392831660805290821660a05230610140528051821660c0526020810151821660e05260408101518216610100526060015116610120526200017b565b6001600160a01b03811681146200008f57600080fd5b50565b80516200009f8162000079565b919050565b600080600083850360c0811215620000bb57600080fd5b8451620000c88162000079565b6020860151909450620000db8162000079565b92506080603f1982011215620000f057600080fd5b50604051608081016001600160401b03811182821017156200012257634e487b7160e01b600052604160045260246000fd5b8060405250620001356040860162000092565b8152620001456060860162000092565b6020820152620001586080860162000092565b60408201526200016b60a0860162000092565b6060820152809150509250925092565b60805160a05160c05160e051610100516101205161014051613816620002856000396000818161026a0152818161070501528181610a6401528181610c27015281816117670152611a7f0152600081816101320152610bd40152600081816101bd01528181610e4d0152611d43015260008181610196015281816106b901528181610a190152818161171b0152611a2b0152600081816102cb0152818161095801528181610b13015281816119780152611b1301526000818161024301528181610554015281816107c701528181610ca5015281816115e2015281816118130152611bc601526000818161029101528181610311015281816114aa0152611e8c01526138166000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c8063759cb23411610097578063bc6b74ab11610066578063bc6b74ab14610265578063c45a01551461028c578063d276ae66146102b3578063ee360f24146102c657600080fd5b8063759cb23414610205578063a81fa02b14610218578063b3fb68d51461022b578063b53c86d21461023e57600080fd5b80632af3fa1b116100d35780632af3fa1b146101915780633fb53a0d146101b85780634b105efb146101df57806357181ab0146101f257600080fd5b806301b31cd0146101055780631d86d38a1461011a5780631de7354b1461012d578063228ca08714610171575b600080fd5b610118610113366004612677565b6102ed565b005b610118610128366004612751565b610ff8565b6101547f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b61018461017f36600461282b565b61109c565b6040516101689190612944565b6101547f000000000000000000000000000000000000000000000000000000000000000081565b6101547f000000000000000000000000000000000000000000000000000000000000000081565b6101186101ed366004612977565b6111ea565b610118610200366004612a34565b61144b565b610154610213366004612a60565b611486565b610118610226366004612afe565b611544565b610154610239366004612bc6565b611e5b565b6101547f000000000000000000000000000000000000000000000000000000000000000081565b6101547f000000000000000000000000000000000000000000000000000000000000000081565b6101547f000000000000000000000000000000000000000000000000000000000000000081565b6101186102c1366004612c07565b611f05565b6101547f000000000000000000000000000000000000000000000000000000000000000081565b60405163429b62e560e01b81526001600160a01b03808616600483015285916000917f0000000000000000000000000000000000000000000000000000000000000000169063429b62e590602401602060405180830381865afa158015610358573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037c9190612c4e565b6001600160a01b0316036103a357604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040f9190612c4e565b6001600160a01b0316146104365760405163c19f17a960e01b815260040160405180910390fd5b6104436080850185612c6b565b610451906060810190612c8b565b90506000036104735760405163f806256560e01b815260040160405180910390fd5b61047d8585611f51565b600061048f6040860160208701612a60565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f09190612cdc565b6040805160098082526101408201909252919250600091906020820161012080368337505060408051600980825261014082019092529293506000929150602082015b60608152602001906001900390816105335790505090506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae61058660608a018a612c6b565b610594906020810190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156105d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fc9190612c4e565b8260008151811061060f5761060f612cf5565b6001600160a01b03909216602092830291909101909101526106346060880188612c6b565b610642906020810190612a60565b61064f6060890189612c6b565b61065d906040810190612d0b565b60405160240161066f93929190612d7b565b60408051601f198184030181529190526020810180516001600160e01b031663bb1757cf60e01b179052815182906000906106ac576106ac612cf5565b60200260200101819052507f0000000000000000000000000000000000000000000000000000000000000000826001815181106106eb576106eb612cf5565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000000000000000000000000000000000000000000007fd5778d3b4056634f1858eb1a0d41471ae1408b6973787dacb8f7fc585e82bdc061075260608a018a612c6b565b610760906060810190612c8b565b6040516024016107739493929190612df2565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b1790528151829060019081106107b2576107b2612cf5565b60209081029190910101526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae6107f960808a018a612c6b565b610807906020810190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561084b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086f9190612c4e565b8260028151811061088257610882612cf5565b6001600160a01b03909216602092830291909101909101526108a76080880188612c6b565b6108b5906020810190612a60565b6108c26080890189612c6b565b6108d0906040810190612e31565b6108da9080612e47565b606001356108eb60808a018a612c6b565b6108f9906020810190612d0b565b60405160240161090c9493929190612e5d565b60408051601f198184030181529190526020810180516001600160e01b03166331f0926560e01b17905281518290600290811061094b5761094b612cf5565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000008260038151811061098a5761098a612cf5565b6001600160a01b03909216602092830291909101909101526109af6080880188612c6b565b6109bd906040810190612e31565b6040516024016109cd9190613064565b60408051601f198184030181529190526020810180516001600160e01b031663071605b760e11b179052815182906003908110610a0c57610a0c612cf5565b60200260200101819052507f000000000000000000000000000000000000000000000000000000000000000082600481518110610a4b57610a4b612cf5565b6001600160a01b039092166020928302919091018201527f000000000000000000000000000000000000000000000000000000000000000090610a9990610a94908a018a612a60565b612125565b610aa660808a018a612c6b565b610ab4906060810190612c8b565b604051602401610ac79493929190612df2565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b179052815182906004908110610b0657610b06612cf5565b60200260200101819052507f000000000000000000000000000000000000000000000000000000000000000082600581518110610b4557610b45612cf5565b6001600160a01b0390921660209283029190910190910152610b6a60a0880188613153565b610b78906060810190612e31565b604051602401610b889190613169565b60408051601f198184030181529190526020810180516001600160e01b031663cd5f81a960e01b179052815182906005908110610bc757610bc7612cf5565b60200260200101819052507f000000000000000000000000000000000000000000000000000000000000000082600681518110610c0657610c06612cf5565b6001600160a01b0390921660209283029190910190910152604051610c51907f0000000000000000000000000000000000000000000000000000000000000000908990602401613271565b60408051601f198184030181529190526020810180516001600160e01b0316632fec330f60e01b179052815182906006908110610c9057610c90612cf5565b60209081029190910101526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae610cd760a08a018a613153565b610ce5906020810190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610d29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4d9190612c4e565b82600781518110610d6057610d60612cf5565b6001600160a01b0390921660209283029190910190910152610d8560a0880188613153565b610d93906020810190612a60565b610da060a0890189613153565b610dae906060810190612e31565b610dbc906020810190612e47565b610dcd906040810190602001612a60565b610dda60a08a018a613153565b610de8906080810190612d0b565b604051602401610dfb94939291906132c0565b60408051601f198184030181529190526020810180516001600160e01b03166346e6744b60e01b179052815182906007908110610e3a57610e3a612cf5565b60209081029190910101528415610efd577f000000000000000000000000000000000000000000000000000000000000000082600881518110610e7f57610e7f612cf5565b60200260200101906001600160a01b031690816001600160a01b0316815250508585604051602401610eb29291906132ed565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b179052815182906008908110610ef157610ef1612cf5565b60200260200101819052505b6040516331fd85cb60e11b81526001600160a01b038916906363fb0b9690610f2b908590859060040161335e565b600060405180830381600087803b158015610f4557600080fd5b505af1158015610f59573d6000803e3d6000fd5b50610f6e925050506040880160208901612a60565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fcf9190612cdc565b8314610fee5760405163648873f960e01b815260040160405180910390fd5b5050505050505050565b33806110076020860186612a60565b6001600160a01b031614158061103b57506001600160a01b03811661102f6020850185612a60565b6001600160a01b031614155b156110595760405163b91a09e760e01b815260040160405180910390fd5b61107061106b3686900386018661282b565b612220565b6110966110823685900385018561282b565b61109136859003850185613417565b6122cd565b50505050565b604080516080808201835260008083526020808401829052838501829052845160c081018652828152908101829052938401819052606080850182905291840181905260a0840152810191909152600080836040516020016110fe9190613501565b60408051601f198184030181529181528151602092830120835282820193909352908201600020825160808101909352805460ff80821615158552919284019161010090910416600181111561115657611156612896565b600181111561116757611167612896565b815281546201000090046001600160a01b03166020808301919091526040805160c081018252600185015462ffffff808216835263010000009182900416938201939093526002808601548284015260039095015480860b606083015292830490940b6080850152660100000000000090910460ff1660a0840152015292915050565b60006111f533611486565b825190915060005b818110156114435760006040518060600160405280856001600160a01b03168152602001876001600160a01b0316815260200186848151811061124257611242612cf5565b602002602001015181525090506000876001600160a01b031663934743f2836040518263ffffffff1660e01b815260040161127d9190613501565b60c0604051808303816000875af115801561129c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c0919061353b565b9050600080886001600160a01b03166399fbab8885604001516040518263ffffffff1660e01b81526004016112f791815260200190565b61018060405180830381865afa158015611315573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133991906135ea565b5050505050965096505050505050600083600001518361135991906136e1565b9050600082856020015161136d91906136e1565b905060008260020b121561138057600091505b60008160020b1215611390575060005b60006040518060c001604052808462ffffff1681526020018362ffffff16815260200187604001518152602001876060015160020b8152602001876080015160020b81526020018760a0015160ff168152509050600060405180608001604052806001151581526020016000600181111561140d5761140d612896565b815260006020820152604001839052905061142888826122cd565b5050505050505050808061143b90613706565b9150506111fd565b505050505050565b600061145633611486565b604080516060810182526001600160a01b0380841682528616602082015290810184905290915061109681612220565b6040516312cfc9b560e31b81526001600160a01b03828116600483015260009182917f0000000000000000000000000000000000000000000000000000000000000000169063967e4da890602401602060405180830381865afa1580156114f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115159190612c4e565b90506001600160a01b03811661153e57604051633098a45560e01b815260040160405180910390fd5b92915050565b6115516060840184612c8b565b90506000036115735760405163f806256560e01b815260040160405180910390fd5b600061157e33611486565b6040805160088082526101208201909252919250600091906020820161010080368337505060408051600880825261012082019092529293506000929150602082015b60608152602001906001900390816115c15790505090506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001663c79aeaae61161460208a018a612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611658573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167c9190612c4e565b8260008151811061168f5761168f612cf5565b6001600160a01b039092166020928302919091018201526116b290880188612a60565b6116bf6040890189612d0b565b6040516024016116d193929190612d7b565b60408051601f198184030181529190526020810180516001600160e01b031663bb1757cf60e01b1790528151829060009061170e5761170e612cf5565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000008260018151811061174d5761174d612cf5565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000000000000000000000000000000000000000000007f5ccc4a216cefac5bdda384f8ea4b40fa5576e2fb51151b4b2ecc34a1ff7b0b796117b460608a018a612c8b565b6040516024016117c79493929190612df2565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b17905281518290600190811061180657611806612cf5565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c79aeaae8760000160208101906118539190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118bb9190612c4e565b826002815181106118ce576118ce612cf5565b6001600160a01b039092166020928302919091018201526118f190870187612a60565b6118fe6040880188612e31565b6119089080612e47565b606001356119196020890189612d0b565b60405160240161192c9493929190612e5d565b60408051601f198184030181529190526020810180516001600160e01b03166331f0926560e01b17905281518290600290811061196b5761196b612cf5565b60200260200101819052507f0000000000000000000000000000000000000000000000000000000000000000826003815181106119aa576119aa612cf5565b6001600160a01b03909216602092830291909101909101526119cf6040870187612e31565b6040516024016119df9190613064565b60408051601f198184030181529190526020810180516001600160e01b031663071605b760e11b179052815182906003908110611a1e57611a1e612cf5565b60200260200101819052507f000000000000000000000000000000000000000000000000000000000000000082600481518110611a5d57611a5d612cf5565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000000000000000000000000000000000000000000000611aa789612125565b611ab46060890189612c8b565b604051602401611ac79493929190612df2565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b179052815182906004908110611b0657611b06612cf5565b60200260200101819052507f000000000000000000000000000000000000000000000000000000000000000082600581518110611b4557611b45612cf5565b6001600160a01b0390921660209283029190910190910152611b6a6060860186612e31565b604051602401611b7a9190613169565b60408051601f198184030181529190526020810180516001600160e01b031663cd5f81a960e01b179052815182906005908110611bb957611bb9612cf5565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c79aeaae866000016020810190611c069190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611c4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c6e9190612c4e565b82600681518110611c8157611c81612cf5565b6001600160a01b03909216602092830291909101820152611ca490860186612a60565b611cb16060870187612e31565b611cbf906020810190612e47565b611cd0906040810190602001612a60565b611cdd6080880188612d0b565b604051602401611cf094939291906132c0565b60408051601f198184030181529190526020810180516001600160e01b03166346e6744b60e01b179052815182906006908110611d2f57611d2f612cf5565b6020908102919091010152835115611df1577f000000000000000000000000000000000000000000000000000000000000000082600781518110611d7557611d75612cf5565b60200260200101906001600160a01b031690816001600160a01b03168152505083604051602401611da6919061371f565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b179052815182906007908110611de557611de5612cf5565b60200260200101819052505b6040516331fd85cb60e11b81526001600160a01b038416906363fb0b9690611e1f908590859060040161335e565b600060405180830381600087803b158015611e3957600080fd5b505af1158015611e4d573d6000803e3d6000fd5b505050505050505050505050565b60405163de0d95ed60e01b81526001600160a01b0384811660048301528381166024830152604482018390526000917f00000000000000000000000000000000000000000000000000000000000000009091169063de0d95ed906064016020604051808303816000875af1158015611ed7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611efb9190612c4e565b90505b9392505050565b6000611f1033611486565b604080516060810182526001600160a01b03808416825287166020820152908101859052909150611f4a8161109136869003860186613417565b5050505050565b6000611f9e6040518060600160405280856001600160a01b03168152602001846020016020810190611f839190612a60565b6001600160a01b03168152602001846040013581525061109c565b606001519050806060015160020b6000148015611fc05750608081015160020b155b15611fde5760405163c20c00ad60e01b815260040160405180910390fd5b600080611ff16040850160208601612a60565b6001600160a01b03166399fbab8885604001356040518263ffffffff1660e01b815260040161202291815260200190565b61018060405180830381865afa158015612040573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206491906135ea565b5050505050965096505050505050600061208f85600001602081019061208a9190612a60565b6124de565b845190915061209e90846136e1565b60020b8160020b121580156120c6575060208401516120bd9083613732565b60020b8160020b125b156120e45760405163227b663760e11b815260040160405180910390fd5b836060015160020b8160020b1315806121075750836080015160020b8160020b12155b1561144357604051633015515760e01b815260040160405180910390fd5b600080826001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612166573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218a9190613757565b90506101f48162ffffff16116121c257507fcb922c4d36cde61b3660729b33f36eff74a31440cf3e852d4467b4bd6045011c92915050565b610bb88162ffffff16116121f857507fc552bcd88e8785f8a0d9f9c5b9dc4e198659e68e9f6645642142b2900cde564d92915050565b507fa7e26cbd23588e6e87ee40cb01079e973bf8a0910c2edb6bc11ba3240a81480b92915050565b600080826040516020016122349190613501565b60408051601f1981840301815291815281516020928301208352908201929092528101600090812080546001600160b01b031916815560018101805465ffffffffffff191690556002810191909155600301805466ffffffffffffff19169055517faa3b569bcc3b07fe86d5ae3e76d5d1006e3078ab36159916f288c61b95d01752906122c2908390613501565b60405180910390a150565b80518190156122e8576122e38160600151612570565b612328565b606080820151015160020b15158061230a575060608101516080015160020b15155b1561232857604051631a0346d160e31b815260040160405180910390fd5b60018160200151600181111561234057612340612896565b1415801561235a575060408101516001600160a01b031615155b156123775760405162db68fd60e51b815260040160405180910390fd5b816000808560405160200161238c9190613501565b60408051601f19818403018152918152815160209283012083528282019390935291016000208251815490151560ff19821681178355928401519192839161ff001990911661ffff19909116176101008360018111156123ee576123ee612896565b0217905550604082810151825462010000600160b01b031916620100006001600160a01b03909216919091021782556060928301518051600184018054602084015162ffffff93841665ffffffffffff199283161763010000009185168202179092558385015160028701559583015160039095018054608085015160a09095015196841697169690961792909116021766ff0000000000001916660100000000000060ff9093169290920291909117909155517f76c25c6d85351a2cd0e75dc6bc7ebb591c17c14d1de78e8d2a8a6efcbda83995906124d19085908590613774565b60405180910390a1505050565b60408051600481526024810182526020810180516001600160e01b0316633850c7bd60e01b179052905160009182916001600160a01b03851691612521916137ac565b6000604051808303816000865af19150503d806000811461255e576040519150601f19603f3d011682016040523d82523d6000602084013e612563565b606091505b5060400151949350505050565b61257c620d89e86137be565b60020b816060015160020b128061259f5750620d89e860020b816060015160020b135b156125bd5760405163d3d0c56960e01b815260040160405180910390fd5b6125c9620d89e86137be565b60020b816080015160020b12806125ec5750620d89e860020b816080015160020b135b1561260a576040516350f3ef1960e11b815260040160405180910390fd5b806080015160020b816060015160020b1261263857604051634a05b96760e11b815260040160405180910390fd5b6101f48160400151111561265f57604051636703cded60e01b815260040160405180910390fd5b50565b6001600160a01b038116811461265f57600080fd5b6000806000806060858703121561268d57600080fd5b843561269881612662565b9350602085013567ffffffffffffffff808211156126b557600080fd5b9086019060c082890312156126c957600080fd5b909350604086013590808211156126df57600080fd5b818701915087601f8301126126f357600080fd5b81358181111561270257600080fd5b8860208260051b850101111561271757600080fd5b95989497505060200194505050565b60006060828403121561273857600080fd5b50919050565b6000610120828403121561273857600080fd5b60008060006101e0848603121561276757600080fd5b6127718585612726565b92506127808560608601612726565b915061278f8560c0860161273e565b90509250925092565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff811182821017156127d1576127d1612798565b60405290565b60405160c0810167ffffffffffffffff811182821017156127d1576127d1612798565b604051601f8201601f1916810167ffffffffffffffff8111828210171561282357612823612798565b604052919050565b60006060828403121561283d57600080fd5b6040516060810181811067ffffffffffffffff8211171561286057612860612798565b604052823561286e81612662565b8152602083013561287e81612662565b60208201526040928301359281019290925250919050565b634e487b7160e01b600052602160045260246000fd5b8051151582526020810151600281106128d557634e487b7160e01b600052602160045260246000fd5b8060208401525060018060a01b036040820151166040830152606081015162ffffff80825116606085015280602083015116608085015250604081015160a0840152606081015160020b60c0840152608081015160020b60e084015260ff60a082015116610100840152505050565b610120810161153e82846128ac565b600067ffffffffffffffff82111561296d5761296d612798565b5060051b60200190565b60008060006060848603121561298c57600080fd5b833561299781612662565b92506020848101356129a881612662565b9250604085013567ffffffffffffffff8111156129c457600080fd5b8501601f810187136129d557600080fd5b80356129e86129e382612953565b6127fa565b81815260059190911b82018301908381019089831115612a0757600080fd5b928401925b82841015612a2557833582529284019290840190612a0c565b80955050505050509250925092565b60008060408385031215612a4757600080fd5b8235612a5281612662565b946020939093013593505050565b600060208284031215612a7257600080fd5b8135611efe81612662565b60006080828403121561273857600080fd5b600082601f830112612aa057600080fd5b81356020612ab06129e383612953565b82815260059290921b84018101918181019086841115612acf57600080fd5b8286015b84811015612af3578035612ae681612662565b8352918301918301612ad3565b509695505050505050565b600080600080600060a08688031215612b1657600080fd5b8535612b2181612662565b9450602086013567ffffffffffffffff80821115612b3e57600080fd5b612b4a89838a01612a7d565b95506040880135915080821115612b6057600080fd5b612b6c89838a01612a7d565b94506060880135915080821115612b8257600080fd5b9087019060a0828a031215612b9657600080fd5b90925060808701359080821115612bac57600080fd5b50612bb988828901612a8f565b9150509295509295909350565b600080600060608486031215612bdb57600080fd5b8335612be681612662565b92506020840135612bf681612662565b929592945050506040919091013590565b60008060006101608486031215612c1d57600080fd5b8335612c2881612662565b92506020840135915061278f856040860161273e565b8051612c4981612662565b919050565b600060208284031215612c6057600080fd5b8151611efe81612662565b60008235607e19833603018112612c8157600080fd5b9190910192915050565b6000808335601e19843603018112612ca257600080fd5b83018035915067ffffffffffffffff821115612cbd57600080fd5b6020019150600581901b3603821315612cd557600080fd5b9250929050565b600060208284031215612cee57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112612d2257600080fd5b83018035915067ffffffffffffffff821115612d3d57600080fd5b602001915036819003821315612cd557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b0384168152604060208201819052600090612da09083018486612d52565b95945050505050565b8183526000602080850194508260005b85811015612de7578135612dcc81612662565b6001600160a01b031687529582019590820190600101612db9565b509495945050505050565b6001600160a01b03851681526001600160e01b031984166020820152606060408201819052600090612e279083018486612da9565b9695505050505050565b60008235603e19833603018112612c8157600080fd5b6000823560be19833603018112612c8157600080fd5b60018060a01b0385168152836020820152606060408201526000612e27606083018486612d52565b6000823560be19833603018112612e9b57600080fd5b90910192915050565b6000808335601e19843603018112612ebb57600080fd5b830160208101925035905067ffffffffffffffff811115612edb57600080fd5b8060051b3603821315612cd557600080fd5b8183526000602080850194508260005b85811015612de7578135612f1081612662565b6001600160a01b031687529582019590820190600101612efd565b81835260006001600160fb1b03831115612f4457600080fd5b8260051b80836020870137939093016020019392505050565b6000808335601e19843603018112612f7457600080fd5b830160208101925035905067ffffffffffffffff811115612f9457600080fd5b803603821315612cd557600080fd5b818352600060208085019450848460051b8601846000805b88811015613056578484038a528235609e19893603018112612fdb578283fd5b880160a08135612fea81612662565b6001600160a01b0390811687528289013589880152604080840135908801526060908184013561301981612662565b1690870152608061302c83820184612f5d565b935082828901526130408389018583612d52565b9d8a019d97505050938701935050600101612fbb565b509198975050505050505050565b6020815260006130748384612e85565b60406020840152803561308681612662565b6001600160a01b0390811660608501526020820135906130a582612662565b1660808401526130b86040820182612ea4565b60c060a08601526130ce61012086018284612eed565b915050606082013560c08501526130e86080830183612ea4565b605f19808785030160e0880152613100848385612f2b565b935061310f60a0860186612f5d565b955092508087850301610100880152505061312b828483612d52565b9250505061313c6020850185612ea4565b848303601f19016040860152612e27838284612fa3565b60008235609e19833603018112612c8157600080fd5b6020815260006131798384612ea4565b6040602085015261318e606085018284612fa3565b91505061319e6020850185612e85565b838203601f1901604085015280356131b581612662565b6001600160a01b0390811683526020820135906131d182612662565b1660208301526131e46040820182612ea4565b60c060408501526131f960c085018284612eed565b9150506132096060830183612ea4565b848303606086015261321c838284612f2b565b9250505061322d6080830183612ea4565b8483036080860152613240838284612f2b565b9250505061325160a0830183612f5d565b925083820360a0850152613266828483612d52565b979650505050505050565b6001600160a01b0383811682526080820190833561328e81612662565b81811660208501525060208401356132a581612662565b81811660408501525050604083013560608301529392505050565b6001600160a01b03858116825284166020820152606060408201819052600090612e279083018486612d52565b602081526000611efb602083018486612da9565b600081518084526020808501945080840160005b83811015612de75781516001600160a01b031687529582019590820190600101613315565b60005b8381101561335557818101518382015260200161333d565b50506000910152565b6040815260006133716040830185613301565b6020838203818501528185518084528284019150828160051b85010183880160005b838110156133d957601f1980888503018652825180518086526133bb818a88018b850161333a565b96880196601f01909116939093018601925090850190600101613393565b50909998505050505050505050565b62ffffff8116811461265f57600080fd5b8060020b811461265f57600080fd5b60ff8116811461265f57600080fd5b600081830361012081121561342b57600080fd5b6134336127ae565b8335801515811461344357600080fd5b815260208401356002811061345757600080fd5b6020820152604084013561346a81612662565b604082015260c0605f198301121561348157600080fd5b6134896127d7565b91506060840135613499816133e8565b825260808401356134a9816133e8565b602083015260a0840135604083015260c08401356134c6816133f9565b606083015260e08401356134d9816133f9565b60808301526101008401356134ed81613408565b60a083015260608101919091529392505050565b81516001600160a01b03908116825260208084015190911690820152604080830151908201526060810161153e565b8051612c49816133f9565b600060c0828403121561354d57600080fd5b6135556127d7565b8251613560816133f9565b81526020830151613570816133f9565b602082015260408381015190820152606083015161358d816133f9565b606082015260808301516135a0816133f9565b608082015260a08301516135b381613408565b60a08201529392505050565b8051612c49816133e8565b80516fffffffffffffffffffffffffffffffff81168114612c4957600080fd5b6000806000806000806000806000806000806101808d8f03121561360d57600080fd5b8c516bffffffffffffffffffffffff8116811461362957600080fd5b9b5061363760208e01612c3e565b9a5061364560408e01612c3e565b995061365360608e01612c3e565b985061366160808e016135bf565b975061366f60a08e01613530565b965061367d60c08e01613530565b955061368b60e08e016135ca565b94506101008d015193506101208d015192506136aa6101408e016135ca565b91506136b96101608e016135ca565b90509295989b509295989b509295989b565b634e487b7160e01b600052601160045260246000fd5b600282810b9082900b03627fffff198112627fffff8213171561153e5761153e6136cb565b600060018201613718576137186136cb565b5060010190565b602081526000611efe6020830184613301565b600281810b9083900b01627fffff8113627fffff198212171561153e5761153e6136cb565b60006020828403121561376957600080fd5b8151611efe816133e8565b82516001600160a01b03908116825260208085015190911690820152604080840151908201526101808101611efe60608301846128ac565b60008251612c8181846020870161333a565b60008160020b627fffff1981036137d7576137d76136cb565b6000039291505056fea2646970667358221220ee2f4f9808b323f9738354f195cf99cb271cea828880f967a23f757ddc00cb9b64736f6c6343000813003300000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d204000000000000000000000000c0c3e0a8e4979ece2aa98370b091fd9586d412b7000000000000000000000000df70bbcf26dfa446f0f492ec0fe054966e31691600000000000000000000000019a2ddd33b0acf84fe9dd5256ff339e9e63388de0000000000000000000000004f025aba4887631a6d601ae3156bf53568f5a5fd
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063759cb23411610097578063bc6b74ab11610066578063bc6b74ab14610265578063c45a01551461028c578063d276ae66146102b3578063ee360f24146102c657600080fd5b8063759cb23414610205578063a81fa02b14610218578063b3fb68d51461022b578063b53c86d21461023e57600080fd5b80632af3fa1b116100d35780632af3fa1b146101915780633fb53a0d146101b85780634b105efb146101df57806357181ab0146101f257600080fd5b806301b31cd0146101055780631d86d38a1461011a5780631de7354b1461012d578063228ca08714610171575b600080fd5b610118610113366004612677565b6102ed565b005b610118610128366004612751565b610ff8565b6101547f0000000000000000000000004f025aba4887631a6d601ae3156bf53568f5a5fd81565b6040516001600160a01b0390911681526020015b60405180910390f35b61018461017f36600461282b565b61109c565b6040516101689190612944565b6101547f000000000000000000000000df70bbcf26dfa446f0f492ec0fe054966e31691681565b6101547f00000000000000000000000019a2ddd33b0acf84fe9dd5256ff339e9e63388de81565b6101186101ed366004612977565b6111ea565b610118610200366004612a34565b61144b565b610154610213366004612a60565b611486565b610118610226366004612afe565b611544565b610154610239366004612bc6565b611e5b565b6101547f000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d20481565b6101547f00000000000000000000000078a5159141ca0e84617f454bbbbbc5b41a9889cf81565b6101547f00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf81565b6101186102c1366004612c07565b611f05565b6101547f000000000000000000000000c0c3e0a8e4979ece2aa98370b091fd9586d412b781565b60405163429b62e560e01b81526001600160a01b03808616600483015285916000917f00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf169063429b62e590602401602060405180830381865afa158015610358573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037c9190612c4e565b6001600160a01b0316036103a357604051633098a45560e01b815260040160405180910390fd5b336001600160a01b0316816001600160a01b03166319d40b086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040f9190612c4e565b6001600160a01b0316146104365760405163c19f17a960e01b815260040160405180910390fd5b6104436080850185612c6b565b610451906060810190612c8b565b90506000036104735760405163f806256560e01b815260040160405180910390fd5b61047d8585611f51565b600061048f6040860160208701612a60565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f09190612cdc565b6040805160098082526101408201909252919250600091906020820161012080368337505060408051600980825261014082019092529293506000929150602082015b60608152602001906001900390816105335790505090506001600160a01b037f000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d2041663c79aeaae61058660608a018a612c6b565b610594906020810190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa1580156105d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fc9190612c4e565b8260008151811061060f5761060f612cf5565b6001600160a01b03909216602092830291909101909101526106346060880188612c6b565b610642906020810190612a60565b61064f6060890189612c6b565b61065d906040810190612d0b565b60405160240161066f93929190612d7b565b60408051601f198184030181529190526020810180516001600160e01b031663bb1757cf60e01b179052815182906000906106ac576106ac612cf5565b60200260200101819052507f000000000000000000000000df70bbcf26dfa446f0f492ec0fe054966e316916826001815181106106eb576106eb612cf5565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000078a5159141ca0e84617f454bbbbbc5b41a9889cf7fd5778d3b4056634f1858eb1a0d41471ae1408b6973787dacb8f7fc585e82bdc061075260608a018a612c6b565b610760906060810190612c8b565b6040516024016107739493929190612df2565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b1790528151829060019081106107b2576107b2612cf5565b60209081029190910101526001600160a01b037f000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d2041663c79aeaae6107f960808a018a612c6b565b610807906020810190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561084b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086f9190612c4e565b8260028151811061088257610882612cf5565b6001600160a01b03909216602092830291909101909101526108a76080880188612c6b565b6108b5906020810190612a60565b6108c26080890189612c6b565b6108d0906040810190612e31565b6108da9080612e47565b606001356108eb60808a018a612c6b565b6108f9906020810190612d0b565b60405160240161090c9493929190612e5d565b60408051601f198184030181529190526020810180516001600160e01b03166331f0926560e01b17905281518290600290811061094b5761094b612cf5565b60200260200101819052507f000000000000000000000000c0c3e0a8e4979ece2aa98370b091fd9586d412b78260038151811061098a5761098a612cf5565b6001600160a01b03909216602092830291909101909101526109af6080880188612c6b565b6109bd906040810190612e31565b6040516024016109cd9190613064565b60408051601f198184030181529190526020810180516001600160e01b031663071605b760e11b179052815182906003908110610a0c57610a0c612cf5565b60200260200101819052507f000000000000000000000000df70bbcf26dfa446f0f492ec0fe054966e31691682600481518110610a4b57610a4b612cf5565b6001600160a01b039092166020928302919091018201527f00000000000000000000000078a5159141ca0e84617f454bbbbbc5b41a9889cf90610a9990610a94908a018a612a60565b612125565b610aa660808a018a612c6b565b610ab4906060810190612c8b565b604051602401610ac79493929190612df2565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b179052815182906004908110610b0657610b06612cf5565b60200260200101819052507f000000000000000000000000c0c3e0a8e4979ece2aa98370b091fd9586d412b782600581518110610b4557610b45612cf5565b6001600160a01b0390921660209283029190910190910152610b6a60a0880188613153565b610b78906060810190612e31565b604051602401610b889190613169565b60408051601f198184030181529190526020810180516001600160e01b031663cd5f81a960e01b179052815182906005908110610bc757610bc7612cf5565b60200260200101819052507f0000000000000000000000004f025aba4887631a6d601ae3156bf53568f5a5fd82600681518110610c0657610c06612cf5565b6001600160a01b0390921660209283029190910190910152604051610c51907f00000000000000000000000078a5159141ca0e84617f454bbbbbc5b41a9889cf908990602401613271565b60408051601f198184030181529190526020810180516001600160e01b0316632fec330f60e01b179052815182906006908110610c9057610c90612cf5565b60209081029190910101526001600160a01b037f000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d2041663c79aeaae610cd760a08a018a613153565b610ce5906020810190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015610d29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4d9190612c4e565b82600781518110610d6057610d60612cf5565b6001600160a01b0390921660209283029190910190910152610d8560a0880188613153565b610d93906020810190612a60565b610da060a0890189613153565b610dae906060810190612e31565b610dbc906020810190612e47565b610dcd906040810190602001612a60565b610dda60a08a018a613153565b610de8906080810190612d0b565b604051602401610dfb94939291906132c0565b60408051601f198184030181529190526020810180516001600160e01b03166346e6744b60e01b179052815182906007908110610e3a57610e3a612cf5565b60209081029190910101528415610efd577f00000000000000000000000019a2ddd33b0acf84fe9dd5256ff339e9e63388de82600881518110610e7f57610e7f612cf5565b60200260200101906001600160a01b031690816001600160a01b0316815250508585604051602401610eb29291906132ed565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b179052815182906008908110610ef157610ef1612cf5565b60200260200101819052505b6040516331fd85cb60e11b81526001600160a01b038916906363fb0b9690610f2b908590859060040161335e565b600060405180830381600087803b158015610f4557600080fd5b505af1158015610f59573d6000803e3d6000fd5b50610f6e925050506040880160208901612a60565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fcf9190612cdc565b8314610fee5760405163648873f960e01b815260040160405180910390fd5b5050505050505050565b33806110076020860186612a60565b6001600160a01b031614158061103b57506001600160a01b03811661102f6020850185612a60565b6001600160a01b031614155b156110595760405163b91a09e760e01b815260040160405180910390fd5b61107061106b3686900386018661282b565b612220565b6110966110823685900385018561282b565b61109136859003850185613417565b6122cd565b50505050565b604080516080808201835260008083526020808401829052838501829052845160c081018652828152908101829052938401819052606080850182905291840181905260a0840152810191909152600080836040516020016110fe9190613501565b60408051601f198184030181529181528151602092830120835282820193909352908201600020825160808101909352805460ff80821615158552919284019161010090910416600181111561115657611156612896565b600181111561116757611167612896565b815281546201000090046001600160a01b03166020808301919091526040805160c081018252600185015462ffffff808216835263010000009182900416938201939093526002808601548284015260039095015480860b606083015292830490940b6080850152660100000000000090910460ff1660a0840152015292915050565b60006111f533611486565b825190915060005b818110156114435760006040518060600160405280856001600160a01b03168152602001876001600160a01b0316815260200186848151811061124257611242612cf5565b602002602001015181525090506000876001600160a01b031663934743f2836040518263ffffffff1660e01b815260040161127d9190613501565b60c0604051808303816000875af115801561129c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c0919061353b565b9050600080886001600160a01b03166399fbab8885604001516040518263ffffffff1660e01b81526004016112f791815260200190565b61018060405180830381865afa158015611315573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133991906135ea565b5050505050965096505050505050600083600001518361135991906136e1565b9050600082856020015161136d91906136e1565b905060008260020b121561138057600091505b60008160020b1215611390575060005b60006040518060c001604052808462ffffff1681526020018362ffffff16815260200187604001518152602001876060015160020b8152602001876080015160020b81526020018760a0015160ff168152509050600060405180608001604052806001151581526020016000600181111561140d5761140d612896565b815260006020820152604001839052905061142888826122cd565b5050505050505050808061143b90613706565b9150506111fd565b505050505050565b600061145633611486565b604080516060810182526001600160a01b0380841682528616602082015290810184905290915061109681612220565b6040516312cfc9b560e31b81526001600160a01b03828116600483015260009182917f00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf169063967e4da890602401602060405180830381865afa1580156114f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115159190612c4e565b90506001600160a01b03811661153e57604051633098a45560e01b815260040160405180910390fd5b92915050565b6115516060840184612c8b565b90506000036115735760405163f806256560e01b815260040160405180910390fd5b600061157e33611486565b6040805160088082526101208201909252919250600091906020820161010080368337505060408051600880825261012082019092529293506000929150602082015b60608152602001906001900390816115c15790505090506001600160a01b037f000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d2041663c79aeaae61161460208a018a612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611658573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167c9190612c4e565b8260008151811061168f5761168f612cf5565b6001600160a01b039092166020928302919091018201526116b290880188612a60565b6116bf6040890189612d0b565b6040516024016116d193929190612d7b565b60408051601f198184030181529190526020810180516001600160e01b031663bb1757cf60e01b1790528151829060009061170e5761170e612cf5565b60200260200101819052507f000000000000000000000000df70bbcf26dfa446f0f492ec0fe054966e3169168260018151811061174d5761174d612cf5565b6001600160a01b03909216602092830291909101909101527f00000000000000000000000078a5159141ca0e84617f454bbbbbc5b41a9889cf7f5ccc4a216cefac5bdda384f8ea4b40fa5576e2fb51151b4b2ecc34a1ff7b0b796117b460608a018a612c8b565b6040516024016117c79493929190612df2565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b17905281518290600190811061180657611806612cf5565b60200260200101819052507f000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d2046001600160a01b031663c79aeaae8760000160208101906118539190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118bb9190612c4e565b826002815181106118ce576118ce612cf5565b6001600160a01b039092166020928302919091018201526118f190870187612a60565b6118fe6040880188612e31565b6119089080612e47565b606001356119196020890189612d0b565b60405160240161192c9493929190612e5d565b60408051601f198184030181529190526020810180516001600160e01b03166331f0926560e01b17905281518290600290811061196b5761196b612cf5565b60200260200101819052507f000000000000000000000000c0c3e0a8e4979ece2aa98370b091fd9586d412b7826003815181106119aa576119aa612cf5565b6001600160a01b03909216602092830291909101909101526119cf6040870187612e31565b6040516024016119df9190613064565b60408051601f198184030181529190526020810180516001600160e01b031663071605b760e11b179052815182906003908110611a1e57611a1e612cf5565b60200260200101819052507f000000000000000000000000df70bbcf26dfa446f0f492ec0fe054966e31691682600481518110611a5d57611a5d612cf5565b60200260200101906001600160a01b031690816001600160a01b0316815250507f00000000000000000000000078a5159141ca0e84617f454bbbbbc5b41a9889cf611aa789612125565b611ab46060890189612c8b565b604051602401611ac79493929190612df2565b60408051601f198184030181529190526020810180516001600160e01b031663dcc3284160e01b179052815182906004908110611b0657611b06612cf5565b60200260200101819052507f000000000000000000000000c0c3e0a8e4979ece2aa98370b091fd9586d412b782600581518110611b4557611b45612cf5565b6001600160a01b0390921660209283029190910190910152611b6a6060860186612e31565b604051602401611b7a9190613169565b60408051601f198184030181529190526020810180516001600160e01b031663cd5f81a960e01b179052815182906005908110611bb957611bb9612cf5565b60200260200101819052507f000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d2046001600160a01b031663c79aeaae866000016020810190611c069190612a60565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015611c4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c6e9190612c4e565b82600681518110611c8157611c81612cf5565b6001600160a01b03909216602092830291909101820152611ca490860186612a60565b611cb16060870187612e31565b611cbf906020810190612e47565b611cd0906040810190602001612a60565b611cdd6080880188612d0b565b604051602401611cf094939291906132c0565b60408051601f198184030181529190526020810180516001600160e01b03166346e6744b60e01b179052815182906006908110611d2f57611d2f612cf5565b6020908102919091010152835115611df1577f00000000000000000000000019a2ddd33b0acf84fe9dd5256ff339e9e63388de82600781518110611d7557611d75612cf5565b60200260200101906001600160a01b031690816001600160a01b03168152505083604051602401611da6919061371f565b60408051601f198184030181529190526020810180516001600160e01b031663d354641160e01b179052815182906007908110611de557611de5612cf5565b60200260200101819052505b6040516331fd85cb60e11b81526001600160a01b038416906363fb0b9690611e1f908590859060040161335e565b600060405180830381600087803b158015611e3957600080fd5b505af1158015611e4d573d6000803e3d6000fd5b505050505050505050505050565b60405163de0d95ed60e01b81526001600160a01b0384811660048301528381166024830152604482018390526000917f00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf9091169063de0d95ed906064016020604051808303816000875af1158015611ed7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611efb9190612c4e565b90505b9392505050565b6000611f1033611486565b604080516060810182526001600160a01b03808416825287166020820152908101859052909150611f4a8161109136869003860186613417565b5050505050565b6000611f9e6040518060600160405280856001600160a01b03168152602001846020016020810190611f839190612a60565b6001600160a01b03168152602001846040013581525061109c565b606001519050806060015160020b6000148015611fc05750608081015160020b155b15611fde5760405163c20c00ad60e01b815260040160405180910390fd5b600080611ff16040850160208601612a60565b6001600160a01b03166399fbab8885604001356040518263ffffffff1660e01b815260040161202291815260200190565b61018060405180830381865afa158015612040573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206491906135ea565b5050505050965096505050505050600061208f85600001602081019061208a9190612a60565b6124de565b845190915061209e90846136e1565b60020b8160020b121580156120c6575060208401516120bd9083613732565b60020b8160020b125b156120e45760405163227b663760e11b815260040160405180910390fd5b836060015160020b8160020b1315806121075750836080015160020b8160020b12155b1561144357604051633015515760e01b815260040160405180910390fd5b600080826001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa158015612166573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061218a9190613757565b90506101f48162ffffff16116121c257507fcb922c4d36cde61b3660729b33f36eff74a31440cf3e852d4467b4bd6045011c92915050565b610bb88162ffffff16116121f857507fc552bcd88e8785f8a0d9f9c5b9dc4e198659e68e9f6645642142b2900cde564d92915050565b507fa7e26cbd23588e6e87ee40cb01079e973bf8a0910c2edb6bc11ba3240a81480b92915050565b600080826040516020016122349190613501565b60408051601f1981840301815291815281516020928301208352908201929092528101600090812080546001600160b01b031916815560018101805465ffffffffffff191690556002810191909155600301805466ffffffffffffff19169055517faa3b569bcc3b07fe86d5ae3e76d5d1006e3078ab36159916f288c61b95d01752906122c2908390613501565b60405180910390a150565b80518190156122e8576122e38160600151612570565b612328565b606080820151015160020b15158061230a575060608101516080015160020b15155b1561232857604051631a0346d160e31b815260040160405180910390fd5b60018160200151600181111561234057612340612896565b1415801561235a575060408101516001600160a01b031615155b156123775760405162db68fd60e51b815260040160405180910390fd5b816000808560405160200161238c9190613501565b60408051601f19818403018152918152815160209283012083528282019390935291016000208251815490151560ff19821681178355928401519192839161ff001990911661ffff19909116176101008360018111156123ee576123ee612896565b0217905550604082810151825462010000600160b01b031916620100006001600160a01b03909216919091021782556060928301518051600184018054602084015162ffffff93841665ffffffffffff199283161763010000009185168202179092558385015160028701559583015160039095018054608085015160a09095015196841697169690961792909116021766ff0000000000001916660100000000000060ff9093169290920291909117909155517f76c25c6d85351a2cd0e75dc6bc7ebb591c17c14d1de78e8d2a8a6efcbda83995906124d19085908590613774565b60405180910390a1505050565b60408051600481526024810182526020810180516001600160e01b0316633850c7bd60e01b179052905160009182916001600160a01b03851691612521916137ac565b6000604051808303816000865af19150503d806000811461255e576040519150601f19603f3d011682016040523d82523d6000602084013e612563565b606091505b5060400151949350505050565b61257c620d89e86137be565b60020b816060015160020b128061259f5750620d89e860020b816060015160020b135b156125bd5760405163d3d0c56960e01b815260040160405180910390fd5b6125c9620d89e86137be565b60020b816080015160020b12806125ec5750620d89e860020b816080015160020b135b1561260a576040516350f3ef1960e11b815260040160405180910390fd5b806080015160020b816060015160020b1261263857604051634a05b96760e11b815260040160405180910390fd5b6101f48160400151111561265f57604051636703cded60e01b815260040160405180910390fd5b50565b6001600160a01b038116811461265f57600080fd5b6000806000806060858703121561268d57600080fd5b843561269881612662565b9350602085013567ffffffffffffffff808211156126b557600080fd5b9086019060c082890312156126c957600080fd5b909350604086013590808211156126df57600080fd5b818701915087601f8301126126f357600080fd5b81358181111561270257600080fd5b8860208260051b850101111561271757600080fd5b95989497505060200194505050565b60006060828403121561273857600080fd5b50919050565b6000610120828403121561273857600080fd5b60008060006101e0848603121561276757600080fd5b6127718585612726565b92506127808560608601612726565b915061278f8560c0860161273e565b90509250925092565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff811182821017156127d1576127d1612798565b60405290565b60405160c0810167ffffffffffffffff811182821017156127d1576127d1612798565b604051601f8201601f1916810167ffffffffffffffff8111828210171561282357612823612798565b604052919050565b60006060828403121561283d57600080fd5b6040516060810181811067ffffffffffffffff8211171561286057612860612798565b604052823561286e81612662565b8152602083013561287e81612662565b60208201526040928301359281019290925250919050565b634e487b7160e01b600052602160045260246000fd5b8051151582526020810151600281106128d557634e487b7160e01b600052602160045260246000fd5b8060208401525060018060a01b036040820151166040830152606081015162ffffff80825116606085015280602083015116608085015250604081015160a0840152606081015160020b60c0840152608081015160020b60e084015260ff60a082015116610100840152505050565b610120810161153e82846128ac565b600067ffffffffffffffff82111561296d5761296d612798565b5060051b60200190565b60008060006060848603121561298c57600080fd5b833561299781612662565b92506020848101356129a881612662565b9250604085013567ffffffffffffffff8111156129c457600080fd5b8501601f810187136129d557600080fd5b80356129e86129e382612953565b6127fa565b81815260059190911b82018301908381019089831115612a0757600080fd5b928401925b82841015612a2557833582529284019290840190612a0c565b80955050505050509250925092565b60008060408385031215612a4757600080fd5b8235612a5281612662565b946020939093013593505050565b600060208284031215612a7257600080fd5b8135611efe81612662565b60006080828403121561273857600080fd5b600082601f830112612aa057600080fd5b81356020612ab06129e383612953565b82815260059290921b84018101918181019086841115612acf57600080fd5b8286015b84811015612af3578035612ae681612662565b8352918301918301612ad3565b509695505050505050565b600080600080600060a08688031215612b1657600080fd5b8535612b2181612662565b9450602086013567ffffffffffffffff80821115612b3e57600080fd5b612b4a89838a01612a7d565b95506040880135915080821115612b6057600080fd5b612b6c89838a01612a7d565b94506060880135915080821115612b8257600080fd5b9087019060a0828a031215612b9657600080fd5b90925060808701359080821115612bac57600080fd5b50612bb988828901612a8f565b9150509295509295909350565b600080600060608486031215612bdb57600080fd5b8335612be681612662565b92506020840135612bf681612662565b929592945050506040919091013590565b60008060006101608486031215612c1d57600080fd5b8335612c2881612662565b92506020840135915061278f856040860161273e565b8051612c4981612662565b919050565b600060208284031215612c6057600080fd5b8151611efe81612662565b60008235607e19833603018112612c8157600080fd5b9190910192915050565b6000808335601e19843603018112612ca257600080fd5b83018035915067ffffffffffffffff821115612cbd57600080fd5b6020019150600581901b3603821315612cd557600080fd5b9250929050565b600060208284031215612cee57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e19843603018112612d2257600080fd5b83018035915067ffffffffffffffff821115612d3d57600080fd5b602001915036819003821315612cd557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b0384168152604060208201819052600090612da09083018486612d52565b95945050505050565b8183526000602080850194508260005b85811015612de7578135612dcc81612662565b6001600160a01b031687529582019590820190600101612db9565b509495945050505050565b6001600160a01b03851681526001600160e01b031984166020820152606060408201819052600090612e279083018486612da9565b9695505050505050565b60008235603e19833603018112612c8157600080fd5b6000823560be19833603018112612c8157600080fd5b60018060a01b0385168152836020820152606060408201526000612e27606083018486612d52565b6000823560be19833603018112612e9b57600080fd5b90910192915050565b6000808335601e19843603018112612ebb57600080fd5b830160208101925035905067ffffffffffffffff811115612edb57600080fd5b8060051b3603821315612cd557600080fd5b8183526000602080850194508260005b85811015612de7578135612f1081612662565b6001600160a01b031687529582019590820190600101612efd565b81835260006001600160fb1b03831115612f4457600080fd5b8260051b80836020870137939093016020019392505050565b6000808335601e19843603018112612f7457600080fd5b830160208101925035905067ffffffffffffffff811115612f9457600080fd5b803603821315612cd557600080fd5b818352600060208085019450848460051b8601846000805b88811015613056578484038a528235609e19893603018112612fdb578283fd5b880160a08135612fea81612662565b6001600160a01b0390811687528289013589880152604080840135908801526060908184013561301981612662565b1690870152608061302c83820184612f5d565b935082828901526130408389018583612d52565b9d8a019d97505050938701935050600101612fbb565b509198975050505050505050565b6020815260006130748384612e85565b60406020840152803561308681612662565b6001600160a01b0390811660608501526020820135906130a582612662565b1660808401526130b86040820182612ea4565b60c060a08601526130ce61012086018284612eed565b915050606082013560c08501526130e86080830183612ea4565b605f19808785030160e0880152613100848385612f2b565b935061310f60a0860186612f5d565b955092508087850301610100880152505061312b828483612d52565b9250505061313c6020850185612ea4565b848303601f19016040860152612e27838284612fa3565b60008235609e19833603018112612c8157600080fd5b6020815260006131798384612ea4565b6040602085015261318e606085018284612fa3565b91505061319e6020850185612e85565b838203601f1901604085015280356131b581612662565b6001600160a01b0390811683526020820135906131d182612662565b1660208301526131e46040820182612ea4565b60c060408501526131f960c085018284612eed565b9150506132096060830183612ea4565b848303606086015261321c838284612f2b565b9250505061322d6080830183612ea4565b8483036080860152613240838284612f2b565b9250505061325160a0830183612f5d565b925083820360a0850152613266828483612d52565b979650505050505050565b6001600160a01b0383811682526080820190833561328e81612662565b81811660208501525060208401356132a581612662565b81811660408501525050604083013560608301529392505050565b6001600160a01b03858116825284166020820152606060408201819052600090612e279083018486612d52565b602081526000611efb602083018486612da9565b600081518084526020808501945080840160005b83811015612de75781516001600160a01b031687529582019590820190600101613315565b60005b8381101561335557818101518382015260200161333d565b50506000910152565b6040815260006133716040830185613301565b6020838203818501528185518084528284019150828160051b85010183880160005b838110156133d957601f1980888503018652825180518086526133bb818a88018b850161333a565b96880196601f01909116939093018601925090850190600101613393565b50909998505050505050505050565b62ffffff8116811461265f57600080fd5b8060020b811461265f57600080fd5b60ff8116811461265f57600080fd5b600081830361012081121561342b57600080fd5b6134336127ae565b8335801515811461344357600080fd5b815260208401356002811061345757600080fd5b6020820152604084013561346a81612662565b604082015260c0605f198301121561348157600080fd5b6134896127d7565b91506060840135613499816133e8565b825260808401356134a9816133e8565b602083015260a0840135604083015260c08401356134c6816133f9565b606083015260e08401356134d9816133f9565b60808301526101008401356134ed81613408565b60a083015260608101919091529392505050565b81516001600160a01b03908116825260208084015190911690820152604080830151908201526060810161153e565b8051612c49816133f9565b600060c0828403121561354d57600080fd5b6135556127d7565b8251613560816133f9565b81526020830151613570816133f9565b602082015260408381015190820152606083015161358d816133f9565b606082015260808301516135a0816133f9565b608082015260a08301516135b381613408565b60a08201529392505050565b8051612c49816133e8565b80516fffffffffffffffffffffffffffffffff81168114612c4957600080fd5b6000806000806000806000806000806000806101808d8f03121561360d57600080fd5b8c516bffffffffffffffffffffffff8116811461362957600080fd5b9b5061363760208e01612c3e565b9a5061364560408e01612c3e565b995061365360608e01612c3e565b985061366160808e016135bf565b975061366f60a08e01613530565b965061367d60c08e01613530565b955061368b60e08e016135ca565b94506101008d015193506101208d015192506136aa6101408e016135ca565b91506136b96101608e016135ca565b90509295989b509295989b509295989b565b634e487b7160e01b600052601160045260246000fd5b600282810b9082900b03627fffff198112627fffff8213171561153e5761153e6136cb565b600060018201613718576137186136cb565b5060010190565b602081526000611efe6020830184613301565b600281810b9083900b01627fffff8113627fffff198212171561153e5761153e6136cb565b60006020828403121561376957600080fd5b8151611efe816133e8565b82516001600160a01b03908116825260208085015190911690820152604080840151908201526101808101611efe60608301846128ac565b60008251612c8181846020870161333a565b60008160020b627fffff1981036137d7576137d76136cb565b6000039291505056fea2646970667358221220ee2f4f9808b323f9738354f195cf99cb271cea828880f967a23f757ddc00cb9b64736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d204000000000000000000000000c0c3e0a8e4979ece2aa98370b091fd9586d412b7000000000000000000000000df70bbcf26dfa446f0f492ec0fe054966e31691600000000000000000000000019a2ddd33b0acf84fe9dd5256ff339e9e63388de0000000000000000000000004f025aba4887631a6d601ae3156bf53568f5a5fd
-----Decoded View---------------
Arg [0] : factory (address): 0x53d9780DbD3831E3A797Fd215be4131636cD5FDf
Arg [1] : connectorRegistry (address): 0xf3442bB9F63d35e668Dde0aBf61b7F716156D204
Arg [2] : libraries (tuple):
Arg [1] : zapLib (address): 0xc0C3E0a8E4979ECe2Aa98370B091fD9586d412B7
Arg [2] : feesLib (address): 0xdf70bbcF26DFA446f0F492Ec0FE054966e316916
Arg [3] : transferLib (address): 0x19A2DDd33b0acf84fe9Dd5256FF339E9E63388DE
Arg [4] : nftSettingsLib (address): 0x4F025Aba4887631a6D601AE3156bf53568f5A5Fd
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 00000000000000000000000053d9780dbd3831e3a797fd215be4131636cd5fdf
Arg [1] : 000000000000000000000000f3442bb9f63d35e668dde0abf61b7f716156d204
Arg [2] : 000000000000000000000000c0c3e0a8e4979ece2aa98370b091fd9586d412b7
Arg [3] : 000000000000000000000000df70bbcf26dfa446f0f492ec0fe054966e316916
Arg [4] : 00000000000000000000000019a2ddd33b0acf84fe9dd5256ff339e9e63388de
Arg [5] : 0000000000000000000000004f025aba4887631a6d601ae3156bf53568f5a5fd
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.