@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,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SerumSubscriber = void 0;
|
|
4
|
+
const serum_1 = require("@project-serum/serum");
|
|
5
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
6
|
+
const numericConstants_1 = require("../constants/numericConstants");
|
|
7
|
+
class SerumSubscriber {
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.connection = config.connection;
|
|
10
|
+
this.programId = config.programId;
|
|
11
|
+
this.marketAddress = config.marketAddress;
|
|
12
|
+
if (config.accountSubscription.type === 'polling') {
|
|
13
|
+
this.subscriptionType = 'polling';
|
|
14
|
+
this.accountLoader = config.accountSubscription.accountLoader;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
this.subscriptionType = 'websocket';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async subscribe() {
|
|
21
|
+
if (this.subscribed) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.market = await serum_1.Market.load(this.connection, this.marketAddress, undefined, this.programId);
|
|
25
|
+
this.asksAddress = this.market.asksAddress;
|
|
26
|
+
this.asks = await this.market.loadAsks(this.connection);
|
|
27
|
+
if (this.subscriptionType === 'websocket') {
|
|
28
|
+
this.asksCallbackId = this.connection.onAccountChange(this.asksAddress, (accountInfo, ctx) => {
|
|
29
|
+
this.lastAsksSlot = ctx.slot;
|
|
30
|
+
this.asks = serum_1.Orderbook.decode(this.market, accountInfo.data);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.asksCallbackId = await this.accountLoader.addAccount(this.asksAddress, (buffer, slot) => {
|
|
35
|
+
this.lastAsksSlot = slot;
|
|
36
|
+
this.asks = serum_1.Orderbook.decode(this.market, buffer);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
this.bidsAddress = this.market.bidsAddress;
|
|
40
|
+
this.bids = await this.market.loadBids(this.connection);
|
|
41
|
+
if (this.subscriptionType === 'websocket') {
|
|
42
|
+
this.bidsCallbackId = this.connection.onAccountChange(this.bidsAddress, (accountInfo, ctx) => {
|
|
43
|
+
this.lastBidsSlot = ctx.slot;
|
|
44
|
+
this.bids = serum_1.Orderbook.decode(this.market, accountInfo.data);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.bidsCallbackId = await this.accountLoader.addAccount(this.bidsAddress, (buffer, slot) => {
|
|
49
|
+
this.lastBidsSlot = slot;
|
|
50
|
+
this.bids = serum_1.Orderbook.decode(this.market, buffer);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
this.subscribed = true;
|
|
54
|
+
}
|
|
55
|
+
getBestBid() {
|
|
56
|
+
const bestBid = this.bids.getL2(1)[0];
|
|
57
|
+
if (!bestBid) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return new anchor_1.BN(bestBid[0] * numericConstants_1.PRICE_PRECISION.toNumber());
|
|
61
|
+
}
|
|
62
|
+
getBestAsk() {
|
|
63
|
+
const bestAsk = this.asks.getL2(1)[0];
|
|
64
|
+
if (!bestAsk) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return new anchor_1.BN(bestAsk[0] * numericConstants_1.PRICE_PRECISION.toNumber());
|
|
68
|
+
}
|
|
69
|
+
getL2Bids() {
|
|
70
|
+
return this.getL2Levels('bids');
|
|
71
|
+
}
|
|
72
|
+
getL2Asks() {
|
|
73
|
+
return this.getL2Levels('asks');
|
|
74
|
+
}
|
|
75
|
+
*getL2Levels(side) {
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
const basePrecision = Math.pow(10, this.market._baseSplTokenDecimals);
|
|
78
|
+
const pricePrecision = numericConstants_1.PRICE_PRECISION.toNumber();
|
|
79
|
+
for (const { price: priceNum, size: sizeNum } of this[side].items(side === 'bids')) {
|
|
80
|
+
const price = new anchor_1.BN(priceNum * pricePrecision);
|
|
81
|
+
const size = new anchor_1.BN(sizeNum * basePrecision);
|
|
82
|
+
yield {
|
|
83
|
+
price,
|
|
84
|
+
size,
|
|
85
|
+
sources: {
|
|
86
|
+
serum: size,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async unsubscribe() {
|
|
92
|
+
if (!this.subscribed) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// remove listeners
|
|
96
|
+
if (this.subscriptionType === 'websocket') {
|
|
97
|
+
await this.connection.removeAccountChangeListener(this.asksCallbackId);
|
|
98
|
+
await this.connection.removeAccountChangeListener(this.bidsCallbackId);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.accountLoader.removeAccount(this.asksAddress, this.asksCallbackId);
|
|
102
|
+
this.accountLoader.removeAccount(this.bidsAddress, this.bidsCallbackId);
|
|
103
|
+
}
|
|
104
|
+
this.subscribed = false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.SerumSubscriber = SerumSubscriber;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { BulkAccountLoader } from '../accounts/bulkAccountLoader';
|
|
3
|
+
export type SerumMarketSubscriberConfig = {
|
|
4
|
+
connection: Connection;
|
|
5
|
+
programId: PublicKey;
|
|
6
|
+
marketAddress: PublicKey;
|
|
7
|
+
accountSubscription: {
|
|
8
|
+
type: 'polling';
|
|
9
|
+
accountLoader: BulkAccountLoader;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'websocket';
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Connection } from '@solana/web3.js';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
import StrictEventEmitter from 'strict-event-emitter-types/types/src';
|
|
6
|
+
type SlotSubscriberConfig = {
|
|
7
|
+
resubTimeoutMs?: number;
|
|
8
|
+
};
|
|
9
|
+
export interface SlotSubscriberEvents {
|
|
10
|
+
newSlot: (newSlot: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare class SlotSubscriber {
|
|
13
|
+
private connection;
|
|
14
|
+
currentSlot: number;
|
|
15
|
+
subscriptionId: number;
|
|
16
|
+
eventEmitter: StrictEventEmitter<EventEmitter, SlotSubscriberEvents>;
|
|
17
|
+
timeoutId?: NodeJS.Timeout;
|
|
18
|
+
resubTimeoutMs?: number;
|
|
19
|
+
isUnsubscribing: boolean;
|
|
20
|
+
receivingData: boolean;
|
|
21
|
+
constructor(connection: Connection, config?: SlotSubscriberConfig);
|
|
22
|
+
subscribe(): Promise<void>;
|
|
23
|
+
private setTimeout;
|
|
24
|
+
getSlot(): number;
|
|
25
|
+
unsubscribe(onResub?: boolean): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlotSubscriber = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
class SlotSubscriber {
|
|
6
|
+
constructor(connection, config) {
|
|
7
|
+
this.connection = connection;
|
|
8
|
+
this.isUnsubscribing = false;
|
|
9
|
+
this.receivingData = false;
|
|
10
|
+
this.eventEmitter = new events_1.EventEmitter();
|
|
11
|
+
this.resubTimeoutMs = config === null || config === void 0 ? void 0 : config.resubTimeoutMs;
|
|
12
|
+
if (this.resubTimeoutMs < 1000) {
|
|
13
|
+
console.log('resubTimeoutMs should be at least 1000ms to avoid spamming resub');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async subscribe() {
|
|
17
|
+
if (this.subscriptionId != null) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.currentSlot = await this.connection.getSlot('confirmed');
|
|
21
|
+
this.subscriptionId = this.connection.onSlotChange((slotInfo) => {
|
|
22
|
+
if (!this.currentSlot || this.currentSlot < slotInfo.slot) {
|
|
23
|
+
if (this.resubTimeoutMs && !this.isUnsubscribing) {
|
|
24
|
+
this.receivingData = true;
|
|
25
|
+
clearTimeout(this.timeoutId);
|
|
26
|
+
this.setTimeout();
|
|
27
|
+
}
|
|
28
|
+
this.currentSlot = slotInfo.slot;
|
|
29
|
+
this.eventEmitter.emit('newSlot', slotInfo.slot);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (this.resubTimeoutMs) {
|
|
33
|
+
this.receivingData = true;
|
|
34
|
+
this.setTimeout();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
setTimeout() {
|
|
38
|
+
this.timeoutId = setTimeout(async () => {
|
|
39
|
+
if (this.isUnsubscribing) {
|
|
40
|
+
// If we are in the process of unsubscribing, do not attempt to resubscribe
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (this.receivingData) {
|
|
44
|
+
console.log(`No new slot in ${this.resubTimeoutMs}ms, slot subscriber resubscribing`);
|
|
45
|
+
await this.unsubscribe(true);
|
|
46
|
+
this.receivingData = false;
|
|
47
|
+
await this.subscribe();
|
|
48
|
+
}
|
|
49
|
+
}, this.resubTimeoutMs);
|
|
50
|
+
}
|
|
51
|
+
getSlot() {
|
|
52
|
+
return this.currentSlot;
|
|
53
|
+
}
|
|
54
|
+
async unsubscribe(onResub = false) {
|
|
55
|
+
if (!onResub) {
|
|
56
|
+
this.resubTimeoutMs = undefined;
|
|
57
|
+
}
|
|
58
|
+
this.isUnsubscribing = true;
|
|
59
|
+
clearTimeout(this.timeoutId);
|
|
60
|
+
this.timeoutId = undefined;
|
|
61
|
+
if (this.subscriptionId != null) {
|
|
62
|
+
await this.connection.removeSlotChangeListener(this.subscriptionId);
|
|
63
|
+
this.subscriptionId = undefined;
|
|
64
|
+
this.isUnsubscribing = false;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.isUnsubscribing = false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.SlotSubscriber = SlotSubscriber;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Commitment, Connection } from '@solana/web3.js';
|
|
3
|
+
type SlothashSubscriberConfig = {
|
|
4
|
+
resubTimeoutMs?: number;
|
|
5
|
+
commitment?: Commitment;
|
|
6
|
+
};
|
|
7
|
+
export type Slothash = {
|
|
8
|
+
slot: number;
|
|
9
|
+
hash: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class SlothashSubscriber {
|
|
12
|
+
private connection;
|
|
13
|
+
currentSlothash: Slothash;
|
|
14
|
+
subscriptionId: number;
|
|
15
|
+
commitment: Commitment;
|
|
16
|
+
timeoutId?: NodeJS.Timeout;
|
|
17
|
+
resubTimeoutMs?: number;
|
|
18
|
+
isUnsubscribing: boolean;
|
|
19
|
+
receivingData: boolean;
|
|
20
|
+
constructor(connection: Connection, config?: SlothashSubscriberConfig);
|
|
21
|
+
subscribe(): Promise<void>;
|
|
22
|
+
private setTimeout;
|
|
23
|
+
getSlothash(): Slothash;
|
|
24
|
+
unsubscribe(onResub?: boolean): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlothashSubscriber = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
|
|
6
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
7
|
+
class SlothashSubscriber {
|
|
8
|
+
constructor(connection, config) {
|
|
9
|
+
var _a;
|
|
10
|
+
this.connection = connection;
|
|
11
|
+
this.isUnsubscribing = false;
|
|
12
|
+
this.receivingData = false;
|
|
13
|
+
this.resubTimeoutMs = config === null || config === void 0 ? void 0 : config.resubTimeoutMs;
|
|
14
|
+
this.commitment = (_a = config === null || config === void 0 ? void 0 : config.commitment) !== null && _a !== void 0 ? _a : 'processed';
|
|
15
|
+
if (this.resubTimeoutMs < 1000) {
|
|
16
|
+
console.log('resubTimeoutMs should be at least 1000ms to avoid spamming resub');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async subscribe() {
|
|
20
|
+
if (this.subscriptionId != null) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const currentAccountData = await this.connection.getAccountInfo(web3_js_1.SYSVAR_SLOT_HASHES_PUBKEY, this.commitment);
|
|
24
|
+
if (currentAccountData == null) {
|
|
25
|
+
throw new Error('Failed to retrieve current slot hash');
|
|
26
|
+
}
|
|
27
|
+
this.currentSlothash = deserializeSlothash(currentAccountData.data);
|
|
28
|
+
this.subscriptionId = this.connection.onAccountChange(web3_js_1.SYSVAR_SLOT_HASHES_PUBKEY, (slothashInfo, context) => {
|
|
29
|
+
if (!this.currentSlothash || this.currentSlothash.slot < context.slot) {
|
|
30
|
+
if (this.resubTimeoutMs && !this.isUnsubscribing) {
|
|
31
|
+
this.receivingData = true;
|
|
32
|
+
clearTimeout(this.timeoutId);
|
|
33
|
+
this.setTimeout();
|
|
34
|
+
}
|
|
35
|
+
this.currentSlothash = deserializeSlothash(slothashInfo.data);
|
|
36
|
+
}
|
|
37
|
+
}, this.commitment);
|
|
38
|
+
if (this.resubTimeoutMs) {
|
|
39
|
+
this.receivingData = true;
|
|
40
|
+
this.setTimeout();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
setTimeout() {
|
|
44
|
+
this.timeoutId = setTimeout(async () => {
|
|
45
|
+
if (this.isUnsubscribing) {
|
|
46
|
+
// If we are in the process of unsubscribing, do not attempt to resubscribe
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (this.receivingData) {
|
|
50
|
+
console.log(`No new slot in ${this.resubTimeoutMs}ms, slot subscriber resubscribing`);
|
|
51
|
+
await this.unsubscribe(true);
|
|
52
|
+
this.receivingData = false;
|
|
53
|
+
await this.subscribe();
|
|
54
|
+
}
|
|
55
|
+
}, this.resubTimeoutMs);
|
|
56
|
+
}
|
|
57
|
+
getSlothash() {
|
|
58
|
+
return this.currentSlothash;
|
|
59
|
+
}
|
|
60
|
+
async unsubscribe(onResub = false) {
|
|
61
|
+
if (!onResub) {
|
|
62
|
+
this.resubTimeoutMs = undefined;
|
|
63
|
+
}
|
|
64
|
+
this.isUnsubscribing = true;
|
|
65
|
+
clearTimeout(this.timeoutId);
|
|
66
|
+
this.timeoutId = undefined;
|
|
67
|
+
if (this.subscriptionId != null) {
|
|
68
|
+
await this.connection.removeSlotChangeListener(this.subscriptionId);
|
|
69
|
+
this.subscriptionId = undefined;
|
|
70
|
+
this.isUnsubscribing = false;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.isUnsubscribing = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.SlothashSubscriber = SlothashSubscriber;
|
|
78
|
+
function deserializeSlothash(data) {
|
|
79
|
+
const slotNumber = new anchor_1.BN(data.subarray(8, 16), 10, 'le');
|
|
80
|
+
const hash = bytes_1.bs58.encode(data.subarray(16, 48));
|
|
81
|
+
return {
|
|
82
|
+
slot: slotNumber.toNumber(),
|
|
83
|
+
hash,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AdminClient } from './adminClient';
|
|
2
|
+
import { ConfirmOptions, Signer, Transaction } from '@solana/web3.js';
|
|
3
|
+
import { TxSigAndSlot } from './tx/types';
|
|
4
|
+
import { DriftClientConfig } from './driftClientConfig';
|
|
5
|
+
export declare class TestClient extends AdminClient {
|
|
6
|
+
constructor(config: DriftClientConfig);
|
|
7
|
+
sendTransaction(tx: Transaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestClient = void 0;
|
|
4
|
+
const adminClient_1 = require("./adminClient");
|
|
5
|
+
class TestClient extends adminClient_1.AdminClient {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
if (config.accountSubscription.type !== 'polling') {
|
|
8
|
+
throw new Error('Test client must be polling');
|
|
9
|
+
}
|
|
10
|
+
super(config);
|
|
11
|
+
}
|
|
12
|
+
async sendTransaction(tx, additionalSigners, opts, preSigned) {
|
|
13
|
+
const { txSig, slot } = await super.sendTransaction(tx, additionalSigners, opts, preSigned);
|
|
14
|
+
let lastFetchedSlot = this.accountSubscriber.accountLoader.mostRecentSlot;
|
|
15
|
+
await this.fetchAccounts();
|
|
16
|
+
while (lastFetchedSlot < slot) {
|
|
17
|
+
await this.fetchAccounts();
|
|
18
|
+
lastFetchedSlot = this.accountSubscriber.accountLoader.mostRecentSlot;
|
|
19
|
+
}
|
|
20
|
+
return { txSig, slot };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.TestClient = TestClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTokenAccount = void 0;
|
|
4
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
5
|
+
function parseTokenAccount(data, pubkey) {
|
|
6
|
+
// mock AccountInfo so unpackAccount can be used
|
|
7
|
+
const accountInfo = {
|
|
8
|
+
data,
|
|
9
|
+
owner: spl_token_1.TOKEN_PROGRAM_ID,
|
|
10
|
+
executable: false,
|
|
11
|
+
lamports: 0,
|
|
12
|
+
};
|
|
13
|
+
return (0, spl_token_1.unpackAccount)(pubkey, accountInfo, spl_token_1.TOKEN_PROGRAM_ID);
|
|
14
|
+
}
|
|
15
|
+
exports.parseTokenAccount = parseTokenAccount;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import * as anchor from '@coral-xyz/anchor';
|
|
3
|
+
import { AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
4
|
+
import { Account } from '@solana/spl-token';
|
|
5
|
+
import { ConfirmOptions, Connection, PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
|
|
6
|
+
import { BN } from '.';
|
|
7
|
+
import { IWallet } from './types';
|
|
8
|
+
import { BankrunContextWrapper } from './bankrun/bankrunConnection';
|
|
9
|
+
export declare class TokenFaucet {
|
|
10
|
+
context?: BankrunContextWrapper;
|
|
11
|
+
connection: Connection;
|
|
12
|
+
wallet: IWallet;
|
|
13
|
+
program: Program;
|
|
14
|
+
provider: AnchorProvider;
|
|
15
|
+
mint: PublicKey;
|
|
16
|
+
opts?: ConfirmOptions;
|
|
17
|
+
constructor(connection: Connection, wallet: IWallet, programId: PublicKey, mint: PublicKey, opts?: ConfirmOptions, context?: BankrunContextWrapper);
|
|
18
|
+
getFaucetConfigPublicKeyAndNonce(): Promise<[
|
|
19
|
+
PublicKey,
|
|
20
|
+
number
|
|
21
|
+
]>;
|
|
22
|
+
getMintAuthority(): Promise<PublicKey>;
|
|
23
|
+
getFaucetConfigPublicKey(): Promise<PublicKey>;
|
|
24
|
+
initialize(): Promise<TransactionSignature>;
|
|
25
|
+
fetchState(): Promise<any>;
|
|
26
|
+
private mintToUserIx;
|
|
27
|
+
mintToUser(userTokenAccount: PublicKey, amount: BN): Promise<TransactionSignature>;
|
|
28
|
+
transferMintAuthority(): Promise<TransactionSignature>;
|
|
29
|
+
createAssociatedTokenAccountAndMintTo(userPublicKey: PublicKey, amount: BN): Promise<[PublicKey, TransactionSignature]>;
|
|
30
|
+
createAssociatedTokenAccountAndMintToInstructions(userPublicKey: PublicKey, amount: BN): Promise<[PublicKey, TransactionInstruction, TransactionInstruction]>;
|
|
31
|
+
getAssosciatedMockUSDMintAddress(props: {
|
|
32
|
+
userPubKey: PublicKey;
|
|
33
|
+
}): Promise<anchor.web3.PublicKey>;
|
|
34
|
+
getTokenAccountInfo(props: {
|
|
35
|
+
userPubKey: PublicKey;
|
|
36
|
+
}): Promise<Account>;
|
|
37
|
+
subscribeToTokenAccount(props: {
|
|
38
|
+
userPubKey: PublicKey;
|
|
39
|
+
callback: (accountInfo: Account) => void;
|
|
40
|
+
}): Promise<boolean>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.TokenFaucet = void 0;
|
|
30
|
+
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
31
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
32
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
33
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
34
|
+
const _1 = require(".");
|
|
35
|
+
const token_faucet_json_1 = __importDefault(require("./idl/token_faucet.json"));
|
|
36
|
+
class TokenFaucet {
|
|
37
|
+
constructor(connection, wallet, programId, mint, opts, context) {
|
|
38
|
+
this.connection = connection;
|
|
39
|
+
this.context = context;
|
|
40
|
+
this.wallet = wallet;
|
|
41
|
+
this.opts = opts || _1.DEFAULT_CONFIRMATION_OPTS;
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
const provider = new anchor_1.AnchorProvider(context ? context.connection.toConnection() : this.connection,
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
wallet, this.opts);
|
|
46
|
+
this.provider = provider;
|
|
47
|
+
this.program = new anchor_1.Program(token_faucet_json_1.default, programId, provider);
|
|
48
|
+
this.mint = mint;
|
|
49
|
+
}
|
|
50
|
+
async getFaucetConfigPublicKeyAndNonce() {
|
|
51
|
+
return anchor.web3.PublicKey.findProgramAddress([
|
|
52
|
+
Buffer.from(anchor.utils.bytes.utf8.encode('faucet_config')),
|
|
53
|
+
this.mint.toBuffer(),
|
|
54
|
+
], this.program.programId);
|
|
55
|
+
}
|
|
56
|
+
async getMintAuthority() {
|
|
57
|
+
return (await anchor.web3.PublicKey.findProgramAddress([
|
|
58
|
+
Buffer.from(anchor.utils.bytes.utf8.encode('mint_authority')),
|
|
59
|
+
this.mint.toBuffer(),
|
|
60
|
+
], this.program.programId))[0];
|
|
61
|
+
}
|
|
62
|
+
async getFaucetConfigPublicKey() {
|
|
63
|
+
return (await this.getFaucetConfigPublicKeyAndNonce())[0];
|
|
64
|
+
}
|
|
65
|
+
async initialize() {
|
|
66
|
+
const [faucetConfigPublicKey] = await this.getFaucetConfigPublicKeyAndNonce();
|
|
67
|
+
const ix = this.program.instruction.initialize({
|
|
68
|
+
accounts: {
|
|
69
|
+
faucetConfig: faucetConfigPublicKey,
|
|
70
|
+
admin: this.wallet.publicKey,
|
|
71
|
+
mintAccount: this.mint,
|
|
72
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
73
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
74
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
const tx = new web3_js_1.Transaction().add(ix);
|
|
78
|
+
const txSig = await this.context.sendTransaction(tx);
|
|
79
|
+
return txSig;
|
|
80
|
+
}
|
|
81
|
+
async fetchState() {
|
|
82
|
+
return await this.program.account.faucetConfig.fetch(await this.getFaucetConfigPublicKey());
|
|
83
|
+
}
|
|
84
|
+
async mintToUserIx(userTokenAccount, amount) {
|
|
85
|
+
return this.program.instruction.mintToUser(amount, {
|
|
86
|
+
accounts: {
|
|
87
|
+
faucetConfig: await this.getFaucetConfigPublicKey(),
|
|
88
|
+
mintAccount: this.mint,
|
|
89
|
+
userTokenAccount,
|
|
90
|
+
mintAuthority: await this.getMintAuthority(),
|
|
91
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async mintToUser(userTokenAccount, amount) {
|
|
96
|
+
const mintIx = await this.mintToUserIx(userTokenAccount, amount);
|
|
97
|
+
const tx = new web3_js_1.Transaction().add(mintIx);
|
|
98
|
+
if (this.context) {
|
|
99
|
+
return await this.context.sendTransaction(tx);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return await this.program.provider.sendAndConfirm(tx, [], this.opts);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async transferMintAuthority() {
|
|
106
|
+
if (this.context) {
|
|
107
|
+
const ix = this.program.instruction.transferMintAuthority({
|
|
108
|
+
accounts: {
|
|
109
|
+
faucetConfig: await this.getFaucetConfigPublicKey(),
|
|
110
|
+
mintAccount: this.mint,
|
|
111
|
+
mintAuthority: await this.getMintAuthority(),
|
|
112
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
113
|
+
admin: this.wallet.publicKey,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
const tx = new web3_js_1.Transaction().add(ix);
|
|
117
|
+
const txSig = await this.context.sendTransaction(tx);
|
|
118
|
+
return txSig;
|
|
119
|
+
}
|
|
120
|
+
return await this.program.rpc.transferMintAuthority({
|
|
121
|
+
accounts: {
|
|
122
|
+
faucetConfig: await this.getFaucetConfigPublicKey(),
|
|
123
|
+
mintAccount: this.mint,
|
|
124
|
+
mintAuthority: await this.getMintAuthority(),
|
|
125
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
126
|
+
admin: this.wallet.publicKey,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async createAssociatedTokenAccountAndMintTo(userPublicKey, amount) {
|
|
131
|
+
const tx = new web3_js_1.Transaction();
|
|
132
|
+
const [associatedTokenPublicKey, createAssociatedAccountIx, mintToTx] = await this.createAssociatedTokenAccountAndMintToInstructions(userPublicKey, amount);
|
|
133
|
+
let associatedTokenAccountExists = false;
|
|
134
|
+
try {
|
|
135
|
+
const assosciatedTokenAccount = await this.context.connection.getAccountInfo(associatedTokenPublicKey);
|
|
136
|
+
associatedTokenAccountExists = !!assosciatedTokenAccount;
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
// token account doesn't exist
|
|
140
|
+
associatedTokenAccountExists = false;
|
|
141
|
+
}
|
|
142
|
+
const skipAccountCreation = associatedTokenAccountExists;
|
|
143
|
+
if (!skipAccountCreation)
|
|
144
|
+
tx.add(createAssociatedAccountIx);
|
|
145
|
+
tx.add(mintToTx);
|
|
146
|
+
let txSig;
|
|
147
|
+
if (this.context) {
|
|
148
|
+
txSig = await this.context.sendTransaction(tx);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
txSig = await this.program.provider.sendAndConfirm(tx, [], this.opts);
|
|
152
|
+
}
|
|
153
|
+
return [associatedTokenPublicKey, txSig];
|
|
154
|
+
}
|
|
155
|
+
async createAssociatedTokenAccountAndMintToInstructions(userPublicKey, amount) {
|
|
156
|
+
const state = await this.fetchState();
|
|
157
|
+
const associateTokenPublicKey = await this.getAssosciatedMockUSDMintAddress({ userPubKey: userPublicKey });
|
|
158
|
+
const createAssociatedAccountIx = (0, spl_token_1.createAssociatedTokenAccountInstruction)(this.wallet.publicKey, associateTokenPublicKey, userPublicKey, state.mint);
|
|
159
|
+
const mintToIx = await this.mintToUserIx(associateTokenPublicKey, amount);
|
|
160
|
+
return [associateTokenPublicKey, createAssociatedAccountIx, mintToIx];
|
|
161
|
+
}
|
|
162
|
+
async getAssosciatedMockUSDMintAddress(props) {
|
|
163
|
+
const state = await this.fetchState();
|
|
164
|
+
return (0, spl_token_1.getAssociatedTokenAddress)(state.mint, props.userPubKey);
|
|
165
|
+
}
|
|
166
|
+
async getTokenAccountInfo(props) {
|
|
167
|
+
const associatedKey = await this.getAssosciatedMockUSDMintAddress(props);
|
|
168
|
+
if (this.context) {
|
|
169
|
+
return await this.context.connection.getTokenAccount(associatedKey);
|
|
170
|
+
}
|
|
171
|
+
return await (0, spl_token_1.getAccount)(this.connection, associatedKey);
|
|
172
|
+
}
|
|
173
|
+
async subscribeToTokenAccount(props) {
|
|
174
|
+
try {
|
|
175
|
+
const tokenAccountKey = await this.getAssosciatedMockUSDMintAddress(props);
|
|
176
|
+
props.callback(await this.getTokenAccountInfo(props));
|
|
177
|
+
// Couldn't find a way to do it using anchor framework subscription, someone on serum discord recommended this way
|
|
178
|
+
this.context.connection.onAccountChange(tokenAccountKey, async (_accountInfo /* accountInfo is a buffer which we don't know how to deserialize */) => {
|
|
179
|
+
props.callback(await this.getTokenAccountInfo(props));
|
|
180
|
+
});
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.TokenFaucet = TokenFaucet;
|