equation-sdk
Version:
🛠An SDK for building applications on top of Equation.
56 lines (55 loc) • 2.07 kB
TypeScript
import { Side } from '../config';
import { IGlobalLiquidityPosition, IPriceState, IPriceVertexBigInt, IState } from '../types';
export interface IMoveStep {
side: Side;
sizeLeft: any;
indexPriceX96: bigint;
basisIndexPriceX96: bigint;
improveBalance: boolean;
from: IPriceVertexBigInt;
current: IPriceVertexBigInt;
to: IPriceVertexBigInt;
}
export interface UpdatePriceStateParameter {
side: Side;
sizeDelta: bigint;
indexPriceX96: bigint;
liquidationVertexIndex: number;
liquidation: boolean;
}
export interface IPriceConfig {
maxPriceImpactLiquidity: bigint;
liquidationVertexIndex: number;
vertices: {
balanceRate: number;
premiumRate: number;
}[];
}
export declare const VERTEX_NUM = 10;
export declare const LATEST_VERTEX: number;
export declare const VERTEX_BASIS_POINT_DIVISOR = 100000000;
export declare const Q96: bigint;
export declare const Q152: bigint;
export declare class PriceUtil {
static calculateMarketPrice(sizeDelta: string, globalLiquidityPosition: IGlobalLiquidityPosition, priceState: IPriceState, side: Side, indexPriceX96: string, baseDecimal: number, quoteDecimal?: number): string;
static updatePriceState(state: any, priceConfig: any, parameter: UpdatePriceStateParameter): 0n | {
tradePriceX96: any;
priceStateCache: any;
globalLiquidityPositionCache: any;
};
private static _updatePriceState;
private static _calculatePriceVertex;
static changePriceVertex(_state: IState, _priceConfig: IPriceConfig, _indexPriceX96: bigint, _startExclusive: number, _endInclusive: number): {
priceVertices: any;
};
private static _changePriceVertex;
static simulateMove(step: IMoveStep): {
reached: boolean;
sizeUsed: any;
tradePriceX96: bigint;
premiumRateAfterX96: any;
};
private static calculateReachedAndSizeUsed;
private static calculatePremiumRateAfterX96;
private static calculateAX248AndBX96;
}