UNPKG

@drift-labs/common

Version:

Common functions for Drift

24 lines (23 loc) 1.08 kB
import { BN, OptionalOrderParams } from '@drift-labs/sdk'; import { NonMarketOrderParamsConfig } from '../base/actions/trade/openPerpOrder/types'; /** * Converts amount and assetType to base asset amount * @param amount - The amount to convert * @param assetType - 'base' or 'quote' * @param limitPrice - Required when assetType is 'quote' for conversion * @returns Base asset amount */ export declare function convertToBaseAssetAmount(amount: BN, assetType: 'base' | 'quote', limitPrice?: BN): BN; /** * Resolves amount parameters from either new (amount + assetType) or legacy (baseAssetAmount) approach */ export declare function resolveBaseAssetAmount(params: { amount?: BN; assetType?: 'base' | 'quote'; baseAssetAmount?: BN; limitPrice?: BN; }): BN; /** * Builds proper order parameters for non-market orders using the same logic as the UI */ export declare function buildNonMarketOrderParams({ marketIndex, marketType, direction, baseAssetAmount, orderConfig, reduceOnly, postOnly, userOrderId, }: NonMarketOrderParamsConfig): OptionalOrderParams;