UNPKG

@drift-labs/sdk

Version:
51 lines 3.19 kB
/// <reference types="bn.js" /> import { BN } from '@coral-xyz/anchor'; import { PerpMarketAccount, PositionDirection, MarginCategory, SpotMarketAccount } from '../types'; import { MMOraclePriceData, OraclePriceData } from '../oracles/types'; import { DLOB } from '../dlob/DLOB'; /** * Calculates market mark price * * @param market * @return markPrice : Precision PRICE_PRECISION */ export declare function calculateReservePrice(market: PerpMarketAccount, mmOraclePriceData: MMOraclePriceData): BN; /** * Calculates market bid price * * @param market * @return bidPrice : Precision PRICE_PRECISION */ export declare function calculateBidPrice(market: PerpMarketAccount, mmOraclePriceData: MMOraclePriceData, latestSlot?: BN): BN; /** * Calculates market ask price * * @param market * @return askPrice : Precision PRICE_PRECISION */ export declare function calculateAskPrice(market: PerpMarketAccount, mmOraclePriceData: MMOraclePriceData, latestSlot?: BN): BN; export declare function calculateNewMarketAfterTrade(baseAssetAmount: BN, direction: PositionDirection, market: PerpMarketAccount): PerpMarketAccount; export declare function calculateOracleReserveSpread(market: PerpMarketAccount, mmOraclePriceData: MMOraclePriceData): BN; export declare function calculateOracleSpread(price: BN, oraclePriceData: OraclePriceData): BN; export declare function calculateMarketMarginRatio(market: PerpMarketAccount, size: BN, marginCategory: MarginCategory, customMarginRatio?: number, userHighLeverageMode?: boolean): number; export declare function calculateUnrealizedAssetWeight(market: PerpMarketAccount, quoteSpotMarket: SpotMarketAccount, unrealizedPnl: BN, marginCategory: MarginCategory, oraclePriceData: Pick<OraclePriceData, 'price'>): BN; export declare function calculateMarketAvailablePNL(perpMarket: PerpMarketAccount, spotMarket: SpotMarketAccount): BN; export declare function calculateMarketMaxAvailableInsurance(perpMarket: PerpMarketAccount, spotMarket: SpotMarketAccount): BN; export declare function calculateNetUserPnl(perpMarket: PerpMarketAccount, oraclePriceData: Pick<OraclePriceData, 'price'>): BN; export declare function calculateNetUserPnlImbalance(perpMarket: PerpMarketAccount, spotMarket: SpotMarketAccount, oraclePriceData: Pick<OraclePriceData, 'price'>, applyFeePoolDiscount?: boolean): BN; export declare function calculateAvailablePerpLiquidity(market: PerpMarketAccount, mmOraclePriceData: MMOraclePriceData, dlob: DLOB, slot: number): { bids: BN; asks: BN; }; export declare function calculatePerpMarketBaseLiquidatorFee(market: PerpMarketAccount, userHighLeverageMode: boolean): number; /** * Calculates trigger price for a perp market based on oracle price and current time * Implements the same logic as the Rust get_trigger_price function * * @param market - The perp market account * @param oraclePrice - Current oracle price (precision: PRICE_PRECISION) * @param now - Current timestamp in seconds * @returns trigger price (precision: PRICE_PRECISION) */ export declare function getTriggerPrice(market: PerpMarketAccount, oraclePrice: BN, now: BN, useMedianPrice: boolean): BN; //# sourceMappingURL=market.d.ts.map