@drift-labs/sdk-browser 2.104.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +276 -0
- package/VERSION +1 -0
- package/bun.lockb +0 -0
- package/get_events.ts +47 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.js +38 -0
- package/lib/browser/accounts/bulkAccountLoader.d.ts +37 -0
- package/lib/browser/accounts/bulkAccountLoader.js +222 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/browser/accounts/bulkUserSubscription.d.ts +7 -0
- package/lib/browser/accounts/bulkUserSubscription.js +21 -0
- package/lib/browser/accounts/fetch.d.ts +6 -0
- package/lib/browser/accounts/fetch.js +30 -0
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +16 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +154 -0
- package/lib/browser/accounts/grpcDriftClientAccountSubscriber.d.ts +12 -0
- package/lib/browser/accounts/grpcDriftClientAccountSubscriber.js +98 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +30 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +171 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.js +28 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +28 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +48 -0
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.d.ts +69 -0
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.js +418 -0
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +111 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +78 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +26 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +78 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +102 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +94 -0
- package/lib/browser/accounts/testBulkAccountLoader.d.ts +4 -0
- package/lib/browser/accounts/testBulkAccountLoader.js +45 -0
- package/lib/browser/accounts/types.d.ts +168 -0
- package/lib/browser/accounts/types.js +16 -0
- package/lib/browser/accounts/utils.d.ts +8 -0
- package/lib/browser/accounts/utils.js +49 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.js +149 -0
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +66 -0
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.js +358 -0
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +69 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +32 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +120 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +61 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +22 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
- package/lib/browser/addresses/marketAddresses.d.ts +2 -0
- package/lib/browser/addresses/marketAddresses.js +15 -0
- package/lib/browser/addresses/pda.d.ts +32 -0
- package/lib/browser/addresses/pda.js +211 -0
- package/lib/browser/adminClient.d.ts +206 -0
- package/lib/browser/adminClient.js +1858 -0
- package/lib/browser/assert/assert.d.ts +1 -0
- package/lib/browser/assert/assert.js +9 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +14 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +32 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/browser/auctionSubscriber/index.d.ts +3 -0
- package/lib/browser/auctionSubscriber/index.js +19 -0
- package/lib/browser/auctionSubscriber/types.d.ts +14 -0
- package/lib/browser/auctionSubscriber/types.js +2 -0
- package/lib/browser/bankrun/bankrunConnection.d.ts +75 -0
- package/lib/browser/bankrun/bankrunConnection.js +332 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +27 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +89 -0
- package/lib/browser/blockhashSubscriber/index.d.ts +1 -0
- package/lib/browser/blockhashSubscriber/index.js +17 -0
- package/lib/browser/blockhashSubscriber/types.d.ts +7 -0
- package/lib/browser/blockhashSubscriber/types.js +2 -0
- package/lib/browser/clock/clockSubscriber.d.ts +31 -0
- package/lib/browser/clock/clockSubscriber.js +80 -0
- package/lib/browser/config.d.ts +60 -0
- package/lib/browser/config.js +130 -0
- package/lib/browser/constants/numericConstants.d.ts +71 -0
- package/lib/browser/constants/numericConstants.js +75 -0
- package/lib/browser/constants/perpMarkets.d.ts +19 -0
- package/lib/browser/constants/perpMarkets.js +997 -0
- package/lib/browser/constants/spotMarkets.d.ts +24 -0
- package/lib/browser/constants/spotMarkets.js +470 -0
- package/lib/browser/constants/txConstants.d.ts +1 -0
- package/lib/browser/constants/txConstants.js +4 -0
- package/lib/browser/decode/phoenix.d.ts +7 -0
- package/lib/browser/decode/phoenix.js +159 -0
- package/lib/browser/decode/user.d.ts +4 -0
- package/lib/browser/decode/user.js +339 -0
- package/lib/browser/dlob/DLOB.d.ts +186 -0
- package/lib/browser/dlob/DLOB.js +1039 -0
- package/lib/browser/dlob/DLOBNode.d.ts +68 -0
- package/lib/browser/dlob/DLOBNode.js +100 -0
- package/lib/browser/dlob/DLOBSubscriber.d.ts +54 -0
- package/lib/browser/dlob/DLOBSubscriber.js +139 -0
- package/lib/browser/dlob/NodeList.d.ts +25 -0
- package/lib/browser/dlob/NodeList.js +126 -0
- package/lib/browser/dlob/orderBookLevels.d.ts +72 -0
- package/lib/browser/dlob/orderBookLevels.js +438 -0
- package/lib/browser/dlob/types.d.ts +18 -0
- package/lib/browser/dlob/types.js +2 -0
- package/lib/browser/driftClient.d.ts +861 -0
- package/lib/browser/driftClient.js +4768 -0
- package/lib/browser/driftClientConfig.d.ts +49 -0
- package/lib/browser/driftClientConfig.js +2 -0
- package/lib/browser/events/eventList.d.ts +22 -0
- package/lib/browser/events/eventList.js +80 -0
- package/lib/browser/events/eventSubscriber.d.ts +46 -0
- package/lib/browser/events/eventSubscriber.js +223 -0
- package/lib/browser/events/eventsServerLogProvider.d.ts +21 -0
- package/lib/browser/events/eventsServerLogProvider.js +121 -0
- package/lib/browser/events/fetchLogs.d.ts +25 -0
- package/lib/browser/events/fetchLogs.js +99 -0
- package/lib/browser/events/parse.d.ts +6 -0
- package/lib/browser/events/parse.js +106 -0
- package/lib/browser/events/pollingLogProvider.d.ts +17 -0
- package/lib/browser/events/pollingLogProvider.js +58 -0
- package/lib/browser/events/sort.d.ts +2 -0
- package/lib/browser/events/sort.js +24 -0
- package/lib/browser/events/txEventCache.d.ts +24 -0
- package/lib/browser/events/txEventCache.js +71 -0
- package/lib/browser/events/types.d.ts +79 -0
- package/lib/browser/events/types.js +32 -0
- package/lib/browser/events/webSocketLogProvider.d.ts +24 -0
- package/lib/browser/events/webSocketLogProvider.js +96 -0
- package/lib/browser/factory/bigNum.d.ts +122 -0
- package/lib/browser/factory/bigNum.js +457 -0
- package/lib/browser/factory/oracleClient.d.ts +5 -0
- package/lib/browser/factory/oracleClient.js +56 -0
- package/lib/browser/idl/drift.json +14440 -0
- package/lib/browser/idl/openbook.json +3854 -0
- package/lib/browser/idl/pyth_solana_receiver.json +628 -0
- package/lib/browser/idl/switchboard.json +8354 -0
- package/lib/browser/idl/switchboard_on_demand_30.json +4546 -0
- package/lib/browser/idl/token_faucet.json +142 -0
- package/lib/browser/index.d.ts +125 -0
- package/lib/browser/index.js +147 -0
- package/lib/browser/isomorphic/grpc.browser.d.ts +1 -0
- package/lib/browser/isomorphic/grpc.browser.js +8 -0
- package/lib/browser/isomorphic/grpc.d.ts +1 -0
- package/lib/browser/isomorphic/grpc.js +8 -0
- package/lib/browser/jupiter/jupiterClient.d.ts +302 -0
- package/lib/browser/jupiter/jupiterClient.js +178 -0
- package/lib/browser/keypair.d.ts +2 -0
- package/lib/browser/keypair.js +28 -0
- package/lib/browser/marinade/index.d.ts +12 -0
- package/lib/browser/marinade/index.js +36 -0
- package/lib/browser/marinade/types.d.ts +1963 -0
- package/lib/browser/marinade/types.js +1965 -0
- package/lib/browser/math/amm.d.ts +98 -0
- package/lib/browser/math/amm.js +626 -0
- package/lib/browser/math/auction.d.ts +23 -0
- package/lib/browser/math/auction.js +130 -0
- package/lib/browser/math/bankruptcy.d.ts +2 -0
- package/lib/browser/math/bankruptcy.js +31 -0
- package/lib/browser/math/conversion.d.ts +2 -0
- package/lib/browser/math/conversion.js +11 -0
- package/lib/browser/math/exchangeStatus.d.ts +6 -0
- package/lib/browser/math/exchangeStatus.js +77 -0
- package/lib/browser/math/fuel.d.ts +6 -0
- package/lib/browser/math/fuel.js +55 -0
- package/lib/browser/math/funding.d.ts +34 -0
- package/lib/browser/math/funding.js +209 -0
- package/lib/browser/math/insurance.d.ts +7 -0
- package/lib/browser/math/insurance.js +73 -0
- package/lib/browser/math/margin.d.ts +39 -0
- package/lib/browser/math/margin.js +184 -0
- package/lib/browser/math/market.d.ts +39 -0
- package/lib/browser/math/market.js +163 -0
- package/lib/browser/math/oracles.d.ts +14 -0
- package/lib/browser/math/oracles.js +134 -0
- package/lib/browser/math/orders.d.ts +23 -0
- package/lib/browser/math/orders.js +216 -0
- package/lib/browser/math/position.d.ts +70 -0
- package/lib/browser/math/position.js +225 -0
- package/lib/browser/math/repeg.d.ts +22 -0
- package/lib/browser/math/repeg.js +164 -0
- package/lib/browser/math/spotBalance.d.ts +83 -0
- package/lib/browser/math/spotBalance.js +373 -0
- package/lib/browser/math/spotMarket.d.ts +11 -0
- package/lib/browser/math/spotMarket.js +49 -0
- package/lib/browser/math/spotPosition.d.ts +19 -0
- package/lib/browser/math/spotPosition.js +78 -0
- package/lib/browser/math/state.d.ts +5 -0
- package/lib/browser/math/state.js +30 -0
- package/lib/browser/math/superStake.d.ts +167 -0
- package/lib/browser/math/superStake.js +306 -0
- package/lib/browser/math/tiers.d.ts +4 -0
- package/lib/browser/math/tiers.js +52 -0
- package/lib/browser/math/trade.d.ts +117 -0
- package/lib/browser/math/trade.js +637 -0
- package/lib/browser/math/userStatus.d.ts +2 -0
- package/lib/browser/math/userStatus.js +8 -0
- package/lib/browser/math/utils.d.ts +23 -0
- package/lib/browser/math/utils.js +112 -0
- package/lib/browser/memcmp.d.ts +11 -0
- package/lib/browser/memcmp.js +99 -0
- package/lib/browser/openbook/openbookV2FulfillmentConfigMap.d.ts +10 -0
- package/lib/browser/openbook/openbookV2FulfillmentConfigMap.js +17 -0
- package/lib/browser/openbook/openbookV2Subscriber.d.ts +36 -0
- package/lib/browser/openbook/openbookV2Subscriber.js +104 -0
- package/lib/browser/oracles/oracleClientCache.d.ts +9 -0
- package/lib/browser/oracles/oracleClientCache.js +19 -0
- package/lib/browser/oracles/oracleId.d.ts +4 -0
- package/lib/browser/oracles/oracleId.js +38 -0
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +12 -0
- package/lib/browser/oracles/prelaunchOracleClient.js +24 -0
- package/lib/browser/oracles/pythClient.d.ts +14 -0
- package/lib/browser/oracles/pythClient.js +51 -0
- package/lib/browser/oracles/pythLazerClient.d.ts +16 -0
- package/lib/browser/oracles/pythLazerClient.js +61 -0
- package/lib/browser/oracles/pythPullClient.d.ts +19 -0
- package/lib/browser/oracles/pythPullClient.js +60 -0
- package/lib/browser/oracles/quoteAssetOracleClient.d.ts +10 -0
- package/lib/browser/oracles/quoteAssetOracleClient.js +21 -0
- package/lib/browser/oracles/strictOraclePrice.d.ts +9 -0
- package/lib/browser/oracles/strictOraclePrice.js +17 -0
- package/lib/browser/oracles/switchboardClient.d.ts +12 -0
- package/lib/browser/oracles/switchboardClient.js +40 -0
- package/lib/browser/oracles/switchboardOnDemandClient.d.ts +12 -0
- package/lib/browser/oracles/switchboardOnDemandClient.js +32 -0
- package/lib/browser/oracles/types.d.ts +23 -0
- package/lib/browser/oracles/types.js +2 -0
- package/lib/browser/orderParams.d.ts +29 -0
- package/lib/browser/orderParams.js +44 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +42 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.js +172 -0
- package/lib/browser/orderSubscriber/PollingSubscription.d.ts +12 -0
- package/lib/browser/orderSubscriber/PollingSubscription.js +23 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +23 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +67 -0
- package/lib/browser/orderSubscriber/grpcSubscription.d.ts +22 -0
- package/lib/browser/orderSubscriber/grpcSubscription.js +66 -0
- package/lib/browser/orderSubscriber/index.d.ts +2 -0
- package/lib/browser/orderSubscriber/index.js +18 -0
- package/lib/browser/orderSubscriber/types.d.ts +34 -0
- package/lib/browser/orderSubscriber/types.js +2 -0
- package/lib/browser/phoenix/phoenixFulfillmentConfigMap.d.ts +10 -0
- package/lib/browser/phoenix/phoenixFulfillmentConfigMap.js +17 -0
- package/lib/browser/phoenix/phoenixSubscriber.d.ts +41 -0
- package/lib/browser/phoenix/phoenixSubscriber.js +152 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +5 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.js +16 -0
- package/lib/browser/priorityFee/averageStrategy.d.ts +5 -0
- package/lib/browser/priorityFee/averageStrategy.js +11 -0
- package/lib/browser/priorityFee/driftPriorityFeeMethod.d.ts +13 -0
- package/lib/browser/priorityFee/driftPriorityFeeMethod.js +26 -0
- package/lib/browser/priorityFee/ewmaStrategy.d.ts +11 -0
- package/lib/browser/priorityFee/ewmaStrategy.js +33 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +20 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +46 -0
- package/lib/browser/priorityFee/index.d.ts +11 -0
- package/lib/browser/priorityFee/index.js +27 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +5 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.js +17 -0
- package/lib/browser/priorityFee/maxStrategy.d.ts +7 -0
- package/lib/browser/priorityFee/maxStrategy.js +9 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +46 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +188 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +48 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +88 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +6 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +21 -0
- package/lib/browser/priorityFee/types.d.ts +31 -0
- package/lib/browser/priorityFee/types.js +10 -0
- package/lib/browser/serum/serumFulfillmentConfigMap.d.ts +10 -0
- package/lib/browser/serum/serumFulfillmentConfigMap.js +17 -0
- package/lib/browser/serum/serumSubscriber.d.ts +32 -0
- package/lib/browser/serum/serumSubscriber.js +107 -0
- package/lib/browser/serum/types.d.ts +13 -0
- package/lib/browser/serum/types.js +2 -0
- package/lib/browser/slot/SlotSubscriber.d.ts +27 -0
- package/lib/browser/slot/SlotSubscriber.js +71 -0
- package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/browser/slot/SlothashSubscriber.js +85 -0
- package/lib/browser/testClient.d.ts +8 -0
- package/lib/browser/testClient.js +23 -0
- package/lib/browser/token/index.d.ts +5 -0
- package/lib/browser/token/index.js +15 -0
- package/lib/browser/tokenFaucet.d.ts +41 -0
- package/lib/browser/tokenFaucet.js +188 -0
- package/lib/browser/tx/baseTxSender.d.ts +59 -0
- package/lib/browser/tx/baseTxSender.js +294 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +8 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +28 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
- package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/browser/tx/blockhashFetcher/types.js +2 -0
- package/lib/browser/tx/fastSingleTxSender.d.ts +41 -0
- package/lib/browser/tx/fastSingleTxSender.js +86 -0
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +37 -0
- package/lib/browser/tx/forwardOnlyTxSender.js +92 -0
- package/lib/browser/tx/priorityFeeCalculator.d.ts +44 -0
- package/lib/browser/tx/priorityFeeCalculator.js +85 -0
- package/lib/browser/tx/reportTransactionError.d.ts +20 -0
- package/lib/browser/tx/reportTransactionError.js +103 -0
- package/lib/browser/tx/retryTxSender.d.ts +37 -0
- package/lib/browser/tx/retryTxSender.js +86 -0
- package/lib/browser/tx/txHandler.d.ts +154 -0
- package/lib/browser/tx/txHandler.js +453 -0
- package/lib/browser/tx/txParamProcessor.d.ts +25 -0
- package/lib/browser/tx/txParamProcessor.js +88 -0
- package/lib/browser/tx/types.d.ts +29 -0
- package/lib/browser/tx/types.js +20 -0
- package/lib/browser/tx/utils.d.ts +2 -0
- package/lib/browser/tx/utils.js +10 -0
- package/lib/browser/tx/whileValidTxSender.d.ts +45 -0
- package/lib/browser/tx/whileValidTxSender.js +167 -0
- package/lib/browser/types.d.ts +1385 -0
- package/lib/browser/types.js +366 -0
- package/lib/browser/user.d.ts +411 -0
- package/lib/browser/user.js +2151 -0
- package/lib/browser/userConfig.d.ts +26 -0
- package/lib/browser/userConfig.js +2 -0
- package/lib/browser/userMap/PollingSubscription.d.ts +16 -0
- package/lib/browser/userMap/PollingSubscription.js +30 -0
- package/lib/browser/userMap/WebsocketSubscription.d.ts +27 -0
- package/lib/browser/userMap/WebsocketSubscription.js +45 -0
- package/lib/browser/userMap/grpcSubscription.d.ts +27 -0
- package/lib/browser/userMap/grpcSubscription.js +44 -0
- package/lib/browser/userMap/referrerMap.d.ts +45 -0
- package/lib/browser/userMap/referrerMap.js +181 -0
- package/lib/browser/userMap/userMap.d.ts +90 -0
- package/lib/browser/userMap/userMap.js +467 -0
- package/lib/browser/userMap/userMapConfig.d.ts +39 -0
- package/lib/browser/userMap/userMapConfig.js +2 -0
- package/lib/browser/userMap/userStatsMap.d.ts +46 -0
- package/lib/browser/userMap/userStatsMap.js +165 -0
- package/lib/browser/userName.d.ts +5 -0
- package/lib/browser/userName.js +21 -0
- package/lib/browser/userStats.d.ts +22 -0
- package/lib/browser/userStats.js +91 -0
- package/lib/browser/userStatsConfig.d.ts +25 -0
- package/lib/browser/userStatsConfig.js +2 -0
- package/lib/browser/util/TransactionConfirmationManager.d.ts +16 -0
- package/lib/browser/util/TransactionConfirmationManager.js +174 -0
- package/lib/browser/util/chainClock.d.ts +17 -0
- package/lib/browser/util/chainClock.js +29 -0
- package/lib/browser/util/computeUnits.d.ts +8 -0
- package/lib/browser/util/computeUnits.js +48 -0
- package/lib/browser/util/digest.d.ts +4 -0
- package/lib/browser/util/digest.js +14 -0
- package/lib/browser/util/promiseTimeout.d.ts +1 -0
- package/lib/browser/util/promiseTimeout.js +14 -0
- package/lib/browser/util/pythOracleUtils.d.ts +17 -0
- package/lib/browser/util/pythOracleUtils.js +107 -0
- package/lib/browser/util/tps.d.ts +2 -0
- package/lib/browser/util/tps.js +16 -0
- package/lib/browser/wallet.d.ts +11 -0
- package/lib/browser/wallet.js +32 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/basicUserAccountSubscriber.js +38 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts +37 -0
- package/lib/node/accounts/bulkAccountLoader.js +222 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/node/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/node/accounts/bulkUserSubscription.d.ts +7 -0
- package/lib/node/accounts/bulkUserSubscription.js +21 -0
- package/lib/node/accounts/fetch.d.ts +6 -0
- package/lib/node/accounts/fetch.js +30 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +16 -0
- package/lib/node/accounts/grpcAccountSubscriber.js +154 -0
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts +12 -0
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.js +98 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +30 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +171 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +10 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.js +28 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +10 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +28 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +48 -0
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts +69 -0
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.js +418 -0
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +111 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +26 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.js +102 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +94 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts +4 -0
- package/lib/node/accounts/testBulkAccountLoader.js +45 -0
- package/lib/node/accounts/types.d.ts +168 -0
- package/lib/node/accounts/types.js +16 -0
- package/lib/node/accounts/utils.d.ts +8 -0
- package/lib/node/accounts/utils.js +49 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/webSocketAccountSubscriber.js +149 -0
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +66 -0
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.js +358 -0
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +69 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +120 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +61 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +22 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
- package/lib/node/addresses/marketAddresses.d.ts +2 -0
- package/lib/node/addresses/marketAddresses.js +15 -0
- package/lib/node/addresses/pda.d.ts +32 -0
- package/lib/node/addresses/pda.js +211 -0
- package/lib/node/adminClient.d.ts +206 -0
- package/lib/node/adminClient.js +1858 -0
- package/lib/node/assert/assert.d.ts +1 -0
- package/lib/node/assert/assert.js +9 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +14 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.js +32 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/node/auctionSubscriber/index.d.ts +3 -0
- package/lib/node/auctionSubscriber/index.js +19 -0
- package/lib/node/auctionSubscriber/types.d.ts +14 -0
- package/lib/node/auctionSubscriber/types.js +2 -0
- package/lib/node/bankrun/bankrunConnection.d.ts +75 -0
- package/lib/node/bankrun/bankrunConnection.js +332 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +27 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +89 -0
- package/lib/node/blockhashSubscriber/index.d.ts +1 -0
- package/lib/node/blockhashSubscriber/index.js +17 -0
- package/lib/node/blockhashSubscriber/types.d.ts +7 -0
- package/lib/node/blockhashSubscriber/types.js +2 -0
- package/lib/node/clock/clockSubscriber.d.ts +31 -0
- package/lib/node/clock/clockSubscriber.js +80 -0
- package/lib/node/config.d.ts +60 -0
- package/lib/node/config.js +130 -0
- package/lib/node/constants/numericConstants.d.ts +71 -0
- package/lib/node/constants/numericConstants.js +75 -0
- package/lib/node/constants/perpMarkets.d.ts +19 -0
- package/lib/node/constants/perpMarkets.js +997 -0
- package/lib/node/constants/spotMarkets.d.ts +24 -0
- package/lib/node/constants/spotMarkets.js +470 -0
- package/lib/node/constants/txConstants.d.ts +1 -0
- package/lib/node/constants/txConstants.js +4 -0
- package/lib/node/decode/phoenix.d.ts +7 -0
- package/lib/node/decode/phoenix.js +159 -0
- package/lib/node/decode/user.d.ts +4 -0
- package/lib/node/decode/user.js +339 -0
- package/lib/node/dlob/DLOB.d.ts +186 -0
- package/lib/node/dlob/DLOB.js +1039 -0
- package/lib/node/dlob/DLOBNode.d.ts +68 -0
- package/lib/node/dlob/DLOBNode.js +100 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts +54 -0
- package/lib/node/dlob/DLOBSubscriber.js +139 -0
- package/lib/node/dlob/NodeList.d.ts +25 -0
- package/lib/node/dlob/NodeList.js +126 -0
- package/lib/node/dlob/orderBookLevels.d.ts +72 -0
- package/lib/node/dlob/orderBookLevels.js +438 -0
- package/lib/node/dlob/types.d.ts +18 -0
- package/lib/node/dlob/types.js +2 -0
- package/lib/node/driftClient.d.ts +861 -0
- package/lib/node/driftClient.js +4768 -0
- package/lib/node/driftClientConfig.d.ts +49 -0
- package/lib/node/driftClientConfig.js +2 -0
- package/lib/node/events/eventList.d.ts +22 -0
- package/lib/node/events/eventList.js +80 -0
- package/lib/node/events/eventSubscriber.d.ts +46 -0
- package/lib/node/events/eventSubscriber.js +223 -0
- package/lib/node/events/eventsServerLogProvider.d.ts +21 -0
- package/lib/node/events/eventsServerLogProvider.js +121 -0
- package/lib/node/events/fetchLogs.d.ts +25 -0
- package/lib/node/events/fetchLogs.js +99 -0
- package/lib/node/events/parse.d.ts +6 -0
- package/lib/node/events/parse.js +106 -0
- package/lib/node/events/pollingLogProvider.d.ts +17 -0
- package/lib/node/events/pollingLogProvider.js +58 -0
- package/lib/node/events/sort.d.ts +2 -0
- package/lib/node/events/sort.js +24 -0
- package/lib/node/events/txEventCache.d.ts +24 -0
- package/lib/node/events/txEventCache.js +71 -0
- package/lib/node/events/types.d.ts +79 -0
- package/lib/node/events/types.js +32 -0
- package/lib/node/events/webSocketLogProvider.d.ts +24 -0
- package/lib/node/events/webSocketLogProvider.js +96 -0
- package/lib/node/factory/bigNum.d.ts +122 -0
- package/lib/node/factory/bigNum.js +457 -0
- package/lib/node/factory/oracleClient.d.ts +5 -0
- package/lib/node/factory/oracleClient.js +56 -0
- package/lib/node/idl/drift.json +14440 -0
- package/lib/node/idl/openbook.json +3854 -0
- package/lib/node/idl/pyth_solana_receiver.json +628 -0
- package/lib/node/idl/switchboard.json +8354 -0
- package/lib/node/idl/switchboard_on_demand_30.json +4546 -0
- package/lib/node/idl/token_faucet.json +142 -0
- package/lib/node/index.d.ts +125 -0
- package/lib/node/index.js +147 -0
- package/lib/node/isomorphic/grpc.browser.d.ts +1 -0
- package/lib/node/isomorphic/grpc.browser.js +8 -0
- package/lib/node/isomorphic/grpc.d.ts +1 -0
- package/lib/node/isomorphic/grpc.js +8 -0
- package/lib/node/jupiter/jupiterClient.d.ts +302 -0
- package/lib/node/jupiter/jupiterClient.js +178 -0
- package/lib/node/keypair.d.ts +2 -0
- package/lib/node/keypair.js +28 -0
- package/lib/node/marinade/index.d.ts +12 -0
- package/lib/node/marinade/index.js +36 -0
- package/lib/node/marinade/types.d.ts +1963 -0
- package/lib/node/marinade/types.js +1965 -0
- package/lib/node/math/amm.d.ts +98 -0
- package/lib/node/math/amm.js +626 -0
- package/lib/node/math/auction.d.ts +23 -0
- package/lib/node/math/auction.js +130 -0
- package/lib/node/math/bankruptcy.d.ts +2 -0
- package/lib/node/math/bankruptcy.js +31 -0
- package/lib/node/math/conversion.d.ts +2 -0
- package/lib/node/math/conversion.js +11 -0
- package/lib/node/math/exchangeStatus.d.ts +6 -0
- package/lib/node/math/exchangeStatus.js +77 -0
- package/lib/node/math/fuel.d.ts +6 -0
- package/lib/node/math/fuel.js +55 -0
- package/lib/node/math/funding.d.ts +34 -0
- package/lib/node/math/funding.js +209 -0
- package/lib/node/math/insurance.d.ts +7 -0
- package/lib/node/math/insurance.js +73 -0
- package/lib/node/math/margin.d.ts +39 -0
- package/lib/node/math/margin.js +184 -0
- package/lib/node/math/market.d.ts +39 -0
- package/lib/node/math/market.js +163 -0
- package/lib/node/math/oracles.d.ts +14 -0
- package/lib/node/math/oracles.js +134 -0
- package/lib/node/math/orders.d.ts +23 -0
- package/lib/node/math/orders.js +216 -0
- package/lib/node/math/position.d.ts +70 -0
- package/lib/node/math/position.js +225 -0
- package/lib/node/math/repeg.d.ts +22 -0
- package/lib/node/math/repeg.js +164 -0
- package/lib/node/math/spotBalance.d.ts +83 -0
- package/lib/node/math/spotBalance.js +373 -0
- package/lib/node/math/spotMarket.d.ts +11 -0
- package/lib/node/math/spotMarket.js +49 -0
- package/lib/node/math/spotPosition.d.ts +19 -0
- package/lib/node/math/spotPosition.js +78 -0
- package/lib/node/math/state.d.ts +5 -0
- package/lib/node/math/state.js +30 -0
- package/lib/node/math/superStake.d.ts +167 -0
- package/lib/node/math/superStake.js +306 -0
- package/lib/node/math/tiers.d.ts +4 -0
- package/lib/node/math/tiers.js +52 -0
- package/lib/node/math/trade.d.ts +117 -0
- package/lib/node/math/trade.js +637 -0
- package/lib/node/math/userStatus.d.ts +2 -0
- package/lib/node/math/userStatus.js +8 -0
- package/lib/node/math/utils.d.ts +23 -0
- package/lib/node/math/utils.js +112 -0
- package/lib/node/memcmp.d.ts +11 -0
- package/lib/node/memcmp.js +99 -0
- package/lib/node/openbook/openbookV2FulfillmentConfigMap.d.ts +10 -0
- package/lib/node/openbook/openbookV2FulfillmentConfigMap.js +17 -0
- package/lib/node/openbook/openbookV2Subscriber.d.ts +36 -0
- package/lib/node/openbook/openbookV2Subscriber.js +104 -0
- package/lib/node/oracles/oracleClientCache.d.ts +9 -0
- package/lib/node/oracles/oracleClientCache.js +19 -0
- package/lib/node/oracles/oracleId.d.ts +4 -0
- package/lib/node/oracles/oracleId.js +38 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts +12 -0
- package/lib/node/oracles/prelaunchOracleClient.js +24 -0
- package/lib/node/oracles/pythClient.d.ts +14 -0
- package/lib/node/oracles/pythClient.js +51 -0
- package/lib/node/oracles/pythLazerClient.d.ts +16 -0
- package/lib/node/oracles/pythLazerClient.js +61 -0
- package/lib/node/oracles/pythPullClient.d.ts +19 -0
- package/lib/node/oracles/pythPullClient.js +60 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts +10 -0
- package/lib/node/oracles/quoteAssetOracleClient.js +21 -0
- package/lib/node/oracles/strictOraclePrice.d.ts +9 -0
- package/lib/node/oracles/strictOraclePrice.js +17 -0
- package/lib/node/oracles/switchboardClient.d.ts +12 -0
- package/lib/node/oracles/switchboardClient.js +40 -0
- package/lib/node/oracles/switchboardOnDemandClient.d.ts +12 -0
- package/lib/node/oracles/switchboardOnDemandClient.js +32 -0
- package/lib/node/oracles/types.d.ts +23 -0
- package/lib/node/oracles/types.js +2 -0
- package/lib/node/orderParams.d.ts +29 -0
- package/lib/node/orderParams.js +44 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +42 -0
- package/lib/node/orderSubscriber/OrderSubscriber.js +172 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts +12 -0
- package/lib/node/orderSubscriber/PollingSubscription.js +23 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +23 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.js +67 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts +22 -0
- package/lib/node/orderSubscriber/grpcSubscription.js +66 -0
- package/lib/node/orderSubscriber/index.d.ts +2 -0
- package/lib/node/orderSubscriber/index.js +18 -0
- package/lib/node/orderSubscriber/types.d.ts +34 -0
- package/lib/node/orderSubscriber/types.js +2 -0
- package/lib/node/phoenix/phoenixFulfillmentConfigMap.d.ts +10 -0
- package/lib/node/phoenix/phoenixFulfillmentConfigMap.js +17 -0
- package/lib/node/phoenix/phoenixSubscriber.d.ts +41 -0
- package/lib/node/phoenix/phoenixSubscriber.js +152 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +5 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.js +16 -0
- package/lib/node/priorityFee/averageStrategy.d.ts +5 -0
- package/lib/node/priorityFee/averageStrategy.js +11 -0
- package/lib/node/priorityFee/driftPriorityFeeMethod.d.ts +13 -0
- package/lib/node/priorityFee/driftPriorityFeeMethod.js +26 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts +11 -0
- package/lib/node/priorityFee/ewmaStrategy.js +33 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +20 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.js +46 -0
- package/lib/node/priorityFee/index.d.ts +11 -0
- package/lib/node/priorityFee/index.js +27 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +5 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.js +17 -0
- package/lib/node/priorityFee/maxStrategy.d.ts +7 -0
- package/lib/node/priorityFee/maxStrategy.js +9 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +46 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.js +188 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +48 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +88 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +6 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.js +21 -0
- package/lib/node/priorityFee/types.d.ts +31 -0
- package/lib/node/priorityFee/types.js +10 -0
- package/lib/node/serum/serumFulfillmentConfigMap.d.ts +10 -0
- package/lib/node/serum/serumFulfillmentConfigMap.js +17 -0
- package/lib/node/serum/serumSubscriber.d.ts +32 -0
- package/lib/node/serum/serumSubscriber.js +107 -0
- package/lib/node/serum/types.d.ts +13 -0
- package/lib/node/serum/types.js +2 -0
- package/lib/node/slot/SlotSubscriber.d.ts +27 -0
- package/lib/node/slot/SlotSubscriber.js +71 -0
- package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/node/slot/SlothashSubscriber.js +85 -0
- package/lib/node/testClient.d.ts +8 -0
- package/lib/node/testClient.js +23 -0
- package/lib/node/token/index.d.ts +5 -0
- package/lib/node/token/index.js +15 -0
- package/lib/node/tokenFaucet.d.ts +41 -0
- package/lib/node/tokenFaucet.js +188 -0
- package/lib/node/tx/baseTxSender.d.ts +59 -0
- package/lib/node/tx/baseTxSender.js +294 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +8 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +28 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/node/tx/blockhashFetcher/types.js +2 -0
- package/lib/node/tx/fastSingleTxSender.d.ts +41 -0
- package/lib/node/tx/fastSingleTxSender.js +86 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts +37 -0
- package/lib/node/tx/forwardOnlyTxSender.js +92 -0
- package/lib/node/tx/priorityFeeCalculator.d.ts +44 -0
- package/lib/node/tx/priorityFeeCalculator.js +85 -0
- package/lib/node/tx/reportTransactionError.d.ts +20 -0
- package/lib/node/tx/reportTransactionError.js +103 -0
- package/lib/node/tx/retryTxSender.d.ts +37 -0
- package/lib/node/tx/retryTxSender.js +86 -0
- package/lib/node/tx/txHandler.d.ts +154 -0
- package/lib/node/tx/txHandler.js +453 -0
- package/lib/node/tx/txParamProcessor.d.ts +25 -0
- package/lib/node/tx/txParamProcessor.js +88 -0
- package/lib/node/tx/types.d.ts +29 -0
- package/lib/node/tx/types.js +20 -0
- package/lib/node/tx/utils.d.ts +2 -0
- package/lib/node/tx/utils.js +10 -0
- package/lib/node/tx/whileValidTxSender.d.ts +45 -0
- package/lib/node/tx/whileValidTxSender.js +167 -0
- package/lib/node/types.d.ts +1385 -0
- package/lib/node/types.js +366 -0
- package/lib/node/user.d.ts +411 -0
- package/lib/node/user.js +2151 -0
- package/lib/node/userConfig.d.ts +26 -0
- package/lib/node/userConfig.js +2 -0
- package/lib/node/userMap/PollingSubscription.d.ts +16 -0
- package/lib/node/userMap/PollingSubscription.js +30 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts +27 -0
- package/lib/node/userMap/WebsocketSubscription.js +45 -0
- package/lib/node/userMap/grpcSubscription.d.ts +27 -0
- package/lib/node/userMap/grpcSubscription.js +44 -0
- package/lib/node/userMap/referrerMap.d.ts +45 -0
- package/lib/node/userMap/referrerMap.js +181 -0
- package/lib/node/userMap/userMap.d.ts +90 -0
- package/lib/node/userMap/userMap.js +467 -0
- package/lib/node/userMap/userMapConfig.d.ts +39 -0
- package/lib/node/userMap/userMapConfig.js +2 -0
- package/lib/node/userMap/userStatsMap.d.ts +46 -0
- package/lib/node/userMap/userStatsMap.js +165 -0
- package/lib/node/userName.d.ts +5 -0
- package/lib/node/userName.js +21 -0
- package/lib/node/userStats.d.ts +22 -0
- package/lib/node/userStats.js +91 -0
- package/lib/node/userStatsConfig.d.ts +25 -0
- package/lib/node/userStatsConfig.js +2 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts +16 -0
- package/lib/node/util/TransactionConfirmationManager.js +174 -0
- package/lib/node/util/chainClock.d.ts +17 -0
- package/lib/node/util/chainClock.js +29 -0
- package/lib/node/util/computeUnits.d.ts +8 -0
- package/lib/node/util/computeUnits.js +48 -0
- package/lib/node/util/digest.d.ts +4 -0
- package/lib/node/util/digest.js +14 -0
- package/lib/node/util/promiseTimeout.d.ts +1 -0
- package/lib/node/util/promiseTimeout.js +14 -0
- package/lib/node/util/pythOracleUtils.d.ts +17 -0
- package/lib/node/util/pythOracleUtils.js +107 -0
- package/lib/node/util/tps.d.ts +2 -0
- package/lib/node/util/tps.js +16 -0
- package/lib/node/wallet.d.ts +11 -0
- package/lib/node/wallet.js +32 -0
- package/package.json +92 -0
- package/scripts/postbuild.js +95 -0
- package/scripts/updateVersion.js +28 -0
- package/src/accounts/basicUserAccountSubscriber.ts +59 -0
- package/src/accounts/bulkAccountLoader.ts +294 -0
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +33 -0
- package/src/accounts/fetch.ts +66 -0
- package/src/accounts/grpcAccountSubscriber.ts +160 -0
- package/src/accounts/grpcDriftClientAccountSubscriber.ts +203 -0
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +56 -0
- package/src/accounts/grpcProgramAccountSubscriber.ts +190 -0
- package/src/accounts/grpcUserAccountSubscriber.ts +48 -0
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +50 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +68 -0
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +644 -0
- package/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +189 -0
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +185 -0
- package/src/accounts/pollingOracleAccountSubscriber.ts +125 -0
- package/src/accounts/pollingTokenAccountSubscriber.ts +118 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +160 -0
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +156 -0
- package/src/accounts/testBulkAccountLoader.ts +53 -0
- package/src/accounts/types.ts +245 -0
- package/src/accounts/utils.ts +62 -0
- package/src/accounts/webSocketAccountSubscriber.ts +205 -0
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +621 -0
- package/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +131 -0
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +129 -0
- package/src/accounts/webSocketProgramAccountSubscriber.ts +182 -0
- package/src/accounts/webSocketUserAccountSubscriber.ts +104 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +98 -0
- package/src/addresses/marketAddresses.ts +17 -0
- package/src/addresses/pda.ts +355 -0
- package/src/adminClient.ts +4030 -0
- package/src/assert/assert.ts +5 -0
- package/src/auctionSubscriber/auctionSubscriber.ts +66 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +70 -0
- package/src/auctionSubscriber/index.ts +3 -0
- package/src/auctionSubscriber/types.ts +20 -0
- package/src/bankrun/bankrunConnection.ts +534 -0
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +126 -0
- package/src/blockhashSubscriber/index.ts +1 -0
- package/src/blockhashSubscriber/types.ts +12 -0
- package/src/clock/clockSubscriber.ts +121 -0
- package/src/config.ts +212 -0
- package/src/constants/numericConstants.ts +113 -0
- package/src/constants/perpMarkets.ts +1084 -0
- package/src/constants/spotMarkets.ts +565 -0
- package/src/constants/txConstants.ts +1 -0
- package/src/decode/phoenix.ts +207 -0
- package/src/decode/user.ts +368 -0
- package/src/dlob/DLOB.ts +1897 -0
- package/src/dlob/DLOBNode.ts +197 -0
- package/src/dlob/DLOBSubscriber.ts +201 -0
- package/src/dlob/NodeList.ts +173 -0
- package/src/dlob/orderBookLevels.ts +643 -0
- package/src/dlob/types.ts +22 -0
- package/src/driftClient.ts +9032 -0
- package/src/driftClientConfig.ts +60 -0
- package/src/events/eventList.ts +97 -0
- package/src/events/eventSubscriber.ts +364 -0
- package/src/events/eventsServerLogProvider.ts +152 -0
- package/src/events/fetchLogs.ts +169 -0
- package/src/events/parse.ts +133 -0
- package/src/events/pollingLogProvider.ts +89 -0
- package/src/events/sort.ts +39 -0
- package/src/events/txEventCache.ts +74 -0
- package/src/events/types.ts +185 -0
- package/src/events/webSocketLogProvider.ts +121 -0
- package/src/factory/bigNum.ts +660 -0
- package/src/factory/oracleClient.ts +72 -0
- package/src/idl/drift.json +14440 -0
- package/src/idl/openbook.json +3854 -0
- package/src/idl/pyth.json +142 -0
- package/src/idl/pyth_solana_receiver.json +628 -0
- package/src/idl/switchboard.json +8354 -0
- package/src/idl/switchboard_on_demand_30.json +4546 -0
- package/src/idl/token_faucet.json +142 -0
- package/src/index.ts +127 -0
- package/src/isomorphic/README.md +19 -0
- package/src/isomorphic/grpc.browser.ts +4 -0
- package/src/isomorphic/grpc.node.ts +23 -0
- package/src/isomorphic/grpc.ts +1 -0
- package/src/jupiter/jupiterClient.ts +510 -0
- package/src/keypair.ts +24 -0
- package/src/marinade/idl/idl.json +1962 -0
- package/src/marinade/index.ts +64 -0
- package/src/marinade/types.ts +3925 -0
- package/src/math/amm.ts +1162 -0
- package/src/math/auction.ts +173 -0
- package/src/math/bankruptcy.ts +34 -0
- package/src/math/conversion.ts +13 -0
- package/src/math/exchangeStatus.ts +121 -0
- package/src/math/fuel.ts +70 -0
- package/src/math/funding.ts +342 -0
- package/src/math/insurance.ts +110 -0
- package/src/math/margin.ts +340 -0
- package/src/math/market.ts +336 -0
- package/src/math/oracles.ts +228 -0
- package/src/math/orders.ts +343 -0
- package/src/math/position.ts +324 -0
- package/src/math/repeg.ts +214 -0
- package/src/math/spotBalance.ts +630 -0
- package/src/math/spotMarket.ts +82 -0
- package/src/math/spotPosition.ts +184 -0
- package/src/math/state.ts +29 -0
- package/src/math/superStake.ts +525 -0
- package/src/math/tiers.ts +44 -0
- package/src/math/trade.ts +993 -0
- package/src/math/userStatus.ts +5 -0
- package/src/math/utils.ts +120 -0
- package/src/memcmp.ts +94 -0
- package/src/openbook/openbookV2FulfillmentConfigMap.ts +29 -0
- package/src/openbook/openbookV2Subscriber.ts +165 -0
- package/src/oracles/oracleClientCache.ts +25 -0
- package/src/oracles/oracleId.ts +28 -0
- package/src/oracles/prelaunchOracleClient.ts +37 -0
- package/src/oracles/pythClient.ts +85 -0
- package/src/oracles/pythLazerClient.ts +102 -0
- package/src/oracles/pythPullClient.ts +111 -0
- package/src/oracles/quoteAssetOracleClient.ts +25 -0
- package/src/oracles/strictOraclePrice.ts +19 -0
- package/src/oracles/switchboardClient.ts +77 -0
- package/src/oracles/switchboardOnDemandClient.ts +56 -0
- package/src/oracles/types.ts +23 -0
- package/src/orderParams.ts +79 -0
- package/src/orderSubscriber/OrderSubscriber.ts +249 -0
- package/src/orderSubscriber/PollingSubscription.ts +39 -0
- package/src/orderSubscriber/WebsocketSubscription.ts +119 -0
- package/src/orderSubscriber/grpcSubscription.ts +121 -0
- package/src/orderSubscriber/index.ts +2 -0
- package/src/orderSubscriber/types.ts +54 -0
- package/src/phoenix/phoenixFulfillmentConfigMap.ts +26 -0
- package/src/phoenix/phoenixSubscriber.ts +235 -0
- package/src/priorityFee/averageOverSlotsStrategy.ts +16 -0
- package/src/priorityFee/averageStrategy.ts +12 -0
- package/src/priorityFee/driftPriorityFeeMethod.ts +42 -0
- package/src/priorityFee/ewmaStrategy.ts +41 -0
- package/src/priorityFee/heliusPriorityFeeMethod.ts +57 -0
- package/src/priorityFee/index.ts +11 -0
- package/src/priorityFee/maxOverSlotsStrategy.ts +17 -0
- package/src/priorityFee/maxStrategy.ts +7 -0
- package/src/priorityFee/priorityFeeSubscriber.ts +251 -0
- package/src/priorityFee/priorityFeeSubscriberMap.ts +112 -0
- package/src/priorityFee/solanaPriorityFeeMethod.ts +34 -0
- package/src/priorityFee/types.ts +60 -0
- package/src/serum/serumFulfillmentConfigMap.ts +26 -0
- package/src/serum/serumSubscriber.ts +169 -0
- package/src/serum/types.ts +17 -0
- package/src/slot/SlotSubscriber.ts +101 -0
- package/src/slot/SlothashSubscriber.ts +126 -0
- package/src/testClient.ts +41 -0
- package/src/token/index.ts +13 -0
- package/src/tokenFaucet.ts +269 -0
- package/src/tx/baseTxSender.ts +477 -0
- package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +19 -0
- package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +90 -0
- package/src/tx/blockhashFetcher/types.ts +5 -0
- package/src/tx/fastSingleTxSender.ts +142 -0
- package/src/tx/forwardOnlyTxSender.ts +145 -0
- package/src/tx/priorityFeeCalculator.ts +117 -0
- package/src/tx/reportTransactionError.ts +159 -0
- package/src/tx/retryTxSender.ts +135 -0
- package/src/tx/txHandler.ts +737 -0
- package/src/tx/txParamProcessor.ts +155 -0
- package/src/tx/types.ts +71 -0
- package/src/tx/utils.ts +11 -0
- package/src/tx/whileValidTxSender.ts +265 -0
- package/src/types.ts +1386 -0
- package/src/user.ts +4054 -0
- package/src/userConfig.ts +32 -0
- package/src/userMap/PollingSubscription.ts +47 -0
- package/src/userMap/WebsocketSubscription.ts +84 -0
- package/src/userMap/grpcSubscription.ts +85 -0
- package/src/userMap/referrerMap.ts +267 -0
- package/src/userMap/userMap.ts +654 -0
- package/src/userMap/userMapConfig.ts +63 -0
- package/src/userMap/userStatsMap.ts +218 -0
- package/src/userName.ts +21 -0
- package/src/userStats.ts +174 -0
- package/src/userStatsConfig.ts +31 -0
- package/src/util/TransactionConfirmationManager.ts +292 -0
- package/src/util/chainClock.ts +41 -0
- package/src/util/computeUnits.ts +65 -0
- package/src/util/digest.ts +11 -0
- package/src/util/promiseTimeout.ts +14 -0
- package/src/util/pythOracleUtils.ts +136 -0
- package/src/util/tps.ts +27 -0
- package/src/wallet.ts +43 -0
- package/tests/amm/test.ts +2092 -0
- package/tests/auctions/test.ts +81 -0
- package/tests/bn/test.ts +341 -0
- package/tests/ci/idl.ts +101 -0
- package/tests/ci/verifyConstants.ts +278 -0
- package/tests/decode/phoenix.ts +71 -0
- package/tests/decode/test.ts +266 -0
- package/tests/decode/userAccountBufferStrings.ts +102 -0
- package/tests/dlob/helpers.ts +749 -0
- package/tests/dlob/test.ts +6623 -0
- package/tests/insurance/test.ts +40 -0
- package/tests/spot/test.ts +226 -0
- package/tests/subscriber/openbook.ts +62 -0
- package/tests/tx/TransactionConfirmationManager.test.ts +305 -0
- package/tests/tx/cachedBlockhashFetcher.test.ts +96 -0
- package/tests/tx/priorityFeeCalculator.ts +77 -0
- package/tests/tx/priorityFeeStrategy.ts +95 -0
- package/tests/user/helpers.ts +92 -0
- package/tests/user/test.ts +517 -0
- package/tsconfig.browser.json +13 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,861 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="bn.js" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
import * as anchor from '@coral-xyz/anchor';
|
|
6
|
+
import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
|
|
7
|
+
import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30';
|
|
8
|
+
import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, RFQMakerOrderParams, RFQMatch, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SwiftOrderParamsMessage, SwiftServerMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount } from './types';
|
|
9
|
+
import { AccountMeta, AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
|
|
10
|
+
import { TokenFaucet } from './tokenFaucet';
|
|
11
|
+
import { EventEmitter } from 'events';
|
|
12
|
+
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
13
|
+
import { DataAndSlot, DriftClientAccountEvents, DriftClientAccountSubscriber } from './accounts/types';
|
|
14
|
+
import { TxSender, TxSigAndSlot } from './tx/types';
|
|
15
|
+
import { OraclePriceData } from './oracles/types';
|
|
16
|
+
import { DriftClientConfig } from './driftClientConfig';
|
|
17
|
+
import { User } from './user';
|
|
18
|
+
import { UserSubscriptionConfig } from './userConfig';
|
|
19
|
+
import { DriftEnv } from './config';
|
|
20
|
+
import { UserStats } from './userStats';
|
|
21
|
+
import { JupiterClient, QuoteResponse, Route, SwapMode } from './jupiter/jupiterClient';
|
|
22
|
+
import { UserStatsSubscriptionConfig } from './userStatsConfig';
|
|
23
|
+
import { TxHandler } from './tx/txHandler';
|
|
24
|
+
import { WormholeCoreBridgeSolana } from '@pythnetwork/pyth-solana-receiver/lib/idl/wormhole_core_bridge_solana';
|
|
25
|
+
import { PythSolanaReceiver } from '@pythnetwork/pyth-solana-receiver/lib/idl/pyth_solana_receiver';
|
|
26
|
+
import { Slothash } from './slot/SlothashSubscriber';
|
|
27
|
+
type RemainingAccountParams = {
|
|
28
|
+
userAccounts: UserAccount[];
|
|
29
|
+
writablePerpMarketIndexes?: number[];
|
|
30
|
+
writableSpotMarketIndexes?: number[];
|
|
31
|
+
readablePerpMarketIndex?: number | number[];
|
|
32
|
+
readableSpotMarketIndexes?: number[];
|
|
33
|
+
useMarketLastSlotCache?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* # DriftClient
|
|
37
|
+
* 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.
|
|
38
|
+
*/
|
|
39
|
+
export declare class DriftClient {
|
|
40
|
+
connection: Connection;
|
|
41
|
+
wallet: IWallet;
|
|
42
|
+
program: Program;
|
|
43
|
+
swiftID: PublicKey;
|
|
44
|
+
provider: AnchorProvider;
|
|
45
|
+
opts?: ConfirmOptions;
|
|
46
|
+
users: Map<string, User>;
|
|
47
|
+
userStats?: UserStats;
|
|
48
|
+
activeSubAccountId: number;
|
|
49
|
+
userAccountSubscriptionConfig: UserSubscriptionConfig;
|
|
50
|
+
userStatsAccountSubscriptionConfig: UserStatsSubscriptionConfig;
|
|
51
|
+
accountSubscriber: DriftClientAccountSubscriber;
|
|
52
|
+
eventEmitter: StrictEventEmitter<EventEmitter, DriftClientAccountEvents>;
|
|
53
|
+
metricsEventEmitter: StrictEventEmitter<EventEmitter, DriftClientMetricsEvents>;
|
|
54
|
+
_isSubscribed: boolean;
|
|
55
|
+
txSender: TxSender;
|
|
56
|
+
perpMarketLastSlotCache: Map<number, number>;
|
|
57
|
+
spotMarketLastSlotCache: Map<number, number>;
|
|
58
|
+
mustIncludePerpMarketIndexes: Set<number>;
|
|
59
|
+
mustIncludeSpotMarketIndexes: Set<number>;
|
|
60
|
+
authority: PublicKey;
|
|
61
|
+
marketLookupTable: PublicKey;
|
|
62
|
+
lookupTableAccount: AddressLookupTableAccount;
|
|
63
|
+
includeDelegates?: boolean;
|
|
64
|
+
authoritySubAccountMap?: Map<string, number[]>;
|
|
65
|
+
skipLoadUsers?: boolean;
|
|
66
|
+
txVersion: TransactionVersion;
|
|
67
|
+
txParams: TxParams;
|
|
68
|
+
enableMetricsEvents?: boolean;
|
|
69
|
+
txHandler: TxHandler;
|
|
70
|
+
receiverProgram?: Program<PythSolanaReceiver>;
|
|
71
|
+
wormholeProgram?: Program<WormholeCoreBridgeSolana>;
|
|
72
|
+
sbOnDemandProgramdId: PublicKey;
|
|
73
|
+
sbOnDemandProgram?: Program30<Idl30>;
|
|
74
|
+
sbProgramFeedConfigs?: Map<string, any>;
|
|
75
|
+
get isSubscribed(): boolean;
|
|
76
|
+
set isSubscribed(val: boolean);
|
|
77
|
+
constructor(config: DriftClientConfig);
|
|
78
|
+
getUserMapKey(subAccountId: number, authority: PublicKey): string;
|
|
79
|
+
createUser(subAccountId: number, accountSubscriptionConfig: UserSubscriptionConfig, authority?: PublicKey): User;
|
|
80
|
+
subscribe(): Promise<boolean>;
|
|
81
|
+
subscribeUsers(): Promise<boolean>[];
|
|
82
|
+
/**
|
|
83
|
+
* Forces the accountSubscriber to fetch account updates from rpc
|
|
84
|
+
*/
|
|
85
|
+
fetchAccounts(): Promise<void>;
|
|
86
|
+
unsubscribe(): Promise<void>;
|
|
87
|
+
unsubscribeUsers(): Promise<void>[];
|
|
88
|
+
statePublicKey?: PublicKey;
|
|
89
|
+
getStatePublicKey(): Promise<PublicKey>;
|
|
90
|
+
signerPublicKey?: PublicKey;
|
|
91
|
+
getSignerPublicKey(): PublicKey;
|
|
92
|
+
getStateAccount(): StateAccount;
|
|
93
|
+
/**
|
|
94
|
+
* Forces a fetch to rpc before returning accounts. Useful for anchor tests.
|
|
95
|
+
*/
|
|
96
|
+
forceGetStateAccount(): Promise<StateAccount>;
|
|
97
|
+
getPerpMarketAccount(marketIndex: number): PerpMarketAccount | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Forces a fetch to rpc before returning accounts. Useful for anchor tests.
|
|
100
|
+
* @param marketIndex
|
|
101
|
+
*/
|
|
102
|
+
forceGetPerpMarketAccount(marketIndex: number): Promise<PerpMarketAccount | undefined>;
|
|
103
|
+
getPerpMarketAccounts(): PerpMarketAccount[];
|
|
104
|
+
getSpotMarketAccount(marketIndex: number): SpotMarketAccount | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Forces a fetch to rpc before returning accounts. Useful for anchor tests.
|
|
107
|
+
* @param marketIndex
|
|
108
|
+
*/
|
|
109
|
+
forceGetSpotMarketAccount(marketIndex: number): Promise<SpotMarketAccount | undefined>;
|
|
110
|
+
getSpotMarketAccounts(): SpotMarketAccount[];
|
|
111
|
+
getQuoteSpotMarketAccount(): SpotMarketAccount;
|
|
112
|
+
getOraclePriceDataAndSlot(oraclePublicKey: PublicKey, oracleSource: OracleSource): DataAndSlot<OraclePriceData> | undefined;
|
|
113
|
+
getSerumV3FulfillmentConfig(serumMarket: PublicKey): Promise<SerumV3FulfillmentConfigAccount>;
|
|
114
|
+
getSerumV3FulfillmentConfigs(): Promise<SerumV3FulfillmentConfigAccount[]>;
|
|
115
|
+
getPhoenixV1FulfillmentConfig(phoenixMarket: PublicKey): Promise<PhoenixV1FulfillmentConfigAccount>;
|
|
116
|
+
getPhoenixV1FulfillmentConfigs(): Promise<PhoenixV1FulfillmentConfigAccount[]>;
|
|
117
|
+
getOpenbookV2FulfillmentConfig(openbookMarket: PublicKey): Promise<OpenbookV2FulfillmentConfigAccount>;
|
|
118
|
+
getOpenbookV2FulfillmentConfigs(): Promise<OpenbookV2FulfillmentConfigAccount[]>;
|
|
119
|
+
fetchMarketLookupTableAccount(): Promise<AddressLookupTableAccount>;
|
|
120
|
+
/**
|
|
121
|
+
* Update the wallet to use for drift transactions and linked user account
|
|
122
|
+
* @param newWallet
|
|
123
|
+
* @param subAccountIds
|
|
124
|
+
* @param activeSubAccountId
|
|
125
|
+
* @param includeDelegates
|
|
126
|
+
*/
|
|
127
|
+
updateWallet(newWallet: IWallet, subAccountIds?: number[], activeSubAccountId?: number, includeDelegates?: boolean, authoritySubaccountMap?: Map<string, number[]>): Promise<boolean>;
|
|
128
|
+
/**
|
|
129
|
+
* Update the subscribed accounts to a given authority, while leaving the
|
|
130
|
+
* connected wallet intact. This allows a user to emulate another user's
|
|
131
|
+
* account on the UI and sign permissionless transactions with their own wallet.
|
|
132
|
+
* @param emulateAuthority
|
|
133
|
+
*/
|
|
134
|
+
emulateAccount(emulateAuthority: PublicKey): Promise<boolean>;
|
|
135
|
+
switchActiveUser(subAccountId: number, authority?: PublicKey): Promise<void>;
|
|
136
|
+
addUser(subAccountId: number, authority?: PublicKey, userAccount?: UserAccount): Promise<boolean>;
|
|
137
|
+
/**
|
|
138
|
+
* Adds and subscribes to users based on params set by the constructor or by updateWallet.
|
|
139
|
+
*/
|
|
140
|
+
addAndSubscribeToUsers(authority?: PublicKey): Promise<boolean>;
|
|
141
|
+
initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
142
|
+
getInitializeUserStatsIx(): Promise<TransactionInstruction>;
|
|
143
|
+
initializeRFQUser(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
144
|
+
getInitializeRFQUserInstruction(userAccountPublicKey: PublicKey): Promise<[PublicKey, TransactionInstruction]>;
|
|
145
|
+
initializeSwiftUserOrders(userAccountPublicKey: PublicKey, numOrders: number, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
146
|
+
getInitializeSwiftUserOrdersAccountIx(userAccountPublicKey: PublicKey, numOrders: number): Promise<[PublicKey, TransactionInstruction]>;
|
|
147
|
+
resizeSwiftUserOrders(userAccountPublicKey: PublicKey, numOrders: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
148
|
+
getResizeSwiftUserOrdersInstruction(userAccountPublicKey: PublicKey, numOrders: number): Promise<TransactionInstruction>;
|
|
149
|
+
getInitializeUserInstructions(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>;
|
|
150
|
+
getNextSubAccountId(): Promise<number>;
|
|
151
|
+
initializeReferrerName(name: string): Promise<TransactionSignature>;
|
|
152
|
+
updateUserName(name: string, subAccountId?: number): Promise<TransactionSignature>;
|
|
153
|
+
updateUserCustomMarginRatio(updates: {
|
|
154
|
+
marginRatio: number;
|
|
155
|
+
subAccountId: number;
|
|
156
|
+
}[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
157
|
+
getUpdateUserCustomMarginRatioIx(marginRatio: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
158
|
+
getUpdateUserMarginTradingEnabledIx(marginTradingEnabled: boolean, subAccountId?: number, userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
159
|
+
updateUserMarginTradingEnabled(updates: {
|
|
160
|
+
marginTradingEnabled: boolean;
|
|
161
|
+
subAccountId: number;
|
|
162
|
+
}[]): Promise<TransactionSignature>;
|
|
163
|
+
updateUserDelegate(delegate: PublicKey, subAccountId?: number): Promise<TransactionSignature>;
|
|
164
|
+
updateUserAdvancedLp(updates: {
|
|
165
|
+
advancedLp: boolean;
|
|
166
|
+
subAccountId: number;
|
|
167
|
+
}[]): Promise<TransactionSignature>;
|
|
168
|
+
getUpdateAdvancedDlpIx(advancedLp: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
|
|
169
|
+
updateUserReduceOnly(updates: {
|
|
170
|
+
reduceOnly: boolean;
|
|
171
|
+
subAccountId: number;
|
|
172
|
+
}[]): Promise<TransactionSignature>;
|
|
173
|
+
getUpdateUserReduceOnlyIx(reduceOnly: boolean, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
|
|
174
|
+
updateUserPoolId(updates: {
|
|
175
|
+
poolId: number;
|
|
176
|
+
subAccountId: number;
|
|
177
|
+
}[]): Promise<TransactionSignature>;
|
|
178
|
+
getUpdateUserPoolIdIx(poolId: number, subAccountId: number): Promise<anchor.web3.TransactionInstruction>;
|
|
179
|
+
fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>;
|
|
180
|
+
getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
|
|
181
|
+
getUserAccountsAndAddressesForAuthority(authority: PublicKey): Promise<ProgramAccount<UserAccount>[]>;
|
|
182
|
+
getUserAccountsForAuthority(authority: PublicKey): Promise<UserAccount[]>;
|
|
183
|
+
getReferredUserStatsAccountsByReferrer(referrer: PublicKey): Promise<UserStatsAccount[]>;
|
|
184
|
+
getReferrerNameAccountsForAuthority(authority: PublicKey): Promise<ReferrerNameAccount[]>;
|
|
185
|
+
deleteUser(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
186
|
+
getUserDeletionIx(userAccountPublicKey: PublicKey): Promise<anchor.web3.TransactionInstruction>;
|
|
187
|
+
forceDeleteUser(userAccountPublicKey: PublicKey, userAccount: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
188
|
+
getForceDeleteUserIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<anchor.web3.TransactionInstruction>;
|
|
189
|
+
deleteSwiftUserOrders(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
190
|
+
getSwiftUserOrdersDeletionIx(userAccountPublicKey: PublicKey): Promise<anchor.web3.TransactionInstruction>;
|
|
191
|
+
reclaimRent(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
192
|
+
getReclaimRentIx(userAccountPublicKey: PublicKey): Promise<anchor.web3.TransactionInstruction>;
|
|
193
|
+
getUser(subAccountId?: number, authority?: PublicKey): User;
|
|
194
|
+
hasUser(subAccountId?: number, authority?: PublicKey): boolean;
|
|
195
|
+
getUsers(): User[];
|
|
196
|
+
getUserStats(): UserStats;
|
|
197
|
+
fetchReferrerNameAccount(name: string): Promise<ReferrerNameAccount | undefined>;
|
|
198
|
+
userStatsAccountPublicKey: PublicKey;
|
|
199
|
+
getUserStatsAccountPublicKey(): PublicKey;
|
|
200
|
+
getUserAccountPublicKey(subAccountId?: number, authority?: PublicKey): Promise<PublicKey>;
|
|
201
|
+
getUserAccount(subAccountId?: number, authority?: PublicKey): UserAccount | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Forces a fetch to rpc before returning accounts. Useful for anchor tests.
|
|
204
|
+
* @param subAccountId
|
|
205
|
+
*/
|
|
206
|
+
forceGetUserAccount(subAccountId?: number): Promise<UserAccount | undefined>;
|
|
207
|
+
getUserAccountAndSlot(subAccountId?: number): DataAndSlot<UserAccount> | undefined;
|
|
208
|
+
getSpotPosition(marketIndex: number, subAccountId?: number): SpotPosition | undefined;
|
|
209
|
+
getQuoteAssetTokenAmount(): BN;
|
|
210
|
+
/**
|
|
211
|
+
* Returns the token amount for a given market. The spot market precision is based on the token mint decimals.
|
|
212
|
+
* Positive if it is a deposit, negative if it is a borrow.
|
|
213
|
+
* @param marketIndex
|
|
214
|
+
*/
|
|
215
|
+
getTokenAmount(marketIndex: number): BN;
|
|
216
|
+
/**
|
|
217
|
+
* Converts an amount to the spot precision for a given market. The spot market precision is based on the token mint decimals.
|
|
218
|
+
* @param marketIndex
|
|
219
|
+
* @param amount
|
|
220
|
+
*/
|
|
221
|
+
convertToSpotPrecision(marketIndex: number, amount: BN | number): BN;
|
|
222
|
+
/**
|
|
223
|
+
* Converts an amount to the perp precision. The perp market precision is {@link BASE_PRECISION} (1e9).
|
|
224
|
+
* @param amount
|
|
225
|
+
*/
|
|
226
|
+
convertToPerpPrecision(amount: BN | number): BN;
|
|
227
|
+
/**
|
|
228
|
+
* Converts an amount to the price precision. The perp market precision is {@link PRICE_PRECISION} (1e6).
|
|
229
|
+
* @param amount
|
|
230
|
+
*/
|
|
231
|
+
convertToPricePrecision(amount: BN | number): BN;
|
|
232
|
+
/**
|
|
233
|
+
* Each drift instruction must include perp and sport market accounts in the ix remaining accounts.
|
|
234
|
+
* Use this function to force a subset of markets to be included in the remaining accounts for every ix
|
|
235
|
+
*
|
|
236
|
+
* @param perpMarketIndexes
|
|
237
|
+
* @param spotMarketIndexes
|
|
238
|
+
*/
|
|
239
|
+
mustIncludeMarketsInIx({ perpMarketIndexes, spotMarketIndexes, }: {
|
|
240
|
+
perpMarketIndexes: number[];
|
|
241
|
+
spotMarketIndexes: number[];
|
|
242
|
+
}): void;
|
|
243
|
+
getRemainingAccounts(params: RemainingAccountParams): AccountMeta[];
|
|
244
|
+
addPerpMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>, perpMarketAccountMap: Map<number, AccountMeta>): void;
|
|
245
|
+
addSpotMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>): void;
|
|
246
|
+
getRemainingAccountMapsForUsers(userAccounts: UserAccount[]): {
|
|
247
|
+
oracleAccountMap: Map<string, AccountMeta>;
|
|
248
|
+
spotMarketAccountMap: Map<number, AccountMeta>;
|
|
249
|
+
perpMarketAccountMap: Map<number, AccountMeta>;
|
|
250
|
+
};
|
|
251
|
+
getOrder(orderId: number, subAccountId?: number): Order | undefined;
|
|
252
|
+
getOrderByUserId(userOrderId: number, subAccountId?: number): Order | undefined;
|
|
253
|
+
/**
|
|
254
|
+
* Get the associated token address for the given spot market
|
|
255
|
+
* @param marketIndex
|
|
256
|
+
* @param useNative
|
|
257
|
+
* @param tokenProgram
|
|
258
|
+
*/
|
|
259
|
+
getAssociatedTokenAccount(marketIndex: number, useNative?: boolean, tokenProgram?: anchor.web3.PublicKey): Promise<PublicKey>;
|
|
260
|
+
createAssociatedTokenAccountIdempotentInstruction(account: PublicKey, payer: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgram?: anchor.web3.PublicKey): TransactionInstruction;
|
|
261
|
+
getDepositTxnIx(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean): Promise<TransactionInstruction[]>;
|
|
262
|
+
createDepositTxn(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams): Promise<VersionedTransaction | Transaction>;
|
|
263
|
+
/**
|
|
264
|
+
* Deposit funds into the given spot market
|
|
265
|
+
*
|
|
266
|
+
* @param amount to deposit
|
|
267
|
+
* @param marketIndex spot market index to deposit into
|
|
268
|
+
* @param associatedTokenAccount can be the wallet public key if using native sol
|
|
269
|
+
* @param subAccountId subaccountId to deposit
|
|
270
|
+
* @param reduceOnly if true, deposit must not increase account risk
|
|
271
|
+
*/
|
|
272
|
+
deposit(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams): Promise<TransactionSignature>;
|
|
273
|
+
getDepositInstruction(amount: BN, marketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
|
|
274
|
+
private checkIfAccountExists;
|
|
275
|
+
getWrappedSolAccountCreationIxs(amount: BN, includeRent?: boolean): Promise<{
|
|
276
|
+
ixs: anchor.web3.TransactionInstruction[];
|
|
277
|
+
/** @deprecated - this array is always going to be empty, in the current implementation */
|
|
278
|
+
signers: Signer[];
|
|
279
|
+
pubkey: PublicKey;
|
|
280
|
+
}>;
|
|
281
|
+
getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
|
|
282
|
+
addTokenMintToRemainingAccounts(spotMarketAccount: SpotMarketAccount, remainingAccounts: AccountMeta[]): void;
|
|
283
|
+
getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey, tokenProgram: PublicKey): anchor.web3.TransactionInstruction;
|
|
284
|
+
createInitializeUserAccountAndDepositCollateralIxs(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, customMaxMarginRatio?: number): Promise<{
|
|
285
|
+
ixs: TransactionInstruction[];
|
|
286
|
+
userAccountPublicKey: PublicKey;
|
|
287
|
+
}>;
|
|
288
|
+
createInitializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number): Promise<[Transaction | VersionedTransaction, PublicKey]>;
|
|
289
|
+
/**
|
|
290
|
+
* Creates the User account for a user, and deposits some initial collateral
|
|
291
|
+
* @param amount
|
|
292
|
+
* @param userTokenAccount
|
|
293
|
+
* @param marketIndex
|
|
294
|
+
* @param subAccountId
|
|
295
|
+
* @param name
|
|
296
|
+
* @param fromSubAccountId
|
|
297
|
+
* @param referrerInfo
|
|
298
|
+
* @param donateAmount
|
|
299
|
+
* @param txParams
|
|
300
|
+
* @returns
|
|
301
|
+
*/
|
|
302
|
+
initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number): Promise<[TransactionSignature, PublicKey]>;
|
|
303
|
+
initializeUserAccountForDevnet(subAccountId: number, name: string, marketIndex: number, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
304
|
+
getWithdrawalIxs(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean, subAccountId?: number, updateFuel?: boolean): Promise<TransactionInstruction[]>;
|
|
305
|
+
/**
|
|
306
|
+
* Withdraws from a user account. If deposit doesn't already exist, creates a borrow
|
|
307
|
+
* @param amount
|
|
308
|
+
* @param marketIndex
|
|
309
|
+
* @param associatedTokenAddress - the token account to withdraw to. can be the wallet public key if using native sol
|
|
310
|
+
* @param reduceOnly
|
|
311
|
+
*/
|
|
312
|
+
withdraw(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean, subAccountId?: number, txParams?: TxParams, updateFuel?: boolean): Promise<TransactionSignature>;
|
|
313
|
+
withdrawAllDustPositions(subAccountId?: number, txParams?: TxParams, opts?: {
|
|
314
|
+
dustPositionCountCallback?: (count: number) => void;
|
|
315
|
+
}): Promise<TransactionSignature | undefined>;
|
|
316
|
+
getWithdrawIx(amount: BN, marketIndex: number, userTokenAccount: PublicKey, reduceOnly?: boolean, subAccountId?: number): Promise<TransactionInstruction>;
|
|
317
|
+
/**
|
|
318
|
+
* Withdraws from the fromSubAccount and deposits into the toSubAccount
|
|
319
|
+
* @param amount
|
|
320
|
+
* @param marketIndex
|
|
321
|
+
* @param fromSubAccountId
|
|
322
|
+
* @param toSubAccountId
|
|
323
|
+
* @param txParams
|
|
324
|
+
*/
|
|
325
|
+
transferDeposit(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
326
|
+
getTransferDepositIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
|
|
327
|
+
updateSpotMarketCumulativeInterest(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
328
|
+
updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
329
|
+
settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
330
|
+
settleLPIx(settleeUserAccountPublicKey: PublicKey, marketIndex: number): Promise<TransactionInstruction>;
|
|
331
|
+
removePerpLpShares(marketIndex: number, sharesToBurn?: BN, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
332
|
+
removePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
333
|
+
getRemovePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN): Promise<TransactionInstruction>;
|
|
334
|
+
getRemovePerpLpSharesIx(marketIndex: number, sharesToBurn?: BN, subAccountId?: number): Promise<TransactionInstruction>;
|
|
335
|
+
addPerpLpShares(amount: BN, marketIndex: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
336
|
+
getAddPerpLpSharesIx(amount: BN, marketIndex: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
337
|
+
getQuoteValuePerLpShare(marketIndex: number): BN;
|
|
338
|
+
/**
|
|
339
|
+
* @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead
|
|
340
|
+
*/
|
|
341
|
+
openPosition(direction: PositionDirection, amount: BN, marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>;
|
|
342
|
+
sendSignedTx(tx: Transaction | VersionedTransaction, opts?: ConfirmOptions): Promise<TransactionSignature>;
|
|
343
|
+
prepareMarketOrderTxs(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], referrerInfo?: ReferrerInfo, cancelExistingOrders?: boolean, settlePnl?: boolean): Promise<{
|
|
344
|
+
cancelExistingOrdersTx?: Transaction | VersionedTransaction;
|
|
345
|
+
settlePnlTx?: Transaction | VersionedTransaction;
|
|
346
|
+
fillTx?: Transaction | VersionedTransaction;
|
|
347
|
+
marketOrderTx: Transaction | VersionedTransaction;
|
|
348
|
+
}>;
|
|
349
|
+
/**
|
|
350
|
+
* 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.
|
|
351
|
+
* @param orderParams
|
|
352
|
+
* @param userAccountPublicKey
|
|
353
|
+
* @param userAccount
|
|
354
|
+
* @param makerInfo
|
|
355
|
+
* @param txParams
|
|
356
|
+
* @param bracketOrdersParams
|
|
357
|
+
* @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
|
|
358
|
+
* @returns
|
|
359
|
+
*/
|
|
360
|
+
sendMarketOrderAndGetSignedFillTx(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], referrerInfo?: ReferrerInfo, cancelExistingOrders?: boolean, settlePnl?: boolean): Promise<{
|
|
361
|
+
txSig: TransactionSignature;
|
|
362
|
+
signedFillTx?: Transaction;
|
|
363
|
+
signedCancelExistingOrdersTx?: Transaction;
|
|
364
|
+
signedSettlePnlTx?: Transaction;
|
|
365
|
+
}>;
|
|
366
|
+
placePerpOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
367
|
+
getPlacePerpOrderIx(orderParams: OptionalOrderParams, subAccountId?: number, depositToTradeArgs?: {
|
|
368
|
+
isMakingNewAccount: boolean;
|
|
369
|
+
depositMarketIndex: number;
|
|
370
|
+
}): Promise<TransactionInstruction>;
|
|
371
|
+
updateAMMs(marketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
372
|
+
getUpdateAMMsIx(marketIndexes: number[]): Promise<TransactionInstruction>;
|
|
373
|
+
settleExpiredMarket(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
374
|
+
getSettleExpiredMarketIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
375
|
+
settleExpiredMarketPoolsToRevenuePool(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
376
|
+
getSettleExpiredMarketPoolsToRevenuePoolIx(perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
377
|
+
cancelOrder(orderId?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
378
|
+
getCancelOrderIx(orderId?: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
379
|
+
cancelOrderByUserId(userOrderId: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
380
|
+
getCancelOrderByUserIdIx(userOrderId: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
381
|
+
cancelOrdersByIds(orderIds?: number[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
382
|
+
getCancelOrdersByIdsIx(orderIds?: number[], subAccountId?: number): Promise<TransactionInstruction>;
|
|
383
|
+
cancelOrders(marketType?: MarketType, marketIndex?: number, direction?: PositionDirection, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
384
|
+
getCancelOrdersIx(marketType: MarketType | null, marketIndex: number | null, direction: PositionDirection | null, subAccountId?: number): Promise<TransactionInstruction>;
|
|
385
|
+
cancelAndPlaceOrders(cancelOrderParams: {
|
|
386
|
+
marketType?: MarketType;
|
|
387
|
+
marketIndex?: number;
|
|
388
|
+
direction?: PositionDirection;
|
|
389
|
+
}, placeOrderParams: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
390
|
+
placeOrders(params: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
391
|
+
preparePlaceOrdersTx(params: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<{
|
|
392
|
+
placeOrdersTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
|
|
393
|
+
}>;
|
|
394
|
+
getPlaceOrdersIx(params: OptionalOrderParams[], subAccountId?: number): Promise<TransactionInstruction>;
|
|
395
|
+
fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams, fillerPublicKey?: number): Promise<TransactionSignature>;
|
|
396
|
+
getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerSubAccountId?: number, isSwift?: boolean): Promise<TransactionInstruction>;
|
|
397
|
+
getRevertFillIx(fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
398
|
+
placeSpotOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
399
|
+
preparePlaceSpotOrderTx(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<{
|
|
400
|
+
placeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
|
|
401
|
+
}>;
|
|
402
|
+
getPlaceSpotOrderIx(orderParams: OptionalOrderParams, subAccountId?: number): Promise<TransactionInstruction>;
|
|
403
|
+
fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
|
|
404
|
+
getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
405
|
+
addSpotFulfillmentAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount): void;
|
|
406
|
+
addSerumRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: SerumV3FulfillmentConfigAccount): void;
|
|
407
|
+
addPhoenixRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: PhoenixV1FulfillmentConfigAccount): void;
|
|
408
|
+
addOpenbookRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: OpenbookV2FulfillmentConfigAccount): void;
|
|
409
|
+
/**
|
|
410
|
+
* Swap tokens in drift account using jupiter
|
|
411
|
+
* @param jupiterClient jupiter client to find routes and jupiter instructions
|
|
412
|
+
* @param outMarketIndex the market index of the token you're buying
|
|
413
|
+
* @param inMarketIndex the market index of the token you're selling
|
|
414
|
+
* @param outAssociatedTokenAccount the token account to receive the token being sold on jupiter
|
|
415
|
+
* @param inAssociatedTokenAccount the token account to
|
|
416
|
+
* @param amount the amount of TokenIn, regardless of swapMode
|
|
417
|
+
* @param slippageBps the max slippage passed to jupiter api
|
|
418
|
+
* @param swapMode jupiter swapMode (ExactIn or ExactOut), default is ExactIn
|
|
419
|
+
* @param route the jupiter route to use for the swap
|
|
420
|
+
* @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
|
|
421
|
+
* @param txParams
|
|
422
|
+
*/
|
|
423
|
+
swap({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, txParams, v6, onlyDirectRoutes, }: {
|
|
424
|
+
jupiterClient: JupiterClient;
|
|
425
|
+
outMarketIndex: number;
|
|
426
|
+
inMarketIndex: number;
|
|
427
|
+
outAssociatedTokenAccount?: PublicKey;
|
|
428
|
+
inAssociatedTokenAccount?: PublicKey;
|
|
429
|
+
amount: BN;
|
|
430
|
+
slippageBps?: number;
|
|
431
|
+
swapMode?: SwapMode;
|
|
432
|
+
route?: Route;
|
|
433
|
+
reduceOnly?: SwapReduceOnly;
|
|
434
|
+
txParams?: TxParams;
|
|
435
|
+
onlyDirectRoutes?: boolean;
|
|
436
|
+
v6?: {
|
|
437
|
+
quote?: QuoteResponse;
|
|
438
|
+
};
|
|
439
|
+
}): Promise<TransactionSignature>;
|
|
440
|
+
getJupiterSwapIx({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, route, reduceOnly, userAccountPublicKey, }: {
|
|
441
|
+
jupiterClient: JupiterClient;
|
|
442
|
+
outMarketIndex: number;
|
|
443
|
+
inMarketIndex: number;
|
|
444
|
+
outAssociatedTokenAccount?: PublicKey;
|
|
445
|
+
inAssociatedTokenAccount?: PublicKey;
|
|
446
|
+
amount: BN;
|
|
447
|
+
slippageBps?: number;
|
|
448
|
+
swapMode?: SwapMode;
|
|
449
|
+
onlyDirectRoutes?: boolean;
|
|
450
|
+
route?: Route;
|
|
451
|
+
reduceOnly?: SwapReduceOnly;
|
|
452
|
+
userAccountPublicKey?: PublicKey;
|
|
453
|
+
}): Promise<{
|
|
454
|
+
ixs: TransactionInstruction[];
|
|
455
|
+
lookupTables: AddressLookupTableAccount[];
|
|
456
|
+
}>;
|
|
457
|
+
getJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, quote, reduceOnly, userAccountPublicKey, }: {
|
|
458
|
+
jupiterClient: JupiterClient;
|
|
459
|
+
outMarketIndex: number;
|
|
460
|
+
inMarketIndex: number;
|
|
461
|
+
outAssociatedTokenAccount?: PublicKey;
|
|
462
|
+
inAssociatedTokenAccount?: PublicKey;
|
|
463
|
+
amount: BN;
|
|
464
|
+
slippageBps?: number;
|
|
465
|
+
swapMode?: SwapMode;
|
|
466
|
+
onlyDirectRoutes?: boolean;
|
|
467
|
+
quote?: QuoteResponse;
|
|
468
|
+
reduceOnly?: SwapReduceOnly;
|
|
469
|
+
userAccountPublicKey?: PublicKey;
|
|
470
|
+
}): Promise<{
|
|
471
|
+
ixs: TransactionInstruction[];
|
|
472
|
+
lookupTables: AddressLookupTableAccount[];
|
|
473
|
+
}>;
|
|
474
|
+
/**
|
|
475
|
+
* Get the drift begin_swap and end_swap instructions
|
|
476
|
+
*
|
|
477
|
+
* @param outMarketIndex the market index of the token you're buying
|
|
478
|
+
* @param inMarketIndex the market index of the token you're selling
|
|
479
|
+
* @param amountIn the amount of the token to sell
|
|
480
|
+
* @param inTokenAccount the token account to move the tokens being sold
|
|
481
|
+
* @param outTokenAccount the token account to receive the tokens being bought
|
|
482
|
+
* @param limitPrice the limit price of the swap
|
|
483
|
+
* @param reduceOnly
|
|
484
|
+
* @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
|
|
485
|
+
*/
|
|
486
|
+
getSwapIx({ outMarketIndex, inMarketIndex, amountIn, inTokenAccount, outTokenAccount, limitPrice, reduceOnly, userAccountPublicKey, }: {
|
|
487
|
+
outMarketIndex: number;
|
|
488
|
+
inMarketIndex: number;
|
|
489
|
+
amountIn: BN;
|
|
490
|
+
inTokenAccount: PublicKey;
|
|
491
|
+
outTokenAccount: PublicKey;
|
|
492
|
+
limitPrice?: BN;
|
|
493
|
+
reduceOnly?: SwapReduceOnly;
|
|
494
|
+
userAccountPublicKey?: PublicKey;
|
|
495
|
+
}): Promise<{
|
|
496
|
+
beginSwapIx: TransactionInstruction;
|
|
497
|
+
endSwapIx: TransactionInstruction;
|
|
498
|
+
}>;
|
|
499
|
+
stakeForMSOL({ amount }: {
|
|
500
|
+
amount: BN;
|
|
501
|
+
}): Promise<TxSigAndSlot>;
|
|
502
|
+
getStakeForMSOLIx({ amount, userAccountPublicKey, }: {
|
|
503
|
+
amount: BN;
|
|
504
|
+
userAccountPublicKey?: PublicKey;
|
|
505
|
+
}): Promise<TransactionInstruction[]>;
|
|
506
|
+
triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
507
|
+
getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
508
|
+
forceCancelOrders(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
509
|
+
getForceCancelOrdersIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
510
|
+
updateUserIdle(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
511
|
+
getUpdateUserIdleIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
512
|
+
logUserBalances(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
513
|
+
getLogUserBalancesIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
514
|
+
updateUserFuelBonus(userAccountPublicKey: PublicKey, user: UserAccount, userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
515
|
+
getUpdateUserFuelBonusIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, userAuthority: PublicKey): Promise<TransactionInstruction>;
|
|
516
|
+
updateUserStatsReferrerStatus(userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
517
|
+
getUpdateUserStatsReferrerStatusIx(userAuthority: PublicKey): Promise<TransactionInstruction>;
|
|
518
|
+
updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
519
|
+
getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
520
|
+
placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
521
|
+
preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean, auctionDurationPercentage?: number): Promise<{
|
|
522
|
+
placeAndTakeTx: Transaction | VersionedTransaction;
|
|
523
|
+
cancelExistingOrdersTx: Transaction | VersionedTransaction;
|
|
524
|
+
settlePnlTx: Transaction | VersionedTransaction;
|
|
525
|
+
}>;
|
|
526
|
+
placeAndTakePerpWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean): Promise<{
|
|
527
|
+
txSig: TransactionSignature;
|
|
528
|
+
signedCancelExistingOrdersTx?: Transaction;
|
|
529
|
+
signedSettlePnlTx?: Transaction;
|
|
530
|
+
}>;
|
|
531
|
+
getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
532
|
+
placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
533
|
+
getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
|
|
534
|
+
encodeSwiftServerMessage(message: SwiftServerMessage): Buffer;
|
|
535
|
+
decodeSwiftServerMessage(encodedMessage: Buffer): SwiftServerMessage;
|
|
536
|
+
signSwiftServerMessage(message: SwiftServerMessage): Buffer;
|
|
537
|
+
signSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Buffer;
|
|
538
|
+
encodeSwiftOrderParamsMessage(orderParamsMessage: SwiftOrderParamsMessage): Buffer;
|
|
539
|
+
decodeSwiftOrderParamsMessage(encodedMessage: Buffer): SwiftOrderParamsMessage;
|
|
540
|
+
signMessage(message: Uint8Array, keypair?: Keypair): Buffer;
|
|
541
|
+
placeSwiftTakerOrder(swiftServerMessage: Buffer, swiftSignature: Buffer, swiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, marketIndex: number, takerInfo: {
|
|
542
|
+
taker: PublicKey;
|
|
543
|
+
takerStats: PublicKey;
|
|
544
|
+
takerUserAccount: UserAccount;
|
|
545
|
+
}, txParams?: TxParams): Promise<TransactionSignature>;
|
|
546
|
+
getPlaceSwiftTakerPerpOrderIxs(encodedSwiftServerMessage: Buffer, swiftSignature: Buffer, encodedSwiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, marketIndex: number, takerInfo: {
|
|
547
|
+
taker: PublicKey;
|
|
548
|
+
takerStats: PublicKey;
|
|
549
|
+
takerUserAccount: UserAccount;
|
|
550
|
+
}, authority?: PublicKey): Promise<TransactionInstruction[]>;
|
|
551
|
+
placeAndMakeSwiftPerpOrder(encodedSwiftMessage: Buffer, swiftSignature: Buffer, encodedSwiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, swiftOrderUuid: Uint8Array, takerInfo: {
|
|
552
|
+
taker: PublicKey;
|
|
553
|
+
takerStats: PublicKey;
|
|
554
|
+
takerUserAccount: UserAccount;
|
|
555
|
+
}, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
556
|
+
getPlaceAndMakeSwiftPerpOrderIxs(encodedSwiftMessage: Buffer, swiftSignature: Buffer, encodedSwiftOrderParamsMessage: Buffer, swiftOrderParamsSignature: Buffer, swiftOrderUuid: Uint8Array, takerInfo: {
|
|
557
|
+
taker: PublicKey;
|
|
558
|
+
takerStats: PublicKey;
|
|
559
|
+
takerUserAccount: UserAccount;
|
|
560
|
+
}, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction[]>;
|
|
561
|
+
encodeRFQMakerOrderParams(message: RFQMakerOrderParams): Buffer;
|
|
562
|
+
placeAndMatchRFQOrders(rfqMatches: RFQMatch[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
563
|
+
getPlaceAndMatchRFQOrdersIxs(rfqMatches: RFQMatch[]): Promise<TransactionInstruction[]>;
|
|
564
|
+
preparePlaceAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<{
|
|
565
|
+
placeAndTakeSpotOrderTx: anchor.web3.Transaction | anchor.web3.VersionedTransaction;
|
|
566
|
+
}>;
|
|
567
|
+
placeAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
568
|
+
getPlaceAndTakeSpotOrderIx(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
|
|
569
|
+
placeAndMakeSpotOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
570
|
+
getPlaceAndMakeSpotOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
|
|
571
|
+
/**
|
|
572
|
+
* @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead
|
|
573
|
+
*/
|
|
574
|
+
closePosition(marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>;
|
|
575
|
+
/**
|
|
576
|
+
* Modifies an open order by closing it and replacing it with a new order.
|
|
577
|
+
* @deprecated use modifyOrder instead
|
|
578
|
+
* @param orderId: The open order to modify
|
|
579
|
+
* @param newBaseAmount: The new base amount for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
580
|
+
* @param newLimitPice: The new limit price for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
581
|
+
* @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
582
|
+
* @returns
|
|
583
|
+
*/
|
|
584
|
+
modifyPerpOrder(orderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: number): Promise<TransactionSignature>;
|
|
585
|
+
/**
|
|
586
|
+
* Modifies an open order by closing it and replacing it with a new order.
|
|
587
|
+
* @deprecated use modifyOrderByUserOrderId instead
|
|
588
|
+
* @param userOrderId: The open order to modify
|
|
589
|
+
* @param newBaseAmount: The new base amount for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
590
|
+
* @param newLimitPice: The new limit price for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
591
|
+
* @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
592
|
+
* @returns
|
|
593
|
+
*/
|
|
594
|
+
modifyPerpOrderByUserOrderId(userOrderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: number): Promise<TransactionSignature>;
|
|
595
|
+
/**
|
|
596
|
+
* Modifies an open order (spot or perp) by closing it and replacing it with a new order.
|
|
597
|
+
* @param orderParams.orderId: The open order to modify
|
|
598
|
+
* @param orderParams.newDirection: The new direction for the order
|
|
599
|
+
* @param orderParams.newBaseAmount: The new base amount for the order
|
|
600
|
+
* @param orderParams.newLimitPice: The new limit price for the order
|
|
601
|
+
* @param orderParams.newOraclePriceOffset: The new oracle price offset for the order
|
|
602
|
+
* @param orderParams.newTriggerPrice: Optional - Thew new trigger price for the order.
|
|
603
|
+
* @param orderParams.auctionDuration:
|
|
604
|
+
* @param orderParams.auctionStartPrice:
|
|
605
|
+
* @param orderParams.auctionEndPrice:
|
|
606
|
+
* @param orderParams.reduceOnly:
|
|
607
|
+
* @param orderParams.postOnly:
|
|
608
|
+
* @param orderParams.immediateOrCancel:
|
|
609
|
+
* @param orderParams.policy:
|
|
610
|
+
* @param orderParams.maxTs:
|
|
611
|
+
* @returns
|
|
612
|
+
*/
|
|
613
|
+
modifyOrder(orderParams: {
|
|
614
|
+
orderId: number;
|
|
615
|
+
newDirection?: PositionDirection;
|
|
616
|
+
newBaseAmount?: BN;
|
|
617
|
+
newLimitPrice?: BN;
|
|
618
|
+
newOraclePriceOffset?: number;
|
|
619
|
+
newTriggerPrice?: BN;
|
|
620
|
+
newTriggerCondition?: OrderTriggerCondition;
|
|
621
|
+
auctionDuration?: number;
|
|
622
|
+
auctionStartPrice?: BN;
|
|
623
|
+
auctionEndPrice?: BN;
|
|
624
|
+
reduceOnly?: boolean;
|
|
625
|
+
postOnly?: boolean;
|
|
626
|
+
immediateOrCancel?: boolean;
|
|
627
|
+
maxTs?: BN;
|
|
628
|
+
policy?: number;
|
|
629
|
+
}, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
630
|
+
getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, policy, }: {
|
|
631
|
+
orderId: number;
|
|
632
|
+
newDirection?: PositionDirection;
|
|
633
|
+
newBaseAmount?: BN;
|
|
634
|
+
newLimitPrice?: BN;
|
|
635
|
+
newOraclePriceOffset?: number;
|
|
636
|
+
newTriggerPrice?: BN;
|
|
637
|
+
newTriggerCondition?: OrderTriggerCondition;
|
|
638
|
+
auctionDuration?: number;
|
|
639
|
+
auctionStartPrice?: BN;
|
|
640
|
+
auctionEndPrice?: BN;
|
|
641
|
+
reduceOnly?: boolean;
|
|
642
|
+
postOnly?: boolean;
|
|
643
|
+
immediateOrCancel?: boolean;
|
|
644
|
+
maxTs?: BN;
|
|
645
|
+
policy?: number;
|
|
646
|
+
}, subAccountId?: number): Promise<TransactionInstruction>;
|
|
647
|
+
/**
|
|
648
|
+
* Modifies an open order by closing it and replacing it with a new order.
|
|
649
|
+
* @param orderParams.userOrderId: The open order to modify
|
|
650
|
+
* @param orderParams.newDirection: The new direction for the order
|
|
651
|
+
* @param orderParams.newBaseAmount: The new base amount for the order
|
|
652
|
+
* @param orderParams.newLimitPice: The new limit price for the order
|
|
653
|
+
* @param orderParams.newOraclePriceOffset: The new oracle price offset for the order
|
|
654
|
+
* @param orderParams.newTriggerPrice: Optional - Thew new trigger price for the order.
|
|
655
|
+
* @param orderParams.auctionDuration: Only required if order type changed to market from something else
|
|
656
|
+
* @param orderParams.auctionStartPrice: Only required if order type changed to market from something else
|
|
657
|
+
* @param orderParams.auctionEndPrice: Only required if order type changed to market from something else
|
|
658
|
+
* @param orderParams.reduceOnly:
|
|
659
|
+
* @param orderParams.postOnly:
|
|
660
|
+
* @param orderParams.immediateOrCancel:
|
|
661
|
+
* @param orderParams.policy:
|
|
662
|
+
* @param orderParams.maxTs:
|
|
663
|
+
* @returns
|
|
664
|
+
*/
|
|
665
|
+
modifyOrderByUserOrderId(orderParams: {
|
|
666
|
+
userOrderId: number;
|
|
667
|
+
newDirection?: PositionDirection;
|
|
668
|
+
newBaseAmount?: BN;
|
|
669
|
+
newLimitPrice?: BN;
|
|
670
|
+
newOraclePriceOffset?: number;
|
|
671
|
+
newTriggerPrice?: BN;
|
|
672
|
+
newTriggerCondition?: OrderTriggerCondition;
|
|
673
|
+
auctionDuration?: number;
|
|
674
|
+
auctionStartPrice?: BN;
|
|
675
|
+
auctionEndPrice?: BN;
|
|
676
|
+
reduceOnly?: boolean;
|
|
677
|
+
postOnly?: boolean;
|
|
678
|
+
immediateOrCancel?: boolean;
|
|
679
|
+
policy?: ModifyOrderPolicy;
|
|
680
|
+
maxTs?: BN;
|
|
681
|
+
}, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
682
|
+
getModifyOrderByUserIdIx({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, policy, }: {
|
|
683
|
+
userOrderId: number;
|
|
684
|
+
newDirection?: PositionDirection;
|
|
685
|
+
newBaseAmount?: BN;
|
|
686
|
+
newLimitPrice?: BN;
|
|
687
|
+
newOraclePriceOffset?: number;
|
|
688
|
+
newTriggerPrice?: BN;
|
|
689
|
+
newTriggerCondition?: OrderTriggerCondition;
|
|
690
|
+
auctionDuration?: number;
|
|
691
|
+
auctionStartPrice?: BN;
|
|
692
|
+
auctionEndPrice?: BN;
|
|
693
|
+
reduceOnly?: boolean;
|
|
694
|
+
postOnly?: boolean;
|
|
695
|
+
immediateOrCancel?: boolean;
|
|
696
|
+
policy?: ModifyOrderPolicy;
|
|
697
|
+
maxTs?: BN;
|
|
698
|
+
txParams?: TxParams;
|
|
699
|
+
}, subAccountId?: number): Promise<TransactionInstruction>;
|
|
700
|
+
settlePNLs(users: {
|
|
701
|
+
settleeUserAccountPublicKey: PublicKey;
|
|
702
|
+
settleeUserAccount: UserAccount;
|
|
703
|
+
}[], marketIndexes: number[], opts?: {
|
|
704
|
+
filterInvalidMarkets?: boolean;
|
|
705
|
+
}, txParams?: TxParams): Promise<TransactionSignature>;
|
|
706
|
+
getSettlePNLsIxs(users: {
|
|
707
|
+
settleeUserAccountPublicKey: PublicKey;
|
|
708
|
+
settleeUserAccount: UserAccount;
|
|
709
|
+
}[], marketIndexes: number[]): Promise<Array<TransactionInstruction>>;
|
|
710
|
+
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
711
|
+
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
712
|
+
settleMultiplePNLs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams): Promise<TransactionSignature>;
|
|
713
|
+
settleMultiplePNLsMultipleTxs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams): Promise<TransactionSignature[]>;
|
|
714
|
+
settleMultiplePNLsIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode): Promise<TransactionInstruction>;
|
|
715
|
+
getSetUserStatusToBeingLiquidatedIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
|
|
716
|
+
setUserStatusToBeingLiquidated(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionSignature>;
|
|
717
|
+
liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
718
|
+
getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
719
|
+
liquidatePerpWithFill(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, makerInfos: MakerInfo[], txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
720
|
+
getLiquidatePerpWithFillIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, makerInfos: MakerInfo[], liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
721
|
+
liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
722
|
+
getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
723
|
+
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
724
|
+
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
725
|
+
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
726
|
+
getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
727
|
+
resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
728
|
+
getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
729
|
+
resolveSpotBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
730
|
+
getResolveSpotBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
731
|
+
updateFundingRate(perpMarketIndex: number, oracle: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
732
|
+
getUpdateFundingRateIx(perpMarketIndex: number, oracle: PublicKey): Promise<TransactionInstruction>;
|
|
733
|
+
updatePrelaunchOracle(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
734
|
+
getUpdatePrelaunchOracleIx(perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
735
|
+
updatePerpBidAskTwap(perpMarketIndex: number, makers: [PublicKey, PublicKey][], txParams?: TxParams): Promise<TransactionSignature>;
|
|
736
|
+
getUpdatePerpBidAskTwapIx(perpMarketIndex: number, makers: [PublicKey, PublicKey][]): Promise<TransactionInstruction>;
|
|
737
|
+
settleFundingPayment(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
738
|
+
getSettleFundingPaymentIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
739
|
+
triggerEvent(eventName: keyof DriftClientAccountEvents, data?: any): void;
|
|
740
|
+
getOracleDataForPerpMarket(marketIndex: number): OraclePriceData;
|
|
741
|
+
getOracleDataForSpotMarket(marketIndex: number): OraclePriceData;
|
|
742
|
+
initializeInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
743
|
+
getInitializeInsuranceFundStakeIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
744
|
+
getAddInsuranceFundStakeIx(marketIndex: number, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
745
|
+
/**
|
|
746
|
+
* Add to an insurance fund stake and optionally initialize the account
|
|
747
|
+
*/
|
|
748
|
+
addInsuranceFundStake({ marketIndex, amount, collateralAccountPublicKey, initializeStakeAccount, fromSubaccount, txParams, }: {
|
|
749
|
+
/**
|
|
750
|
+
* Spot market index
|
|
751
|
+
*/
|
|
752
|
+
marketIndex: number;
|
|
753
|
+
amount: BN;
|
|
754
|
+
/**
|
|
755
|
+
* The account where the funds to stake come from. Usually an associated token account
|
|
756
|
+
*/
|
|
757
|
+
collateralAccountPublicKey: PublicKey;
|
|
758
|
+
/**
|
|
759
|
+
* Add instructions to initialize the staking account -- required if its the first time the currrent authority has staked in this market
|
|
760
|
+
*/
|
|
761
|
+
initializeStakeAccount?: boolean;
|
|
762
|
+
/**
|
|
763
|
+
* Optional -- withdraw from current subaccount to fund stake amount, instead of wallet balance
|
|
764
|
+
*/
|
|
765
|
+
fromSubaccount?: boolean;
|
|
766
|
+
txParams?: TxParams;
|
|
767
|
+
}): Promise<TransactionSignature>;
|
|
768
|
+
requestRemoveInsuranceFundStake(marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
769
|
+
cancelRequestRemoveInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
770
|
+
removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
771
|
+
updateUserQuoteAssetInsuranceStake(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
772
|
+
getUpdateUserQuoteAssetInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
|
|
773
|
+
updateUserGovTokenInsuranceStake(authority: PublicKey, txParams?: TxParams, env?: DriftEnv): Promise<TransactionSignature>;
|
|
774
|
+
getUpdateUserGovTokenInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
|
|
775
|
+
getUpdateUserGovTokenInsuranceStakeDevnetIx(authority: PublicKey, amount?: BN): Promise<TransactionInstruction>;
|
|
776
|
+
settleRevenueToInsuranceFund(spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
777
|
+
getSettleRevenueToInsuranceFundIx(spotMarketIndex: number): Promise<TransactionInstruction>;
|
|
778
|
+
resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
779
|
+
getResolvePerpPnlDeficitIx(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
780
|
+
getDepositIntoSpotMarketRevenuePoolIx(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
781
|
+
/**
|
|
782
|
+
* This ix will donate your funds to drift revenue pool. It does not deposit into your user account
|
|
783
|
+
* @param marketIndex
|
|
784
|
+
* @param amount
|
|
785
|
+
* @param userTokenAccountPublicKey
|
|
786
|
+
* @returns
|
|
787
|
+
*/
|
|
788
|
+
depositIntoSpotMarketRevenuePool(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
789
|
+
getPerpMarketExtendedInfo(marketIndex: number): PerpMarketExtendedInfo;
|
|
790
|
+
/**
|
|
791
|
+
* Calculates taker / maker fee (as a percentage, e.g. .001 = 10 basis points) for particular marketType
|
|
792
|
+
* @param marketType
|
|
793
|
+
* @param positionMarketIndex
|
|
794
|
+
* @returns : {takerFee: number, makerFee: number} Precision None
|
|
795
|
+
*/
|
|
796
|
+
getMarketFees(marketType: MarketType, marketIndex?: number, user?: User): {
|
|
797
|
+
takerFee: number;
|
|
798
|
+
makerFee: number;
|
|
799
|
+
};
|
|
800
|
+
/**
|
|
801
|
+
* Returns the market index and type for a given market name
|
|
802
|
+
* E.g. "SOL-PERP" -> { marketIndex: 0, marketType: MarketType.PERP }
|
|
803
|
+
*
|
|
804
|
+
* @param name
|
|
805
|
+
*/
|
|
806
|
+
getMarketIndexAndType(name: string): {
|
|
807
|
+
marketIndex: number;
|
|
808
|
+
marketType: MarketType;
|
|
809
|
+
} | undefined;
|
|
810
|
+
getReceiverProgram(): Program<PythSolanaReceiver>;
|
|
811
|
+
getSwitchboardOnDemandProgram(): Promise<Program30<Idl30>>;
|
|
812
|
+
postPythPullOracleUpdateAtomic(vaaString: string, feedId: string): Promise<TransactionSignature>;
|
|
813
|
+
postMultiPythPullOracleUpdatesAtomic(vaaString: string, feedIds: string[]): Promise<TransactionSignature>;
|
|
814
|
+
getPostPythPullOracleUpdateAtomicIxs(vaaString: string, feedIds: string | string[], numSignatures?: number): Promise<TransactionInstruction[]>;
|
|
815
|
+
private getSinglePostPythPullOracleAtomicIx;
|
|
816
|
+
updatePythPullOracle(vaaString: string, feedId: string): Promise<TransactionSignature>;
|
|
817
|
+
getUpdatePythPullOracleIxs(params: {
|
|
818
|
+
merklePriceUpdate: {
|
|
819
|
+
message: Buffer;
|
|
820
|
+
proof: number[][];
|
|
821
|
+
};
|
|
822
|
+
}, feedId: string, encodedVaaAddress: PublicKey): Promise<TransactionInstruction>;
|
|
823
|
+
postPythLazerOracleUpdate(feedIds: number[], pythMessageHex: string): Promise<string>;
|
|
824
|
+
getPostPythLazerOracleUpdateIxs(feedIds: number[], pythMessageHex: string, precedingIxs?: TransactionInstruction[], overrideIxCount?: number): TransactionInstruction[];
|
|
825
|
+
getPostSwitchboardOnDemandUpdateAtomicIx(feed: PublicKey, recentSlothash?: Slothash, numSignatures?: number): Promise<TransactionInstruction | undefined>;
|
|
826
|
+
postSwitchboardOnDemandUpdate(feed: PublicKey, recentSlothash?: Slothash, numSignatures?: number): Promise<TransactionSignature>;
|
|
827
|
+
private getBuildEncodedVaaIxs;
|
|
828
|
+
enableUserHighLeverageMode(subAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
829
|
+
getEnableHighLeverageModeIx(subAccountId: number, depositToTradeArgs?: {
|
|
830
|
+
isMakingNewAccount: boolean;
|
|
831
|
+
depositMarketIndex: number;
|
|
832
|
+
orderMarketIndex: number;
|
|
833
|
+
}): Promise<TransactionInstruction>;
|
|
834
|
+
disableUserHighLeverageMode(user: PublicKey, userAccount?: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
835
|
+
getDisableHighLeverageModeIx(user: PublicKey, userAccount?: UserAccount): Promise<TransactionInstruction>;
|
|
836
|
+
fetchHighLeverageModeConfig(): Promise<HighLeverageModeConfig>;
|
|
837
|
+
private handleSignedTransaction;
|
|
838
|
+
private handlePreSignedTransaction;
|
|
839
|
+
private isVersionedTransaction;
|
|
840
|
+
/**
|
|
841
|
+
* Send a transaction.
|
|
842
|
+
*
|
|
843
|
+
* @param tx
|
|
844
|
+
* @param additionalSigners
|
|
845
|
+
* @param opts :: Will fallback to DriftClient's opts if not provided
|
|
846
|
+
* @param preSigned
|
|
847
|
+
* @returns
|
|
848
|
+
*/
|
|
849
|
+
sendTransaction(tx: Transaction | VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
850
|
+
buildTransaction(instructions: TransactionInstruction | TransactionInstruction[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean, recentBlockhash?: BlockhashWithExpiryBlockHeight): Promise<Transaction | VersionedTransaction>;
|
|
851
|
+
buildBulkTransactions(instructions: (TransactionInstruction | TransactionInstruction[])[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<(Transaction | VersionedTransaction)[]>;
|
|
852
|
+
buildTransactionsMap(instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>, txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<MappedRecord<Record<string, anchor.web3.TransactionInstruction | anchor.web3.TransactionInstruction[]>, anchor.web3.Transaction | anchor.web3.VersionedTransaction>>;
|
|
853
|
+
buildAndSignTransactionsMap(instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>, txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<{
|
|
854
|
+
signedTxMap: Record<string, anchor.web3.Transaction>;
|
|
855
|
+
signedTxData: SignedTxData[];
|
|
856
|
+
} | {
|
|
857
|
+
signedTxMap: MappedRecord<Record<string, anchor.web3.TransactionInstruction | anchor.web3.TransactionInstruction[]>, anchor.web3.Transaction | anchor.web3.VersionedTransaction>;
|
|
858
|
+
signedTxData: SignedTxData[];
|
|
859
|
+
}>;
|
|
860
|
+
}
|
|
861
|
+
export {};
|