PoolDepositWithdraw

Git Source

Inherits: IPoolDepositWithdraw, PoolInternal, ReentrancyGuard

Functions

constructor

constructor(
    address factory,
    address router,
    address wrappedNativeToken,
    address feeReceiver,
    address referral,
    address settings,
    address vaultRegistry,
    address vxPremia
) PoolInternal(factory, router, wrappedNativeToken, feeReceiver, referral, settings, vaultRegistry, vxPremia);

deposit

Deposits a position (combination of owner/operator, price range, bid/ask collateral, and long/short contracts) into the pool. Tx will revert if market price is not between minMarketPrice and maxMarketPrice.

function deposit(
    Position.Key calldata p,
    UD60x18 belowLower,
    UD60x18 belowUpper,
    UD60x18 size,
    UD60x18 minMarketPrice,
    UD60x18 maxMarketPrice
) external nonReentrant returns (Position.Delta memory delta);

Parameters

NameTypeDescription
pPosition.KeyThe position key
belowLowerUD60x18The normalized price of nearest existing tick below lower. The search is done off-chain, passed as arg and validated on-chain to save gas (18 decimals)
belowUpperUD60x18The normalized price of nearest existing tick below upper. The search is done off-chain, passed as arg and validated on-chain to save gas (18 decimals)
sizeUD60x18The position size to deposit (18 decimals)
minMarketPriceUD60x18Min market price, as normalized value. (If below, tx will revert) (18 decimals)
maxMarketPriceUD60x18Max market price, as normalized value. (If above, tx will revert) (18 decimals)

Returns

NameTypeDescription
deltaPosition.DeltaThe amount of collateral / longs / shorts deposited

deposit

Deposits a position (combination of owner/operator, price range, bid/ask collateral, and long/short contracts) into the pool. Tx will revert if market price is not between minMarketPrice and maxMarketPrice.

function deposit(
    Position.Key calldata p,
    UD60x18 belowLower,
    UD60x18 belowUpper,
    UD60x18 size,
    UD60x18 minMarketPrice,
    UD60x18 maxMarketPrice,
    bool isBidIfStrandedMarketPrice
) external nonReentrant returns (Position.Delta memory delta);

Parameters

NameTypeDescription
pPosition.KeyThe position key
belowLowerUD60x18The normalized price of nearest existing tick below lower. The search is done off-chain, passed as arg and validated on-chain to save gas (18 decimals)
belowUpperUD60x18The normalized price of nearest existing tick below upper. The search is done off-chain, passed as arg and validated on-chain to save gas (18 decimals)
sizeUD60x18The position size to deposit (18 decimals)
minMarketPriceUD60x18Min market price, as normalized value. (If below, tx will revert) (18 decimals)
maxMarketPriceUD60x18Max market price, as normalized value. (If above, tx will revert) (18 decimals)
isBidIfStrandedMarketPricebool

Returns

NameTypeDescription
deltaPosition.DeltaThe amount of collateral / longs / shorts deposited

withdraw

Withdraws a position (combination of owner/operator, price range, bid/ask collateral, and long/short contracts) from the pool. Tx will revert if market price is not between minMarketPrice and maxMarketPrice.

function withdraw(Position.Key calldata p, UD60x18 size, UD60x18 minMarketPrice, UD60x18 maxMarketPrice)
    external
    nonReentrant
    returns (Position.Delta memory delta);

Parameters

NameTypeDescription
pPosition.KeyThe position key
sizeUD60x18The position size to withdraw (18 decimals)
minMarketPriceUD60x18Min market price, as normalized value. (If below, tx will revert) (18 decimals)
maxMarketPriceUD60x18Max market price, as normalized value. (If above, tx will revert) (18 decimals)

Returns

NameTypeDescription
deltaPosition.DeltaThe amount of collateral / longs / shorts withdrawn

getNearestTicksBelow

Get nearest ticks below lower and upper.

If no tick between lower and upper, then the nearest tick below upper, will be lower

function getNearestTicksBelow(UD60x18 lower, UD60x18 upper)
    external
    view
    returns (UD60x18 nearestBelowLower, UD60x18 nearestBelowUpper);

Parameters

NameTypeDescription
lowerUD60x18The lower bound of the range (18 decimals)
upperUD60x18The upper bound of the range (18 decimals)

Returns

NameTypeDescription
nearestBelowLowerUD60x18The nearest tick below lower (18 decimals)
nearestBelowUpperUD60x18The nearest tick below upper (18 decimals)