import { BigNumber } from 'bignumber.js'; import { OrderSide } from '#types/enums/request'; import type { L2OrderBook, OrderBookLevelL1, OrderBookLevelL2 } from '#types/orderBook'; import type { KumaInitialMarginFractionOverride, KumaMarket, KumaOrder, KumaPosition, KumaWallet } from '#types/rest/endpoints/index'; export type LeverageParameters = Pick; export type LeverageParametersBigInt = Record; type Position = { market: string; quantity: bigint; indexPrice: bigint; marginRequirement: bigint; }; /** * Price and Size values form the {@link OrderBookLevelL1} type */ export type PriceAndSize = Pick; /** * Standing orders */ export type StandingOrder = Pick; type ActiveStandingOrder = StandingOrder & { price: string; }; type ActiveStandingOrderBigInt = Pick & { openQuantity: bigint; price: bigint; }; export declare function isActiveStandingOrder(order: StandingOrder): order is ActiveStandingOrder; export declare const asksTickRoundingMode: 0; export declare const bidsTickRoundingMode: 1; export declare const nullLevel: OrderBookLevelL2; /** * Returns the initial margin fraction for a position or an order. * * Use {@link convertToLeverageParametersBigInt} to convert a {@link KumaMarket} * or {@link LeverageParameters} object to {@link LeverageParametersBigInt}. */ export declare function calculateInitialMarginFractionWithOverride(args: { /** Signed */ baseQuantity: bigint; initialMarginFractionOverride: bigint | null; leverageParameters: LeverageParametersBigInt; }): bigint; export declare function calculateMaximumInitialMarginFractionOverride(market: Pick, wallet: Pick, walletInitialMarginFractionOverrides: KumaInitialMarginFractionOverride[]): string; export declare function convertToActiveStandingOrderBigInt(order: ActiveStandingOrder): ActiveStandingOrderBigInt; export declare function convertToLeverageParametersBigInt(leverageParameters: LeverageParameters): LeverageParametersBigInt; /** * Converts a {@link KumaPosition} object to one used by some functions in this * file. */ export declare function convertToPositionBigInt(position: KumaPosition): Position; /** * Determines the liquidity available in the given order book (asks or bids) * for a given taker quantity (which may be expressed in base or quote asset) * and price (optional). * In other words, it performs very basic order matching to provide an estimate * of the base and quote quantities with which a taker order of the given * size (quantity) and limit price (optional) would be filled. * * The taker order may represent a limit or a market order: If a limit price is * given, it is matched as a limit order (which necessitates specifying whether * it's a buy or a sell). Otherwise it is matched as a market order. * * The provided list of orders or price levels (asks or bids) is expected to be * sorted by best price (ascending for asks (lowest first), descending for bids * (highest first)). Multiple orders per price level are supported. * * To support high-precision calculations in which pip-precision is * insufficient, the result may optionally be returned in double-pip precision; * the returned values then represent numbers with 16 decimals instead of 8. * * @param returnInDoublePipPrecision - Defaults to false */ export declare function calculateGrossFillQuantities(makerSideOrders: Iterable, takerOrder: { side: OrderSide; quantity: bigint; isQuantityInQuote: boolean; limitPrice?: bigint; }, returnInDoublePipPrecision?: boolean): { baseQuantity: bigint; quoteQuantity: bigint; }; /** * Reduce-only orders may only be on the books if their execution would in fact * result in a reduction of an open position. That is, if any of the wallet's * other standing orders would be matched and executed first and reduce the * position, any reduce-only liquidity newly added to the books may not exceed * the remaining size of the position. * * This function returns the size of the given open position minus the combined * size of all the wallet's standing orders on the other side of the book that * are priced better (higher for buys, lower for sells) or equal to the provided * limit price. */ export declare function determineMaximumReduceOnlyQuantityAvailableAtPriceLevel(args: { limitPrice: bigint; position: KumaPosition; orderSide: OrderSide; walletsStandingOrders: StandingOrder[]; }): bigint; /** * Helper function to re-aggregate L2 orderbook price levels at a larger (more zeroes) tick size */ export declare function aggregateL2OrderBookAtTickSize(inputBook: L2OrderBook, tickSize: bigint): L2OrderBook; /** * Adjusts prices in pips to account for tick size by discarding insignificant digits using * specified rounding mode. Ex price 123456789 at tick size 1 is 123456789, at tick size 10 * 123456780, at 100 123456700, etc */ export declare function adjustPriceToTickSize(price: bigint, tickSize: bigint, roundingMode?: BigNumber.RoundingMode): bigint; export {}; //# sourceMappingURL=quantities.d.ts.map