Class AdminClient

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.

Hierarchy

Constructors

Properties

Accessors

Methods

addAndSubscribeToUsers addInsuranceFundStake addOpenbookRemainingAccounts addPerpLpShares addPerpMarketToRemainingAccountMaps addPhoenixRemainingAccounts addSerumRemainingAccounts addSpotFulfillmentAccounts addSpotMarketToRemainingAccountMaps addTokenMintToRemainingAccounts addUser buildAndSignTransactionsMap buildBulkTransactions buildTransaction buildTransactionsMap cancelAndPlaceOrders cancelOrder cancelOrderByUserId cancelOrders cancelOrdersByIds cancelRequestRemoveInsuranceFundStake closePosition convertToPerpPrecision convertToPricePrecision convertToSpotPrecision createAssociatedTokenAccountIdempotentInstruction createDepositTxn createInitializeUserAccountAndDepositCollateral createInitializeUserAccountAndDepositCollateralIxs createUser decodeSwiftOrderParamsMessage decodeSwiftServerMessage deleteInitializedPerpMarket deleteInitializedSpotMarket deletePrelaunchOracle deleteUser deposit depositIntoPerpMarketFeePool depositIntoSpotMarketRevenuePool depositIntoSpotMarketVault emulateAccount encodeSwiftOrderParamsMessage encodeSwiftServerMessage fetchAccounts fetchAllUserAccounts fetchMarketLookupTableAccount fetchReferrerNameAccount fillPerpOrder fillSpotOrder forceCancelOrders forceGetPerpMarketAccount forceGetSpotMarketAccount forceGetStateAccount forceGetUserAccount getAddInsuranceFundStakeIx getAddPerpLpSharesIx getAssociatedTokenAccount getAssociatedTokenAccountCreationIx getCancelOrderByUserIdIx getCancelOrderIx getCancelOrdersByIdsIx getCancelOrdersIx getDeleteInitializedPerpMarketIx getDeleteInitializedSpotMarketIx getDeletePrelaunchOracleIx getDepositInstruction getDepositIntoPerpMarketFeePoolIx getDepositIntoSpotMarketRevenuePoolIx getDepositIntoSpotMarketVaultIx getDepositTxnIx getFillPerpOrderIx getFillSpotOrderIx getForceCancelOrdersIx getInitUserFuelIx getInitializeInsuranceFundStakeIx getInitializeOpenbookV2FulfillmentConfigIx getInitializePerpMarketIx getInitializePhoenixFulfillmentConfigIx getInitializePredictionMarketIx getInitializePrelaunchOracleIx getInitializeProtocolIfSharesTransferConfigIx getInitializePythPullOracleIx getInitializeSerumFulfillmentConfigIx getInitializeSpotMarketIx getInitializeUserInstructions getInitializeUserStatsIx getJupiterSwapIx getJupiterSwapIxV6 getLiquidateBorrowForPerpPnlIx getLiquidatePerpIx getLiquidatePerpPnlForDepositIx getLiquidatePerpWithFillIx getLiquidateSpotIx getMarketFees getMarketIndexAndType getModifyOrderByUserIdIx getModifyOrderIx getMoveAmmPriceIx getMoveAmmToPriceIx getNextSubAccountId getOpenbookV2FulfillmentConfig getOpenbookV2FulfillmentConfigs getOracleDataForPerpMarket getOracleDataForSpotMarket getOraclePriceDataAndSlot getOrder getOrderByUserId getPerpMarketAccount getPerpMarketAccounts getPerpMarketExtendedInfo getPhoenixV1FulfillmentConfig getPhoenixV1FulfillmentConfigs getPlaceAndMakePerpOrderIx getPlaceAndMakeSpotOrderIx getPlaceAndMakeSwiftPerpOrderIxs getPlaceAndTakePerpOrderIx getPlaceAndTakeSpotOrderIx getPlaceOrdersIx getPlacePerpOrderIx getPlaceSpotOrderIx getPlaceSwiftTakerPerpOrderIxs getPostPythPullOracleUpdateAtomicIxs getPostSwitchboardOnDemandUpdateAtomicIx getQuoteAssetTokenAmount getQuoteSpotMarketAccount getQuoteValuePerLpShare getReceiverProgram getRecenterPerpMarketAmmIx getReclaimRentIx getReferredUserStatsAccountsByReferrer getReferrerNameAccountsForAuthority getRemainingAccountMapsForUsers getRemainingAccounts getRemovePerpLpSharesInExpiringMarket getRemovePerpLpSharesIx getRepegAmmCurveIx getResetPerpMarketAmmOracleTwapIx getResolvePerpBankruptcyIx getResolvePerpPnlDeficitIx getResolveSpotBankruptcyIx getRevertFillIx getSerumV3FulfillmentConfig getSerumV3FulfillmentConfigs getSetUserStatusToBeingLiquidatedIx getSettleExpiredMarketIx getSettleFundingPaymentIx getSettlePNLsIxs getSettleRevenueToInsuranceFundIx getSignerPublicKey getSpotMarketAccount getSpotMarketAccounts getSpotPosition getStakeForMSOLIx getStateAccount getStatePublicKey getSwapIx getSwitchboardOnDemandProgram getTokenAmount getTokenProgramForSpotMarket getTransferDepositIx getTriggerOrderIx getUpdateAMMsIx getUpdateAdminIx getUpdateAdvancedDlpIx getUpdateAmmJitIntensityIx getUpdateDiscountMintIx getUpdateExchangeStatusIx getUpdateFundingRateIx getUpdateInitialPctToLiquidateIx getUpdateInsuranceFundUnstakingPeriodIx getUpdateKIx getUpdateLiquidationDurationIx getUpdateLiquidationMarginBufferRatioIx getUpdateLpCooldownTimeIx getUpdateMaxSlippageRatioIx getUpdateOracleGuardRailsIx getUpdatePerpAuctionDurationIx getUpdatePerpBidAskTwapIx getUpdatePerpFeeStructureIx getUpdatePerpMarketAmmOracleTwapIx getUpdatePerpMarketAmmSummaryStatsIx getUpdatePerpMarketBaseSpreadIx getUpdatePerpMarketConcentrationScaleIx getUpdatePerpMarketContractTierIx getUpdatePerpMarketCurveUpdateIntensityIx getUpdatePerpMarketExpiryIx getUpdatePerpMarketFeeAdjustmentIx getUpdatePerpMarketFuelIx getUpdatePerpMarketImfFactorIx getUpdatePerpMarketLiquidationFeeIx getUpdatePerpMarketMarginRatioIx getUpdatePerpMarketMaxFillReserveFractionIx getUpdatePerpMarketMaxImbalancesIx getUpdatePerpMarketMaxOpenInterestIx getUpdatePerpMarketMaxSpreadIx getUpdatePerpMarketMinOrderSizeIx getUpdatePerpMarketNameIx getUpdatePerpMarketNumberOfUsersIx getUpdatePerpMarketOracleIx getUpdatePerpMarketPausedOperationsIx getUpdatePerpMarketPerLpBaseIx getUpdatePerpMarketStatusIx getUpdatePerpMarketStepSizeAndTickSizeIx getUpdatePerpMarketTargetBaseAssetAmountPerLpIx getUpdatePerpMarketUnrealizedAssetWeightIx getUpdatePhoenixFulfillmentConfigStatusIx getUpdatePrelaunchOracleIx getUpdatePrelaunchOracleParamsIx getUpdateProtocolIfSharesTransferConfigIx getUpdatePythPullOracleIxs getUpdateSerumFulfillmentConfigStatusIx getUpdateSerumVaultIx getUpdateSpotAuctionDurationIx getUpdateSpotFeeStructureIx getUpdateSpotMarketAssetTierIx getUpdateSpotMarketBorrowRateIx getUpdateSpotMarketExpiryIx getUpdateSpotMarketFeeAdjustmentIx getUpdateSpotMarketFuelIx getUpdateSpotMarketIfFactorIx getUpdateSpotMarketIfPausedOperationsIx getUpdateSpotMarketLiquidationFeeIx getUpdateSpotMarketMarginWeightsIx getUpdateSpotMarketMaxTokenBorrowsIx getUpdateSpotMarketMaxTokenDepositsIx getUpdateSpotMarketMinOrderSizeIx getUpdateSpotMarketNameIx getUpdateSpotMarketOracleIx getUpdateSpotMarketOrdersEnabledIx getUpdateSpotMarketPausedOperationsIx getUpdateSpotMarketRevenueSettlePeriodIx getUpdateSpotMarketScaleInitialAssetWeightStartIx getUpdateSpotMarketStatusIx getUpdateSpotMarketStepSizeAndTickSizeIx getUpdateStateMaxInitializeUserFeeIx getUpdateStateMaxNumberOfSubAccountsIx getUpdateStateSettlementDurationIx getUpdateUserCustomMarginRatioIx getUpdateUserGovTokenInsuranceStakeIx getUpdateUserIdleIx getUpdateUserMarginTradingEnabledIx getUpdateUserOpenOrdersCountIx getUpdateUserQuoteAssetInsuranceStakeIx getUpdateUserReduceOnlyIx getUpdateWhitelistMintIx getUpdateWithdrawGuardThresholdIx getUser getUserAccount getUserAccountAndSlot getUserAccountPublicKey getUserAccountsAndAddressesForAuthority getUserAccountsForAuthority getUserAccountsForDelegate getUserDeletionIx getUserMapKey getUserStats getUserStatsAccountPublicKey getUsers getWithdrawIx getWrappedSolAccountCreationIxs hasUser initUserFuel initialize initializeInsuranceFundStake initializeOpenbookV2FulfillmentConfig initializePerpMarket initializePhoenixFulfillmentConfig initializePredictionMarket initializePrelaunchOracle initializeProtocolIfSharesTransferConfig initializePythPullOracle initializeReferrerName initializeSerumFulfillmentConfig initializeSpotMarket initializeUserAccount initializeUserAccountAndDepositCollateral initializeUserAccountForDevnet liquidateBorrowForPerpPnl liquidatePerp liquidatePerpPnlForDeposit liquidatePerpWithFill liquidateSpot modifyOrder modifyOrderByUserOrderId modifyPerpOrder modifyPerpOrderByUserOrderId moveAmmPrice moveAmmToPrice mustIncludeMarketsInIx openPosition placeAndMakePerpOrder placeAndMakeSpotOrder placeAndMakeSwiftPerpOrder placeAndTakePerpOrder placeAndTakePerpWithAdditionalOrders placeAndTakeSpotOrder placeOrders placePerpOrder placeSpotOrder placeSwiftTakerOrder postMultiPythPullOracleUpdatesAtomic postPythPullOracleUpdateAtomic postSwitchboardOnDemandUpdate prepareMarketOrderTxs preparePlaceAndTakePerpOrderWithAdditionalOrders preparePlaceAndTakeSpotOrder preparePlaceOrdersTx preparePlaceSpotOrderTx recenterPerpMarketAmm reclaimRent removeInsuranceFundStake removePerpLpShares removePerpLpSharesInExpiringMarket repegAmmCurve requestRemoveInsuranceFundStake resetPerpMarketAmmOracleTwap resolvePerpBankruptcy resolvePerpPnlDeficit resolveSpotBankruptcy sendMarketOrderAndGetSignedFillTx sendSignedTx sendTransaction setUserStatusToBeingLiquidated settleExpiredMarket settleExpiredMarketPoolsToRevenuePool settleFundingPayment settleLP settleLPIx settleMultiplePNLs settleMultiplePNLsIx settlePNL settlePNLIx settlePNLs settleRevenueToInsuranceFund signMessage signSwiftOrderParamsMessage signSwiftServerMessage stakeForMSOL subscribe subscribeUsers swap switchActiveUser transferDeposit triggerEvent triggerOrder unsubscribe unsubscribeUsers updateAMMs updateAdmin updateAmmJitIntensity updateDiscountMint updateExchangeStatus updateFundingRate updateInitialPctToLiquidate updateInsuranceFundUnstakingPeriod updateK updateLiquidationDuration updateLiquidationMarginBufferRatio updateLpCooldownTime updateMaxSlippageRatio updateOracleGuardRails updatePerpAuctionDuration updatePerpBidAskTwap updatePerpFeeStructure updatePerpMarketAmmOracleTwap updatePerpMarketAmmSummaryStats updatePerpMarketBaseSpread updatePerpMarketConcentrationScale updatePerpMarketContractTier updatePerpMarketCurveUpdateIntensity updatePerpMarketExpiry updatePerpMarketFeeAdjustment updatePerpMarketFuel updatePerpMarketImfFactor updatePerpMarketLiquidationFee updatePerpMarketMarginRatio updatePerpMarketMaxFillReserveFraction updatePerpMarketMaxImbalances updatePerpMarketMaxOpenInterest updatePerpMarketMaxSpread updatePerpMarketMinOrderSize updatePerpMarketName updatePerpMarketNumberOfUser updatePerpMarketOracle updatePerpMarketPausedOperations updatePerpMarketPerLpBase updatePerpMarketStatus updatePerpMarketStepSizeAndTickSize updatePerpMarketTargetBaseAssetAmountPerLp updatePerpMarketUnrealizedAssetWeight updatePhoenixFulfillmentConfigStatus updatePrelaunchOracle updatePrelaunchOracleParams updateProtocolIfSharesTransferConfig updatePythPullOracle updateSerumFulfillmentConfigStatus updateSerumVault updateSpotAuctionDuration updateSpotFeeStructure updateSpotMarketAssetTier updateSpotMarketBorrowRate updateSpotMarketCumulativeInterest updateSpotMarketCumulativeInterestIx updateSpotMarketExpiry updateSpotMarketFeeAdjustment updateSpotMarketFuel updateSpotMarketIfFactor updateSpotMarketIfPausedOperations updateSpotMarketLiquidationFee updateSpotMarketMarginWeights updateSpotMarketMaxTokenBorrows updateSpotMarketMaxTokenDeposits updateSpotMarketMinOrderSize updateSpotMarketName updateSpotMarketOracle updateSpotMarketOrdersEnabled updateSpotMarketPausedOperations updateSpotMarketRevenueSettlePeriod updateSpotMarketScaleInitialAssetWeightStart updateSpotMarketStatus updateSpotMarketStepSizeAndTickSize updateStateMaxInitializeUserFee updateStateMaxNumberOfSubAccounts updateStateSettlementDuration updateUserAdvancedLp updateUserCustomMarginRatio updateUserDelegate updateUserGovTokenInsuranceStake updateUserIdle updateUserMarginTradingEnabled updateUserName updateUserOpenOrdersCount updateUserQuoteAssetInsuranceStake updateUserReduceOnly updateWallet updateWhitelistMint updateWithdrawGuardThreshold withdraw withdrawAllDustPositions

Constructors

Properties

_isSubscribed: boolean = false
accountSubscriber: DriftClientAccountSubscriber
activeSubAccountId: number
authority: PublicKey
authoritySubAccountMap?: Map<string, number[]>
connection: Connection
enableMetricsEvents?: boolean
eventEmitter: StrictEventEmitter<EventEmitter<DefaultEventMap>, DriftClientAccountEvents, DriftClientAccountEvents, "addEventListener" | "removeEventListener", "on" | "addListener" | "removeListener" | "once" | "emit">
includeDelegates?: boolean
lookupTableAccount: AddressLookupTableAccount
marketLookupTable: PublicKey
metricsEventEmitter: StrictEventEmitter<EventEmitter<DefaultEventMap>, DriftClientMetricsEvents, DriftClientMetricsEvents, "addEventListener" | "removeEventListener", "on" | "addListener" | "removeListener" | "once" | "emit">
mustIncludePerpMarketIndexes: Set<number> = ...
mustIncludeSpotMarketIndexes: Set<number> = ...
opts?: ConfirmOptions
perpMarketLastSlotCache: Map<number, number> = ...
program: Program<Idl>
provider: AnchorProvider
receiverProgram?: Program<PythSolanaReceiver>
sbOnDemandProgram?: Program<Idl>
sbOnDemandProgramdId: PublicKey
sbProgramFeedConfigs?: Map<string, any>
signerPublicKey?: PublicKey
skipLoadUsers?: boolean
spotMarketLastSlotCache: Map<number, number> = ...
statePublicKey?: PublicKey
swiftID: PublicKey
txHandler: TxHandler
txParams: TxParams
txSender: TxSender
txVersion: TransactionVersion
userAccountSubscriptionConfig: UserSubscriptionConfig
userStats?: UserStats
userStatsAccountPublicKey: PublicKey
userStatsAccountSubscriptionConfig: UserStatsSubscriptionConfig
users: Map<string, User> = ...
wallet: IWallet
wormholeProgram?: Program<WormholeCoreBridgeSolana>

Accessors

  • get isSubscribed(): boolean
  • Returns boolean

  • set isSubscribed(val: boolean): void
  • Parameters

    • val: boolean

    Returns void

Methods

  • Add to an insurance fund stake and optionally initialize the account

    Parameters

    • __namedParameters: {
          amount: BN;
          collateralAccountPublicKey: PublicKey;
          fromSubaccount?: boolean;
          initializeStakeAccount?: boolean;
          marketIndex: number;
          txParams?: TxParams;
      }
      • amount: BN
      • collateralAccountPublicKey: PublicKey

        The account where the funds to stake come from. Usually an associated token account

      • Optional fromSubaccount?: boolean

        Optional -- withdraw from current subaccount to fund stake amount, instead of wallet balance

      • Optional initializeStakeAccount?: boolean

        Add instructions to initialize the staking account -- required if its the first time the currrent authority has staked in this market

      • marketIndex: number

        Spot market index

      • Optional txParams?: TxParams

    Returns Promise<string>

  • Parameters

    • marketIndex: number
    • writable: boolean
    • oracleAccountMap: Map<string, AccountMeta>
    • spotMarketAccountMap: Map<number, AccountMeta>
    • perpMarketAccountMap: Map<number, AccountMeta>

    Returns void

  • Parameters

    • marketIndex: number
    • writable: boolean
    • oracleAccountMap: Map<string, AccountMeta>
    • spotMarketAccountMap: Map<number, AccountMeta>

    Returns void

  • Parameters

    • instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>
    • Optional txParams: TxParams
    • Optional txVersion: TransactionVersion
    • Optional lookupTables: AddressLookupTableAccount[]
    • Optional forceVersionedTransaction: boolean

    Returns Promise<{
        signedTxData: SignedTxData[];
        signedTxMap: Record<string, Transaction>;
    } | {
        signedTxData: SignedTxData[];
        signedTxMap: MappedRecord<Record<string, TransactionInstruction | TransactionInstruction[]>, Transaction | VersionedTransaction>;
    }>

  • Parameters

    • instructions: (TransactionInstruction | TransactionInstruction[])[]
    • Optional txParams: TxParams
    • Optional txVersion: TransactionVersion
    • Optional lookupTables: AddressLookupTableAccount[]
    • Optional forceVersionedTransaction: boolean

    Returns Promise<(Transaction | VersionedTransaction)[]>

  • Parameters

    • instructions: TransactionInstruction | TransactionInstruction[]
    • Optional txParams: TxParams
    • Optional txVersion: TransactionVersion
    • Optional lookupTables: AddressLookupTableAccount[]
    • Optional forceVersionedTransaction: boolean
    • Optional recentBlockhash: Readonly<{
          blockhash: string;
          lastValidBlockHeight: number;
      }>

    Returns Promise<Transaction | VersionedTransaction>

  • Parameters

    • instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>
    • Optional txParams: TxParams
    • Optional txVersion: TransactionVersion
    • Optional lookupTables: AddressLookupTableAccount[]
    • Optional forceVersionedTransaction: boolean

    Returns Promise<MappedRecord<Record<string, TransactionInstruction | TransactionInstruction[]>, Transaction | VersionedTransaction>>

  • Converts an amount to the spot precision for a given market. The spot market precision is based on the token mint decimals.

    Parameters

    • marketIndex: number
    • amount: number | BN

    Returns BN

  • Parameters

    • amount: BN
    • marketIndex: number
    • associatedTokenAccount: PublicKey
    • Optional subAccountId: number
    • reduceOnly: boolean = false
    • Optional txParams: TxParams

    Returns Promise<Transaction | VersionedTransaction>

  • Parameters

    • amount: BN
    • userTokenAccount: PublicKey
    • marketIndex: number = 0
    • subAccountId: number = 0
    • Optional name: string
    • Optional fromSubAccountId: number
    • Optional referrerInfo: ReferrerInfo
    • Optional donateAmount: BN
    • Optional customMaxMarginRatio: number

    Returns Promise<{
        ixs: TransactionInstruction[];
        userAccountPublicKey: PublicKey;
    }>

  • Parameters

    • marketIndex: number

    Returns Promise<string>

  • Parameters

    • marketIndex: number

    Returns Promise<string>

  • Parameters

    • perpMarketIndex: number

    Returns Promise<string>

  • Deposit funds into the given spot market

    Parameters

    • amount: BN

      to deposit

    • marketIndex: number

      spot market index to deposit into

    • associatedTokenAccount: PublicKey

      can be the wallet public key if using native sol

    • Optional subAccountId: number

      subaccountId to deposit

    • reduceOnly: boolean = false

      if true, deposit must not increase account risk

    • Optional txParams: TxParams

    Returns Promise<string>

  • 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.

    Parameters

    Returns Promise<boolean>

  • Parameters

    • Optional orderId: number
    • Optional subAccountId: number

    Returns Promise<TransactionInstruction>

  • Parameters

    • marketIndex: number

    Returns Promise<TransactionInstruction>

  • Parameters

    • marketIndex: number

    Returns Promise<TransactionInstruction>

  • Parameters

    • perpMarketIndex: number
    • Optional price: BN
    • Optional maxPrice: BN

    Returns Promise<TransactionInstruction>

  • Parameters

    • amount: BN
    • marketIndex: number
    • userTokenAccount: PublicKey
    • Optional subAccountId: number
    • reduceOnly: boolean = false
    • userInitialized: boolean = true

    Returns Promise<TransactionInstruction>

  • Parameters

    • perpMarketIndex: number
    • amount: BN
    • sourceVault: PublicKey

    Returns Promise<TransactionInstruction>

  • Parameters

    • spotMarketIndex: number
    • amount: BN
    • sourceVault: PublicKey

    Returns Promise<TransactionInstruction>

  • Parameters

    • amount: BN
    • marketIndex: number
    • associatedTokenAccount: PublicKey
    • Optional subAccountId: number
    • reduceOnly: boolean = false

    Returns Promise<TransactionInstruction[]>

  • Parameters

    • user: PublicKey
    • authority: PublicKey
    • Optional fuelBonusDeposits: number
    • Optional fuelBonusBorrows: number
    • Optional fuelBonusTaker: number
    • Optional fuelBonusMaker: number
    • Optional fuelBonusInsurance: number

    Returns Promise<TransactionInstruction>

  • Parameters

    • marketIndex: number
    • openbookMarket: PublicKey

    Returns Promise<TransactionInstruction>

  • Parameters

    • marketIndex: number
    • priceOracle: PublicKey
    • baseAssetReserve: BN
    • quoteAssetReserve: BN
    • periodicity: BN
    • pegMultiplier: BN = PEG_PRECISION
    • oracleSource: OracleSource = OracleSource.PYTH
    • contractTier: ContractTier = ContractTier.SPECULATIVE
    • marginRatioInitial: number = 2000
    • marginRatioMaintenance: number = 500
    • liquidatorFee: number = 0
    • ifLiquidatorFee: number = 10000
    • imfFactor: number = 0
    • activeStatus: boolean = true
    • baseSpread: number = 0
    • maxSpread: number = 142500
    • maxOpenInterest: BN = ZERO
    • maxRevenueWithdrawPerPeriod: BN = ZERO
    • quoteMaxInsurance: BN = ZERO
    • orderStepSize: BN = ...
    • orderTickSize: BN = ...
    • minOrderSize: BN = ...
    • concentrationCoefScale: BN = ONE
    • curveUpdateIntensity: number = 0
    • ammJitIntensity: number = 0
    • name: string = DEFAULT_MARKET_NAME

    Returns Promise<TransactionInstruction>

  • Parameters

    • marketIndex: number
    • phoenixMarket: PublicKey

    Returns Promise<TransactionInstruction>

  • Parameters

    • perpMarketIndex: number

    Returns Promise<TransactionInstruction>

  • Parameters

    • perpMarketIndex: number
    • Optional price: BN
    • Optional maxPrice: BN

    Returns Promise<TransactionInstruction>

  • Returns Promise<TransactionInstruction>

  • Parameters

    • feedId: string

    Returns Promise<TransactionInstruction>

  • Parameters

    • mint: PublicKey
    • optimalUtilization: number
    • optimalRate: number
    • maxRate: number
    • oracle: PublicKey
    • oracleSource: OracleSource
    • initialAssetWeight: number
    • maintenanceAssetWeight: number
    • initialLiabilityWeight: number
    • maintenanceLiabilityWeight: number
    • imfFactor: number = 0
    • liquidatorFee: number = 0
    • ifLiquidationFee: number = 0
    • activeStatus: boolean = true
    • assetTier: {
          collateral: {};
      } = AssetTier.COLLATERAL
      • collateral: {}
      • scaleInitialAssetWeightStart: BN = ZERO
      • withdrawGuardThreshold: BN = ZERO
      • orderTickSize: BN = ONE
      • orderStepSize: BN = ONE
      • ifTotalFactor: number = 0
      • name: string = DEFAULT_MARKET_NAME
      • Optional marketIndex: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • __namedParameters: {
            amount: BN;
            inAssociatedTokenAccount?: PublicKey;
            inMarketIndex: number;
            jupiterClient: JupiterClient;
            onlyDirectRoutes?: boolean;
            outAssociatedTokenAccount?: PublicKey;
            outMarketIndex: number;
            reduceOnly?: SwapReduceOnly;
            route?: Route;
            slippageBps?: number;
            swapMode?: SwapMode;
            userAccountPublicKey?: PublicKey;
        }
        • amount: BN
        • Optional inAssociatedTokenAccount?: PublicKey
        • inMarketIndex: number
        • jupiterClient: JupiterClient
        • Optional onlyDirectRoutes?: boolean
        • Optional outAssociatedTokenAccount?: PublicKey
        • outMarketIndex: number
        • Optional reduceOnly?: SwapReduceOnly
        • Optional route?: Route
        • Optional slippageBps?: number
        • Optional swapMode?: SwapMode
        • Optional userAccountPublicKey?: PublicKey

      Returns Promise<{
          ixs: TransactionInstruction[];
          lookupTables: AddressLookupTableAccount[];
      }>

    • Parameters

      • __namedParameters: {
            amount: BN;
            inAssociatedTokenAccount?: PublicKey;
            inMarketIndex: number;
            jupiterClient: JupiterClient;
            onlyDirectRoutes?: boolean;
            outAssociatedTokenAccount?: PublicKey;
            outMarketIndex: number;
            quote?: QuoteResponse;
            reduceOnly?: SwapReduceOnly;
            slippageBps?: number;
            swapMode?: SwapMode;
            userAccountPublicKey?: PublicKey;
        }

      Returns Promise<{
          ixs: TransactionInstruction[];
          lookupTables: AddressLookupTableAccount[];
      }>

    • Parameters

      • userAccountPublicKey: PublicKey
      • userAccount: UserAccount
      • perpMarketIndex: number
      • liabilityMarketIndex: number
      • maxLiabilityTransfer: BN
      • Optional limitPrice: BN
      • Optional liquidatorSubAccountId: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • userAccountPublicKey: PublicKey
      • userAccount: UserAccount
      • assetMarketIndex: number
      • liabilityMarketIndex: number
      • maxLiabilityTransfer: BN
      • Optional limitPrice: BN
      • Optional liquidatorSubAccountId: number

      Returns Promise<TransactionInstruction>

    • Calculates taker / maker fee (as a percentage, e.g. .001 = 10 basis points) for particular marketType

      Returns

      : {takerFee: number, makerFee: number} Precision None

      Parameters

      • marketType: MarketType
      • Optional marketIndex: number
      • Optional user: User

      Returns {
          makerFee: number;
          takerFee: number;
      }

      • makerFee: number
      • takerFee: number
    • Returns the market index and type for a given market name E.g. "SOL-PERP" -> { marketIndex: 0, marketType: MarketType.PERP }

      Parameters

      • name: string

      Returns {
          marketIndex: number;
          marketType: MarketType;
      }

    • Parameters

      • __namedParameters: {
            auctionDuration?: number;
            auctionEndPrice?: BN;
            auctionStartPrice?: BN;
            immediateOrCancel?: boolean;
            maxTs?: BN;
            newBaseAmount?: BN;
            newDirection?: PositionDirection;
            newLimitPrice?: BN;
            newOraclePriceOffset?: number;
            newTriggerCondition?: OrderTriggerCondition;
            newTriggerPrice?: BN;
            policy?: ModifyOrderPolicy;
            postOnly?: boolean;
            reduceOnly?: boolean;
            txParams?: TxParams;
            userOrderId: number;
        }
        • Optional auctionDuration?: number
        • Optional auctionEndPrice?: BN
        • Optional auctionStartPrice?: BN
        • Optional immediateOrCancel?: boolean
        • Optional maxTs?: BN
        • Optional newBaseAmount?: BN
        • Optional newDirection?: PositionDirection
        • Optional newLimitPrice?: BN
        • Optional newOraclePriceOffset?: number
        • Optional newTriggerCondition?: OrderTriggerCondition
        • Optional newTriggerPrice?: BN
        • Optional policy?: ModifyOrderPolicy
        • Optional postOnly?: boolean
        • Optional reduceOnly?: boolean
        • Optional txParams?: TxParams
        • userOrderId: number
      • Optional subAccountId: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • __namedParameters: {
            auctionDuration?: number;
            auctionEndPrice?: BN;
            auctionStartPrice?: BN;
            immediateOrCancel?: boolean;
            maxTs?: BN;
            newBaseAmount?: BN;
            newDirection?: PositionDirection;
            newLimitPrice?: BN;
            newOraclePriceOffset?: number;
            newTriggerCondition?: OrderTriggerCondition;
            newTriggerPrice?: BN;
            orderId: number;
            policy?: ModifyOrderPolicy;
            postOnly?: boolean;
            reduceOnly?: boolean;
        }
        • Optional auctionDuration?: number
        • Optional auctionEndPrice?: BN
        • Optional auctionStartPrice?: BN
        • Optional immediateOrCancel?: boolean
        • Optional maxTs?: BN
        • Optional newBaseAmount?: BN
        • Optional newDirection?: PositionDirection
        • Optional newLimitPrice?: BN
        • Optional newOraclePriceOffset?: number
        • Optional newTriggerCondition?: OrderTriggerCondition
        • Optional newTriggerPrice?: BN
        • orderId: number
        • Optional policy?: ModifyOrderPolicy
        • Optional postOnly?: boolean
        • Optional reduceOnly?: boolean
      • Optional subAccountId: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • baseAssetReserve: BN
      • quoteAssetReserve: BN
      • Optional sqrtK: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • targetPrice: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • orderParams: OptionalOrderParams
      • Optional subAccountId: number
      • Optional depositToTradeArgs: {
            depositMarketIndex: number;
            isMakingNewAccount: boolean;
        }
        • depositMarketIndex: number
        • isMakingNewAccount: boolean

      Returns Promise<TransactionInstruction>

    • Parameters

      • encodedSwiftServerMessage: Buffer
      • swiftSignature: Buffer
      • encodedSwiftOrderParamsMessage: Buffer
      • swiftOrderParamsSignature: Buffer
      • marketIndex: number
      • takerInfo: {
            taker: PublicKey;
            takerStats: PublicKey;
            takerUserAccount: UserAccount;
        }

      Returns Promise<TransactionInstruction[]>

    • Parameters

      • vaaString: string
      • feedIds: string | string[]
      • numSignatures: number = 2

      Returns Promise<TransactionInstruction[]>

    • Parameters

      • perpMarketIndex: number
      • pegMultiplier: BN
      • sqrtK: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      Returns {
          oracleAccountMap: Map<string, AccountMeta>;
          perpMarketAccountMap: Map<number, AccountMeta>;
          spotMarketAccountMap: Map<number, AccountMeta>;
      }

      • oracleAccountMap: Map<string, AccountMeta>
      • perpMarketAccountMap: Map<number, AccountMeta>
      • spotMarketAccountMap: Map<number, AccountMeta>
    • Parameters

      • marketIndex: number
      • Optional sharesToBurn: BN
      • Optional subAccountId: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • newPeg: BN
      • perpMarketIndex: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • users: {
            settleeUserAccount: UserAccount;
            settleeUserAccountPublicKey: PublicKey;
        }[]
      • marketIndexes: number[]

      Returns Promise<TransactionInstruction[]>

    • Parameters

      • __namedParameters: {
            amount: BN;
            userAccountPublicKey?: PublicKey;
        }

      Returns Promise<TransactionInstruction[]>

    • Get the drift begin_swap and end_swap instructions

      Parameters

      • __namedParameters: {
            amountIn: BN;
            inMarketIndex: number;
            inTokenAccount: PublicKey;
            limitPrice?: BN;
            outMarketIndex: number;
            outTokenAccount: PublicKey;
            reduceOnly?: SwapReduceOnly;
            userAccountPublicKey?: PublicKey;
        }

      Returns Promise<{
          beginSwapIx: TransactionInstruction;
          endSwapIx: TransactionInstruction;
      }>

    • 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.

      Parameters

      • marketIndex: number

      Returns BN

    • Parameters

      • amount: BN
      • marketIndex: number
      • fromSubAccountId: number
      • toSubAccountId: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • ammJitIntensity: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • initialPctToLiquidate: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • insuranceWithdrawEscrowPeriod: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • sqrtK: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • liquidationDuration: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • updateLiquidationMarginBufferRatio: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • cooldownTime: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • maxSlippageRatio: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • minDuration: number | BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • Optional updateAmmSummaryStats: boolean
      • Optional quoteAssetAmountWithUnsettledLp: BN
      • Optional netUnsettledFundingPnl: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • baseSpread: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • concentrationScale: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • curveUpdateIntensity: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • expiryTs: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • feeAdjustment: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • Optional fuelBoostTaker: number
      • Optional fuelBoostMaker: number
      • Optional fuelBoostPosition: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • imfFactor: number
      • unrealizedPnlImfFactor: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • liquidatorFee: number
      • ifLiquidationFee: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • marginRatioInitial: number
      • marginRatioMaintenance: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • maxBaseAssetAmountRatio: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • unrealizedMaxImbalance: BN
      • maxRevenueWithdrawPerPeriod: BN
      • quoteMaxInsurance: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • maxOpenInterest: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • maxSpread: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • orderSize: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • name: string

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • Optional numberOfUsers: number
      • Optional numberOfUsersWithBase: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • pausedOperations: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • perLpBase: number

      Returns Promise<TransactionInstruction>

    • Parameters

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • stepSize: BN
      • tickSize: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • targetBaseAssetAmountPerLP: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • unrealizedInitialAssetWeight: number
      • unrealizedMaintenanceAssetWeight: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • perpMarketIndex: number
      • Optional price: BN
      • Optional maxPrice: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • Optional whitelistedSigners: PublicKey[]
      • Optional maxTransferPerEpoch: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • params: {
            merklePriceUpdate: {
                message: Buffer;
                proof: number[][];
            };
        }
        • merklePriceUpdate: {
              message: Buffer;
              proof: number[][];
          }
          • message: Buffer
          • proof: number[][]
      • feedId: string
      • encodedVaaAddress: PublicKey

      Returns Promise<TransactionInstruction>

    • Parameters

      • defaultAuctionDuration: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • assetTier: AssetTier

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • optimalUtilization: number
      • optimalBorrowRate: number
      • optimalMaxRate: number
      • Optional minBorrowRate: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • expiryTs: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • feeAdjustment: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • Optional fuelBoostDeposits: number
      • Optional fuelBoostBorrows: number
      • Optional fuelBoostTaker: number
      • Optional fuelBoostMaker: number
      • Optional fuelBoostInsurance: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • userIfFactor: BN
      • totalIfFactor: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • pausedOperations: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • liquidatorFee: number
      • ifLiquidationFee: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • initialAssetWeight: number
      • maintenanceAssetWeight: number
      • initialLiabilityWeight: number
      • maintenanceLiabilityWeight: number
      • imfFactor: number = 0

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • maxTokenBorrowsFraction: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • maxTokenDeposits: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • orderSize: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • name: string

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • ordersEnabled: boolean

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • pausedOperations: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • revenueSettlePeriod: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • scaleInitialAssetWeightStart: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • stepSize: BN
      • tickSize: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • maxInitializeUserFee: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • maxNumberOfSubAccounts: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • settlementDuration: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • spotMarketIndex: number
      • withdrawGuardThreshold: BN

      Returns Promise<TransactionInstruction>

    • Parameters

      • amount: BN
      • marketIndex: number
      • userTokenAccount: PublicKey
      • reduceOnly: boolean = false
      • Optional subAccountId: number

      Returns Promise<TransactionInstruction>

    • Parameters

      • amount: BN
      • Optional includeRent: boolean

      Returns Promise<{
          ixs: TransactionInstruction[];
          pubkey: PublicKey;
          signers: Signer[];
      }>

    • Parameters

      • user: PublicKey
      • authority: PublicKey
      • Optional fuelBonusDeposits: number
      • Optional fuelBonusBorrows: number
      • Optional fuelBonusTaker: number
      • Optional fuelBonusMaker: number
      • Optional fuelBonusInsurance: number

      Returns Promise<string>

    • Parameters

      • marketIndex: number
      • openbookMarket: PublicKey

      Returns Promise<string>

    • Parameters

      • marketIndex: number
      • priceOracle: PublicKey
      • baseAssetReserve: BN
      • quoteAssetReserve: BN
      • periodicity: BN
      • pegMultiplier: BN = PEG_PRECISION
      • oracleSource: OracleSource = OracleSource.PYTH
      • contractTier: ContractTier = ContractTier.SPECULATIVE
      • marginRatioInitial: number = 2000
      • marginRatioMaintenance: number = 500
      • liquidatorFee: number = 0
      • ifLiquidatorFee: number = 10000
      • imfFactor: number = 0
      • activeStatus: boolean = true
      • baseSpread: number = 0
      • maxSpread: number = 142500
      • maxOpenInterest: BN = ZERO
      • maxRevenueWithdrawPerPeriod: BN = ZERO
      • quoteMaxInsurance: BN = ZERO
      • orderStepSize: BN = ...
      • orderTickSize: BN = ...
      • minOrderSize: BN = ...
      • concentrationCoefScale: BN = ONE
      • curveUpdateIntensity: number = 0
      • ammJitIntensity: number = 0
      • name: string = DEFAULT_MARKET_NAME

      Returns Promise<string>

    • Parameters

      • perpMarketIndex: number

      Returns Promise<string>

    • Parameters

      • perpMarketIndex: number
      • Optional price: BN
      • Optional maxPrice: BN

      Returns Promise<string>

    • Parameters

      • feedId: string

      Returns Promise<string>

    • Parameters

      • mint: PublicKey
      • optimalUtilization: number
      • optimalRate: number
      • maxRate: number
      • oracle: PublicKey
      • oracleSource: OracleSource
      • initialAssetWeight: number
      • maintenanceAssetWeight: number
      • initialLiabilityWeight: number
      • maintenanceLiabilityWeight: number
      • imfFactor: number = 0
      • liquidatorFee: number = 0
      • ifLiquidationFee: number = 0
      • activeStatus: boolean = true
      • assetTier: {
            collateral: {};
        } = AssetTier.COLLATERAL
        • collateral: {}
        • scaleInitialAssetWeightStart: BN = ZERO
        • withdrawGuardThreshold: BN = ZERO
        • orderTickSize: BN = ONE
        • orderStepSize: BN = ONE
        • ifTotalFactor: number = 0
        • name: string = DEFAULT_MARKET_NAME
        • Optional marketIndex: number

        Returns Promise<string>

      • Parameters

        • userAccountPublicKey: PublicKey
        • userAccount: UserAccount
        • assetMarketIndex: number
        • liabilityMarketIndex: number
        • maxLiabilityTransfer: BN
        • Optional limitPrice: BN
        • Optional txParams: TxParams
        • Optional liquidatorSubAccountId: number

        Returns Promise<string>

      • Modifies an open order (spot or perp) by closing it and replacing it with a new order.

        Returns

        Parameters

        • orderParams: {
              auctionDuration?: number;
              auctionEndPrice?: BN;
              auctionStartPrice?: BN;
              immediateOrCancel?: boolean;
              maxTs?: BN;
              newBaseAmount?: BN;
              newDirection?: PositionDirection;
              newLimitPrice?: BN;
              newOraclePriceOffset?: number;
              newTriggerCondition?: OrderTriggerCondition;
              newTriggerPrice?: BN;
              orderId: number;
              policy?: ModifyOrderPolicy;
              postOnly?: boolean;
              reduceOnly?: boolean;
          }
          • Optional auctionDuration?: number
          • Optional auctionEndPrice?: BN
          • Optional auctionStartPrice?: BN
          • Optional immediateOrCancel?: boolean
          • Optional maxTs?: BN
          • Optional newBaseAmount?: BN
          • Optional newDirection?: PositionDirection
          • Optional newLimitPrice?: BN
          • Optional newOraclePriceOffset?: number
          • Optional newTriggerCondition?: OrderTriggerCondition
          • Optional newTriggerPrice?: BN
          • orderId: number
          • Optional policy?: ModifyOrderPolicy
          • Optional postOnly?: boolean
          • Optional reduceOnly?: boolean
        • Optional txParams: TxParams
        • Optional subAccountId: number

        Returns Promise<string>

      • Modifies an open order by closing it and replacing it with a new order.

        Returns

        Parameters

        • orderParams: {
              auctionDuration?: number;
              auctionEndPrice?: BN;
              auctionStartPrice?: BN;
              immediateOrCancel?: boolean;
              maxTs?: BN;
              newBaseAmount?: BN;
              newDirection?: PositionDirection;
              newLimitPrice?: BN;
              newOraclePriceOffset?: number;
              newTriggerCondition?: OrderTriggerCondition;
              newTriggerPrice?: BN;
              policy?: ModifyOrderPolicy;
              postOnly?: boolean;
              reduceOnly?: boolean;
              userOrderId: number;
          }
          • Optional auctionDuration?: number
          • Optional auctionEndPrice?: BN
          • Optional auctionStartPrice?: BN
          • Optional immediateOrCancel?: boolean
          • Optional maxTs?: BN
          • Optional newBaseAmount?: BN
          • Optional newDirection?: PositionDirection
          • Optional newLimitPrice?: BN
          • Optional newOraclePriceOffset?: number
          • Optional newTriggerCondition?: OrderTriggerCondition
          • Optional newTriggerPrice?: BN
          • Optional policy?: ModifyOrderPolicy
          • Optional postOnly?: boolean
          • Optional reduceOnly?: boolean
          • userOrderId: number
        • Optional txParams: TxParams
        • Optional subAccountId: number

        Returns Promise<string>

      • Modifies an open order by closing it and replacing it with a new order.

        Deprecated

        use modifyOrder instead

        Returns

        Parameters

        • orderId: number
        • Optional newBaseAmount: BN
        • Optional newLimitPrice: BN
        • Optional newOraclePriceOffset: number

        Returns Promise<string>

      • Modifies an open order by closing it and replacing it with a new order.

        Deprecated

        use modifyOrderByUserOrderId instead

        Returns

        Parameters

        • userOrderId: number
        • Optional newBaseAmount: BN
        • Optional newLimitPrice: BN
        • Optional newOraclePriceOffset: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • baseAssetReserve: BN
        • quoteAssetReserve: BN
        • Optional sqrtK: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • targetPrice: BN

        Returns Promise<string>

      • 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

        Parameters

        • __namedParameters: {
              perpMarketIndexes: number[];
              spotMarketIndexes: number[];
          }
          • perpMarketIndexes: number[]
          • spotMarketIndexes: number[]

        Returns void

      • Parameters

        • swiftServerMessage: Buffer
        • swiftSignature: Buffer
        • swiftOrderParamsMessage: Buffer
        • swiftOrderParamsSignature: Buffer
        • marketIndex: number
        • takerInfo: {
              taker: PublicKey;
              takerStats: PublicKey;
              takerUserAccount: UserAccount;
          }
        • Optional txParams: TxParams

        Returns Promise<string>

      • Parameters

        Returns Promise<{
            cancelExistingOrdersTx?: Transaction | VersionedTransaction;
            fillTx?: Transaction | VersionedTransaction;
            marketOrderTx: Transaction | VersionedTransaction;
            settlePnlTx?: Transaction | VersionedTransaction;
        }>

      • Parameters

        Returns Promise<{
            cancelExistingOrdersTx: Transaction | VersionedTransaction;
            placeAndTakeTx: Transaction | VersionedTransaction;
            settlePnlTx: Transaction | VersionedTransaction;
        }>

      • Parameters

        • perpMarketIndex: number
        • pegMultiplier: BN
        • sqrtK: BN

        Returns Promise<string>

      • Parameters

        • newPeg: BN
        • perpMarketIndex: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number

        Returns Promise<string>

      • 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.

        Returns

        Parameters

        • orderParams: OptionalOrderParams
        • userAccountPublicKey: PublicKey
        • userAccount: UserAccount
        • Optional makerInfo: MakerInfo | MakerInfo[]
        • Optional txParams: TxParams
        • bracketOrdersParams: OptionalOrderParams[] = ...
        • Optional referrerInfo: ReferrerInfo
        • Optional cancelExistingOrders: boolean

          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

        • Optional settlePnl: boolean

        Returns Promise<{
            signedCancelExistingOrdersTx?: Transaction;
            signedFillTx?: Transaction;
            signedSettlePnlTx?: Transaction;
            txSig: string;
        }>

      • Parameters

        • tx: Transaction | VersionedTransaction
        • Optional opts: ConfirmOptions

        Returns Promise<string>

      • Parameters

        • tx: Transaction | VersionedTransaction
        • Optional additionalSigners: Signer[]
        • Optional opts: ConfirmOptions
        • Optional preSigned: boolean

        Returns Promise<TxSigAndSlot>

      • Parameters

        • users: {
              settleeUserAccount: UserAccount;
              settleeUserAccountPublicKey: PublicKey;
          }[]
        • marketIndexes: number[]
        • Optional opts: {
              filterInvalidMarkets?: boolean;
          }
          • Optional filterInvalidMarkets?: boolean
        • Optional txParams: TxParams

        Returns Promise<string>

      • Swap tokens in drift account using jupiter

        Parameters

        • __namedParameters: {
              amount: BN;
              inAssociatedTokenAccount?: PublicKey;
              inMarketIndex: number;
              jupiterClient: JupiterClient;
              onlyDirectRoutes?: boolean;
              outAssociatedTokenAccount?: PublicKey;
              outMarketIndex: number;
              reduceOnly?: SwapReduceOnly;
              route?: Route;
              slippageBps?: number;
              swapMode?: SwapMode;
              txParams?: TxParams;
              v6?: {
                  quote?: QuoteResponse;
              };
          }

        Returns Promise<string>

      • Withdraws from the fromSubAccount and deposits into the toSubAccount

        Parameters

        • amount: BN
        • marketIndex: number
        • fromSubAccountId: number
        • toSubAccountId: number
        • Optional txParams: TxParams

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • ammJitIntensity: number

        Returns Promise<string>

      • Parameters

        • initialPctToLiquidate: number

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • insuranceWithdrawEscrowPeriod: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • sqrtK: BN

        Returns Promise<string>

      • Parameters

        • liquidationDuration: number

        Returns Promise<string>

      • Parameters

        • updateLiquidationMarginBufferRatio: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • maxSlippageRatio: number

        Returns Promise<string>

      • Parameters

        • minDuration: number | BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • Optional updateAmmSummaryStats: boolean
        • Optional quoteAssetAmountWithUnsettledLp: BN
        • Optional netUnsettledFundingPnl: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • baseSpread: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • concentrationScale: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • curveUpdateIntensity: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • expiryTs: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • feeAdjustment: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • Optional fuelBoostTaker: number
        • Optional fuelBoostMaker: number
        • Optional fuelBoostPosition: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • imfFactor: number
        • unrealizedPnlImfFactor: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • liquidatorFee: number
        • ifLiquidationFee: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • marginRatioInitial: number
        • marginRatioMaintenance: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • maxBaseAssetAmountRatio: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • unrealizedMaxImbalance: BN
        • maxRevenueWithdrawPerPeriod: BN
        • quoteMaxInsurance: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • maxOpenInterest: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • maxSpread: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • orderSize: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • name: string

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • Optional numberOfUsers: number
        • Optional numberOfUsersWithBase: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • pausedOperations: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • perLpBase: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • stepSize: BN
        • tickSize: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • targetBaseAssetAmountPerLP: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • unrealizedInitialAssetWeight: number
        • unrealizedMaintenanceAssetWeight: number

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • Optional price: BN
        • Optional maxPrice: BN

        Returns Promise<string>

      • Parameters

        • Optional whitelistedSigners: PublicKey[]
        • Optional maxTransferPerEpoch: BN

        Returns Promise<string>

      • Parameters

        • defaultAuctionDuration: number

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • optimalUtilization: number
        • optimalBorrowRate: number
        • optimalMaxRate: number
        • Optional minBorrowRate: number

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • expiryTs: BN

        Returns Promise<string>

      • Parameters

        • perpMarketIndex: number
        • feeAdjustment: number

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • Optional fuelBoostDeposits: number
        • Optional fuelBoostBorrows: number
        • Optional fuelBoostTaker: number
        • Optional fuelBoostMaker: number
        • Optional fuelBoostInsurance: number

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • userIfFactor: BN
        • totalIfFactor: BN

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • pausedOperations: number

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • liquidatorFee: number
        • ifLiquidationFee: number

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • initialAssetWeight: number
        • maintenanceAssetWeight: number
        • initialLiabilityWeight: number
        • maintenanceLiabilityWeight: number
        • imfFactor: number = 0

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • maxTokenBorrowsFraction: number

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • maxTokenDeposits: BN

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • orderSize: BN

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • name: string

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • ordersEnabled: boolean

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • pausedOperations: number

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • revenueSettlePeriod: BN

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • scaleInitialAssetWeightStart: BN

        Returns Promise<string>

      • Parameters

        • spotMarketIndex: number
        • stepSize: BN
        • tickSize: BN

        Returns Promise<string>

      • Parameters

        • maxInitializeUserFee: number

        Returns Promise<string>

      • Parameters

        • maxNumberOfSubAccounts: number

        Returns Promise<string>

      • Parameters

        • settlementDuration: number

        Returns Promise<string>

      • Parameters

        • updates: {
              advancedLp: boolean;
              subAccountId: number;
          }[]

        Returns Promise<string>

      • Parameters

        • updates: {
              marginTradingEnabled: boolean;
              subAccountId: number;
          }[]

        Returns Promise<string>

      • Parameters

        • updates: {
              reduceOnly: boolean;
              subAccountId: number;
          }[]

        Returns Promise<string>

      • Update the wallet to use for drift transactions and linked user account

        Parameters

        • newWallet: IWallet
        • Optional subAccountIds: number[]
        • Optional activeSubAccountId: number
        • Optional includeDelegates: boolean
        • Optional authoritySubaccountMap: Map<string, number[]>

        Returns Promise<boolean>

      • Parameters

        • spotMarketIndex: number
        • withdrawGuardThreshold: BN

        Returns Promise<string>

      • Withdraws from a user account. If deposit doesn't already exist, creates a borrow

        Parameters

        • amount: BN
        • marketIndex: number
        • associatedTokenAddress: PublicKey

          the token account to withdraw to. can be the wallet public key if using native sol

        • reduceOnly: boolean = false
        • Optional subAccountId: number
        • Optional txParams: TxParams

        Returns Promise<string>

      • Parameters

        • Optional subAccountId: number
        • Optional txParams: TxParams
        • Optional opts: {
              dustPositionCountCallback?: ((count: number) => void);
          }
          • Optional dustPositionCountCallback?: ((count: number) => void)
              • (count: number): void
              • Parameters

                • count: number

                Returns void

        Returns Promise<string>

      Generated using TypeDoc