@drift-labs/sdk 2.97.0-beta.21 → 2.97.0-beta.23
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/VERSION +1 -1
- package/bun.lockb +0 -0
- package/lib/{accounts → browser/accounts}/bulkAccountLoader.d.ts +1 -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 +97 -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/{accounts → browser/accounts}/types.d.ts +8 -0
- package/lib/{accounts → browser/accounts}/webSocketAccountSubscriber.d.ts +2 -1
- package/lib/{accounts → browser/accounts}/webSocketDriftClientAccountSubscriber.d.ts +3 -3
- package/lib/{accounts → browser/accounts}/webSocketProgramAccountSubscriber.d.ts +2 -1
- package/lib/{addresses → browser/addresses}/pda.d.ts +1 -0
- package/lib/{addresses → browser/addresses}/pda.js +8 -1
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/{auctionSubscriber → browser/auctionSubscriber}/index.d.ts +1 -0
- package/lib/browser/auctionSubscriber/index.js +19 -0
- package/lib/{auctionSubscriber → browser/auctionSubscriber}/types.d.ts +2 -0
- package/lib/{bankrun → browser/bankrun}/bankrunConnection.d.ts +1 -0
- package/lib/{decode → browser/decode}/phoenix.d.ts +1 -0
- package/lib/{decode → browser/decode}/user.d.ts +1 -0
- package/lib/{dlob → browser/dlob}/DLOBOrders.d.ts +1 -0
- package/lib/{driftClient.d.ts → browser/driftClient.d.ts} +11 -5
- package/lib/{driftClient.js → browser/driftClient.js} +132 -34
- package/lib/{driftClientConfig.d.ts → browser/driftClientConfig.d.ts} +6 -1
- package/lib/{idl → browser/idl}/drift.json +256 -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/isomorphic/grpc.node.d.ts +5 -0
- package/lib/{math → browser/math}/oracles.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/prelaunchOracleClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/pythClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/pythPullClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/quoteAssetOracleClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/switchboardClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/switchboardOnDemandClient.d.ts +1 -0
- package/lib/{oracles → browser/oracles}/types.d.ts +1 -0
- package/lib/{orderSubscriber → browser/orderSubscriber}/OrderSubscriber.d.ts +3 -1
- package/lib/{orderSubscriber → browser/orderSubscriber}/OrderSubscriber.js +18 -4
- package/lib/browser/orderSubscriber/grpcSubscription.d.ts +22 -0
- package/lib/browser/orderSubscriber/grpcSubscription.js +66 -0
- package/lib/{orderSubscriber → browser/orderSubscriber}/types.d.ts +9 -0
- package/lib/{token → browser/token}/index.d.ts +1 -0
- package/lib/{tx → browser/tx}/baseTxSender.d.ts +1 -0
- package/lib/{tx → browser/tx}/fastSingleTxSender.d.ts +1 -0
- package/lib/{tx → browser/tx}/forwardOnlyTxSender.d.ts +1 -0
- package/lib/{tx → browser/tx}/retryTxSender.d.ts +1 -0
- package/lib/{tx → browser/tx}/types.d.ts +1 -0
- package/lib/{tx → browser/tx}/whileValidTxSender.d.ts +1 -0
- package/lib/{types.d.ts → browser/types.d.ts} +20 -0
- package/lib/{user.js → browser/user.js} +11 -4
- package/lib/{userConfig.d.ts → browser/userConfig.d.ts} +6 -1
- package/lib/{userMap → browser/userMap}/WebsocketSubscription.d.ts +1 -0
- package/lib/browser/userMap/grpcSubscription.d.ts +24 -0
- package/lib/browser/userMap/grpcSubscription.js +40 -0
- package/lib/{userMap → browser/userMap}/userMap.js +17 -1
- package/lib/{userMap → browser/userMap}/userMapConfig.d.ts +6 -0
- package/lib/{userStats.js → browser/userStats.js} +11 -4
- package/lib/{userStatsConfig.d.ts → browser/userStatsConfig.d.ts} +6 -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 +97 -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 +415 -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 +155 -0
- package/lib/node/accounts/types.js +16 -0
- package/lib/node/accounts/utils.d.ts +8 -0
- package/lib/node/accounts/utils.js +39 -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 +352 -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 +34 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +127 -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 +30 -0
- package/lib/node/addresses/pda.js +193 -0
- package/lib/node/adminClient.d.ts +202 -0
- package/lib/node/adminClient.js +1826 -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 +74 -0
- package/lib/node/bankrun/bankrunConnection.js +318 -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 +58 -0
- package/lib/node/config.js +126 -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 +868 -0
- package/lib/node/constants/spotMarkets.d.ts +23 -0
- package/lib/node/constants/spotMarkets.js +361 -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 +166 -0
- package/lib/node/dlob/DLOB.js +1142 -0
- package/lib/node/dlob/DLOBApiClient.d.ts +14 -0
- package/lib/node/dlob/DLOBApiClient.js +34 -0
- package/lib/node/dlob/DLOBNode.d.ts +57 -0
- package/lib/node/dlob/DLOBNode.js +86 -0
- package/lib/node/dlob/DLOBOrders.d.ts +17 -0
- package/lib/node/dlob/DLOBOrders.js +40 -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 +27 -0
- package/lib/node/dlob/NodeList.js +141 -0
- package/lib/node/dlob/dlobIdl.json +248 -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 +820 -0
- package/lib/node/driftClient.js +4487 -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 +77 -0
- package/lib/node/events/types.js +30 -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 +52 -0
- package/lib/node/idl/drift.json +13651 -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 +4541 -0
- package/lib/node/idl/token_faucet.json +142 -0
- package/lib/node/index.d.ts +112 -0
- package/lib/node/index.js +134 -0
- package/lib/node/isomorphic/grpc.browser.d.ts +1 -0
- package/lib/node/isomorphic/grpc.d.ts +1 -0
- package/lib/node/isomorphic/grpc.js +17 -0
- package/lib/node/isomorphic/grpc.node.d.ts +5 -0
- package/lib/node/isomorphic/grpc.node.js +17 -0
- package/lib/node/jupiter/jupiterClient.d.ts +296 -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 +127 -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 +54 -0
- package/lib/node/math/position.js +198 -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/utils.d.ts +23 -0
- package/lib/node/math/utils.js +112 -0
- package/lib/node/memcmp.d.ts +7 -0
- package/lib/node/memcmp.js +63 -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/prelaunchOracleClient.d.ts +12 -0
- package/lib/node/oracles/prelaunchOracleClient.js +24 -0
- package/lib/node/oracles/pythClient.d.ts +15 -0
- package/lib/node/oracles/pythClient.js +52 -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 +179 -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/{auctionSubscriber → node/orderSubscriber}/index.js +1 -1
- 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/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 +55 -0
- package/lib/node/tx/baseTxSender.js +288 -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 +40 -0
- package/lib/node/tx/fastSingleTxSender.js +85 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts +36 -0
- package/lib/node/tx/forwardOnlyTxSender.js +91 -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 +36 -0
- package/lib/node/tx/retryTxSender.js +85 -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 +43 -0
- package/lib/node/tx/whileValidTxSender.js +165 -0
- package/lib/node/types.d.ts +1351 -0
- package/lib/node/types.js +347 -0
- package/lib/node/user.d.ts +411 -0
- package/lib/node/user.js +2161 -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 +25 -0
- package/lib/node/userMap/WebsocketSubscription.js +41 -0
- package/lib/node/userMap/grpcSubscription.d.ts +24 -0
- package/lib/node/userMap/grpcSubscription.js +40 -0
- package/lib/node/userMap/userMap.d.ts +88 -0
- package/lib/node/userMap/userMap.js +455 -0
- package/lib/node/userMap/userMapConfig.d.ts +37 -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 +19 -0
- package/lib/node/userStats.js +65 -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 +46 -0
- package/lib/node/util/promiseTimeout.d.ts +1 -0
- package/lib/node/util/promiseTimeout.js +14 -0
- package/lib/node/util/pythPullOracleUtils.d.ts +2 -0
- package/lib/node/util/pythPullOracleUtils.js +15 -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 +8 -4
- package/scripts/postbuild.js +61 -0
- package/src/accounts/grpcAccountSubscriber.ts +160 -0
- package/src/accounts/grpcDriftClientAccountSubscriber.ts +197 -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/types.ts +8 -0
- package/src/accounts/webSocketAccountSubscriber.ts +1 -1
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +3 -3
- package/src/accounts/webSocketProgramAccountSubscriber.ts +1 -1
- package/src/addresses/pda.ts +13 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +70 -0
- package/src/auctionSubscriber/index.ts +1 -0
- package/src/auctionSubscriber/types.ts +2 -0
- package/src/driftClient.ts +175 -24
- package/src/driftClientConfig.ts +7 -1
- package/src/idl/drift.json +256 -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/orderSubscriber/OrderSubscriber.ts +14 -1
- package/src/orderSubscriber/grpcSubscription.ts +121 -0
- package/src/orderSubscriber/types.ts +10 -0
- package/src/types.ts +23 -0
- package/src/user.ts +11 -0
- package/src/userConfig.ts +7 -1
- package/src/userMap/grpcSubscription.ts +78 -0
- package/src/userMap/userMap.ts +21 -2
- package/src/userMap/userMapConfig.ts +7 -0
- package/src/userStats.ts +11 -0
- package/src/userStatsConfig.ts +7 -0
- package/tsconfig.browser.json +13 -0
- package/tsconfig.json +1 -1
- /package/lib/{accounts → browser/accounts}/basicUserAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/basicUserAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/bulkAccountLoader.js +0 -0
- /package/lib/{accounts → browser/accounts}/bulkUserStatsSubscription.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/bulkUserStatsSubscription.js +0 -0
- /package/lib/{accounts → browser/accounts}/bulkUserSubscription.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/bulkUserSubscription.js +0 -0
- /package/lib/{accounts → browser/accounts}/fetch.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/fetch.js +0 -0
- /package/lib/{accounts → browser/accounts}/oneShotUserAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/oneShotUserAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingDriftClientAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingDriftClientAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingInsuranceFundStakeAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingInsuranceFundStakeAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingOracleAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingOracleAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingTokenAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingTokenAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingUserAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingUserAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/pollingUserStatsAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/pollingUserStatsAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/testBulkAccountLoader.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/testBulkAccountLoader.js +0 -0
- /package/lib/{accounts → browser/accounts}/types.js +0 -0
- /package/lib/{accounts → browser/accounts}/utils.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/utils.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketDriftClientAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketInsuranceFundStakeAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketInsuranceFundStakeAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketProgramAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketUserAccountSubscriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketUserAccountSubscriber.js +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketUserStatsAccountSubsriber.d.ts +0 -0
- /package/lib/{accounts → browser/accounts}/webSocketUserStatsAccountSubsriber.js +0 -0
- /package/lib/{addresses → browser/addresses}/marketAddresses.d.ts +0 -0
- /package/lib/{addresses → browser/addresses}/marketAddresses.js +0 -0
- /package/lib/{adminClient.d.ts → browser/adminClient.d.ts} +0 -0
- /package/lib/{adminClient.js → browser/adminClient.js} +0 -0
- /package/lib/{assert → browser/assert}/assert.d.ts +0 -0
- /package/lib/{assert → browser/assert}/assert.js +0 -0
- /package/lib/{auctionSubscriber → browser/auctionSubscriber}/auctionSubscriber.d.ts +0 -0
- /package/lib/{auctionSubscriber → browser/auctionSubscriber}/auctionSubscriber.js +0 -0
- /package/lib/{auctionSubscriber → browser/auctionSubscriber}/types.js +0 -0
- /package/lib/{bankrun → browser/bankrun}/bankrunConnection.js +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/BlockhashSubscriber.d.ts +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/BlockhashSubscriber.js +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/index.d.ts +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/index.js +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/types.d.ts +0 -0
- /package/lib/{blockhashSubscriber → browser/blockhashSubscriber}/types.js +0 -0
- /package/lib/{clock → browser/clock}/clockSubscriber.d.ts +0 -0
- /package/lib/{clock → browser/clock}/clockSubscriber.js +0 -0
- /package/lib/{config.d.ts → browser/config.d.ts} +0 -0
- /package/lib/{config.js → browser/config.js} +0 -0
- /package/lib/{constants → browser/constants}/numericConstants.d.ts +0 -0
- /package/lib/{constants → browser/constants}/numericConstants.js +0 -0
- /package/lib/{constants → browser/constants}/perpMarkets.d.ts +0 -0
- /package/lib/{constants → browser/constants}/perpMarkets.js +0 -0
- /package/lib/{constants → browser/constants}/spotMarkets.d.ts +0 -0
- /package/lib/{constants → browser/constants}/spotMarkets.js +0 -0
- /package/lib/{constants → browser/constants}/txConstants.d.ts +0 -0
- /package/lib/{constants → browser/constants}/txConstants.js +0 -0
- /package/lib/{decode → browser/decode}/phoenix.js +0 -0
- /package/lib/{decode → browser/decode}/user.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOB.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/DLOB.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBApiClient.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBApiClient.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBNode.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBNode.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBOrders.js +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBSubscriber.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/DLOBSubscriber.js +0 -0
- /package/lib/{dlob → browser/dlob}/NodeList.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/NodeList.js +0 -0
- /package/lib/{dlob → browser/dlob}/dlobIdl.json +0 -0
- /package/lib/{dlob → browser/dlob}/orderBookLevels.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/orderBookLevels.js +0 -0
- /package/lib/{dlob → browser/dlob}/types.d.ts +0 -0
- /package/lib/{dlob → browser/dlob}/types.js +0 -0
- /package/lib/{driftClientConfig.js → browser/driftClientConfig.js} +0 -0
- /package/lib/{events → browser/events}/eventList.d.ts +0 -0
- /package/lib/{events → browser/events}/eventList.js +0 -0
- /package/lib/{events → browser/events}/eventSubscriber.d.ts +0 -0
- /package/lib/{events → browser/events}/eventSubscriber.js +0 -0
- /package/lib/{events → browser/events}/eventsServerLogProvider.d.ts +0 -0
- /package/lib/{events → browser/events}/eventsServerLogProvider.js +0 -0
- /package/lib/{events → browser/events}/fetchLogs.d.ts +0 -0
- /package/lib/{events → browser/events}/fetchLogs.js +0 -0
- /package/lib/{events → browser/events}/parse.d.ts +0 -0
- /package/lib/{events → browser/events}/parse.js +0 -0
- /package/lib/{events → browser/events}/pollingLogProvider.d.ts +0 -0
- /package/lib/{events → browser/events}/pollingLogProvider.js +0 -0
- /package/lib/{events → browser/events}/sort.d.ts +0 -0
- /package/lib/{events → browser/events}/sort.js +0 -0
- /package/lib/{events → browser/events}/txEventCache.d.ts +0 -0
- /package/lib/{events → browser/events}/txEventCache.js +0 -0
- /package/lib/{events → browser/events}/types.d.ts +0 -0
- /package/lib/{events → browser/events}/types.js +0 -0
- /package/lib/{events → browser/events}/webSocketLogProvider.d.ts +0 -0
- /package/lib/{events → browser/events}/webSocketLogProvider.js +0 -0
- /package/lib/{factory → browser/factory}/bigNum.d.ts +0 -0
- /package/lib/{factory → browser/factory}/bigNum.js +0 -0
- /package/lib/{factory → browser/factory}/oracleClient.d.ts +0 -0
- /package/lib/{factory → browser/factory}/oracleClient.js +0 -0
- /package/lib/{idl → browser/idl}/openbook.json +0 -0
- /package/lib/{idl → browser/idl}/pyth_solana_receiver.json +0 -0
- /package/lib/{idl → browser/idl}/switchboard.json +0 -0
- /package/lib/{idl → browser/idl}/switchboard_on_demand_30.json +0 -0
- /package/lib/{idl → browser/idl}/token_faucet.json +0 -0
- /package/lib/{index.d.ts → browser/index.d.ts} +0 -0
- /package/lib/{index.js → browser/index.js} +0 -0
- /package/lib/{jupiter → browser/jupiter}/jupiterClient.d.ts +0 -0
- /package/lib/{jupiter → browser/jupiter}/jupiterClient.js +0 -0
- /package/lib/{keypair.d.ts → browser/keypair.d.ts} +0 -0
- /package/lib/{keypair.js → browser/keypair.js} +0 -0
- /package/lib/{marinade → browser/marinade}/index.d.ts +0 -0
- /package/lib/{marinade → browser/marinade}/index.js +0 -0
- /package/lib/{marinade → browser/marinade}/types.d.ts +0 -0
- /package/lib/{marinade → browser/marinade}/types.js +0 -0
- /package/lib/{math → browser/math}/amm.d.ts +0 -0
- /package/lib/{math → browser/math}/amm.js +0 -0
- /package/lib/{math → browser/math}/auction.d.ts +0 -0
- /package/lib/{math → browser/math}/auction.js +0 -0
- /package/lib/{math → browser/math}/bankruptcy.d.ts +0 -0
- /package/lib/{math → browser/math}/bankruptcy.js +0 -0
- /package/lib/{math → browser/math}/conversion.d.ts +0 -0
- /package/lib/{math → browser/math}/conversion.js +0 -0
- /package/lib/{math → browser/math}/exchangeStatus.d.ts +0 -0
- /package/lib/{math → browser/math}/exchangeStatus.js +0 -0
- /package/lib/{math → browser/math}/fuel.d.ts +0 -0
- /package/lib/{math → browser/math}/fuel.js +0 -0
- /package/lib/{math → browser/math}/funding.d.ts +0 -0
- /package/lib/{math → browser/math}/funding.js +0 -0
- /package/lib/{math → browser/math}/insurance.d.ts +0 -0
- /package/lib/{math → browser/math}/insurance.js +0 -0
- /package/lib/{math → browser/math}/margin.d.ts +0 -0
- /package/lib/{math → browser/math}/margin.js +0 -0
- /package/lib/{math → browser/math}/market.d.ts +0 -0
- /package/lib/{math → browser/math}/market.js +0 -0
- /package/lib/{math → browser/math}/oracles.js +0 -0
- /package/lib/{math → browser/math}/orders.d.ts +0 -0
- /package/lib/{math → browser/math}/orders.js +0 -0
- /package/lib/{math → browser/math}/position.d.ts +0 -0
- /package/lib/{math → browser/math}/position.js +0 -0
- /package/lib/{math → browser/math}/repeg.d.ts +0 -0
- /package/lib/{math → browser/math}/repeg.js +0 -0
- /package/lib/{math → browser/math}/spotBalance.d.ts +0 -0
- /package/lib/{math → browser/math}/spotBalance.js +0 -0
- /package/lib/{math → browser/math}/spotMarket.d.ts +0 -0
- /package/lib/{math → browser/math}/spotMarket.js +0 -0
- /package/lib/{math → browser/math}/spotPosition.d.ts +0 -0
- /package/lib/{math → browser/math}/spotPosition.js +0 -0
- /package/lib/{math → browser/math}/state.d.ts +0 -0
- /package/lib/{math → browser/math}/state.js +0 -0
- /package/lib/{math → browser/math}/superStake.d.ts +0 -0
- /package/lib/{math → browser/math}/superStake.js +0 -0
- /package/lib/{math → browser/math}/tiers.d.ts +0 -0
- /package/lib/{math → browser/math}/tiers.js +0 -0
- /package/lib/{math → browser/math}/trade.d.ts +0 -0
- /package/lib/{math → browser/math}/trade.js +0 -0
- /package/lib/{math → browser/math}/utils.d.ts +0 -0
- /package/lib/{math → browser/math}/utils.js +0 -0
- /package/lib/{memcmp.d.ts → browser/memcmp.d.ts} +0 -0
- /package/lib/{memcmp.js → browser/memcmp.js} +0 -0
- /package/lib/{openbook → browser/openbook}/openbookV2FulfillmentConfigMap.d.ts +0 -0
- /package/lib/{openbook → browser/openbook}/openbookV2FulfillmentConfigMap.js +0 -0
- /package/lib/{openbook → browser/openbook}/openbookV2Subscriber.d.ts +0 -0
- /package/lib/{openbook → browser/openbook}/openbookV2Subscriber.js +0 -0
- /package/lib/{oracles → browser/oracles}/oracleClientCache.d.ts +0 -0
- /package/lib/{oracles → browser/oracles}/oracleClientCache.js +0 -0
- /package/lib/{oracles → browser/oracles}/prelaunchOracleClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/pythClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/pythPullClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/quoteAssetOracleClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/strictOraclePrice.d.ts +0 -0
- /package/lib/{oracles → browser/oracles}/strictOraclePrice.js +0 -0
- /package/lib/{oracles → browser/oracles}/switchboardClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/switchboardOnDemandClient.js +0 -0
- /package/lib/{oracles → browser/oracles}/types.js +0 -0
- /package/lib/{orderParams.d.ts → browser/orderParams.d.ts} +0 -0
- /package/lib/{orderParams.js → browser/orderParams.js} +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/PollingSubscription.d.ts +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/PollingSubscription.js +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/WebsocketSubscription.d.ts +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/WebsocketSubscription.js +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/index.d.ts +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/index.js +0 -0
- /package/lib/{orderSubscriber → browser/orderSubscriber}/types.js +0 -0
- /package/lib/{phoenix → browser/phoenix}/phoenixFulfillmentConfigMap.d.ts +0 -0
- /package/lib/{phoenix → browser/phoenix}/phoenixFulfillmentConfigMap.js +0 -0
- /package/lib/{phoenix → browser/phoenix}/phoenixSubscriber.d.ts +0 -0
- /package/lib/{phoenix → browser/phoenix}/phoenixSubscriber.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/averageOverSlotsStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/averageOverSlotsStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/averageStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/averageStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/driftPriorityFeeMethod.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/driftPriorityFeeMethod.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/ewmaStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/ewmaStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/heliusPriorityFeeMethod.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/heliusPriorityFeeMethod.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/index.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/index.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/maxOverSlotsStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/maxOverSlotsStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/maxStrategy.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/maxStrategy.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/priorityFeeSubscriber.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/priorityFeeSubscriber.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/priorityFeeSubscriberMap.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/priorityFeeSubscriberMap.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/solanaPriorityFeeMethod.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/solanaPriorityFeeMethod.js +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/types.d.ts +0 -0
- /package/lib/{priorityFee → browser/priorityFee}/types.js +0 -0
- /package/lib/{serum → browser/serum}/serumFulfillmentConfigMap.d.ts +0 -0
- /package/lib/{serum → browser/serum}/serumFulfillmentConfigMap.js +0 -0
- /package/lib/{serum → browser/serum}/serumSubscriber.d.ts +0 -0
- /package/lib/{serum → browser/serum}/serumSubscriber.js +0 -0
- /package/lib/{serum → browser/serum}/types.d.ts +0 -0
- /package/lib/{serum → browser/serum}/types.js +0 -0
- /package/lib/{slot → browser/slot}/SlotSubscriber.d.ts +0 -0
- /package/lib/{slot → browser/slot}/SlotSubscriber.js +0 -0
- /package/lib/{testClient.d.ts → browser/testClient.d.ts} +0 -0
- /package/lib/{testClient.js → browser/testClient.js} +0 -0
- /package/lib/{token → browser/token}/index.js +0 -0
- /package/lib/{tokenFaucet.d.ts → browser/tokenFaucet.d.ts} +0 -0
- /package/lib/{tokenFaucet.js → browser/tokenFaucet.js} +0 -0
- /package/lib/{tx → browser/tx}/baseTxSender.js +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/baseBlockhashFetcher.d.ts +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/baseBlockhashFetcher.js +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/cachedBlockhashFetcher.d.ts +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/cachedBlockhashFetcher.js +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/types.d.ts +0 -0
- /package/lib/{tx → browser/tx}/blockhashFetcher/types.js +0 -0
- /package/lib/{tx → browser/tx}/fastSingleTxSender.js +0 -0
- /package/lib/{tx → browser/tx}/forwardOnlyTxSender.js +0 -0
- /package/lib/{tx → browser/tx}/priorityFeeCalculator.d.ts +0 -0
- /package/lib/{tx → browser/tx}/priorityFeeCalculator.js +0 -0
- /package/lib/{tx → browser/tx}/reportTransactionError.d.ts +0 -0
- /package/lib/{tx → browser/tx}/reportTransactionError.js +0 -0
- /package/lib/{tx → browser/tx}/retryTxSender.js +0 -0
- /package/lib/{tx → browser/tx}/txHandler.d.ts +0 -0
- /package/lib/{tx → browser/tx}/txHandler.js +0 -0
- /package/lib/{tx → browser/tx}/txParamProcessor.d.ts +0 -0
- /package/lib/{tx → browser/tx}/txParamProcessor.js +0 -0
- /package/lib/{tx → browser/tx}/types.js +0 -0
- /package/lib/{tx → browser/tx}/utils.d.ts +0 -0
- /package/lib/{tx → browser/tx}/utils.js +0 -0
- /package/lib/{tx → browser/tx}/whileValidTxSender.js +0 -0
- /package/lib/{types.js → browser/types.js} +0 -0
- /package/lib/{user.d.ts → browser/user.d.ts} +0 -0
- /package/lib/{userConfig.js → browser/userConfig.js} +0 -0
- /package/lib/{userMap → browser/userMap}/PollingSubscription.d.ts +0 -0
- /package/lib/{userMap → browser/userMap}/PollingSubscription.js +0 -0
- /package/lib/{userMap → browser/userMap}/WebsocketSubscription.js +0 -0
- /package/lib/{userMap → browser/userMap}/userMap.d.ts +0 -0
- /package/lib/{userMap → browser/userMap}/userMapConfig.js +0 -0
- /package/lib/{userMap → browser/userMap}/userStatsMap.d.ts +0 -0
- /package/lib/{userMap → browser/userMap}/userStatsMap.js +0 -0
- /package/lib/{userName.d.ts → browser/userName.d.ts} +0 -0
- /package/lib/{userName.js → browser/userName.js} +0 -0
- /package/lib/{userStats.d.ts → browser/userStats.d.ts} +0 -0
- /package/lib/{userStatsConfig.js → browser/userStatsConfig.js} +0 -0
- /package/lib/{util → browser/util}/TransactionConfirmationManager.d.ts +0 -0
- /package/lib/{util → browser/util}/TransactionConfirmationManager.js +0 -0
- /package/lib/{util → browser/util}/chainClock.d.ts +0 -0
- /package/lib/{util → browser/util}/chainClock.js +0 -0
- /package/lib/{util → browser/util}/computeUnits.d.ts +0 -0
- /package/lib/{util → browser/util}/computeUnits.js +0 -0
- /package/lib/{util → browser/util}/promiseTimeout.d.ts +0 -0
- /package/lib/{util → browser/util}/promiseTimeout.js +0 -0
- /package/lib/{util → browser/util}/pythPullOracleUtils.d.ts +0 -0
- /package/lib/{util → browser/util}/pythPullOracleUtils.js +0 -0
- /package/lib/{util → browser/util}/tps.d.ts +0 -0
- /package/lib/{util → browser/util}/tps.js +0 -0
- /package/lib/{wallet.d.ts → browser/wallet.d.ts} +0 -0
- /package/lib/{wallet.js → browser/wallet.js} +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserStatsMap = void 0;
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
class UserStatsMap {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new UserStatsMap instance.
|
|
9
|
+
*
|
|
10
|
+
* @param {DriftClient} driftClient - The DriftClient instance.
|
|
11
|
+
* @param {BulkAccountLoader} [bulkAccountLoader] - If not provided, a new BulkAccountLoader with polling disabled will be created.
|
|
12
|
+
*/
|
|
13
|
+
constructor(driftClient, bulkAccountLoader) {
|
|
14
|
+
/**
|
|
15
|
+
* map from authority pubkey to UserStats
|
|
16
|
+
*/
|
|
17
|
+
this.userStatsMap = new Map();
|
|
18
|
+
this.driftClient = driftClient;
|
|
19
|
+
if (!bulkAccountLoader) {
|
|
20
|
+
bulkAccountLoader = new __1.BulkAccountLoader(driftClient.connection, driftClient.opts.commitment, 0);
|
|
21
|
+
}
|
|
22
|
+
this.bulkAccountLoader = bulkAccountLoader;
|
|
23
|
+
}
|
|
24
|
+
async subscribe(authorities) {
|
|
25
|
+
if (this.size() > 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
await this.driftClient.subscribe();
|
|
29
|
+
await this.sync(authorities);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param authority that owns the UserStatsAccount
|
|
34
|
+
* @param userStatsAccount optional UserStatsAccount to subscribe to, if undefined will be fetched later
|
|
35
|
+
* @param skipFetch if true, will not immediately fetch the UserStatsAccount
|
|
36
|
+
*/
|
|
37
|
+
async addUserStat(authority, userStatsAccount, skipFetch) {
|
|
38
|
+
const userStat = new __1.UserStats({
|
|
39
|
+
driftClient: this.driftClient,
|
|
40
|
+
userStatsAccountPublicKey: (0, __1.getUserStatsAccountPublicKey)(this.driftClient.program.programId, authority),
|
|
41
|
+
accountSubscription: {
|
|
42
|
+
type: 'polling',
|
|
43
|
+
accountLoader: this.bulkAccountLoader,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
if (skipFetch) {
|
|
47
|
+
await userStat.accountSubscriber.addToAccountLoader();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
await userStat.subscribe(userStatsAccount);
|
|
51
|
+
}
|
|
52
|
+
this.userStatsMap.set(authority.toString(), userStat);
|
|
53
|
+
}
|
|
54
|
+
async updateWithOrderRecord(record, userMap) {
|
|
55
|
+
const user = await userMap.mustGet(record.user.toString());
|
|
56
|
+
if (!this.has(user.getUserAccount().authority.toString())) {
|
|
57
|
+
await this.addUserStat(user.getUserAccount().authority, undefined, false);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async updateWithEventRecord(record, userMap) {
|
|
61
|
+
if (record.eventType === 'DepositRecord') {
|
|
62
|
+
const depositRecord = record;
|
|
63
|
+
await this.mustGet(depositRecord.userAuthority.toString());
|
|
64
|
+
}
|
|
65
|
+
else if (record.eventType === 'FundingPaymentRecord') {
|
|
66
|
+
const fundingPaymentRecord = record;
|
|
67
|
+
await this.mustGet(fundingPaymentRecord.userAuthority.toString());
|
|
68
|
+
}
|
|
69
|
+
else if (record.eventType === 'LiquidationRecord') {
|
|
70
|
+
if (!userMap) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const liqRecord = record;
|
|
74
|
+
const user = await userMap.mustGet(liqRecord.user.toString());
|
|
75
|
+
await this.mustGet(user.getUserAccount().authority.toString());
|
|
76
|
+
const liquidatorUser = await userMap.mustGet(liqRecord.liquidator.toString());
|
|
77
|
+
await this.mustGet(liquidatorUser.getUserAccount().authority.toString());
|
|
78
|
+
}
|
|
79
|
+
else if (record.eventType === 'OrderRecord') {
|
|
80
|
+
if (!userMap) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const orderRecord = record;
|
|
84
|
+
await userMap.updateWithOrderRecord(orderRecord);
|
|
85
|
+
}
|
|
86
|
+
else if (record.eventType === 'OrderActionRecord') {
|
|
87
|
+
if (!userMap) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const actionRecord = record;
|
|
91
|
+
if (actionRecord.taker) {
|
|
92
|
+
const taker = await userMap.mustGet(actionRecord.taker.toString());
|
|
93
|
+
await this.mustGet(taker.getUserAccount().authority.toString());
|
|
94
|
+
}
|
|
95
|
+
if (actionRecord.maker) {
|
|
96
|
+
const maker = await userMap.mustGet(actionRecord.maker.toString());
|
|
97
|
+
await this.mustGet(maker.getUserAccount().authority.toString());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (record.eventType === 'SettlePnlRecord') {
|
|
101
|
+
if (!userMap) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const settlePnlRecord = record;
|
|
105
|
+
const user = await userMap.mustGet(settlePnlRecord.user.toString());
|
|
106
|
+
await this.mustGet(user.getUserAccount().authority.toString());
|
|
107
|
+
}
|
|
108
|
+
else if (record.eventType === 'NewUserRecord') {
|
|
109
|
+
const newUserRecord = record;
|
|
110
|
+
await this.mustGet(newUserRecord.userAuthority.toString());
|
|
111
|
+
}
|
|
112
|
+
else if (record.eventType === 'LPRecord') {
|
|
113
|
+
if (!userMap) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const lpRecord = record;
|
|
117
|
+
const user = await userMap.mustGet(lpRecord.user.toString());
|
|
118
|
+
await this.mustGet(user.getUserAccount().authority.toString());
|
|
119
|
+
}
|
|
120
|
+
else if (record.eventType === 'InsuranceFundStakeRecord') {
|
|
121
|
+
const ifStakeRecord = record;
|
|
122
|
+
await this.mustGet(ifStakeRecord.userAuthority.toString());
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
has(authorityPublicKey) {
|
|
126
|
+
return this.userStatsMap.has(authorityPublicKey);
|
|
127
|
+
}
|
|
128
|
+
get(authorityPublicKey) {
|
|
129
|
+
return this.userStatsMap.get(authorityPublicKey);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Enforce that a UserStats will exist for the given authorityPublicKey,
|
|
133
|
+
* reading one from the blockchain if necessary.
|
|
134
|
+
* @param authorityPublicKey
|
|
135
|
+
* @returns
|
|
136
|
+
*/
|
|
137
|
+
async mustGet(authorityPublicKey) {
|
|
138
|
+
if (!this.has(authorityPublicKey)) {
|
|
139
|
+
await this.addUserStat(new web3_js_1.PublicKey(authorityPublicKey), undefined, false);
|
|
140
|
+
}
|
|
141
|
+
return this.get(authorityPublicKey);
|
|
142
|
+
}
|
|
143
|
+
values() {
|
|
144
|
+
return this.userStatsMap.values();
|
|
145
|
+
}
|
|
146
|
+
size() {
|
|
147
|
+
return this.userStatsMap.size;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Sync the UserStatsMap
|
|
151
|
+
* @param authorities list of authorities to derive UserStatsAccount public keys from.
|
|
152
|
+
* You may want to get this list from UserMap in order to filter out idle users
|
|
153
|
+
*/
|
|
154
|
+
async sync(authorities) {
|
|
155
|
+
await Promise.all(authorities.map((authority) => this.addUserStat(authority, undefined, true)));
|
|
156
|
+
await this.bulkAccountLoader.load();
|
|
157
|
+
}
|
|
158
|
+
async unsubscribe() {
|
|
159
|
+
for (const [key, userStats] of this.userStatsMap.entries()) {
|
|
160
|
+
await userStats.unsubscribe();
|
|
161
|
+
this.userStatsMap.delete(key);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.UserStatsMap = UserStatsMap;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const MAX_NAME_LENGTH = 32;
|
|
2
|
+
export declare const DEFAULT_USER_NAME = "Main Account";
|
|
3
|
+
export declare const DEFAULT_MARKET_NAME = "Default Market Name";
|
|
4
|
+
export declare function encodeName(name: string): number[];
|
|
5
|
+
export declare function decodeName(bytes: number[]): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeName = exports.encodeName = exports.DEFAULT_MARKET_NAME = exports.DEFAULT_USER_NAME = exports.MAX_NAME_LENGTH = void 0;
|
|
4
|
+
exports.MAX_NAME_LENGTH = 32;
|
|
5
|
+
exports.DEFAULT_USER_NAME = 'Main Account';
|
|
6
|
+
exports.DEFAULT_MARKET_NAME = 'Default Market Name';
|
|
7
|
+
function encodeName(name) {
|
|
8
|
+
if (name.length > exports.MAX_NAME_LENGTH) {
|
|
9
|
+
throw Error(`Name (${name}) longer than 32 characters`);
|
|
10
|
+
}
|
|
11
|
+
const buffer = Buffer.alloc(32);
|
|
12
|
+
buffer.fill(name);
|
|
13
|
+
buffer.fill(' ', name.length);
|
|
14
|
+
return Array(...buffer);
|
|
15
|
+
}
|
|
16
|
+
exports.encodeName = encodeName;
|
|
17
|
+
function decodeName(bytes) {
|
|
18
|
+
const buffer = Buffer.from(bytes);
|
|
19
|
+
return buffer.toString('utf8').trim();
|
|
20
|
+
}
|
|
21
|
+
exports.decodeName = decodeName;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DriftClient } from './driftClient';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { DataAndSlot, UserStatsAccountSubscriber } from './accounts/types';
|
|
4
|
+
import { UserStatsConfig } from './userStatsConfig';
|
|
5
|
+
import { ReferrerInfo, UserStatsAccount } from './types';
|
|
6
|
+
export declare class UserStats {
|
|
7
|
+
driftClient: DriftClient;
|
|
8
|
+
userStatsAccountPublicKey: PublicKey;
|
|
9
|
+
accountSubscriber: UserStatsAccountSubscriber;
|
|
10
|
+
isSubscribed: boolean;
|
|
11
|
+
constructor(config: UserStatsConfig);
|
|
12
|
+
subscribe(userStatsAccount?: UserStatsAccount): Promise<boolean>;
|
|
13
|
+
fetchAccounts(): Promise<void>;
|
|
14
|
+
unsubscribe(): Promise<void>;
|
|
15
|
+
getAccountAndSlot(): DataAndSlot<UserStatsAccount>;
|
|
16
|
+
getAccount(): UserStatsAccount;
|
|
17
|
+
getReferrerInfo(): ReferrerInfo | undefined;
|
|
18
|
+
static getOldestActionTs(account: UserStatsAccount): number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserStats = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const pollingUserStatsAccountSubscriber_1 = require("./accounts/pollingUserStatsAccountSubscriber");
|
|
6
|
+
const webSocketUserStatsAccountSubsriber_1 = require("./accounts/webSocketUserStatsAccountSubsriber");
|
|
7
|
+
const pda_1 = require("./addresses/pda");
|
|
8
|
+
const grpcUserStatsAccountSubscriber_1 = require("./accounts/grpcUserStatsAccountSubscriber");
|
|
9
|
+
class UserStats {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
12
|
+
this.driftClient = config.driftClient;
|
|
13
|
+
this.userStatsAccountPublicKey = config.userStatsAccountPublicKey;
|
|
14
|
+
if (((_a = config.accountSubscription) === null || _a === void 0 ? void 0 : _a.type) === 'polling') {
|
|
15
|
+
this.accountSubscriber = new pollingUserStatsAccountSubscriber_1.PollingUserStatsAccountSubscriber(config.driftClient.program, config.userStatsAccountPublicKey, config.accountSubscription.accountLoader);
|
|
16
|
+
}
|
|
17
|
+
else if (((_b = config.accountSubscription) === null || _b === void 0 ? void 0 : _b.type) === 'grpc') {
|
|
18
|
+
this.accountSubscriber = new grpcUserStatsAccountSubscriber_1.grpcUserStatsAccountSubscriber(config.accountSubscription.grpcConfigs, config.driftClient.program, config.userStatsAccountPublicKey, {
|
|
19
|
+
resubTimeoutMs: (_c = config.accountSubscription) === null || _c === void 0 ? void 0 : _c.resubTimeoutMs,
|
|
20
|
+
logResubMessages: (_d = config.accountSubscription) === null || _d === void 0 ? void 0 : _d.logResubMessages,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else if (((_e = config.accountSubscription) === null || _e === void 0 ? void 0 : _e.type) === 'websocket') {
|
|
24
|
+
this.accountSubscriber = new webSocketUserStatsAccountSubsriber_1.WebSocketUserStatsAccountSubscriber(config.driftClient.program, config.userStatsAccountPublicKey, {
|
|
25
|
+
resubTimeoutMs: (_f = config.accountSubscription) === null || _f === void 0 ? void 0 : _f.resubTimeoutMs,
|
|
26
|
+
logResubMessages: (_g = config.accountSubscription) === null || _g === void 0 ? void 0 : _g.logResubMessages,
|
|
27
|
+
}, config.accountSubscription.commitment);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new Error(`Unknown user stats account subscription type: ${(_h = config.accountSubscription) === null || _h === void 0 ? void 0 : _h.type}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async subscribe(userStatsAccount) {
|
|
34
|
+
this.isSubscribed = await this.accountSubscriber.subscribe(userStatsAccount);
|
|
35
|
+
return this.isSubscribed;
|
|
36
|
+
}
|
|
37
|
+
async fetchAccounts() {
|
|
38
|
+
await this.accountSubscriber.fetch();
|
|
39
|
+
}
|
|
40
|
+
async unsubscribe() {
|
|
41
|
+
await this.accountSubscriber.unsubscribe();
|
|
42
|
+
this.isSubscribed = false;
|
|
43
|
+
}
|
|
44
|
+
getAccountAndSlot() {
|
|
45
|
+
return this.accountSubscriber.getUserStatsAccountAndSlot();
|
|
46
|
+
}
|
|
47
|
+
getAccount() {
|
|
48
|
+
return this.accountSubscriber.getUserStatsAccountAndSlot().data;
|
|
49
|
+
}
|
|
50
|
+
getReferrerInfo() {
|
|
51
|
+
if (this.getAccount().referrer.equals(web3_js_1.PublicKey.default)) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return {
|
|
56
|
+
referrer: (0, pda_1.getUserAccountPublicKeySync)(this.driftClient.program.programId, this.getAccount().referrer, 0),
|
|
57
|
+
referrerStats: (0, pda_1.getUserStatsAccountPublicKey)(this.driftClient.program.programId, this.getAccount().referrer),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static getOldestActionTs(account) {
|
|
62
|
+
return Math.min(account.lastFillerVolume30DTs.toNumber(), account.lastMakerVolume30DTs.toNumber(), account.lastTakerVolume30DTs.toNumber());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.UserStats = UserStats;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DriftClient } from './driftClient';
|
|
2
|
+
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { BulkAccountLoader } from './accounts/bulkAccountLoader';
|
|
4
|
+
import { GrpcConfigs } from './accounts/types';
|
|
5
|
+
export type UserStatsConfig = {
|
|
6
|
+
accountSubscription?: UserStatsSubscriptionConfig;
|
|
7
|
+
driftClient: DriftClient;
|
|
8
|
+
userStatsAccountPublicKey: PublicKey;
|
|
9
|
+
};
|
|
10
|
+
export type UserStatsSubscriptionConfig = {
|
|
11
|
+
type: 'websocket';
|
|
12
|
+
resubTimeoutMs?: number;
|
|
13
|
+
logResubMessages?: boolean;
|
|
14
|
+
commitment?: Commitment;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'polling';
|
|
17
|
+
accountLoader: BulkAccountLoader;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'custom';
|
|
20
|
+
} | {
|
|
21
|
+
type: 'grpc';
|
|
22
|
+
resubTimeoutMs?: number;
|
|
23
|
+
logResubMessages?: boolean;
|
|
24
|
+
grpcConfigs: GrpcConfigs;
|
|
25
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Connection, RpcResponseAndContext, SignatureResult, SignatureStatus, TransactionConfirmationStatus } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Class to await for transaction confirmations in an optimised manner. It tracks a shared list of all pending transactions and fetches them in bulk in a shared RPC request whenever they have an "overlapping" polling interval. E.g. tx1 with an interval of 200ms and tx2 with an interval of 300ms (if sent at the same time) will be fetched together at at 600ms, 1200ms, 1800ms, etc.
|
|
4
|
+
*/
|
|
5
|
+
export declare class TransactionConfirmationManager {
|
|
6
|
+
private connection;
|
|
7
|
+
private pendingConfirmations;
|
|
8
|
+
private intervalId;
|
|
9
|
+
constructor(connection: Connection);
|
|
10
|
+
confirmTransactionWebSocket(txSig: string, timeout?: number, desiredConfirmationStatus?: TransactionConfirmationStatus): Promise<RpcResponseAndContext<SignatureResult>>;
|
|
11
|
+
confirmTransactionPolling(txSig: string, desiredConfirmationStatus?: TransactionConfirmationStatus, timeout?: number, pollInterval?: number, searchTransactionHistory?: boolean): Promise<SignatureStatus>;
|
|
12
|
+
private startConfirmationLoop;
|
|
13
|
+
private checkPendingConfirmations;
|
|
14
|
+
private checkStatusMatchesDesiredConfirmationStatus;
|
|
15
|
+
private checkTransactionStatuses;
|
|
16
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionConfirmationManager = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
const txConstants_1 = require("../constants/txConstants");
|
|
7
|
+
const reportTransactionError_1 = require("../tx/reportTransactionError");
|
|
8
|
+
const promiseTimeout_1 = require("./promiseTimeout");
|
|
9
|
+
const confirmationStatusValues = {
|
|
10
|
+
processed: 0,
|
|
11
|
+
confirmed: 1,
|
|
12
|
+
finalized: 2,
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Class to await for transaction confirmations in an optimised manner. It tracks a shared list of all pending transactions and fetches them in bulk in a shared RPC request whenever they have an "overlapping" polling interval. E.g. tx1 with an interval of 200ms and tx2 with an interval of 300ms (if sent at the same time) will be fetched together at at 600ms, 1200ms, 1800ms, etc.
|
|
16
|
+
*/
|
|
17
|
+
class TransactionConfirmationManager {
|
|
18
|
+
constructor(connection) {
|
|
19
|
+
this.pendingConfirmations = new Map();
|
|
20
|
+
this.intervalId = null;
|
|
21
|
+
this.connection = connection;
|
|
22
|
+
}
|
|
23
|
+
async confirmTransactionWebSocket(txSig, timeout = 30000, desiredConfirmationStatus = config_1.DEFAULT_CONFIRMATION_OPTS.commitment) {
|
|
24
|
+
const start = Date.now();
|
|
25
|
+
const subscriptionCommitment = desiredConfirmationStatus || config_1.DEFAULT_CONFIRMATION_OPTS.commitment;
|
|
26
|
+
let response = null;
|
|
27
|
+
let subscriptionId;
|
|
28
|
+
const confirmationPromise = new Promise((resolve, reject) => {
|
|
29
|
+
try {
|
|
30
|
+
subscriptionId = this.connection.onSignature(txSig, (result, context) => {
|
|
31
|
+
response = {
|
|
32
|
+
context,
|
|
33
|
+
value: result,
|
|
34
|
+
};
|
|
35
|
+
resolve(null);
|
|
36
|
+
}, subscriptionCommitment);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
reject(err);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
// We do a one-shot confirmation check just in case the transaction is ALREADY confirmed when we create the websocket confirmation .. We want to run this concurrently with the onSignature subscription. If this returns true then we can return early as the transaction has already been confirmed.
|
|
43
|
+
const oneShotConfirmationPromise = this.connection.getSignatureStatuses([
|
|
44
|
+
txSig,
|
|
45
|
+
]);
|
|
46
|
+
const resolveReference = {};
|
|
47
|
+
// This is the promise we are waiting on to resolve the overall confirmation. It will resolve the faster of a positive oneShot confirmation, or the websocket confirmation, or the timeout.
|
|
48
|
+
const overallWaitingForConfirmationPromise = new Promise((resolve) => {
|
|
49
|
+
resolveReference.resolve = resolve;
|
|
50
|
+
});
|
|
51
|
+
// Await for the one shot confirmation and resolve the waiting promise if we get a positive confirmation result
|
|
52
|
+
oneShotConfirmationPromise.then(async (oneShotResponse) => {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
if (!oneShotResponse || !((_a = oneShotResponse === null || oneShotResponse === void 0 ? void 0 : oneShotResponse.value) === null || _a === void 0 ? void 0 : _a[0]))
|
|
55
|
+
return;
|
|
56
|
+
const resultValue = oneShotResponse.value[0];
|
|
57
|
+
if (resultValue.err) {
|
|
58
|
+
await (0, reportTransactionError_1.throwTransactionError)(txSig, this.connection);
|
|
59
|
+
}
|
|
60
|
+
if (this.checkStatusMatchesDesiredConfirmationStatus(resultValue, desiredConfirmationStatus)) {
|
|
61
|
+
response = {
|
|
62
|
+
context: oneShotResponse.context,
|
|
63
|
+
value: oneShotResponse.value[0],
|
|
64
|
+
};
|
|
65
|
+
(_b = resolveReference.resolve) === null || _b === void 0 ? void 0 : _b.call(resolveReference);
|
|
66
|
+
}
|
|
67
|
+
}, (onRejected) => {
|
|
68
|
+
throw onRejected;
|
|
69
|
+
});
|
|
70
|
+
// Await for the websocket confirmation with the configured timeout
|
|
71
|
+
(0, promiseTimeout_1.promiseTimeout)(confirmationPromise, timeout).then(() => {
|
|
72
|
+
var _a;
|
|
73
|
+
(_a = resolveReference.resolve) === null || _a === void 0 ? void 0 : _a.call(resolveReference);
|
|
74
|
+
}, (onRejected) => {
|
|
75
|
+
throw onRejected;
|
|
76
|
+
});
|
|
77
|
+
try {
|
|
78
|
+
await overallWaitingForConfirmationPromise;
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
if (subscriptionId !== undefined) {
|
|
82
|
+
this.connection.removeSignatureListener(subscriptionId);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const duration = (Date.now() - start) / 1000;
|
|
86
|
+
if (response === null) {
|
|
87
|
+
throw new __1.TxSendError(`Transaction was not confirmed in ${duration.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${txSig} using the Solana Explorer or CLI tools.`, txConstants_1.NOT_CONFIRMED_ERROR_CODE);
|
|
88
|
+
}
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
async confirmTransactionPolling(txSig, desiredConfirmationStatus = config_1.DEFAULT_CONFIRMATION_OPTS.commitment, timeout = 30000, pollInterval = 1000, searchTransactionHistory = false) {
|
|
92
|
+
// Interval must be > 400ms and a multiple of 100ms
|
|
93
|
+
if (pollInterval < 400 || pollInterval % 100 !== 0) {
|
|
94
|
+
throw new Error('Transaction confirmation polling interval must be at least 400ms and a multiple of 100ms');
|
|
95
|
+
}
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
this.pendingConfirmations.set(txSig, {
|
|
98
|
+
txSig,
|
|
99
|
+
desiredConfirmationStatus,
|
|
100
|
+
timeout,
|
|
101
|
+
pollInterval,
|
|
102
|
+
searchTransactionHistory,
|
|
103
|
+
startTime: Date.now(),
|
|
104
|
+
resolve,
|
|
105
|
+
reject,
|
|
106
|
+
});
|
|
107
|
+
if (!this.intervalId) {
|
|
108
|
+
this.startConfirmationLoop();
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
startConfirmationLoop() {
|
|
113
|
+
this.intervalId = setInterval(() => this.checkPendingConfirmations(), 100);
|
|
114
|
+
}
|
|
115
|
+
async checkPendingConfirmations() {
|
|
116
|
+
const now = Date.now();
|
|
117
|
+
const transactionsToCheck = [];
|
|
118
|
+
for (const [txSig, request] of this.pendingConfirmations.entries()) {
|
|
119
|
+
if (now - request.startTime >= request.timeout) {
|
|
120
|
+
request.reject(new Error(`Transaction confirmation timeout after ${request.timeout}ms`));
|
|
121
|
+
this.pendingConfirmations.delete(txSig);
|
|
122
|
+
}
|
|
123
|
+
else if ((now - request.startTime) % request.pollInterval < 100) {
|
|
124
|
+
transactionsToCheck.push(request);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (transactionsToCheck.length > 0) {
|
|
128
|
+
await this.checkTransactionStatuses(transactionsToCheck);
|
|
129
|
+
}
|
|
130
|
+
if (this.pendingConfirmations.size === 0 && this.intervalId) {
|
|
131
|
+
clearInterval(this.intervalId);
|
|
132
|
+
this.intervalId = null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
checkStatusMatchesDesiredConfirmationStatus(status, desiredConfirmationStatus) {
|
|
136
|
+
if (status.confirmationStatus &&
|
|
137
|
+
confirmationStatusValues[status.confirmationStatus] >=
|
|
138
|
+
confirmationStatusValues[desiredConfirmationStatus]) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
async checkTransactionStatuses(requests) {
|
|
144
|
+
const txSigs = requests.map((request) => request.txSig);
|
|
145
|
+
const { value: statuses } = await this.connection.getSignatureStatuses(txSigs, {
|
|
146
|
+
searchTransactionHistory: requests.some((req) => req.searchTransactionHistory),
|
|
147
|
+
});
|
|
148
|
+
if (!statuses || statuses.length !== txSigs.length) {
|
|
149
|
+
throw new Error('Failed to get signature statuses');
|
|
150
|
+
}
|
|
151
|
+
for (let i = 0; i < statuses.length; i++) {
|
|
152
|
+
const status = statuses[i];
|
|
153
|
+
const request = requests[i];
|
|
154
|
+
if (status === null) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (status.err) {
|
|
158
|
+
this.pendingConfirmations.delete(request.txSig);
|
|
159
|
+
request.reject(await (0, reportTransactionError_1.getTransactionErrorFromTxSig)(request.txSig, this.connection));
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (confirmationStatusValues[status.confirmationStatus] === undefined ||
|
|
163
|
+
confirmationStatusValues[request.desiredConfirmationStatus] ===
|
|
164
|
+
undefined) {
|
|
165
|
+
throw new Error(`Invalid confirmation status when awaiting confirmation: ${status.confirmationStatus}`);
|
|
166
|
+
}
|
|
167
|
+
if (this.checkStatusMatchesDesiredConfirmationStatus(status, request.desiredConfirmationStatus)) {
|
|
168
|
+
request.resolve(status);
|
|
169
|
+
this.pendingConfirmations.delete(request.txSig);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.TransactionConfirmationManager = TransactionConfirmationManager;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Commitment } from '@solana/web3.js';
|
|
2
|
+
export type ChainClockProgress = {
|
|
3
|
+
blockHeight?: number;
|
|
4
|
+
slot?: number;
|
|
5
|
+
ts?: number;
|
|
6
|
+
};
|
|
7
|
+
export type ChainClockUpdateProps = {
|
|
8
|
+
commitment: Commitment;
|
|
9
|
+
} & ChainClockProgress;
|
|
10
|
+
export type ChainClockState = Map<Commitment, ChainClockProgress>;
|
|
11
|
+
export type ChainClickInitialisationProps = ChainClockUpdateProps[];
|
|
12
|
+
export declare class ChainClock {
|
|
13
|
+
private _state;
|
|
14
|
+
constructor(props: ChainClickInitialisationProps);
|
|
15
|
+
update(props: ChainClockUpdateProps): void;
|
|
16
|
+
getState(commitment: Commitment): ChainClockProgress;
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChainClock = void 0;
|
|
4
|
+
class ChainClock {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
this._state = new Map();
|
|
7
|
+
props.forEach((prop) => {
|
|
8
|
+
this._state.set(prop.commitment, prop);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
update(props) {
|
|
12
|
+
const state = this._state.get(props.commitment);
|
|
13
|
+
if (state) {
|
|
14
|
+
if (props.blockHeight)
|
|
15
|
+
state.blockHeight = props.blockHeight;
|
|
16
|
+
if (props.slot)
|
|
17
|
+
state.slot = props.slot;
|
|
18
|
+
if (props.ts)
|
|
19
|
+
state.ts = props.ts;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this._state.set(props.commitment, props);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
getState(commitment) {
|
|
26
|
+
return this._state.get(commitment);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.ChainClock = ChainClock;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Connection, Finality, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
export declare function findComputeUnitConsumption(programId: PublicKey, connection: Connection, txSignature: string, commitment?: Finality): Promise<number[]>;
|
|
3
|
+
export declare function isSetComputeUnitsIx(ix: TransactionInstruction): boolean;
|
|
4
|
+
export declare function isSetComputeUnitPriceIx(ix: TransactionInstruction): boolean;
|
|
5
|
+
export declare function containsComputeUnitIxs(ixs: TransactionInstruction[]): {
|
|
6
|
+
hasSetComputeUnitLimitIx: boolean;
|
|
7
|
+
hasSetComputeUnitPriceIx: boolean;
|
|
8
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.containsComputeUnitIxs = exports.isSetComputeUnitPriceIx = exports.isSetComputeUnitsIx = exports.findComputeUnitConsumption = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
async function findComputeUnitConsumption(programId, connection, txSignature, commitment = 'confirmed') {
|
|
6
|
+
const tx = await connection.getTransaction(txSignature, { commitment });
|
|
7
|
+
const computeUnits = [];
|
|
8
|
+
const regex = new RegExp(`Program ${programId.toString()} consumed ([0-9]{0,6}) of ([0-9]{0,7}) compute units`);
|
|
9
|
+
tx.meta.logMessages.forEach((logMessage) => {
|
|
10
|
+
const match = logMessage.match(regex);
|
|
11
|
+
if (match && match[1]) {
|
|
12
|
+
computeUnits.push(match[1]);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return computeUnits;
|
|
16
|
+
}
|
|
17
|
+
exports.findComputeUnitConsumption = findComputeUnitConsumption;
|
|
18
|
+
function isSetComputeUnitsIx(ix) {
|
|
19
|
+
// Compute budget program discriminator is first byte
|
|
20
|
+
// 2: set compute unit limit
|
|
21
|
+
// 3: set compute unit price
|
|
22
|
+
if (ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId) &&
|
|
23
|
+
ix.data.at(0) === 2) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
exports.isSetComputeUnitsIx = isSetComputeUnitsIx;
|
|
29
|
+
function isSetComputeUnitPriceIx(ix) {
|
|
30
|
+
// Compute budget program discriminator is first byte
|
|
31
|
+
// 2: set compute unit limit
|
|
32
|
+
// 3: set compute unit price
|
|
33
|
+
if (ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId) &&
|
|
34
|
+
ix.data.at(0) === 3) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
exports.isSetComputeUnitPriceIx = isSetComputeUnitPriceIx;
|
|
40
|
+
function containsComputeUnitIxs(ixs) {
|
|
41
|
+
return {
|
|
42
|
+
hasSetComputeUnitLimitIx: ixs.some(isSetComputeUnitsIx),
|
|
43
|
+
hasSetComputeUnitPriceIx: ixs.some(isSetComputeUnitPriceIx),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.containsComputeUnitIxs = containsComputeUnitIxs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function promiseTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T | null>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promiseTimeout = void 0;
|
|
4
|
+
function promiseTimeout(promise, timeoutMs) {
|
|
5
|
+
let timeoutId;
|
|
6
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
7
|
+
timeoutId = setTimeout(() => resolve(null), timeoutMs);
|
|
8
|
+
});
|
|
9
|
+
return Promise.race([promise, timeoutPromise]).then((result) => {
|
|
10
|
+
clearTimeout(timeoutId);
|
|
11
|
+
return result;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.promiseTimeout = promiseTimeout;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFeedIdUint8Array = exports.trimFeedId = void 0;
|
|
4
|
+
function trimFeedId(feedId) {
|
|
5
|
+
if (feedId.startsWith('0x')) {
|
|
6
|
+
return feedId.slice(2);
|
|
7
|
+
}
|
|
8
|
+
return feedId;
|
|
9
|
+
}
|
|
10
|
+
exports.trimFeedId = trimFeedId;
|
|
11
|
+
function getFeedIdUint8Array(feedId) {
|
|
12
|
+
const trimmedFeedId = trimFeedId(feedId);
|
|
13
|
+
return Uint8Array.from(Buffer.from(trimmedFeedId, 'hex'));
|
|
14
|
+
}
|
|
15
|
+
exports.getFeedIdUint8Array = getFeedIdUint8Array;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.estimateTps = void 0;
|
|
4
|
+
async function estimateTps(programId, connection, failed) {
|
|
5
|
+
let signatures = await connection.getSignaturesForAddress(programId, undefined, 'finalized');
|
|
6
|
+
if (failed) {
|
|
7
|
+
signatures = signatures.filter((signature) => signature.err);
|
|
8
|
+
}
|
|
9
|
+
const numberOfSignatures = signatures.length;
|
|
10
|
+
if (numberOfSignatures === 0) {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
return (numberOfSignatures /
|
|
14
|
+
(signatures[0].blockTime - signatures[numberOfSignatures - 1].blockTime));
|
|
15
|
+
}
|
|
16
|
+
exports.estimateTps = estimateTps;
|