Skip to main content

Function: frameSlot0

frameSlot0(slot0): FramedSlot0

Puts a slot0 answer into the frame of the request. The backend always answers in the pool's canonical order and says so with flippedFromRequest; when the caller asked for the reverse order the price is inverted here (at 60 significant digits, so a very large or very small reciprocal keeps its precision) and the tick is re-derived from the inverted price with the contract's greatest-tick rule. Negating the tick instead is wrong for a price between ticks (and -t - 1 is wrong for a price exactly on a tick: sqrtPrice 1 / tick 0 stays 1 / 0).

Parameters​

ParameterType
slot0{ flippedFromRequest?: boolean; sqrtPrice: string; tick: number; }
slot0.flippedFromRequest?boolean
slot0.sqrtPricestring
slot0.ticknumber

Returns​

FramedSlot0

Example​

const slot0 = await gSwap.pools.getSlot0('A', 'B', 500);
const { sqrtPrice, tick } = frameSlot0(slot0);