/// /// import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor'; import { StateAccount, IWallet, PositionDirection, UserAccount, PerpMarketAccount, OrderParams, Order, SpotMarketAccount, SpotPosition, MakerInfo, TakerInfo, OptionalOrderParams, ReferrerInfo, MarketType, TxParams, SerumV3FulfillmentConfigAccount, ReferrerNameAccount, OrderTriggerCondition, PerpMarketExtendedInfo, UserStatsAccount, PhoenixV1FulfillmentConfigAccount, ModifyOrderPolicy, SwapReduceOnly } from './types'; import * as anchor from '@coral-xyz/anchor'; import { Connection, PublicKey, TransactionSignature, ConfirmOptions, Transaction, TransactionInstruction, AccountMeta, Signer, AddressLookupTableAccount, TransactionVersion, VersionedTransaction } from '@solana/web3.js'; import { TokenFaucet } from './tokenFaucet'; import { EventEmitter } from 'events'; import StrictEventEmitter from 'strict-event-emitter-types'; import { DriftClientAccountSubscriber, DriftClientAccountEvents, DataAndSlot, DriftClientMetricsEvents } from './accounts/types'; import { TxSender, TxSigAndSlot } from './tx/types'; import { OraclePriceData } from './oracles/types'; import { DriftClientConfig } from './driftClientConfig'; import { User } from './user'; import { UserSubscriptionConfig } from './userConfig'; import { UserStats } from './userStats'; import { JupiterClient, QuoteResponse, Route, SwapMode } from './jupiter/jupiterClient'; import { UserStatsSubscriptionConfig } from './userStatsConfig'; 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; opts?: ConfirmOptions; users: Map; userStats?: UserStats; activeSubAccountId: number; userAccountSubscriptionConfig: UserSubscriptionConfig; userStatsAccountSubscriptionConfig: UserStatsSubscriptionConfig; accountSubscriber: DriftClientAccountSubscriber; eventEmitter: StrictEventEmitter; metricsEventEmitter: StrictEventEmitter; _isSubscribed: boolean; txSender: TxSender; perpMarketLastSlotCache: Map; spotMarketLastSlotCache: Map; mustIncludePerpMarketIndexes: Set; mustIncludeSpotMarketIndexes: Set; authority: PublicKey; marketLookupTable: PublicKey; lookupTableAccount: AddressLookupTableAccount; includeDelegates?: boolean; authoritySubAccountMap?: Map; skipLoadUsers?: boolean; txVersion: TransactionVersion; txParams: TxParams; enableMetricsEvents?: boolean; 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; subscribeUsers(): Promise[]; /** * Forces the accountSubscriber to fetch account updates from rpc */ fetchAccounts(): Promise; unsubscribe(): Promise; unsubscribeUsers(): Promise[]; statePublicKey?: PublicKey; getStatePublicKey(): Promise; signerPublicKey?: PublicKey; getSignerPublicKey(): PublicKey; getStateAccount(): StateAccount; /** * Forces a fetch to rpc before returning accounts. Useful for anchor tests. */ forceGetStateAccount(): Promise; getPerpMarketAccount(marketIndex: number): PerpMarketAccount | undefined; /** * Forces a fetch to rpc before returning accounts. Useful for anchor tests. * @param marketIndex */ forceGetPerpMarketAccount(marketIndex: number): Promise; 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; getSpotMarketAccounts(): SpotMarketAccount[]; getQuoteSpotMarketAccount(): SpotMarketAccount; getOraclePriceDataAndSlot(oraclePublicKey: PublicKey): DataAndSlot | undefined; getSerumV3FulfillmentConfig(serumMarket: PublicKey): Promise; getPhoenixV1FulfillmentConfig(phoenixMarket: PublicKey): Promise; fetchMarketLookupTableAccount(): Promise; /** * 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): Promise; switchActiveUser(subAccountId: number, authority?: PublicKey): Promise; addUser(subAccountId: number, authority?: PublicKey, userAccount?: UserAccount): Promise; /** * Adds and subscribes to users based on params set by the constructor or by updateWallet. */ addAndSubscribeToUsers(): Promise; initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>; getInitializeUserInstructions(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>; getInitializeUserStatsIx(): Promise; getNextSubAccountId(): Promise; initializeReferrerName(name: string): Promise; updateUserName(name: string, subAccountId?: number): Promise; updateUserCustomMarginRatio(updates: { marginRatio: number; subAccountId: number; }[], txParams?: TxParams): Promise; getUpdateUserCustomMarginRatioIx(marginRatio: number, subAccountId?: number): Promise; getUpdateUserMarginTradingEnabledIx(marginTradingEnabled: boolean, subAccountId?: number, userAccountPublicKey?: PublicKey): Promise; updateUserMarginTradingEnabled(updates: { marginTradingEnabled: boolean; subAccountId: number; }[]): Promise; updateUserDelegate(delegate: PublicKey, subAccountId?: number): Promise; fetchAllUserAccounts(includeIdle?: boolean): Promise[]>; getUserAccountsForDelegate(delegate: PublicKey): Promise; getUserAccountsAndAddressesForAuthority(authority: PublicKey): Promise[]>; getUserAccountsForAuthority(authority: PublicKey): Promise; getReferredUserStatsAccountsByReferrer(referrer: PublicKey): Promise; getReferrerNameAccountsForAuthority(authority: PublicKey): Promise; deleteUser(subAccountId?: number, txParams?: TxParams): Promise; getUserDeletionIx(userAccountPublicKey: PublicKey): Promise; reclaimRent(subAccountId?: number, txParams?: TxParams): Promise; getReclaimRentIx(userAccountPublicKey: PublicKey): Promise; getUser(subAccountId?: number, authority?: PublicKey): User; hasUser(subAccountId?: number, authority?: PublicKey): boolean; getUsers(): User[]; getUserStats(): UserStats; fetchReferrerNameAccount(name: string): Promise; userStatsAccountPublicKey: PublicKey; getUserStatsAccountPublicKey(): PublicKey; getUserAccountPublicKey(subAccountId?: number, authority?: PublicKey): Promise; getUserAccount(subAccountId?: number, authority?: PublicKey): UserAccount | undefined; /** * Forces a fetch to rpc before returning accounts. Useful for anchor tests. * @param subAccountId */ forceGetUserAccount(subAccountId?: number): Promise; getUserAccountAndSlot(subAccountId?: number): DataAndSlot | 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, spotMarketAccountMap: Map, perpMarketAccountMap: Map): void; addSpotMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map, spotMarketAccountMap: Map): void; getRemainingAccountMapsForUsers(userAccounts: UserAccount[]): { oracleAccountMap: Map; spotMarketAccountMap: Map; perpMarketAccountMap: Map; }; 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 */ getAssociatedTokenAccount(marketIndex: number, useNative?: boolean): Promise; createAssociatedTokenAccountIdempotentInstruction(account: PublicKey, payer: PublicKey, owner: PublicKey, mint: PublicKey): TransactionInstruction; /** * 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): Promise; getDepositInstruction(amount: BN, marketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise; 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; }>; getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey): anchor.web3.TransactionInstruction; /** * 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): Promise<[TransactionSignature, PublicKey]>; initializeUserAccountForDevnet(subAccountId: number, name: string, marketIndex: number, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>; /** * 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): Promise; getWithdrawIx(amount: BN, marketIndex: number, userTokenAccount: PublicKey, reduceOnly?: boolean, subAccountId?: number): Promise; /** * 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; getTransferDepositIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise; updateSpotMarketCumulativeInterest(marketIndex: number, txParams?: TxParams): Promise; updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise; settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number, txParams?: TxParams): Promise; settleLPIx(settleeUserAccountPublicKey: PublicKey, marketIndex: number): Promise; removePerpLpShares(marketIndex: number, sharesToBurn?: BN, txParams?: TxParams, subAccountId?: number): Promise; removePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN, txParams?: TxParams): Promise; getRemovePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN): Promise; getRemovePerpLpSharesIx(marketIndex: number, sharesToBurn?: BN, subAccountId?: number): Promise; addPerpLpShares(amount: BN, marketIndex: number, txParams?: TxParams, subAccountId?: number): Promise; getAddPerpLpSharesIx(amount: BN, marketIndex: number, subAccountId?: number): Promise; getQuoteValuePerLpShare(marketIndex: number): BN; /** * @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead */ openPosition(direction: PositionDirection, amount: BN, marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise; sendSignedTx(tx: Transaction): Promise; /** * 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; getPlacePerpOrderIx(orderParams: OptionalOrderParams, subAccountId?: number): Promise; updateAMMs(marketIndexes: number[], txParams?: TxParams): Promise; getUpdateAMMsIx(marketIndexes: number[]): Promise; settleExpiredMarket(marketIndex: number, txParams?: TxParams): Promise; getSettleExpiredMarketIx(marketIndex: number): Promise; settleExpiredMarketPoolsToRevenuePool(perpMarketIndex: number, txParams?: TxParams): Promise; cancelOrder(orderId?: number, txParams?: TxParams, subAccountId?: number): Promise; getCancelOrderIx(orderId?: number, subAccountId?: number): Promise; cancelOrderByUserId(userOrderId: number, txParams?: TxParams, subAccountId?: number): Promise; getCancelOrderByUserIdIx(userOrderId: number, subAccountId?: number): Promise; cancelOrdersByIds(orderIds?: number[], txParams?: TxParams, subAccountId?: number): Promise; getCancelOrdersByIdsIx(orderIds?: number[], subAccountId?: number): Promise; cancelOrders(marketType?: MarketType, marketIndex?: number, direction?: PositionDirection, txParams?: TxParams, subAccountId?: number): Promise; getCancelOrdersIx(marketType: MarketType | null, marketIndex: number | null, direction: PositionDirection | null, subAccountId?: number): Promise; cancelAndPlaceOrders(cancelOrderParams: { marketType?: MarketType; marketIndex?: number; direction?: PositionDirection; }, placeOrderParams: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise; placeOrders(params: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise; getPlaceOrdersIx(params: OptionalOrderParams[], subAccountId?: number): Promise; fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams, fillerPublicKey?: number): Promise; getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerSubAccountId?: number): Promise; getRevertFillIx(fillerPublicKey?: PublicKey): Promise; placeSpotOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise; getPlaceSpotOrderIx(orderParams: OptionalOrderParams, subAccountId?: number): Promise; fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise; getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, fillerPublicKey?: PublicKey): Promise; addSpotFulfillmentAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount): void; addSerumRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: SerumV3FulfillmentConfigAccount): void; addPhoenixRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: PhoenixV1FulfillmentConfigAccount): 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 txParams */ swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, v6, onlyDirectRoutes, }: { jupiterClient: JupiterClient; outMarketIndex: number; inMarketIndex: number; outAssociatedTokenAccount?: PublicKey; inAssociatedTokenAccount?: PublicKey; amount: BN; slippageBps?: number; swapMode?: SwapMode; route?: Route; reduceOnly?: SwapReduceOnly; txParams?: TxParams; onlyDirectRoutes?: boolean; v6?: { quote?: QuoteResponse; }; }): Promise; getJupiterSwapIx({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, route, reduceOnly, userAccountPublicKey, }: { jupiterClient: JupiterClient; outMarketIndex: number; inMarketIndex: number; outAssociatedTokenAccount?: PublicKey; inAssociatedTokenAccount?: PublicKey; amount: BN; slippageBps?: number; swapMode?: SwapMode; onlyDirectRoutes?: boolean; route?: Route; reduceOnly?: SwapReduceOnly; userAccountPublicKey?: PublicKey; }): Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[]; }>; 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; getStakeForMSOLIx({ amount, userAccountPublicKey, }: { amount: BN; userAccountPublicKey?: PublicKey; }): Promise; triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise; getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, fillerPublicKey?: PublicKey): Promise; forceCancelOrders(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise; getForceCancelOrdersIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise; updateUserIdle(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise; getUpdateUserIdleIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise; updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise; getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise; placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise; placeAndTakePerpWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean): Promise<{ txSig: TransactionSignature; signedCancelExistingOrdersTx?: Transaction; signedSettlePnlTx?: Transaction; }>; getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, subAccountId?: number): Promise; placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise; getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise; placeAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise; getPlaceAndTakeSpotOrderIx(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise; placeAndMakeSpotOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise; getPlaceAndMakeSpotOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise; /** * @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead */ closePosition(marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise; /** * 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; /** * 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; /** * 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.immediateOrCancel: * @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; postOnly?: boolean; immediateOrCancel?: boolean; maxTs?: BN; policy?: ModifyOrderPolicy; }, txParams?: TxParams, subAccountId?: number): Promise; getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, policy, }: { orderId: number; newDirection?: PositionDirection; newBaseAmount?: BN; newLimitPrice?: BN; newOraclePriceOffset?: number; newTriggerPrice?: BN; newTriggerCondition?: OrderTriggerCondition; auctionDuration?: number; auctionStartPrice?: BN; auctionEndPrice?: BN; reduceOnly?: boolean; postOnly?: boolean; immediateOrCancel?: boolean; maxTs?: BN; policy?: ModifyOrderPolicy; }, subAccountId?: number): Promise; /** * Modifies an open order by closing it and replacing it with a new order. * @param orderParams.userOrderId: 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: Only required if order type changed to market from something else * @param orderParams.auctionStartPrice: Only required if order type changed to market from something else * @param orderParams.auctionEndPrice: Only required if order type changed to market from something else * @param orderParams.reduceOnly: * @param orderParams.postOnly: * @param orderParams.immediateOrCancel: * @param orderParams.policy: * @param orderParams.maxTs: * @returns */ modifyOrderByUserOrderId(orderParams: { userOrderId: number; newDirection?: PositionDirection; newBaseAmount?: BN; newLimitPrice?: BN; newOraclePriceOffset?: number; newTriggerPrice?: BN; newTriggerCondition?: OrderTriggerCondition; auctionDuration?: number; auctionStartPrice?: BN; auctionEndPrice?: BN; reduceOnly?: boolean; postOnly?: boolean; immediateOrCancel?: boolean; policy?: ModifyOrderPolicy; maxTs?: BN; }, txParams?: TxParams, subAccountId?: number): Promise; getModifyOrderByUserIdIx({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, policy, }: { userOrderId: number; newDirection?: PositionDirection; newBaseAmount?: BN; newLimitPrice?: BN; newOraclePriceOffset?: number; newTriggerPrice?: BN; newTriggerCondition?: OrderTriggerCondition; auctionDuration?: number; auctionStartPrice?: BN; auctionEndPrice?: BN; reduceOnly?: boolean; postOnly?: boolean; immediateOrCancel?: boolean; policy?: ModifyOrderPolicy; maxTs?: BN; txParams?: TxParams; }, subAccountId?: number): Promise; settlePNLs(users: { settleeUserAccountPublicKey: PublicKey; settleeUserAccount: UserAccount; }[], marketIndexes: number[]): Promise; getSettlePNLsIxs(users: { settleeUserAccountPublicKey: PublicKey; settleeUserAccount: UserAccount; }[], marketIndexes: number[]): Promise>; settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, txParams?: TxParams): Promise; settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise; liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise; getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise; liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise; getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise; liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise; getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise; liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise; getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise; resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise; getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise; resolveSpotBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise; getResolveSpotBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise; updateFundingRate(perpMarketIndex: number, oracle: PublicKey, txParams?: TxParams): Promise; getUpdateFundingRateIx(perpMarketIndex: number, oracle: PublicKey): Promise; updatePerpBidAskTwap(perpMarketIndex: number, makers: [PublicKey, PublicKey][], txParams?: TxParams): Promise; getUpdatePerpBidAskTwapIx(perpMarketIndex: number, makers: [PublicKey, PublicKey][]): Promise; settleFundingPayment(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise; getSettleFundingPaymentIx(userAccountPublicKey: PublicKey): Promise; triggerEvent(eventName: keyof DriftClientAccountEvents, data?: any): void; getOracleDataForPerpMarket(marketIndex: number): OraclePriceData; getOracleDataForSpotMarket(marketIndex: number): OraclePriceData; initializeInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise; getInitializeInsuranceFundStakeIx(marketIndex: number): Promise; getAddInsuranceFundStakeIx(marketIndex: number, amount: BN, collateralAccountPublicKey: PublicKey): Promise; /** * Add to an insurance fund stake and optionally initialize the account */ addInsuranceFundStake({ marketIndex, amount, collateralAccountPublicKey, initializeStakeAccount, fromSubaccount, }: { /** * Spot market index */ marketIndex: number; amount: BN; /** * The account where the funds to stake come from. Usually an associated token account */ collateralAccountPublicKey: PublicKey; /** * Add instructions to initialize the staking account -- required if its the first time the currrent authority has staked in this market */ initializeStakeAccount?: boolean; /** * Optional -- withdraw from current subaccount to fund stake amount, instead of wallet balance */ fromSubaccount?: boolean; }): Promise; requestRemoveInsuranceFundStake(marketIndex: number, amount: BN): Promise; cancelRequestRemoveInsuranceFundStake(marketIndex: number): Promise; removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey): Promise; settleRevenueToInsuranceFund(marketIndex: number): Promise; resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise; getResolvePerpPnlDeficitIx(spotMarketIndex: number, perpMarketIndex: number): Promise; getDepositIntoSpotMarketRevenuePoolIx(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise; depositIntoSpotMarketRevenuePool(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise; getPerpMarketExtendedInfo(marketIndex: number): PerpMarketExtendedInfo; /** * Returns the market index and type for a given market name * E.g. "SOL-PERP" -> { marketIndex: 0, marketType: MarketType.PERP } * * @param name */ getMarketIndexAndType(name: string): { marketIndex: number; marketType: MarketType; } | undefined; private handleSignedTransaction; sendTransaction(tx: Transaction | VersionedTransaction, additionalSigners?: Array, opts?: ConfirmOptions, preSigned?: boolean): Promise; buildTransaction(instructions: TransactionInstruction | TransactionInstruction[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[]): Promise; } export {};