IPoolDepositWithdraw
Inherits: IPoolInternal
Functions
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 returns (Position.Delta memory delta);
Parameters
Name | Type | Description |
---|---|---|
p | Position.Key | The position key |
belowLower | UD60x18 | The 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) |
belowUpper | UD60x18 | The 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) |
size | UD60x18 | The position size to deposit (18 decimals) |
minMarketPrice | UD60x18 | Min market price, as normalized value. (If below, tx will revert) (18 decimals) |
maxMarketPrice | UD60x18 | Max market price, as normalized value. (If above, tx will revert) (18 decimals) |
Returns
Name | Type | Description |
---|---|---|
delta | Position.Delta | The 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 returns (Position.Delta memory delta);
Parameters
Name | Type | Description |
---|---|---|
p | Position.Key | The position key |
belowLower | UD60x18 | The 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) |
belowUpper | UD60x18 | The 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) |
size | UD60x18 | The position size to deposit (18 decimals) |
minMarketPrice | UD60x18 | Min market price, as normalized value. (If below, tx will revert) (18 decimals) |
maxMarketPrice | UD60x18 | Max market price, as normalized value. (If above, tx will revert) (18 decimals) |
isBidIfStrandedMarketPrice | bool | Whether this is a bid or ask order when the market price is stranded (This argument doesnt matter if market price is not stranded) |
Returns
Name | Type | Description |
---|---|---|
delta | Position.Delta | The 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
returns (Position.Delta memory delta);
Parameters
Name | Type | Description |
---|---|---|
p | Position.Key | The position key |
size | UD60x18 | The position size to withdraw (18 decimals) |
minMarketPrice | UD60x18 | Min market price, as normalized value. (If below, tx will revert) (18 decimals) |
maxMarketPrice | UD60x18 | Max market price, as normalized value. (If above, tx will revert) (18 decimals) |
Returns
Name | Type | Description |
---|---|---|
delta | Position.Delta | The 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
Name | Type | Description |
---|---|---|
lower | UD60x18 | The lower bound of the range (18 decimals) |
upper | UD60x18 | The upper bound of the range (18 decimals) |
Returns
Name | Type | Description |
---|---|---|
nearestBelowLower | UD60x18 | The nearest tick below lower (18 decimals) |
nearestBelowUpper | UD60x18 | The nearest tick below upper (18 decimals) |