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).
framed slot0 flipped from request
Parameters
| Parameter | Type |
|---|---|
slot0 | { flippedFromRequest?: boolean; sqrtPrice: string; tick: number; } |
slot0.flippedFromRequest? | boolean |
slot0.sqrtPrice | string |
slot0.tick | number |
flipped from request sqrt price
Returns
framed slot0
Example
const slot0 = await gSwap.pools.getSlot0('A', 'B', 500);
const { sqrtPrice, tick } = frameSlot0(slot0);