IPancakeSwapV4StandardModule

Git Source

Functions

initialize

initialize function to delegate call onced the beacon proxy is deployed, for initializing the uniswap v4 standard module.

this function will deposit fund as left over on poolManager.

function initialize(
    uint256 init0_,
    uint256 init1_,
    bool isInversed_,
    PoolKey calldata poolKey_,
    IOracleWrapper oracle_,
    uint24 maxSlippage_,
    address metaVault_
) external;

Parameters

NameTypeDescription
init0_uint256initial amount of token0 to provide to uniswap standard module.
init1_uint256initial amount of token1 to provide to valantis module.
isInversed_boolboolean to check if the poolKey's currencies pair are inversed, compared to the module's tokens pair.
poolKey_PoolKeypool key of the uniswap v4 pool that will be used by the module.
oracle_IOracleWrapperaddress of the oracle used by the uniswap v4 standard module.
maxSlippage_uint24allowed to manager for rebalancing the inventory using swap.
metaVault_addressaddress of the meta vault

approve

function approve(
    address spender_,
    address[] calldata tokens_,
    uint256[] calldata amounts
) external;

setPool

function used to set the pool for the module.

function setPool(
    PoolKey calldata poolKey_,
    LiquidityRange[] calldata liquidityRanges_,
    SwapPayload calldata swapPayload_,
    uint256 minBurn0_,
    uint256 minBurn1_,
    uint256 minDeposit0_,
    uint256 minDeposit1_
) external;

Parameters

NameTypeDescription
poolKey_PoolKeypool key of the uniswap v4 pool that will be used by the module.
liquidityRanges_LiquidityRange[]list of liquidity ranges to be used by the module on the new pool.
swapPayload_SwapPayloadswap payload to be used during rebalance.
minBurn0_uint256minimum amount of token0 to burn.
minBurn1_uint256minimum amount of token1 to burn.
minDeposit0_uint256minimum amount of token0 to deposit.
minDeposit1_uint256minimum amount of token1 to deposit.

rebalance

function used to rebalance the inventory of the module.

function rebalance(
    LiquidityRange[] calldata liquidityRanges_,
    SwapPayload memory swapPayload_,
    uint256 minBurn0_,
    uint256 minBurn1_,
    uint256 minDeposit0_,
    uint256 minDeposit1_
)
    external
    returns (
        uint256 amount0Minted,
        uint256 amount1Minted,
        uint256 amount0Burned,
        uint256 amount1Burned
    );

Parameters

NameTypeDescription
liquidityRanges_LiquidityRange[]list of liquidity ranges to be used by the module.
swapPayload_SwapPayloadswap payload to be used during rebalance.
minBurn0_uint256minimum amount of token0 to burn.
minBurn1_uint256minimum amount of token1 to burn.
minDeposit0_uint256minimum amount of token0 to deposit.
minDeposit1_uint256minimum amount of token1 to deposit.

Returns

NameTypeDescription
amount0Minteduint256amount of token0 minted.
amount1Minteduint256amount of token1 minted.
amount0Burneduint256amount of token0 burned.
amount1Burneduint256amount of token1 burned.

withdrawEth

function used to withdraw eth from the module.

these fund will be used to swap eth to the other token of the currencyPair to rebalance the inventory inside a single tx.

function withdrawEth(
    uint256 amount_
) external;

poolManager

function used to get the uniswap v4 pool manager.

function poolManager() external view returns (ICLPoolManager);

Returns

NameTypeDescription
<none>ICLPoolManagerpoolManager return the pool manager.

isInversed

function used to know if the poolKey's currencies pair are inversed.

function isInversed() external view returns (bool);

vault

function vault() external view returns (IVault);

poolKey

function used to get the pool's key of the module.

function poolKey()
    external
    view
    returns (
        Currency currency0,
        Currency currency1,
        IHooks hooks,
        IPoolManager poolManager,
        uint24 fee,
        bytes32 parameters
    );

oracle

function used to get the oracle that will be used to proctect rebalances.

function oracle() external view returns (IOracleWrapper);

maxSlippage

function used to get the max slippage that can occur during swap rebalance.

function maxSlippage() external view returns (uint24);

getRanges

function used to get the list of active ranges.

function getRanges() external view returns (Range[] memory ranges);

Returns

NameTypeDescription
rangesRange[]active ranges

Events

LogApproval

event LogApproval(
    address indexed spender, address[] tokens, uint256[] amounts
);

LogRebalance

event LogRebalance(
    LiquidityRange[] liquidityRanges,
    uint256 amount0Minted,
    uint256 amount1Minted,
    uint256 amount0Burned,
    uint256 amount1Burned
);

LogSetPool

event LogSetPool(PoolKey oldPoolKey, PoolKey poolKey);

LogSetRewardReceiver

event LogSetRewardReceiver(address rewardReceiver);

Errors

Currency0DtToken0

error Currency0DtToken0(address currency0, address token0);

Currency1DtToken1

error Currency1DtToken1(address currency1, address token1);

Currency1DtToken0

error Currency1DtToken0(address currency1, address token0);

Currency0DtToken1

error Currency0DtToken1(address currency0, address token1);

RangeShouldBeActive

error RangeShouldBeActive(int24 tickLower, int24 tickUpper);

SqrtPriceZero

error SqrtPriceZero();

OverBurning

error OverBurning();

MaxSlippageGtTenPercent

error MaxSlippageGtTenPercent();

NativeCoinCannotBeToken1

error NativeCoinCannotBeToken1();

NoRemoveOrAddLiquidityHooks

error NoRemoveOrAddLiquidityHooks();

OnlyMetaVaultOwner

error OnlyMetaVaultOwner();

InsufficientFunds

error InsufficientFunds();

OverMaxDeviation

error OverMaxDeviation();

AmountZero

error AmountZero();

BurnToken0

error BurnToken0();

BurnToken1

error BurnToken1();

MintToken0

error MintToken0();

MintToken1

error MintToken1();

SamePool

error SamePool();

ExpectedMinReturnTooLow

error ExpectedMinReturnTooLow();

InvalidCurrencyDelta

error InvalidCurrencyDelta();

WrongRouter

error WrongRouter();

SlippageTooHigh

error SlippageTooHigh();

InvalidMsgValue

error InvalidMsgValue();

OnlyVault

error OnlyVault();

TicksMisordered

error TicksMisordered(int24 tickLower, int24 tickUpper);

TickLowerOutOfBounds

error TickLowerOutOfBounds(int24 tickLower);

TickUpperOutOfBounds

error TickUpperOutOfBounds(int24 tickUpper);

OnlyManagerOrVaultOwner

error OnlyManagerOrVaultOwner();

LengthsNotEqual

error LengthsNotEqual();

SameRewardReceiver

error SameRewardReceiver();

Structs

Range

struct Range {
    int24 tickLower;
    int24 tickUpper;
}

LiquidityRange

struct LiquidityRange {
    Range range;
    int128 liquidity;
}