UNPKG

@drift-labs/sdk

Version:
700 lines • 72.8 kB
/// <reference types="node" /> /// <reference types="bn.js" /> /// <reference types="node" /> /// <reference types="node" /> import * as anchor from '@coral-xyz/anchor'; import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor'; import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30'; import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SignedMsgOrderParamsMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount, ProtectedMakerModeConfig, SignedMsgOrderParamsDelegateMessage, PostOnlyParams } from './types'; import { AccountMeta, AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js'; import { TokenFaucet } from './tokenFaucet'; import { EventEmitter } from 'events'; import StrictEventEmitter from 'strict-event-emitter-types'; import { DataAndSlot, DriftClientAccountEvents, DriftClientAccountSubscriber } from './accounts/types'; import { TxSender, TxSigAndSlot } from './tx/types'; import { MMOraclePriceData, OraclePriceData } from './oracles/types'; import { DriftClientConfig } from './driftClientConfig'; import { User } from './user'; import { UserSubscriptionConfig } from './userConfig'; import { DriftEnv } from './config'; import { UserStats } from './userStats'; import { JupiterClient, QuoteResponse, SwapMode } from './jupiter/jupiterClient'; import { UserStatsSubscriptionConfig } from './userStatsConfig'; import { TxHandler } from './tx/txHandler'; import { WormholeCoreBridgeSolana } from '@pythnetwork/pyth-solana-receiver/lib/idl/wormhole_core_bridge_solana'; import { PythSolanaReceiver } from '@pythnetwork/pyth-solana-receiver/lib/idl/pyth_solana_receiver'; import { Slothash } from './slot/SlothashSubscriber'; import { SignedMsgOrderParams } from './types'; type RemainingAccountParams = { userAccounts: UserAccount[]; writablePerpMarketIndexes?: number[]; writableSpotMarketIndexes?: number[]; readablePerpMarketIndex?: number | number[]; readableSpotMarketIndexes?: number[]; useMarketLastSlotCache?: boolean; }; /** * # DriftClient * This class is the main way to interact with Drift Protocol. It allows you to subscribe to the various accounts where the Market's state is stored, as well as: opening positions, liquidating, settling funding, depositing & withdrawing, and more. */ export declare class DriftClient { connection: Connection; wallet: IWallet; program: Program; provider: AnchorProvider; env: DriftEnv; opts?: ConfirmOptions; useHotWalletAdmin?: boolean; users: Map<string, User>; userStats?: UserStats; activeSubAccountId: number; userAccountSubscriptionConfig: UserSubscriptionConfig; userStatsAccountSubscriptionConfig: UserStatsSubscriptionConfig; accountSubscriber: DriftClientAccountSubscriber; eventEmitter: StrictEventEmitter<EventEmitter, DriftClientAccountEvents>; metricsEventEmitter: StrictEventEmitter<EventEmitter, DriftClientMetricsEvents>; _isSubscribed: boolean; txSender: TxSender; perpMarketLastSlotCache: Map<number, number>; spotMarketLastSlotCache: Map<number, number>; mustIncludePerpMarketIndexes: Set<number>; mustIncludeSpotMarketIndexes: Set<number>; authority: PublicKey; /** @deprecated use marketLookupTables */ marketLookupTable: PublicKey; /** @deprecated use lookupTableAccounts */ lookupTableAccount: AddressLookupTableAccount; marketLookupTables: PublicKey[]; lookupTableAccounts: AddressLookupTableAccount[]; includeDelegates?: boolean; authoritySubAccountMap?: Map<string, number[]>; skipLoadUsers?: boolean; txVersion: TransactionVersion; txParams: TxParams; enableMetricsEvents?: boolean; txHandler: TxHandler; receiverProgram?: Program<PythSolanaReceiver>; wormholeProgram?: Program<WormholeCoreBridgeSolana>; sbOnDemandProgramdId: PublicKey; sbOnDemandProgram?: Program30<Idl30>; sbProgramFeedConfigs?: Map<string, any>; get isSubscribed(): boolean; set isSubscribed(val: boolean); constructor(config: DriftClientConfig); getUserMapKey(subAccountId: number, authority: PublicKey): string; createUser(subAccountId: number, accountSubscriptionConfig: UserSubscriptionConfig, authority?: PublicKey): User; subscribe(): Promise<boolean>; subscribeUsers(): Promise<boolean>[]; /** * Forces the accountSubscriber to fetch account updates from rpc */ fetchAccounts(): Promise<void>; unsubscribe(): Promise<void>; unsubscribeUsers(): Promise<void>[]; statePublicKey?: PublicKey; getStatePublicKey(): Promise<PublicKey>; signerPublicKey?: PublicKey; getSignerPublicKey(): PublicKey; getStateAccount(): StateAccount; /** * Forces a fetch to rpc before returning accounts. Useful for anchor tests. */ forceGetStateAccount(): Promise<StateAccount>; getPerpMarketAccount(marketIndex: number): PerpMarketAccount | undefined; /** * Forces a fetch to rpc before returning accounts. Useful for anchor tests. * @param marketIndex */ forceGetPerpMarketAccount(marketIndex: number): Promise<PerpMarketAccount | undefined>; getPerpMarketAccounts(): PerpMarketAccount[]; getSpotMarketAccount(marketIndex: number): SpotMarketAccount | undefined; /** * Forces a fetch to rpc before returning accounts. Useful for anchor tests. * @param marketIndex */ forceGetSpotMarketAccount(marketIndex: number): Promise<SpotMarketAccount | undefined>; getSpotMarketAccounts(): SpotMarketAccount[]; getQuoteSpotMarketAccount(): SpotMarketAccount; getOraclePriceDataAndSlot(oraclePublicKey: PublicKey, oracleSource: OracleSource): DataAndSlot<OraclePriceData> | undefined; getSerumV3FulfillmentConfig(serumMarket: PublicKey): Promise<SerumV3FulfillmentConfigAccount>; getSerumV3FulfillmentConfigs(): Promise<SerumV3FulfillmentConfigAccount[]>; getPhoenixV1FulfillmentConfig(phoenixMarket: PublicKey): Promise<PhoenixV1FulfillmentConfigAccount>; getPhoenixV1FulfillmentConfigs(): Promise<PhoenixV1FulfillmentConfigAccount[]>; getOpenbookV2FulfillmentConfig(openbookMarket: PublicKey): Promise<OpenbookV2FulfillmentConfigAccount>; getOpenbookV2FulfillmentConfigs(): Promise<OpenbookV2FulfillmentConfigAccount[]>; /** @deprecated use fetchAllLookupTableAccounts() */ fetchMarketLookupTableAccount(): Promise<AddressLookupTableAccount>; fetchAllLookupTableAccounts(): Promise<AddressLookupTableAccount[]>; private getTxVersionForNewWallet; /** * Update the wallet to use for drift transactions and linked user account * @param newWallet * @param subAccountIds * @param activeSubAccountId * @param includeDelegates */ updateWallet(newWallet: IWallet, subAccountIds?: number[], activeSubAccountId?: number, includeDelegates?: boolean, authoritySubaccountMap?: Map<string, number[]>): Promise<boolean>; /** * Update the subscribed accounts to a given authority, while leaving the * connected wallet intact. This allows a user to emulate another user's * account on the UI and sign permissionless transactions with their own wallet. * @param emulateAuthority */ emulateAccount(emulateAuthority: PublicKey): Promise<boolean>; switchActiveUser(subAccountId: number, authority?: PublicKey): Promise<void>; addUser(subAccountId: number, authority?: PublicKey, userAccount?: UserAccount): Promise<boolean>; /** * Adds and subscribes to users based on params set by the constructor or by updateWallet. */ addAndSubscribeToUsers(authority?: PublicKey): Promise<boolean>; /** * Returns the instructions to initialize a user account and the public key of the user account. * @param subAccountId * @param name * @param referrerInfo * @returns [instructions, userAccountPublicKey] */ getInitializeUserAccountIxs(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, poolId?: number): Promise<[TransactionInstruction[], PublicKey]>; /** * Initializes a user account and returns the transaction signature and the public key of the user account. * @param subAccountId * @param name * @param referrerInfo * @param txParams * @returns [transactionSignature, userAccountPublicKey] */ initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>; getInitializeUserStatsIx(): Promise<TransactionInstruction>; initializeSignedMsgUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>; getInitializeSignedMsgUserOrdersAccountIx(authority: PublicKey, numOrders: number): Promise<[PublicKey, TransactionInstruction]>; resizeSignedMsgUserOrders(authority: PublicKey, numOrders: number, userSubaccountId?: number, txParams?: TxParams): Promise<TransactionSignature>; getResizeSignedMsgUserOrdersInstruction(authority: PublicKey, numOrders: number, userSubaccountId?: number): Promise<TransactionInstruction>; initializeSignedMsgWsDelegatesAccount(authority: PublicKey, delegates?: PublicKey[], txParams?: TxParams): Promise<TransactionSignature>; getInitializeSignedMsgWsDelegatesAccountIx(authority: PublicKey, delegates?: PublicKey[]): Promise<TransactionInstruction>; addSignedMsgWsDelegate(authority: PublicKey, delegate: PublicKey, txParams?: TxParams): Promise<TransactionSignature>; getAddSignedMsgWsDelegateIx(authority: PublicKey, delegate: PublicKey): Promise<TransactionInstruction>; removeSignedMsgWsDelegate(authority: PublicKey, delegate: PublicKey, txParams?: TxParams): Promise<TransactionSignature>; getRemoveSignedMsgWsDelegateIx(authority: PublicKey, delegate: PublicKey): Promise<TransactionInstruction>; initializeFuelOverflow(authority?: PublicKey): Promise<TransactionSignature>; getInitializeFuelOverflowIx(authority?: PublicKey): Promise<TransactionInstruction>; sweepFuel(authority?: PublicKey): Promise<TransactionSignature>; getSweepFuelIx(authority?: PublicKey): Promise<TransactionInstruction>; private getInitializeUserInstructions; getNextSubAccountId(): Promise<number>; initializeReferrerName(name: string): Promise<TransactionSignature>; updateUserName(name: string, subAccountId?: number): Promise<TransactionSignature>; updateUserCustomMarginRatio(updates: { marginRatio: number; subAccountId: number; }[], txParams?: TxParams): Promise<TransactionSignature>; getUpdateUserCustomMarginRatioIx(marginRatio: number, subAccountId?: number): Promise<TransactionInstruction>; getUpdateUserPerpPositionCustomMarginRatioIx(perpMarketIndex: number, marginRatio: number, subAccountId?: number): Promise<TransactionInstruction>; updateUserPerpPositionCustomMarginRatio(perpMarketIndex: number, marginRatio: number, subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>; getUpdateUserMarginTradingEnabledIx(marginTradingEnabled: boolean, subAccountId?: number, userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>; updateUserMarginTradingEnabled(updates: { marginTradingEnabled: boolean; subAccountId: number; }[]): Promise<TransactionSignature>; getUpdateUserDelegateIx(delegate: PublicKey, overrides: { subAccountId?: number; userAccountPublicKey?: PublicKey; authority?: PublicKey; }): Promise<TransactionInstruction>; updateUserDelegate(delegate: PublicKey, subAccountId?: number): Promise<TransactionSignature>; updateUserAdvancedLp(updates: { advancedLp: boolean; subAccountId: number; }[]): Promise<TransactionSignature>; getUpdateAdvancedDlpIx(advancedLp: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>; updateUserReduceOnly(updates: { reduceOnly: boolean; subAccountId: number; }[]): Promise<TransactionSignature>; getUpdateUserReduceOnlyIx(reduceOnly: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>; updateUserPoolId(updates: { poolId: number; subAccountId: number; }[]): Promise<TransactionSignature>; getUpdateUserPoolIdIx(poolId: number, subAccountId: number): Promise<anchor.web3.TransactionInstruction>; fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>; getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>; getUserAccountsAndAddressesForAuthority(authority: PublicKey): Promise<ProgramAccount<UserAccount>[]>; getUserAccountsForAuthority(authority: PublicKey): Promise<UserAccount[]>; getReferredUserStatsAccountsByReferrer(referrer: PublicKey): Promise<UserStatsAccount[]>; getReferrerNameAccountsForAuthority(authority: PublicKey): Promise<ReferrerNameAccount[]>; deleteUser(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>; getUserDeletionIx(userAccountPublicKey: PublicKey): Promise<anchor.web3.TransactionInstruction>; forceDeleteUser(userAccountPublicKey: PublicKey, userAccount: UserAccount, txParams?: TxParams): Promise<TransactionSignature>; getForceDeleteUserIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<anchor.web3.TransactionInstruction>; deleteSignedMsgUserOrders(txParams?: TxParams): Promise<TransactionSignature>; getSignedMsgUserOrdersDeletionIx(authority: PublicKey): Promise<anchor.web3.TransactionInstruction>; /** * Checks if a SignedMsg User Orders account exists for the given authority. * The account pubkey is derived using the program ID and authority as seeds. * Makes an RPC call to check if the account exists on-chain. * * @param authority The authority public key to check for * @returns Promise that resolves to true if the account exists, false otherwise */ isSignedMsgUserOrdersAccountInitialized(authority: PublicKey): Promise<boolean>; reclaimRent(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>; getReclaimRentIx(userAccountPublicKey: PublicKey): Promise<anchor.web3.TransactionInstruction>; getUser(subAccountId?: number, authority?: PublicKey): User; hasUser(subAccountId?: number, authority?: PublicKey): boolean; getUsers(): User[]; getUserStats(): UserStats; fetchReferrerNameAccount(name: string): Promise<ReferrerNameAccount | undefined>; userStatsAccountPublicKey: PublicKey; getUserStatsAccountPublicKey(): PublicKey; getUserAccountPublicKey(subAccountId?: number, authority?: PublicKey): Promise<PublicKey>; getUserAccount(subAccountId?: number, authority?: PublicKey): UserAccount | undefined; /** * Forces a fetch to rpc before returning accounts. Useful for anchor tests. * @param subAccountId */ forceGetUserAccount(subAccountId?: number, authority?: PublicKey): Promise<UserAccount | undefined>; getUserAccountAndSlot(subAccountId?: number, authority?: PublicKey): DataAndSlot<UserAccount> | undefined; getSpotPosition(marketIndex: number, subAccountId?: number): SpotPosition | undefined; getQuoteAssetTokenAmount(): BN; /** * Returns the token amount for a given market. The spot market precision is based on the token mint decimals. * Positive if it is a deposit, negative if it is a borrow. * @param marketIndex */ getTokenAmount(marketIndex: number): BN; /** * Converts an amount to the spot precision for a given market. The spot market precision is based on the token mint decimals. * @param marketIndex * @param amount */ convertToSpotPrecision(marketIndex: number, amount: BN | number): BN; /** * Converts an amount to the perp precision. The perp market precision is {@link BASE_PRECISION} (1e9). * @param amount */ convertToPerpPrecision(amount: BN | number): BN; /** * Converts an amount to the price precision. The perp market precision is {@link PRICE_PRECISION} (1e6). * @param amount */ convertToPricePrecision(amount: BN | number): BN; /** * Each drift instruction must include perp and sport market accounts in the ix remaining accounts. * Use this function to force a subset of markets to be included in the remaining accounts for every ix * * @param perpMarketIndexes * @param spotMarketIndexes */ mustIncludeMarketsInIx({ perpMarketIndexes, spotMarketIndexes, }: { perpMarketIndexes: number[]; spotMarketIndexes: number[]; }): void; getRemainingAccounts(params: RemainingAccountParams): AccountMeta[]; addPerpMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>, perpMarketAccountMap: Map<number, AccountMeta>): void; addSpotMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>): void; getRemainingAccountMapsForUsers(userAccounts: UserAccount[]): { oracleAccountMap: Map<string, AccountMeta>; spotMarketAccountMap: Map<number, AccountMeta>; perpMarketAccountMap: Map<number, AccountMeta>; }; getOrder(orderId: number, subAccountId?: number): Order | undefined; getOrderByUserId(userOrderId: number, subAccountId?: number): Order | undefined; /** * Get the associated token address for the given spot market * @param marketIndex * @param useNative * @param tokenProgram */ getAssociatedTokenAccount(marketIndex: number, useNative?: boolean, tokenProgram?: anchor.web3.PublicKey): Promise<PublicKey>; createAssociatedTokenAccountIdempotentInstruction(account: PublicKey, payer: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgram?: anchor.web3.PublicKey): TransactionInstruction; getDepositTxnIx(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean): Promise<TransactionInstruction[]>; buildSwiftDepositTx(signedOrderParams: SignedMsgOrderParams, takerInfo: { taker: PublicKey; takerStats: PublicKey; takerUserAccount: UserAccount; signingAuthority: PublicKey; }, depositAmount: BN, depositSpotMarketIndex: number, tradePerpMarketIndex: number, subAccountId: number, takerAssociatedTokenAccount: PublicKey, initSwiftAccount?: boolean): Promise<void>; createDepositTxn(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams, initSwiftAccount?: boolean): Promise<VersionedTransaction | Transaction>; /** * Deposit funds into the given spot market * * @param amount to deposit * @param marketIndex spot market index to deposit into * @param associatedTokenAccount can be the wallet public key if using native sol * @param subAccountId subaccountId to deposit * @param reduceOnly if true, deposit must not increase account risk */ deposit(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams, initSwiftAccount?: boolean): Promise<TransactionSignature>; getDepositInstruction(amount: BN, marketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>; private checkIfAccountExists; getWrappedSolAccountCreationIxs(amount: BN, includeRent?: boolean): Promise<{ ixs: anchor.web3.TransactionInstruction[]; /** @deprecated - this array is always going to be empty, in the current implementation */ signers: Signer[]; pubkey: PublicKey; }>; getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey; isToken2022(spotMarketAccount: SpotMarketAccount): boolean; isTransferHook(spotMarketAccount: SpotMarketAccount): boolean; addTokenMintToRemainingAccounts(spotMarketAccount: SpotMarketAccount, remainingAccounts: AccountMeta[]): void; addExtraAccountMetasToRemainingAccounts(mint: PublicKey, remainingAccounts: AccountMeta[]): Promise<void>; getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey, tokenProgram: PublicKey): anchor.web3.TransactionInstruction; createInitializeUserAccountAndDepositCollateralIxs(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, customMaxMarginRatio?: number, poolId?: number): Promise<{ ixs: TransactionInstruction[]; userAccountPublicKey: PublicKey; }>; createInitializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number, poolId?: number): Promise<[Transaction | VersionedTransaction, PublicKey]>; /** * Creates the User account for a user, and deposits some initial collateral * @param amount * @param userTokenAccount * @param marketIndex * @param subAccountId * @param name * @param fromSubAccountId * @param referrerInfo * @param donateAmount * @param txParams * @returns */ initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number, poolId?: number): Promise<[TransactionSignature, PublicKey]>; initializeUserAccountForDevnet(subAccountId: number, name: string, marketIndex: number, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>; getWithdrawalIxs(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean, subAccountId?: number, updateFuel?: boolean): Promise<TransactionInstruction[]>; /** * Withdraws from a user account. If deposit doesn't already exist, creates a borrow * @param amount * @param marketIndex * @param associatedTokenAddress - the token account to withdraw to. can be the wallet public key if using native sol * @param reduceOnly */ withdraw(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean, subAccountId?: number, txParams?: TxParams, updateFuel?: boolean): Promise<TransactionSignature>; withdrawAllDustPositions(subAccountId?: number, txParams?: TxParams, opts?: { dustPositionCountCallback?: (count: number) => void; }): Promise<TransactionSignature | undefined>; getWithdrawIx(amount: BN, marketIndex: number, userTokenAccount: PublicKey, reduceOnly?: boolean, subAccountId?: number): Promise<TransactionInstruction>; /** * Withdraws from the fromSubAccount and deposits into the toSubAccount * @param amount * @param marketIndex * @param fromSubAccountId * @param toSubAccountId * @param txParams */ transferDeposit(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>; getTransferDepositIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>; transferPools(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>; getTransferPoolsIx(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, isToNewSubAccount?: boolean): Promise<TransactionInstruction>; transferPerpPosition(fromSubAccountId: number, toSubAccountId: number, marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>; getTransferPerpPositionIx(fromSubAccountId: number, toSubAccountId: number, marketIndex: number, amount: BN): Promise<TransactionInstruction>; updateSpotMarketCumulativeInterest(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>; updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>; settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>; settleLPIx(settleeUserAccountPublicKey: PublicKey, marketIndex: number): Promise<TransactionInstruction>; removePerpLpShares(marketIndex: number, sharesToBurn?: BN, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; removePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN, txParams?: TxParams): Promise<TransactionSignature>; getRemovePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN): Promise<TransactionInstruction>; getRemovePerpLpSharesIx(marketIndex: number, sharesToBurn?: BN, subAccountId?: number): Promise<TransactionInstruction>; addPerpLpShares(amount: BN, marketIndex: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; getAddPerpLpSharesIx(amount: BN, marketIndex: number, subAccountId?: number): Promise<TransactionInstruction>; getQuoteValuePerLpShare(marketIndex: number): BN; /** * @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead */ openPosition(direction: PositionDirection, amount: BN, marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>; sendSignedTx(tx: Transaction | VersionedTransaction, opts?: ConfirmOptions): Promise<TransactionSignature>; prepareMarketOrderTxs(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], referrerInfo?: ReferrerInfo, cancelExistingOrders?: boolean, settlePnl?: boolean): Promise<{ cancelExistingOrdersTx?: Transaction | VersionedTransaction; settlePnlTx?: Transaction | VersionedTransaction; fillTx?: Transaction | VersionedTransaction; marketOrderTx: Transaction | VersionedTransaction; }>; /** * Sends a market order and returns a signed tx which can fill the order against the vamm, which the caller can use to fill their own order if required. * @param orderParams * @param userAccountPublicKey * @param userAccount * @param makerInfo * @param txParams * @param bracketOrdersParams * @param cancelExistingOrders - Builds and returns an extra transaciton to cancel the existing orders in the same perp market. Intended use is to auto-cancel TP/SL orders when closing a position. Ignored if orderParams.marketType is not MarketType.PERP * @returns */ sendMarketOrderAndGetSignedFillTx(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], referrerInfo?: ReferrerInfo, cancelExistingOrders?: boolean, settlePnl?: boolean): Promise<{ txSig: TransactionSignature; signedFillTx?: Transaction; signedCancelExistingOrdersTx?: Transaction; signedSettlePnlTx?: Transaction; }>; placePerpOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; getPlacePerpOrderIx(orderParams: OptionalOrderParams, subAccountId?: number, depositToTradeArgs?: { isMakingNewAccount: boolean; depositMarketIndex: number; }): Promise<TransactionInstruction>; updateAMMs(marketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>; getUpdateAMMsIx(marketIndexes: number[]): Promise<TransactionInstruction>; settleExpiredMarket(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>; getSettleExpiredMarketIx(marketIndex: number): Promise<TransactionInstruction>; settleExpiredMarketPoolsToRevenuePool(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>; getSettleExpiredMarketPoolsToRevenuePoolIx(perpMarketIndex: number): Promise<TransactionInstruction>; cancelOrder(orderId?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; getCancelOrderIx(orderId?: number, subAccountId?: number): Promise<TransactionInstruction>; cancelOrderByUserId(userOrderId: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; getCancelOrderByUserIdIx(userOrderId: number, subAccountId?: number): Promise<TransactionInstruction>; /** * Sends a transaction to cancel the provided order ids. * * @param orderIds - The order ids to cancel. * @param txParams - The transaction parameters. * @param subAccountId - The sub account id to cancel the orders for. * @param user - The user to cancel the orders for. If provided, it will be prioritized over the subAccountId. * @returns The transaction signature. */ cancelOrdersByIds(orderIds?: number[], txParams?: TxParams, subAccountId?: number, user?: User): Promise<TransactionSignature>; /** * Returns the transaction instruction to cancel the provided order ids. * * @param orderIds - The order ids to cancel. * @param subAccountId - The sub account id to cancel the orders for. * @param user - The user to cancel the orders for. If provided, it will be prioritized over the subAccountId. * @returns The transaction instruction to cancel the orders. */ getCancelOrdersByIdsIx(orderIds?: number[], subAccountId?: number, user?: User): Promise<TransactionInstruction>; cancelOrders(marketType?: MarketType, marketIndex?: number, direction?: PositionDirection, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; getCancelOrdersIx(marketType: MarketType | null, marketIndex: number | null, direction: PositionDirection | null, subAccountId?: number): Promise<TransactionInstruction>; cancelAndPlaceOrders(cancelOrderParams: { marketType?: MarketType; marketIndex?: number; direction?: PositionDirection; }, placeOrderParams: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; placeOrders(params: OrderParams[], txParams?: TxParams, subAccountId?: number, optionalIxs?: TransactionInstruction[]): Promise<TransactionSignature>; preparePlaceOrdersTx(params: OrderParams[], txParams?: TxParams, subAccountId?: number, optionalIxs?: TransactionInstruction[]): Promise<{ placeOrdersTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction; }>; getPlaceOrdersIx(params: OptionalOrderParams[], subAccountId?: number): Promise<TransactionInstruction>; fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams, fillerSubAccountId?: number, fillerAuthority?: PublicKey): Promise<TransactionSignature>; getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerSubAccountId?: number, isSignedMsg?: boolean, fillerAuthority?: PublicKey): Promise<TransactionInstruction>; getRevertFillIx(fillerPublicKey?: PublicKey): Promise<TransactionInstruction>; placeSpotOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; preparePlaceSpotOrderTx(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<{ placeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction; }>; getPlaceSpotOrderIx(orderParams: OptionalOrderParams, subAccountId?: number): Promise<TransactionInstruction>; fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>; getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>; addSpotFulfillmentAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount): void; addSerumRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: SerumV3FulfillmentConfigAccount): void; addPhoenixRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: PhoenixV1FulfillmentConfigAccount): void; addOpenbookRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: OpenbookV2FulfillmentConfigAccount): void; /** * Swap tokens in drift account using jupiter * @param jupiterClient jupiter client to find routes and jupiter instructions * @param outMarketIndex the market index of the token you're buying * @param inMarketIndex the market index of the token you're selling * @param outAssociatedTokenAccount the token account to receive the token being sold on jupiter * @param inAssociatedTokenAccount the token account to * @param amount the amount of TokenIn, regardless of swapMode * @param slippageBps the max slippage passed to jupiter api * @param swapMode jupiter swapMode (ExactIn or ExactOut), default is ExactIn * @param route the jupiter route to use for the swap * @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap * @param v6 pass in the quote response from Jupiter quote's API (deprecated, use quote instead) * @param quote pass in the quote response from Jupiter quote's API * @param txParams */ swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, reduceOnly, txParams, v6, quote, onlyDirectRoutes, }: { jupiterClient: JupiterClient; outMarketIndex: number; inMarketIndex: number; outAssociatedTokenAccount?: PublicKey; inAssociatedTokenAccount?: PublicKey; amount: BN; slippageBps?: number; swapMode?: SwapMode; reduceOnly?: SwapReduceOnly; txParams?: TxParams; onlyDirectRoutes?: boolean; v6?: { quote?: QuoteResponse; }; quote?: QuoteResponse; }): Promise<TransactionSignature>; getJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, quote, reduceOnly, userAccountPublicKey, }: { jupiterClient: JupiterClient; outMarketIndex: number; inMarketIndex: number; outAssociatedTokenAccount?: PublicKey; inAssociatedTokenAccount?: PublicKey; amount: BN; slippageBps?: number; swapMode?: SwapMode; onlyDirectRoutes?: boolean; quote?: QuoteResponse; reduceOnly?: SwapReduceOnly; userAccountPublicKey?: PublicKey; }): Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[]; }>; /** * Get the drift begin_swap and end_swap instructions * * @param outMarketIndex the market index of the token you're buying * @param inMarketIndex the market index of the token you're selling * @param amountIn the amount of the token to sell * @param inTokenAccount the token account to move the tokens being sold * @param outTokenAccount the token account to receive the tokens being bought * @param limitPrice the limit price of the swap * @param reduceOnly * @param userAccountPublicKey optional, specify a custom userAccountPublicKey to use instead of getting the current user account; can be helpful if the account is being created within the current tx */ getSwapIx({ outMarketIndex, inMarketIndex, amountIn, inTokenAccount, outTokenAccount, limitPrice, reduceOnly, userAccountPublicKey, }: { outMarketIndex: number; inMarketIndex: number; amountIn: BN; inTokenAccount: PublicKey; outTokenAccount: PublicKey; limitPrice?: BN; reduceOnly?: SwapReduceOnly; userAccountPublicKey?: PublicKey; }): Promise<{ beginSwapIx: TransactionInstruction; endSwapIx: TransactionInstruction; }>; stakeForMSOL({ amount }: { amount: BN; }): Promise<TxSigAndSlot>; getStakeForMSOLIx({ amount, userAccountPublicKey, }: { amount: BN; userAccountPublicKey?: PublicKey; }): Promise<TransactionInstruction[]>; triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>; getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>; forceCancelOrders(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>; getForceCancelOrdersIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>; updateUserIdle(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>; getUpdateUserIdleIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>; logUserBalances(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>; getLogUserBalancesIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>; updateUserFuelBonus(userAccountPublicKey: PublicKey, user: UserAccount, userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>; getUpdateUserFuelBonusIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, userAuthority: PublicKey): Promise<TransactionInstruction>; updateUserStatsReferrerStatus(userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>; getUpdateUserStatsReferrerStatusIx(userAuthority: PublicKey): Promise<TransactionInstruction>; updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>; getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>; placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean, auctionDurationPercentage?: number, optionalIxs?: TransactionInstruction[]): Promise<{ placeAndTakeTx: Transaction | VersionedTransaction; cancelExistingOrdersTx: Transaction | VersionedTransaction; settlePnlTx: Transaction | VersionedTransaction; }>; placeAndTakePerpWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean): Promise<{ txSig: TransactionSignature; signedCancelExistingOrdersTx?: Transaction; signedSettlePnlTx?: Transaction; }>; getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, subAccountId?: number): Promise<TransactionInstruction>; placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>; signSignedMsgOrderParamsMessage(orderParamsMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, delegateSigner?: boolean): SignedMsgOrderParams; /** * Builds a deposit and place request for Swift service * * @param depositTx - The signed tx containing a drift deposit (e.g. see `buildSwiftDepositTx`) * @param orderParamsMessage - The order parameters message to sign * @param delegateSigner - Whether this is a delegate signer * * @returns request object for Swift service */ buildDepositAndPlaceSignedMsgOrderRequest(depositTx: VersionedTransaction, orderParamsMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, delegateSigner?: boolean): { deposit_tx: Buffer; swift_order: SignedMsgOrderParams; }; encodeSignedMsgOrderParamsMessage(orderParamsMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, delegateSigner?: boolean): Buffer; decodeSignedMsgOrderParamsMessage(encodedMessage: Buffer, delegateSigner?: boolean): SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage; signMessage(message: Uint8Array, keypair?: Keypair): Buffer; placeSignedMsgTakerOrder(signedSignedMsgOrderParams: SignedMsgOrderParams, marketIndex: number, takerInfo: { taker: PublicKey; takerStats: PublicKey; takerUserAccount: UserAccount; signingAuthority: PublicKey; }, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number, txParams?: TxParams): Promise<TransactionSignature>; getPlaceSignedMsgTakerPerpOrderIxs(signedSignedMsgOrderParams: SignedMsgOrderParams, marketIndex: number, takerInfo: { taker: PublicKey; takerStats: PublicKey; takerUserAccount: UserAccount; signingAuthority: PublicKey; }, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number): Promise<TransactionInstruction[]>; placeAndMakeSignedMsgPerpOrder(signedSignedMsgOrderParams: SignedMsgOrderParams, signedMsgOrderUuid: Uint8Array, takerInfo: { taker: PublicKey; takerStats: PublicKey; takerUserAccount: UserAccount; signingAuthority: PublicKey; }, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number): Promise<TransactionSignature>; getPlaceAndMakeSignedMsgPerpOrderIxs(signedSignedMsgOrderParams: SignedMsgOrderParams, signedMsgOrderUuid: Uint8Array, takerInfo: { taker: PublicKey; takerStats: PublicKey; takerUserAccount: UserAccount; signingAuthority: PublicKey; }, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number): Promise<TransactionInstruction[]>; preparePlaceAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<{ placeAndTakeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction; }>; placeAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; getPlaceAndTakeSpotOrderIx(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>; placeAndMakeSpotOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>; getPlaceAndMakeSpotOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>; /** * @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead */ closePosition(marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>; /** * Modifies an open order by closing it and replacing it with a new order. * @deprecated use modifyOrder instead * @param orderId: The open order to modify * @param newBaseAmount: The new base amount for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided. * @param newLimitPice: The new limit price for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided. * @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided. * @returns */ modifyPerpOrder(orderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: number): Promise<TransactionSignature>; /** * Modifies an open order by closing it and replacing it with a new order. * @deprecated use modifyOrderByUserOrderId instead * @param userOrderId: The open order to modify * @param newBaseAmount: The new base amount for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided. * @param newLimitPice: The new limit price for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided. * @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided. * @returns */ modifyPerpOrderByUserOrderId(userOrderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: number): Promise<TransactionSignature>; /** * Modifies an open order (spot or perp) by closing it and replacing it with a new order. * @param orderParams.orderId: The open order to modify * @param orderParams.newDirection: The new direction for the order * @param orderParams.newBaseAmount: The new base amount for the order * @param orderParams.newLimitPice: The new limit price for the order * @param orderParams.newOraclePriceOffset: The new oracle price offset for the order * @param orderParams.newTriggerPrice: Optional - Thew new trigger price for the order. * @param orderParams.auctionDuration: * @param orderParams.auctionStartPrice: * @param orderParams.auctionEndPrice: * @param orderParams.reduceOnly: * @param orderParams.postOnly: * @param orderParams.bitFlags: * @param orderParams.policy: * @param orderParams.maxTs: * @returns */ modifyOrder(orderParams: { orderId: number; newDirection?: PositionDirection; newBaseAmount?: BN; newLimitPrice?: BN; newOraclePriceOffset?: number; newTriggerPrice?: BN; newTriggerCondition?: OrderTriggerCondition; auctionDuration?: number; auctionStartPrice?: BN; auctionEndPrice?: BN; reduceOnly?: boolean; p