@drift-labs/sdk-browser 2.162.0-beta.2 → 2.163.0-beta.9
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/.prettierignore +1 -0
- package/.yarn/install-state.gz +0 -0
- package/README.md +2 -2
- package/VERSION +1 -1
- package/bun.lock +47 -79
- package/lib/browser/accounts/fetch.d.ts +6 -6
- package/lib/browser/accounts/fetch.js +4 -4
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcDriftClientAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.js +2 -2
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.js +2 -2
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +1 -1
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +2 -2
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +1 -1
- package/lib/browser/accounts/testBulkAccountLoader.js +3 -5
- package/lib/browser/accounts/types.d.ts +11 -14
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketAccountSubscriber.js +1 -2
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +5 -5
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.js +2 -2
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriberV2.js +2 -2
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +3 -3
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +2 -2
- package/lib/browser/addresses/pda.d.ts +6 -2
- package/lib/browser/addresses/pda.js +7 -12
- package/lib/browser/adminClient.d.ts +11 -9
- package/lib/browser/adminClient.js +30 -72
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
- package/lib/browser/config.d.ts +7 -3
- package/lib/browser/config.js +9 -7
- package/lib/browser/constants/index.d.ts +5 -0
- package/lib/browser/constants/index.js +5 -0
- package/lib/browser/constants/numericConstants.d.ts +1 -1
- package/lib/browser/constants/numericConstants.js +3 -3
- package/lib/browser/constants/perpMarkets.js +3 -412
- package/lib/browser/constants/spotMarkets.js +7 -91
- package/lib/browser/constituentMap/constituentMap.js +2 -2
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.d.ts +3 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +3 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +1 -1
- package/lib/browser/decode/customCoder.d.ts +7 -9
- package/lib/browser/decode/customCoder.js +17 -28
- package/lib/browser/decode/user.js +7 -25
- package/lib/browser/dlob/DLOB.d.ts +12 -0
- package/lib/browser/dlob/DLOB.js +12 -0
- package/lib/browser/dlob/orderBookLevels.js +1 -1
- package/lib/browser/driftClient.d.ts +32 -59
- package/lib/browser/driftClient.js +85 -562
- package/lib/browser/driftClientConfig.d.ts +7 -0
- package/lib/browser/events/eventSubscriber.d.ts +8 -0
- package/lib/browser/events/eventSubscriber.js +5 -2
- package/lib/browser/events/parse.d.ts +1 -1
- package/lib/browser/factory/oracleClient.d.ts +2 -2
- package/lib/browser/factory/oracleClient.js +9 -21
- package/lib/browser/idl/drift.d.ts +25708 -0
- package/lib/browser/idl/drift.js +2 -0
- package/lib/browser/idl/drift.json +20850 -15287
- package/lib/browser/idl/pyth.d.ts +97 -0
- package/lib/browser/idl/pyth.js +2 -0
- package/lib/browser/idl/token_faucet.d.ts +197 -0
- package/lib/browser/idl/token_faucet.js +2 -0
- package/lib/browser/idl/token_faucet.json +148 -61
- package/lib/browser/index.d.ts +13 -6
- package/lib/browser/index.js +12 -5
- package/lib/browser/marinade/index.d.ts +1 -1
- package/lib/browser/marinade/index.js +2 -2
- package/lib/browser/math/amm.d.ts +4 -5
- package/lib/browser/math/amm.js +8 -35
- package/lib/browser/math/funding.js +6 -1
- package/lib/browser/math/margin.d.ts +3 -4
- package/lib/browser/math/margin.js +16 -47
- package/lib/browser/math/market.d.ts +2 -2
- package/lib/browser/math/market.js +10 -42
- package/lib/browser/math/oracles.js +14 -19
- package/lib/browser/math/position.js +1 -1
- package/lib/browser/math/trade.js +4 -4
- package/lib/browser/memcmp.js +8 -8
- package/lib/browser/openbook/openbookV2Subscriber.d.ts +1 -1
- package/lib/browser/openbook/openbookV2Subscriber.js +3 -3
- package/lib/browser/oracles/oracleClientCache.d.ts +2 -2
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +2 -2
- package/lib/browser/oracles/prelaunchOracleClient.js +1 -1
- package/lib/browser/oracles/pythLazerClient.js +3 -5
- package/lib/browser/oracles/types.d.ts +6 -0
- package/lib/browser/orderParams.d.ts +0 -1
- package/lib/browser/orderParams.js +1 -5
- package/lib/browser/orderSubscriber/OrderSubscriber.js +3 -4
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/browser/orderSubscriber/index.d.ts +5 -0
- package/lib/browser/orderSubscriber/index.js +5 -0
- package/lib/browser/priorityFee/index.d.ts +5 -0
- package/lib/browser/priorityFee/index.js +5 -0
- package/lib/browser/pyth/index.d.ts +2 -2
- package/lib/browser/pyth/types.d.ts +1 -1
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
- package/lib/browser/swift/index.d.ts +7 -0
- package/lib/browser/swift/index.js +7 -0
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +4 -3
- package/lib/browser/tokenFaucet.d.ts +2 -2
- package/lib/browser/tokenFaucet.js +4 -4
- package/lib/browser/tx/txHandler.d.ts +12 -0
- package/lib/browser/tx/txHandler.js +12 -0
- package/lib/browser/types.d.ts +19 -31
- package/lib/browser/types.js +6 -11
- package/lib/browser/user.d.ts +27 -18
- package/lib/browser/user.js +64 -100
- package/lib/browser/userMap/WebsocketSubscription.js +1 -1
- package/lib/browser/userMap/grpcSubscription.js +1 -1
- package/lib/browser/userMap/revenueShareEscrowMap.js +4 -4
- package/lib/browser/userMap/userMap.js +4 -5
- package/lib/browser/userMap/userStatsMap.js +2 -3
- package/lib/browser/userStats.d.ts +5 -0
- package/lib/node/accounts/fetch.d.ts +6 -6
- package/lib/node/accounts/fetch.d.ts.map +1 -1
- package/lib/node/accounts/fetch.js +4 -4
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.js +2 -2
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.js +2 -2
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +2 -2
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +1 -1
- package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/testBulkAccountLoader.js +3 -5
- package/lib/node/accounts/types.d.ts +11 -14
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +1 -2
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +5 -5
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.js +2 -2
- package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.js +2 -2
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +3 -3
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/addresses/pda.d.ts +6 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +7 -12
- package/lib/node/adminClient.d.ts +11 -9
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +30 -72
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
- package/lib/node/config.d.ts +7 -3
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +9 -7
- package/lib/node/constants/index.d.ts +5 -0
- package/lib/node/constants/index.d.ts.map +1 -1
- package/lib/node/constants/index.js +5 -0
- package/lib/node/constants/numericConstants.d.ts +1 -1
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +3 -3
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +3 -412
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +7 -91
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +2 -2
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts +3 -3
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +3 -3
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +1 -1
- package/lib/node/decode/customCoder.d.ts +7 -9
- package/lib/node/decode/customCoder.d.ts.map +1 -1
- package/lib/node/decode/customCoder.js +17 -28
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +7 -25
- package/lib/node/dlob/DLOB.d.ts +12 -0
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +12 -0
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +1 -1
- package/lib/node/driftClient.d.ts +32 -59
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +85 -562
- package/lib/node/driftClientConfig.d.ts +7 -0
- package/lib/node/driftClientConfig.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.d.ts +8 -0
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +5 -2
- package/lib/node/events/parse.d.ts +1 -1
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/factory/oracleClient.d.ts +2 -2
- package/lib/node/factory/oracleClient.d.ts.map +1 -1
- package/lib/node/factory/oracleClient.js +9 -21
- package/lib/node/idl/drift.d.ts +25709 -0
- package/lib/node/idl/drift.d.ts.map +1 -0
- package/lib/node/idl/drift.js +2 -0
- package/lib/node/idl/drift.json +20850 -15287
- package/lib/node/idl/pyth.d.ts +98 -0
- package/lib/node/idl/pyth.d.ts.map +1 -0
- package/lib/node/idl/pyth.js +2 -0
- package/lib/node/idl/token_faucet.d.ts +198 -0
- package/lib/node/idl/token_faucet.d.ts.map +1 -0
- package/lib/node/idl/token_faucet.js +2 -0
- package/lib/node/idl/token_faucet.json +148 -61
- package/lib/node/index.d.ts +13 -6
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +12 -5
- package/lib/node/marinade/index.d.ts +1 -1
- package/lib/node/marinade/index.d.ts.map +1 -1
- package/lib/node/marinade/index.js +2 -2
- package/lib/node/math/amm.d.ts +4 -5
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +8 -35
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +6 -1
- package/lib/node/math/margin.d.ts +3 -4
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +16 -47
- package/lib/node/math/market.d.ts +2 -2
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +10 -42
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +14 -19
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +1 -1
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +4 -4
- package/lib/node/memcmp.js +8 -8
- package/lib/node/openbook/openbookV2Subscriber.d.ts +1 -1
- package/lib/node/openbook/openbookV2Subscriber.d.ts.map +1 -1
- package/lib/node/openbook/openbookV2Subscriber.js +3 -3
- package/lib/node/oracles/oracleClientCache.d.ts +2 -2
- package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.d.ts +2 -2
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +1 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +3 -5
- package/lib/node/oracles/types.d.ts +6 -0
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/orderParams.d.ts +0 -1
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderParams.js +1 -5
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +3 -4
- package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/node/orderSubscriber/index.d.ts +5 -0
- package/lib/node/orderSubscriber/index.d.ts.map +1 -1
- package/lib/node/orderSubscriber/index.js +5 -0
- package/lib/node/priorityFee/index.d.ts +5 -0
- package/lib/node/priorityFee/index.d.ts.map +1 -1
- package/lib/node/priorityFee/index.js +5 -0
- package/lib/node/pyth/index.d.ts +2 -2
- package/lib/node/pyth/index.d.ts.map +1 -1
- package/lib/node/pyth/types.d.ts +1 -1
- package/lib/node/pyth/types.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
- package/lib/node/swift/index.d.ts +7 -0
- package/lib/node/swift/index.d.ts.map +1 -1
- package/lib/node/swift/index.js +7 -0
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +4 -3
- package/lib/node/tokenFaucet.d.ts +2 -2
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +4 -4
- package/lib/node/tx/txHandler.d.ts +12 -0
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +12 -0
- package/lib/node/types.d.ts +19 -31
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +6 -11
- package/lib/node/user.d.ts +27 -18
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +64 -100
- package/lib/node/userMap/WebsocketSubscription.js +1 -1
- package/lib/node/userMap/grpcSubscription.js +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +4 -4
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +4 -5
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +2 -3
- package/lib/node/userStats.d.ts +5 -0
- package/lib/node/userStats.d.ts.map +1 -1
- package/package.json +5 -7
- package/src/accounts/fetch.ts +18 -17
- package/src/accounts/grpcAccountSubscriber.ts +3 -3
- package/src/accounts/grpcDriftClientAccountSubscriber.ts +2 -3
- package/src/accounts/grpcDriftClientAccountSubscriberV2.ts +5 -6
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +2 -2
- package/src/accounts/grpcMultiAccountSubscriber.ts +4 -4
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +4 -4
- package/src/accounts/grpcProgramAccountSubscriber.ts +3 -3
- package/src/accounts/grpcUserAccountSubscriber.ts +2 -2
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +2 -2
- package/src/accounts/laserProgramAccountSubscriber.ts +3 -3
- package/src/accounts/oneShotUserAccountSubscriber.ts +6 -7
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +10 -9
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +12 -11
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -10
- package/src/accounts/pollingOracleAccountSubscriber.ts +2 -2
- package/src/accounts/pollingTokenAccountSubscriber.ts +2 -2
- package/src/accounts/pollingUserAccountSubscriber.ts +2 -2
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +14 -14
- package/src/accounts/testBulkAccountLoader.ts +3 -5
- package/src/accounts/types.ts +10 -25
- package/src/accounts/webSocketAccountSubscriber.ts +5 -5
- package/src/accounts/webSocketAccountSubscriberV2.ts +4 -3
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +9 -10
- package/src/accounts/webSocketDriftClientAccountSubscriberV2.ts +13 -10
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +3 -3
- package/src/accounts/webSocketProgramAccountSubscriber.ts +4 -3
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +4 -3
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +4 -3
- package/src/accounts/webSocketUserAccountSubscriber.ts +3 -3
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +3 -3
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +4 -4
- package/src/addresses/pda.ts +6 -22
- package/src/adminClient.ts +154 -239
- package/src/auctionSubscriber/auctionSubscriber.ts +5 -3
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +5 -3
- package/src/config.ts +24 -16
- package/src/constants/index.ts +5 -0
- package/src/constants/numericConstants.ts +2 -3
- package/src/constants/perpMarkets.ts +3 -445
- package/src/constants/spotMarkets.ts +7 -102
- package/src/constituentMap/constituentMap.ts +5 -6
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +3 -3
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +6 -6
- package/src/decode/customCoder.ts +26 -35
- package/src/decode/user.ts +7 -25
- package/src/dlob/DLOB.ts +12 -0
- package/src/dlob/orderBookLevels.ts +0 -1
- package/src/driftClient.ts +245 -1091
- package/src/driftClientConfig.ts +7 -0
- package/src/events/eventSubscriber.ts +14 -2
- package/src/events/parse.ts +2 -2
- package/src/factory/oracleClient.ts +17 -28
- package/src/idl/drift.json +20850 -15287
- package/src/idl/drift.ts +25708 -0
- package/src/idl/pyth.ts +97 -0
- package/src/idl/token_faucet.json +148 -61
- package/src/idl/token_faucet.ts +197 -0
- package/src/index.ts +13 -12
- package/src/margin/README.md +0 -1
- package/src/marinade/index.ts +2 -2
- package/src/math/amm.ts +2 -48
- package/src/math/funding.ts +8 -3
- package/src/math/margin.ts +12 -67
- package/src/math/market.ts +15 -69
- package/src/math/oracles.ts +14 -30
- package/src/math/position.ts +0 -1
- package/src/math/trade.ts +0 -4
- package/src/memcmp.ts +1 -1
- package/src/openbook/openbookV2Subscriber.ts +1 -1
- package/src/oracles/oracleClientCache.ts +2 -2
- package/src/oracles/prelaunchOracleClient.ts +9 -8
- package/src/oracles/pythLazerClient.ts +10 -12
- package/src/oracles/types.ts +6 -0
- package/src/orderParams.ts +0 -5
- package/src/orderSubscriber/OrderSubscriber.ts +7 -6
- package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
- package/src/orderSubscriber/grpcSubscription.ts +2 -2
- package/src/orderSubscriber/index.ts +5 -0
- package/src/priorityFee/index.ts +5 -0
- package/src/pyth/index.ts +4 -4
- package/src/pyth/types.ts +1 -1
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +1 -1
- package/src/swift/index.ts +7 -0
- package/src/swift/signedMsgUserAccountSubscriber.ts +7 -4
- package/src/tokenFaucet.ts +8 -4
- package/src/tx/txHandler.ts +12 -0
- package/src/types.ts +16 -20
- package/src/user.ts +66 -144
- package/src/userMap/WebsocketSubscription.ts +1 -1
- package/src/userMap/grpcSubscription.ts +1 -1
- package/src/userMap/revenueShareEscrowMap.ts +24 -20
- package/src/userMap/userMap.ts +8 -7
- package/src/userMap/userStatsMap.ts +6 -5
- package/src/userStats.ts +5 -0
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +5 -4
- package/tests/amm/test.ts +45 -64
- package/tests/ci/verifyConstants.ts +23 -26
- package/tests/decode/test.ts +2 -4
- package/tests/dlob/helpers.ts +8 -15
- package/tests/user/helpers.ts +0 -2
- package/tests/user/marginCalculations.test.ts +2 -3
- package/tests/user/test.ts +18 -15
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +0 -29
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +0 -111
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +0 -23
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +0 -69
- package/lib/browser/idl/pyth_solana_receiver.json +0 -628
- package/lib/browser/idl/switchboard.json +0 -8354
- package/lib/browser/idl/switchboard_on_demand_30.json +0 -5849
- package/lib/browser/oracles/pythPullClient.d.ts +0 -19
- package/lib/browser/oracles/pythPullClient.js +0 -65
- package/lib/browser/oracles/switchboardClient.d.ts +0 -12
- package/lib/browser/oracles/switchboardClient.js +0 -40
- package/lib/browser/oracles/switchboardOnDemandClient.d.ts +0 -12
- package/lib/browser/oracles/switchboardOnDemandClient.js +0 -33
- package/lib/browser/util/pythOracleUtils.d.ts +0 -2
- package/lib/browser/util/pythOracleUtils.js +0 -15
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +0 -30
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts.map +0 -1
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +0 -111
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +0 -24
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts.map +0 -1
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +0 -69
- package/lib/node/idl/pyth_solana_receiver.json +0 -628
- package/lib/node/idl/switchboard.json +0 -8354
- package/lib/node/idl/switchboard_on_demand_30.json +0 -5849
- package/lib/node/oracles/pythPullClient.d.ts +0 -20
- package/lib/node/oracles/pythPullClient.d.ts.map +0 -1
- package/lib/node/oracles/pythPullClient.js +0 -65
- package/lib/node/oracles/switchboardClient.d.ts +0 -13
- package/lib/node/oracles/switchboardClient.d.ts.map +0 -1
- package/lib/node/oracles/switchboardClient.js +0 -40
- package/lib/node/oracles/switchboardOnDemandClient.d.ts +0 -13
- package/lib/node/oracles/switchboardOnDemandClient.d.ts.map +0 -1
- package/lib/node/oracles/switchboardOnDemandClient.js +0 -33
- package/lib/node/util/pythOracleUtils.d.ts +0 -3
- package/lib/node/util/pythOracleUtils.d.ts.map +0 -1
- package/lib/node/util/pythOracleUtils.js +0 -15
- package/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +0 -189
- package/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +0 -131
- package/src/idl/switchboard.json +0 -8354
- package/src/idl/switchboard_on_demand_30.json +0 -5849
- package/src/oracles/pythPullClient.ts +0 -112
- package/src/oracles/switchboardClient.ts +0 -77
- package/src/oracles/switchboardOnDemandClient.ts +0 -64
- package/src/util/pythOracleUtils.ts +0 -11
package/lib/node/userStats.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
|
+
/**
|
|
3
|
+
* UserStats — abstraction over the on-chain `UserStats` account.
|
|
4
|
+
* Tracks referral links, 30-day maker/taker volume, fuel rewards, and IF staking stats.
|
|
5
|
+
* One `UserStats` account exists per authority (shared across all subaccounts).
|
|
6
|
+
*/
|
|
2
7
|
import { DriftClient } from './driftClient';
|
|
3
8
|
import { PublicKey } from '@solana/web3.js';
|
|
4
9
|
import { DataAndSlot, UserStatsAccountSubscriber } from './accounts/types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userStats.d.ts","sourceRoot":"","sources":["../../src/userStats.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAqB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAY5E,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAGvC,qBAAa,SAAS;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,yBAAyB,EAAE,SAAS,CAAC;IACrC,iBAAiB,EAAE,0BAA0B,CAAC;IAC9C,YAAY,EAAE,OAAO,CAAC;gBAEH,MAAM,EAAE,eAAe;IAyC7B,SAAS,CACrB,gBAAgB,CAAC,EAAE,gBAAgB,GACjC,OAAO,CAAC,OAAO,CAAC;IAON,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAKlC,iBAAiB,IAAI,WAAW,CAAC,gBAAgB,CAAC;IAIlD,UAAU,IAAI,gBAAgB;IAI9B,qBAAqB,CAC3B,GAAG,EAAE,EAAE,EACP,cAAc,UAAO,EACrB,gBAAgB,UAAO,GACrB,EAAE;IAuDE,eAAe,IAAI,YAAY,GAAG,SAAS;WAkBpC,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM;CAOlE"}
|
|
1
|
+
{"version":3,"file":"userStats.d.ts","sourceRoot":"","sources":["../../src/userStats.ts"],"names":[],"mappings":";AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAqB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAY5E,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAGvC,qBAAa,SAAS;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,yBAAyB,EAAE,SAAS,CAAC;IACrC,iBAAiB,EAAE,0BAA0B,CAAC;IAC9C,YAAY,EAAE,OAAO,CAAC;gBAEH,MAAM,EAAE,eAAe;IAyC7B,SAAS,CACrB,gBAAgB,CAAC,EAAE,gBAAgB,GACjC,OAAO,CAAC,OAAO,CAAC;IAON,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAKlC,iBAAiB,IAAI,WAAW,CAAC,gBAAgB,CAAC;IAIlD,UAAU,IAAI,gBAAgB;IAI9B,qBAAqB,CAC3B,GAAG,EAAE,EAAE,EACP,cAAc,UAAO,EACrB,gBAAgB,UAAO,GACrB,EAAE;IAuDE,eAAe,IAAI,YAAY,GAAG,SAAS;WAkBpC,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM;CAOlE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drift-labs/sdk-browser",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.163.0-beta.9",
|
|
4
4
|
"main": "lib/node/index.js",
|
|
5
5
|
"types": "lib/node/index.d.ts",
|
|
6
6
|
"module": "./lib/browser/index.js",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@coral-xyz/anchor": "0.
|
|
46
|
-
"@coral-xyz/anchor-
|
|
45
|
+
"@coral-xyz/anchor": "npm:@coral-xyz/anchor@0.32.1",
|
|
46
|
+
"@coral-xyz/anchor-29": "npm:@coral-xyz/anchor@0.29.0",
|
|
47
47
|
"@ellipsis-labs/phoenix-sdk": "1.4.5",
|
|
48
48
|
"@msgpack/msgpack": "^3.1.2",
|
|
49
49
|
"@openbook-dex/openbook-v2": "0.2.10",
|
|
@@ -53,14 +53,12 @@
|
|
|
53
53
|
"@pythnetwork/pyth-lazer-sdk": "6.0.0",
|
|
54
54
|
"@solana/spl-token": "0.4.13",
|
|
55
55
|
"@solana/web3.js": "1.98.0",
|
|
56
|
-
"@switchboard-xyz/common": "3.0.14",
|
|
57
|
-
"@switchboard-xyz/on-demand": "2.4.1",
|
|
58
56
|
"@triton-one/yellowstone-grpc": "5.0.5",
|
|
59
|
-
"anchor-bankrun": "0.
|
|
57
|
+
"anchor-bankrun": "0.5.0",
|
|
60
58
|
"gill": "^0.10.2",
|
|
61
59
|
"nanoid": "3.3.4",
|
|
62
60
|
"node-cache": "5.1.2",
|
|
63
|
-
"solana-bankrun": "0.
|
|
61
|
+
"solana-bankrun": "0.4.0",
|
|
64
62
|
"strict-event-emitter-types": "2.0.0",
|
|
65
63
|
"tweetnacl": "1.0.3",
|
|
66
64
|
"tweetnacl-util": "0.15.1",
|
package/src/accounts/fetch.ts
CHANGED
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
getUserAccountPublicKey,
|
|
12
12
|
getUserStatsAccountPublicKey,
|
|
13
13
|
} from '../addresses/pda';
|
|
14
|
-
import {
|
|
14
|
+
import { DriftProgram } from '../config';
|
|
15
15
|
|
|
16
16
|
export async function fetchUserAccounts(
|
|
17
17
|
connection: Connection,
|
|
18
|
-
program:
|
|
18
|
+
program: DriftProgram,
|
|
19
19
|
authority: PublicKey,
|
|
20
20
|
limit = 8
|
|
21
21
|
): Promise<(UserAccount | undefined)[]> {
|
|
@@ -31,7 +31,7 @@ export async function fetchUserAccounts(
|
|
|
31
31
|
|
|
32
32
|
export async function fetchUserAccountsUsingKeys(
|
|
33
33
|
connection: Connection,
|
|
34
|
-
program:
|
|
34
|
+
program: DriftProgram,
|
|
35
35
|
userAccountPublicKeys: PublicKey[]
|
|
36
36
|
): Promise<(UserAccount | undefined)[]> {
|
|
37
37
|
const accountInfos = await connection.getMultipleAccountsInfo(
|
|
@@ -43,8 +43,8 @@ export async function fetchUserAccountsUsingKeys(
|
|
|
43
43
|
if (!accountInfo) {
|
|
44
44
|
return undefined;
|
|
45
45
|
}
|
|
46
|
-
return program.account.user.coder.accounts.decodeUnchecked(
|
|
47
|
-
'
|
|
46
|
+
return (program.account as any).user.coder.accounts.decodeUnchecked(
|
|
47
|
+
'user',
|
|
48
48
|
accountInfo.data
|
|
49
49
|
) as UserAccount;
|
|
50
50
|
});
|
|
@@ -52,7 +52,7 @@ export async function fetchUserAccountsUsingKeys(
|
|
|
52
52
|
|
|
53
53
|
export async function fetchUserStatsAccount(
|
|
54
54
|
connection: Connection,
|
|
55
|
-
program:
|
|
55
|
+
program: DriftProgram,
|
|
56
56
|
authority: PublicKey
|
|
57
57
|
): Promise<UserStatsAccount | undefined> {
|
|
58
58
|
const userStatsPublicKey = getUserStatsAccountPublicKey(
|
|
@@ -65,8 +65,8 @@ export async function fetchUserStatsAccount(
|
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
return accountInfo
|
|
68
|
-
? (program.account.user.coder.accounts.decodeUnchecked(
|
|
69
|
-
'
|
|
68
|
+
? ((program.account as any).user.coder.accounts.decodeUnchecked(
|
|
69
|
+
'userStats',
|
|
70
70
|
accountInfo.data
|
|
71
71
|
) as UserStatsAccount)
|
|
72
72
|
: undefined;
|
|
@@ -74,7 +74,7 @@ export async function fetchUserStatsAccount(
|
|
|
74
74
|
|
|
75
75
|
export async function fetchRevenueShareAccount(
|
|
76
76
|
connection: Connection,
|
|
77
|
-
program:
|
|
77
|
+
program: DriftProgram,
|
|
78
78
|
authority: PublicKey
|
|
79
79
|
): Promise<RevenueShareAccount | null> {
|
|
80
80
|
const revenueShareAccountPublicKey = getRevenueShareAccountPublicKey(
|
|
@@ -85,15 +85,15 @@ export async function fetchRevenueShareAccount(
|
|
|
85
85
|
revenueShareAccountPublicKey
|
|
86
86
|
);
|
|
87
87
|
if (!accountInfo) return null;
|
|
88
|
-
return program.account.revenueShare.coder.accounts.decode(
|
|
89
|
-
'
|
|
88
|
+
return (program.account as any).revenueShare.coder.accounts.decode(
|
|
89
|
+
'revenueShare',
|
|
90
90
|
accountInfo.data
|
|
91
91
|
) as RevenueShareAccount;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
export async function fetchRevenueShareEscrowAccount(
|
|
95
95
|
connection: Connection,
|
|
96
|
-
program:
|
|
96
|
+
program: DriftProgram,
|
|
97
97
|
authority: PublicKey
|
|
98
98
|
): Promise<RevenueShareEscrowAccount | null> {
|
|
99
99
|
const revenueShareEscrowPubKey = getRevenueShareEscrowAccountPublicKey(
|
|
@@ -105,11 +105,12 @@ export async function fetchRevenueShareEscrowAccount(
|
|
|
105
105
|
|
|
106
106
|
if (!escrow) return null;
|
|
107
107
|
|
|
108
|
-
const escrowAccount =
|
|
109
|
-
program.account
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
const escrowAccount = (
|
|
109
|
+
program.account as any
|
|
110
|
+
).revenueShareEscrow.coder.accounts.decode(
|
|
111
|
+
'revenueShareEscrow',
|
|
112
|
+
escrow.data
|
|
113
|
+
) as RevenueShareEscrowAccount;
|
|
113
114
|
|
|
114
115
|
return escrowAccount;
|
|
115
116
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResubOpts, GrpcConfigs } from './types';
|
|
2
|
-
import { Program } from '@coral-xyz/anchor';
|
|
3
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { DriftProgram } from '../config';
|
|
4
4
|
import * as Buffer from 'buffer';
|
|
5
5
|
|
|
6
6
|
import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber';
|
|
@@ -23,7 +23,7 @@ export class grpcAccountSubscriber<T> extends WebSocketAccountSubscriber<T> {
|
|
|
23
23
|
client: Client,
|
|
24
24
|
commitmentLevel: CommitmentLevel,
|
|
25
25
|
accountName: string,
|
|
26
|
-
program:
|
|
26
|
+
program: DriftProgram,
|
|
27
27
|
accountPublicKey: PublicKey,
|
|
28
28
|
decodeBuffer?: (buffer: Buffer) => T,
|
|
29
29
|
resubOpts?: ResubOpts
|
|
@@ -36,7 +36,7 @@ export class grpcAccountSubscriber<T> extends WebSocketAccountSubscriber<T> {
|
|
|
36
36
|
public static async create<U>(
|
|
37
37
|
grpcConfigs: GrpcConfigs,
|
|
38
38
|
accountName: string,
|
|
39
|
-
program:
|
|
39
|
+
program: DriftProgram,
|
|
40
40
|
accountPublicKey: PublicKey,
|
|
41
41
|
decodeBuffer?: (buffer: Buffer) => U,
|
|
42
42
|
resubOpts?: ResubOpts,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WebSocketDriftClientAccountSubscriber } from './webSocketDriftClientAccountSubscriber';
|
|
2
2
|
import { OracleInfo, OraclePriceData } from '../oracles/types';
|
|
3
|
-
import {
|
|
4
|
-
import { findAllMarketAndOracles } from '../config';
|
|
3
|
+
import { findAllMarketAndOracles, DriftProgram } from '../config';
|
|
5
4
|
import {
|
|
6
5
|
getDriftStateAccountPublicKey,
|
|
7
6
|
getPerpMarketPublicKey,
|
|
@@ -17,7 +16,7 @@ export class grpcDriftClientAccountSubscriber extends WebSocketDriftClientAccoun
|
|
|
17
16
|
|
|
18
17
|
constructor(
|
|
19
18
|
grpcConfigs: GrpcConfigs,
|
|
20
|
-
program:
|
|
19
|
+
program: DriftProgram,
|
|
21
20
|
perpMarketIndexes: number[],
|
|
22
21
|
spotMarketIndexes: number[],
|
|
23
22
|
oracleInfos: OracleInfo[],
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { OracleInfo, OraclePriceData } from '../oracles/types';
|
|
4
|
-
import { Program } from '@coral-xyz/anchor';
|
|
5
4
|
import { PublicKey } from '@solana/web3.js';
|
|
6
|
-
import { findAllMarketAndOracles } from '../config';
|
|
5
|
+
import { findAllMarketAndOracles, DriftProgram } from '../config';
|
|
7
6
|
import {
|
|
8
7
|
getDriftStateAccountPublicKey,
|
|
9
8
|
getPerpMarketPublicKey,
|
|
@@ -51,7 +50,7 @@ export class grpcDriftClientAccountSubscriberV2
|
|
|
51
50
|
>;
|
|
52
51
|
public isSubscribed: boolean;
|
|
53
52
|
public isSubscribing: boolean;
|
|
54
|
-
public program:
|
|
53
|
+
public program: DriftProgram;
|
|
55
54
|
public perpMarketIndexes: number[];
|
|
56
55
|
public spotMarketIndexes: number[];
|
|
57
56
|
public shouldFindAllMarketsAndOracles: boolean;
|
|
@@ -76,7 +75,7 @@ export class grpcDriftClientAccountSubscriberV2
|
|
|
76
75
|
|
|
77
76
|
constructor(
|
|
78
77
|
grpcConfigs: GrpcConfigs,
|
|
79
|
-
program:
|
|
78
|
+
program: DriftProgram,
|
|
80
79
|
perpMarketIndexes: number[],
|
|
81
80
|
spotMarketIndexes: number[],
|
|
82
81
|
oracleInfos: OracleInfo[],
|
|
@@ -134,7 +133,7 @@ export class grpcDriftClientAccountSubscriberV2
|
|
|
134
133
|
.filter((accountInfo) => !!accountInfo)
|
|
135
134
|
.map((accountInfo) => {
|
|
136
135
|
const perpMarket = this.program.coder.accounts.decode(
|
|
137
|
-
'
|
|
136
|
+
'perpMarket',
|
|
138
137
|
accountInfo.data
|
|
139
138
|
);
|
|
140
139
|
return [perpMarket.marketIndex, perpMarket];
|
|
@@ -162,7 +161,7 @@ export class grpcDriftClientAccountSubscriberV2
|
|
|
162
161
|
.filter((accountInfo) => !!accountInfo)
|
|
163
162
|
.map((accountInfo) => {
|
|
164
163
|
const spotMarket = this.program.coder.accounts.decode(
|
|
165
|
-
'
|
|
164
|
+
'spotMarket',
|
|
166
165
|
accountInfo.data
|
|
167
166
|
);
|
|
168
167
|
return [spotMarket.marketIndex, spotMarket];
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { GrpcConfigs } from './types';
|
|
2
|
-
import { Program } from '@coral-xyz/anchor';
|
|
3
2
|
import { PublicKey } from '@solana/web3.js';
|
|
4
3
|
import { InsuranceFundStake } from '../types';
|
|
5
4
|
import { WebSocketInsuranceFundStakeAccountSubscriber } from './webSocketInsuranceFundStakeAccountSubscriber';
|
|
6
5
|
import { grpcAccountSubscriber } from './grpcAccountSubscriber';
|
|
6
|
+
import { DriftProgram } from '../config';
|
|
7
7
|
|
|
8
8
|
export class grpcInsuranceFundStakeAccountSubscriber extends WebSocketInsuranceFundStakeAccountSubscriber {
|
|
9
9
|
private grpcConfigs: GrpcConfigs;
|
|
10
10
|
|
|
11
11
|
public constructor(
|
|
12
12
|
grpcConfigs: GrpcConfigs,
|
|
13
|
-
program:
|
|
13
|
+
program: DriftProgram,
|
|
14
14
|
insuranceFundStakeAccountPublicKey: PublicKey,
|
|
15
15
|
resubTimeoutMs?: number
|
|
16
16
|
) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Program } from '@coral-xyz/anchor';
|
|
2
1
|
import { Commitment, Context, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { DriftProgram } from '../config';
|
|
3
3
|
import * as Buffer from 'buffer';
|
|
4
4
|
import bs58 from 'bs58';
|
|
5
5
|
|
|
@@ -40,7 +40,7 @@ export class grpcMultiAccountSubscriber<T, U = undefined> {
|
|
|
40
40
|
private client: Client;
|
|
41
41
|
private stream: ClientDuplexStream;
|
|
42
42
|
private commitmentLevel: CommitmentLevel;
|
|
43
|
-
private program:
|
|
43
|
+
private program: DriftProgram;
|
|
44
44
|
private accountName: string;
|
|
45
45
|
private decodeBufferFn?: (
|
|
46
46
|
buffer: Buffer,
|
|
@@ -69,7 +69,7 @@ export class grpcMultiAccountSubscriber<T, U = undefined> {
|
|
|
69
69
|
client: Client,
|
|
70
70
|
commitmentLevel: CommitmentLevel,
|
|
71
71
|
accountName: string,
|
|
72
|
-
program:
|
|
72
|
+
program: DriftProgram,
|
|
73
73
|
decodeBuffer?: (buffer: Buffer, pubkey?: string) => T,
|
|
74
74
|
resubOpts?: ResubOpts,
|
|
75
75
|
onUnsubscribe?: () => Promise<void>,
|
|
@@ -88,7 +88,7 @@ export class grpcMultiAccountSubscriber<T, U = undefined> {
|
|
|
88
88
|
public static async create<T, U = undefined>(
|
|
89
89
|
grpcConfigs: GrpcConfigs,
|
|
90
90
|
accountName: string,
|
|
91
|
-
program:
|
|
91
|
+
program: DriftProgram,
|
|
92
92
|
decodeBuffer?: (buffer: Buffer, pubkey?: string, accountProps?: U) => T,
|
|
93
93
|
resubOpts?: ResubOpts,
|
|
94
94
|
clientProp?: Client,
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
10
10
|
import { EventEmitter } from 'events';
|
|
11
11
|
import { Context, PublicKey } from '@solana/web3.js';
|
|
12
|
-
import { Program } from '@coral-xyz/anchor';
|
|
13
12
|
import { UserAccount } from '../types';
|
|
13
|
+
import { DriftProgram } from '../config';
|
|
14
14
|
import { grpcMultiAccountSubscriber } from './grpcMultiAccountSubscriber';
|
|
15
15
|
|
|
16
16
|
export class grpcMultiUserAccountSubscriber {
|
|
17
|
-
private program:
|
|
17
|
+
private program: DriftProgram;
|
|
18
18
|
private multiSubscriber: grpcMultiAccountSubscriber<UserAccount>;
|
|
19
19
|
|
|
20
20
|
private userData = new Map<string, DataAndSlot<UserAccount>>();
|
|
@@ -50,7 +50,7 @@ export class grpcMultiUserAccountSubscriber {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
public constructor(
|
|
53
|
-
program:
|
|
53
|
+
program: DriftProgram,
|
|
54
54
|
grpcConfigs: GrpcConfigs,
|
|
55
55
|
resubOpts?: ResubOpts,
|
|
56
56
|
multiSubscriber?: grpcMultiAccountSubscriber<UserAccount>
|
|
@@ -157,7 +157,7 @@ export class grpcMultiUserAccountSubscriber {
|
|
|
157
157
|
'Must subscribe before fetching account updates'
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
|
-
const account = (await parent.program.account.user.fetch(
|
|
160
|
+
const account = (await (parent.program.account as any).user.fetch(
|
|
161
161
|
userAccountPublicKey
|
|
162
162
|
)) as UserAccount;
|
|
163
163
|
this.updateData(account, 0);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResubOpts, GrpcConfigs } from './types';
|
|
2
|
-
import { Program } from '@coral-xyz/anchor';
|
|
3
2
|
import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { DriftProgram } from '../config';
|
|
4
4
|
import * as Buffer from 'buffer';
|
|
5
5
|
import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber';
|
|
6
6
|
import {
|
|
@@ -24,7 +24,7 @@ export class grpcProgramAccountSubscriber<
|
|
|
24
24
|
commitmentLevel: CommitmentLevel,
|
|
25
25
|
subscriptionName: string,
|
|
26
26
|
accountDiscriminator: string,
|
|
27
|
-
program:
|
|
27
|
+
program: DriftProgram,
|
|
28
28
|
decodeBufferFn: (accountName: string, ix: Buffer) => T,
|
|
29
29
|
options: { filters: MemcmpFilter[] } = {
|
|
30
30
|
filters: [],
|
|
@@ -47,7 +47,7 @@ export class grpcProgramAccountSubscriber<
|
|
|
47
47
|
grpcConfigs: GrpcConfigs,
|
|
48
48
|
subscriptionName: string,
|
|
49
49
|
accountDiscriminator: string,
|
|
50
|
-
program:
|
|
50
|
+
program: DriftProgram,
|
|
51
51
|
decodeBufferFn: (accountName: string, ix: Buffer) => U,
|
|
52
52
|
options: { filters: MemcmpFilter[] } = {
|
|
53
53
|
filters: [],
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ResubOpts, GrpcConfigs } from './types';
|
|
2
|
-
import { Program } from '@coral-xyz/anchor';
|
|
3
2
|
import { PublicKey } from '@solana/web3.js';
|
|
4
3
|
import { UserAccount } from '../types';
|
|
5
4
|
import { WebSocketUserAccountSubscriber } from './webSocketUserAccountSubscriber';
|
|
6
5
|
import { grpcAccountSubscriber } from './grpcAccountSubscriber';
|
|
6
|
+
import { DriftProgram } from '../config';
|
|
7
7
|
|
|
8
8
|
export class grpcUserAccountSubscriber extends WebSocketUserAccountSubscriber {
|
|
9
9
|
private grpcConfigs: GrpcConfigs;
|
|
10
10
|
|
|
11
11
|
public constructor(
|
|
12
12
|
grpcConfigs: GrpcConfigs,
|
|
13
|
-
program:
|
|
13
|
+
program: DriftProgram,
|
|
14
14
|
userAccountPublicKey: PublicKey,
|
|
15
15
|
resubOpts?: ResubOpts
|
|
16
16
|
) {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ResubOpts, GrpcConfigs } from './types';
|
|
2
|
-
import { Program } from '@coral-xyz/anchor';
|
|
3
2
|
import { PublicKey } from '@solana/web3.js';
|
|
4
3
|
import { UserStatsAccount } from '../types';
|
|
5
4
|
import { WebSocketUserStatsAccountSubscriber } from './webSocketUserStatsAccountSubsriber';
|
|
6
5
|
import { grpcAccountSubscriber } from './grpcAccountSubscriber';
|
|
6
|
+
import { DriftProgram } from '../config';
|
|
7
7
|
|
|
8
8
|
export class grpcUserStatsAccountSubscriber extends WebSocketUserStatsAccountSubscriber {
|
|
9
9
|
private grpcConfigs: GrpcConfigs;
|
|
10
10
|
|
|
11
11
|
public constructor(
|
|
12
12
|
grpcConfigs: GrpcConfigs,
|
|
13
|
-
program:
|
|
13
|
+
program: DriftProgram,
|
|
14
14
|
userStatsAccountPublicKey: PublicKey,
|
|
15
15
|
resubOpts?: ResubOpts
|
|
16
16
|
) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LaserGrpcConfigs, ResubOpts } from './types';
|
|
2
|
-
import { Program } from '@coral-xyz/anchor';
|
|
3
2
|
import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { DriftProgram } from '../config';
|
|
4
4
|
import * as Buffer from 'buffer';
|
|
5
5
|
import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber';
|
|
6
6
|
|
|
@@ -41,7 +41,7 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
41
41
|
laserCommitmentLevel: typeof LaserCommitmentLevel,
|
|
42
42
|
subscriptionName: string,
|
|
43
43
|
accountDiscriminator: string,
|
|
44
|
-
program:
|
|
44
|
+
program: DriftProgram,
|
|
45
45
|
decodeBufferFn: (accountName: string, ix: Buffer) => T,
|
|
46
46
|
options: { filters: MemcmpFilter[] } = { filters: [] },
|
|
47
47
|
resubOpts?: ResubOpts
|
|
@@ -63,7 +63,7 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
63
63
|
grpcConfigs: LaserGrpcConfigs,
|
|
64
64
|
subscriptionName: string,
|
|
65
65
|
accountDiscriminator: string,
|
|
66
|
-
program:
|
|
66
|
+
program: DriftProgram,
|
|
67
67
|
decodeBufferFn: (accountName: string, ix: Buffer) => U,
|
|
68
68
|
options: { filters: MemcmpFilter[] } = {
|
|
69
69
|
filters: [],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { UserAccount } from '../types';
|
|
3
3
|
import { BasicUserAccountSubscriber } from './basicUserAccountSubscriber';
|
|
4
|
-
import { Program } from '@coral-xyz/anchor';
|
|
5
4
|
import { UserAccountSubscriber } from './types';
|
|
5
|
+
import { DriftProgram } from '../config';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Simple implementation of UserAccountSubscriber. It will fetch the UserAccount
|
|
@@ -13,11 +13,11 @@ export class OneShotUserAccountSubscriber
|
|
|
13
13
|
extends BasicUserAccountSubscriber
|
|
14
14
|
implements UserAccountSubscriber
|
|
15
15
|
{
|
|
16
|
-
program:
|
|
16
|
+
program: DriftProgram;
|
|
17
17
|
commitment: Commitment;
|
|
18
18
|
|
|
19
19
|
public constructor(
|
|
20
|
-
program:
|
|
20
|
+
program: DriftProgram,
|
|
21
21
|
userAccountPublicKey: PublicKey,
|
|
22
22
|
data?: UserAccount,
|
|
23
23
|
slot?: number,
|
|
@@ -49,10 +49,9 @@ export class OneShotUserAccountSubscriber
|
|
|
49
49
|
|
|
50
50
|
async fetch(): Promise<void> {
|
|
51
51
|
try {
|
|
52
|
-
const dataAndContext = await
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
);
|
|
52
|
+
const dataAndContext = await (
|
|
53
|
+
this.program.account as any
|
|
54
|
+
).user.fetchAndContext(this.userAccountPublicKey, this.commitment);
|
|
56
55
|
if (dataAndContext.context.slot > (this.user?.slot ?? 0)) {
|
|
57
56
|
this.user = {
|
|
58
57
|
data: dataAndContext.data as UserAccount,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { UserStatsAccount } from '../types';
|
|
3
3
|
import { BasicUserStatsAccountSubscriber } from './basicUserStatsAccountSubscriber';
|
|
4
|
-
import { Program } from '@coral-xyz/anchor';
|
|
5
4
|
import { UserStatsAccountSubscriber } from './types';
|
|
5
|
+
import { DriftProgram } from '../config';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Simple implementation of UserStatsAccountSubscriber. It will fetch the UserStatsAccount
|
|
@@ -13,11 +13,11 @@ export class OneShotUserStatsAccountSubscriber
|
|
|
13
13
|
extends BasicUserStatsAccountSubscriber
|
|
14
14
|
implements UserStatsAccountSubscriber
|
|
15
15
|
{
|
|
16
|
-
program:
|
|
16
|
+
program: DriftProgram;
|
|
17
17
|
commitment: Commitment;
|
|
18
18
|
|
|
19
19
|
public constructor(
|
|
20
|
-
program:
|
|
20
|
+
program: DriftProgram,
|
|
21
21
|
userStatsAccountPublicKey: PublicKey,
|
|
22
22
|
data?: UserStatsAccount,
|
|
23
23
|
slot?: number,
|
|
@@ -49,14 +49,15 @@ export class OneShotUserStatsAccountSubscriber
|
|
|
49
49
|
|
|
50
50
|
async fetch(): Promise<void> {
|
|
51
51
|
try {
|
|
52
|
-
const dataAndContext =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
const dataAndContext = await (
|
|
53
|
+
this.program.account as any
|
|
54
|
+
).userStats.fetchAndContext(
|
|
55
|
+
this.userStatsAccountPublicKey,
|
|
56
|
+
this.commitment
|
|
57
|
+
);
|
|
57
58
|
if (dataAndContext.context.slot > (this.userStats?.slot ?? 0)) {
|
|
58
59
|
this.userStats = {
|
|
59
|
-
data: dataAndContext.data as UserStatsAccount,
|
|
60
|
+
data: dataAndContext.data as unknown as UserStatsAccount,
|
|
60
61
|
slot: dataAndContext.context.slot,
|
|
61
62
|
};
|
|
62
63
|
}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
NotSubscribedError,
|
|
8
8
|
OraclesToPoll,
|
|
9
9
|
} from './types';
|
|
10
|
-
import { Program } from '@coral-xyz/anchor';
|
|
11
10
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
12
11
|
import { EventEmitter } from 'events';
|
|
13
12
|
import {
|
|
@@ -23,12 +22,12 @@ import {
|
|
|
23
22
|
getSpotMarketPublicKey,
|
|
24
23
|
} from '../addresses/pda';
|
|
25
24
|
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
26
|
-
import {
|
|
25
|
+
import { findDelistedPerpMarketsAndOracles } from './utils';
|
|
27
26
|
import { PublicKey } from '@solana/web3.js';
|
|
28
27
|
import { OracleInfo, OraclePriceData } from '../oracles/types';
|
|
29
28
|
import { OracleClientCache } from '../oracles/oracleClientCache';
|
|
30
29
|
import { QUOTE_ORACLE_PRICE_DATA } from '../oracles/quoteAssetOracleClient';
|
|
31
|
-
import { findAllMarketAndOracles } from '../config';
|
|
30
|
+
import { findAllMarketAndOracles, DriftProgram } from '../config';
|
|
32
31
|
import { getOracleId } from '../oracles/oracleId';
|
|
33
32
|
|
|
34
33
|
const ORACLE_DEFAULT_ID = getOracleId(
|
|
@@ -40,7 +39,7 @@ export class PollingDriftClientAccountSubscriber
|
|
|
40
39
|
implements DriftClientAccountSubscriber
|
|
41
40
|
{
|
|
42
41
|
isSubscribed: boolean;
|
|
43
|
-
program:
|
|
42
|
+
program: DriftProgram;
|
|
44
43
|
perpMarketIndexes: number[];
|
|
45
44
|
spotMarketIndexes: number[];
|
|
46
45
|
oracleInfos: OracleInfo[];
|
|
@@ -71,7 +70,7 @@ export class PollingDriftClientAccountSubscriber
|
|
|
71
70
|
private subscriptionPromiseResolver: (val: boolean) => void;
|
|
72
71
|
|
|
73
72
|
public constructor(
|
|
74
|
-
program:
|
|
73
|
+
program: DriftProgram,
|
|
75
74
|
accountLoader: BulkAccountLoader,
|
|
76
75
|
perpMarketIndexes: number[],
|
|
77
76
|
spotMarketIndexes: number[],
|
|
@@ -256,9 +255,10 @@ export class PollingDriftClientAccountSubscriber
|
|
|
256
255
|
(buffer: Buffer, slot: number) => {
|
|
257
256
|
if (!buffer) return;
|
|
258
257
|
|
|
259
|
-
const account = this.program.
|
|
260
|
-
accountToPoll.key
|
|
261
|
-
|
|
258
|
+
const account = this.program.coder.accounts.decodeUnchecked(
|
|
259
|
+
accountToPoll.key,
|
|
260
|
+
buffer
|
|
261
|
+
);
|
|
262
262
|
const dataAndSlot = {
|
|
263
263
|
data: account,
|
|
264
264
|
slot,
|
|
@@ -328,9 +328,10 @@ export class PollingDriftClientAccountSubscriber
|
|
|
328
328
|
const { buffer, slot } = bufferAndSlot;
|
|
329
329
|
|
|
330
330
|
if (buffer) {
|
|
331
|
-
const account = this.program.
|
|
332
|
-
accountToPoll.key
|
|
333
|
-
|
|
331
|
+
const account = this.program.coder.accounts.decodeUnchecked(
|
|
332
|
+
accountToPoll.key,
|
|
333
|
+
buffer
|
|
334
|
+
);
|
|
334
335
|
if (accountToPoll.mapKey != undefined) {
|
|
335
336
|
this[accountToPoll.key].set(accountToPoll.mapKey, {
|
|
336
337
|
data: account,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
InsuranceFundStakeAccountEvents,
|
|
5
5
|
InsuranceFundStakeAccountSubscriber,
|
|
6
6
|
} from './types';
|
|
7
|
-
import {
|
|
7
|
+
import { DriftProgram } from '../config';
|
|
8
8
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
9
9
|
import { EventEmitter } from 'events';
|
|
10
10
|
import { PublicKey } from '@solana/web3.js';
|
|
@@ -15,7 +15,7 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
15
15
|
implements InsuranceFundStakeAccountSubscriber
|
|
16
16
|
{
|
|
17
17
|
isSubscribed: boolean;
|
|
18
|
-
program:
|
|
18
|
+
program: DriftProgram;
|
|
19
19
|
eventEmitter: StrictEventEmitter<
|
|
20
20
|
EventEmitter,
|
|
21
21
|
InsuranceFundStakeAccountEvents
|
|
@@ -29,7 +29,7 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
29
29
|
insuranceFundStakeAccountAndSlot?: DataAndSlot<InsuranceFundStake>;
|
|
30
30
|
|
|
31
31
|
public constructor(
|
|
32
|
-
program:
|
|
32
|
+
program: DriftProgram,
|
|
33
33
|
publicKey: PublicKey,
|
|
34
34
|
accountLoader: BulkAccountLoader
|
|
35
35
|
) {
|
|
@@ -81,8 +81,8 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
const account = this.program.
|
|
85
|
-
'
|
|
84
|
+
const account = this.program.coder.accounts.decode(
|
|
85
|
+
'insuranceFundStake',
|
|
86
86
|
buffer
|
|
87
87
|
);
|
|
88
88
|
this.insuranceFundStakeAccountAndSlot = { data: account, slot };
|
|
@@ -104,11 +104,12 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
104
104
|
|
|
105
105
|
async fetch(): Promise<void> {
|
|
106
106
|
try {
|
|
107
|
-
const dataAndContext =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const dataAndContext = await (
|
|
108
|
+
this.program.account as any
|
|
109
|
+
).insuranceFundStake.fetchAndContext(
|
|
110
|
+
this.insuranceFundStakeAccountPublicKey,
|
|
111
|
+
this.accountLoader.commitment
|
|
112
|
+
);
|
|
112
113
|
if (
|
|
113
114
|
dataAndContext.context.slot >
|
|
114
115
|
(this.insuranceFundStakeAccountAndSlot?.slot ?? 0)
|
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
OracleEvents,
|
|
5
5
|
OracleAccountSubscriber,
|
|
6
6
|
} from './types';
|
|
7
|
-
import { Program } from '@coral-xyz/anchor';
|
|
8
7
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
9
8
|
import { EventEmitter } from 'events';
|
|
10
9
|
import { PublicKey } from '@solana/web3.js';
|
|
11
10
|
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
12
11
|
import { OracleClient, OraclePriceData } from '../oracles/types';
|
|
12
|
+
import { DriftProgram } from '../config';
|
|
13
13
|
|
|
14
14
|
export class PollingOracleAccountSubscriber implements OracleAccountSubscriber {
|
|
15
15
|
isSubscribed: boolean;
|
|
16
|
-
program:
|
|
16
|
+
program: DriftProgram;
|
|
17
17
|
eventEmitter: StrictEventEmitter<EventEmitter, OracleEvents>;
|
|
18
18
|
publicKey: PublicKey;
|
|
19
19
|
|