IUniV4StandardModule

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 used to approve a spender to use the left over of the module.

function approve(
    address spender_,
    uint256 amount0_,
    uint256 amount1_
) external;

Parameters

NameTypeDescription
spender_addressaddress that will be allowed to use left over.
amount0_uint256amount of token0 allowed to be used by spender.
amount1_uint256amount of token1 allowed to be used by spender.

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;

ethWithdrawers

function used to get eth withdrawers allowances.

function ethWithdrawers(
    address
) external view returns (uint256);

getRanges

function used to get the list of active ranges.

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

Returns

NameTypeDescription
rangesRange[]active ranges

poolKey

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

function poolKey()
    external
    view
    returns (
        Currency currency0,
        Currency currency1,
        uint24 fee,
        int24 tickSpacing,
        IHooks hooks
    );

Returns

NameTypeDescription
currency0Currencycurrency0 of the pool.
currency1Currencycurrency1 of the pool.
feeuint24fee of the pool.
tickSpacingint24tick spacing of the pool.
hooksIHookshooks of the pool.

poolManager

function used to get the uniswap v4 pool manager.

function poolManager() external view returns (IPoolManager);

Returns

NameTypeDescription
<none>IPoolManagerpoolManager return the pool manager.

isInversed

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

function isInversed() external view returns (bool);

maxSlippage

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

function maxSlippage() external view returns (uint24);

oracle

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

function oracle() external view returns (IOracleWrapper);

Events

LogApproval

event LogApproval(
    address indexed spender, uint256 amount0, uint256 amount1
);

LogSetPool

event LogSetPool(PoolKey oldPoolKey, PoolKey poolKey);

LogRebalance

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

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);

SqrtPriceZero

error SqrtPriceZero();

OnlyPoolManager

error OnlyPoolManager();

InvalidCurrencyDelta

error InvalidCurrencyDelta();

RangeShouldBeActive

error RangeShouldBeActive(int24 tickLower, int24 tickUpper);

OverBurning

error OverBurning();

TicksMisordered

error TicksMisordered(int24 tickLower, int24 tickUpper);

TickLowerOutOfBounds

error TickLowerOutOfBounds(int24 tickLower);

TickUpperOutOfBounds

error TickUpperOutOfBounds(int24 tickUpper);

SamePool

error SamePool();

NoRemoveOrAddLiquidityHooks

error NoRemoveOrAddLiquidityHooks();

OverMaxDeviation

error OverMaxDeviation();

NativeCoinCannotBeToken1

error NativeCoinCannotBeToken1();

MaxSlippageGtTenPercent

error MaxSlippageGtTenPercent();

ExpectedMinReturnTooLow

error ExpectedMinReturnTooLow();

WrongRouter

error WrongRouter();

SlippageTooHigh

error SlippageTooHigh();

OnlyMetaVaultOwner

error OnlyMetaVaultOwner();

InvalidMsgValue

error InvalidMsgValue();

InsufficientFunds

error InsufficientFunds();

AmountZero

error AmountZero();

BurnToken0

error BurnToken0();

BurnToken1

error BurnToken1();

MintToken0

error MintToken0();

MintToken1

error MintToken1();

Structs

Range

struct Range {
    int24 tickLower;
    int24 tickUpper;
}

LiquidityRange

struct LiquidityRange {
    Range range;
    int128 liquidity;
}