@velocity-exchange/sdk 0.1.0 → 0.2.0
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/CHANGELOG.md +15 -0
- package/bun.lock +23 -1
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +5 -3
- package/lib/browser/accounts/basicUserAccountSubscriber.js +4 -3
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +4 -3
- package/lib/browser/accounts/bulkAccountLoader.d.ts +5 -5
- package/lib/browser/accounts/bulkAccountLoader.js +12 -1
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcAccountSubscriber.js +8 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +13 -5
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +12 -8
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +8 -2
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +3 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +4 -3
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +16 -5
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +16 -5
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +8 -4
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +17 -11
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +6 -6
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
- package/lib/browser/accounts/types.d.ts +4 -4
- package/lib/browser/accounts/utils.d.ts +1 -0
- package/lib/browser/accounts/utils.js +8 -1
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketAccountSubscriber.js +17 -5
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +17 -6
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +14 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +9 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +0 -3
- package/lib/browser/addresses/marketAddresses.js +3 -2
- package/lib/browser/addresses/pda.d.ts +0 -2
- package/lib/browser/addresses/pda.js +1 -14
- package/lib/browser/adminClient.d.ts +24 -28
- package/lib/browser/adminClient.js +156 -157
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +6 -4
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/browser/bankrun/bankrunConnection.d.ts +6 -4
- package/lib/browser/bankrun/bankrunConnection.js +69 -31
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +3 -2
- package/lib/browser/clock/clockSubscriber.d.ts +6 -6
- package/lib/browser/clock/clockSubscriber.js +4 -3
- package/lib/browser/config.d.ts +1 -1
- package/lib/browser/config.js +8 -4
- package/lib/browser/constants/index.d.ts +1 -2
- package/lib/browser/constants/index.js +1 -2
- package/lib/browser/constants/numericConstants.d.ts +1 -3
- package/lib/browser/constants/numericConstants.js +3 -5
- package/lib/browser/constituentMap/constituentMap.js +5 -1
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
- package/lib/browser/core/instructions/perpOrders.d.ts +14 -0
- package/lib/browser/core/instructions/perpOrders.js +14 -0
- package/lib/browser/core/remainingAccounts.d.ts +2 -2
- package/lib/browser/core/remainingAccounts.js +2 -2
- package/lib/browser/decode/user.js +9 -1
- package/lib/browser/dlob/DLOB.d.ts +6 -1
- package/lib/browser/dlob/DLOB.js +201 -138
- package/lib/browser/dlob/DLOBNode.d.ts +5 -2
- package/lib/browser/dlob/DLOBNode.js +7 -0
- package/lib/browser/dlob/DLOBSubscriber.js +37 -32
- package/lib/browser/dlob/NodeList.js +8 -7
- package/lib/browser/dlob/orderBookLevels.js +19 -12
- package/lib/browser/events/eventList.js +4 -1
- package/lib/browser/events/eventSubscriber.d.ts +5 -2
- package/lib/browser/events/eventSubscriber.js +75 -26
- package/lib/browser/events/eventsServerLogProvider.d.ts +1 -1
- package/lib/browser/events/eventsServerLogProvider.js +15 -8
- package/lib/browser/events/fetchLogs.d.ts +1 -1
- package/lib/browser/events/fetchLogs.js +4 -2
- package/lib/browser/events/pollingLogProvider.d.ts +1 -1
- package/lib/browser/events/pollingLogProvider.js +1 -0
- package/lib/browser/events/txEventCache.js +6 -2
- package/lib/browser/events/types.d.ts +2 -4
- package/lib/browser/events/types.js +0 -2
- package/lib/browser/events/webSocketLogProvider.d.ts +1 -1
- package/lib/browser/events/webSocketLogProvider.js +5 -2
- package/lib/browser/factory/bigNum.js +1 -1
- package/lib/browser/idl/velocity.d.ts +1243 -1586
- package/lib/browser/idl/velocity.json +1234 -1577
- package/lib/browser/index.d.ts +0 -2
- package/lib/browser/index.js +0 -2
- package/lib/browser/jupiter/jupiterClient.d.ts +1 -1
- package/lib/browser/jupiter/jupiterClient.js +18 -8
- package/lib/browser/marginCalculation.js +1 -0
- package/lib/browser/math/amm.d.ts +31 -13
- package/lib/browser/math/amm.js +77 -22
- package/lib/browser/math/bankruptcy.js +1 -1
- package/lib/browser/math/funding.js +6 -6
- package/lib/browser/math/insurance.d.ts +1 -1
- package/lib/browser/math/insurance.js +4 -5
- package/lib/browser/math/margin.d.ts +1 -9
- package/lib/browser/math/margin.js +3 -62
- package/lib/browser/math/market.d.ts +4 -12
- package/lib/browser/math/market.js +6 -40
- package/lib/browser/math/oracles.d.ts +0 -3
- package/lib/browser/math/oracles.js +1 -14
- package/lib/browser/math/orders.d.ts +0 -5
- package/lib/browser/math/orders.js +2 -74
- package/lib/browser/math/position.d.ts +0 -4
- package/lib/browser/math/position.js +5 -10
- package/lib/browser/math/repeg.d.ts +0 -1
- package/lib/browser/math/repeg.js +1 -23
- package/lib/browser/math/spotBalance.d.ts +4 -4
- package/lib/browser/math/spotBalance.js +6 -6
- package/lib/browser/math/spotMarket.d.ts +0 -6
- package/lib/browser/math/spotMarket.js +1 -16
- package/lib/browser/math/spotPosition.d.ts +4 -4
- package/lib/browser/math/state.d.ts +0 -2
- package/lib/browser/math/state.js +1 -9
- package/lib/browser/math/superStake.d.ts +3 -53
- package/lib/browser/math/superStake.js +16 -13
- package/lib/browser/math/trade.js +6 -6
- package/lib/browser/memcmp.d.ts +0 -1
- package/lib/browser/memcmp.js +1 -10
- package/lib/browser/oracles/prelaunchOracleClient.js +3 -2
- package/lib/browser/oracles/pythClient.js +9 -3
- package/lib/browser/oracles/pythLazerClient.js +3 -2
- package/lib/browser/oracles/utils.d.ts +4 -0
- package/lib/browser/oracles/utils.js +9 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +1 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -2
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +32 -8
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/pyth/types.d.ts +0 -1
- package/lib/browser/slot/SlotSubscriber.d.ts +1 -1
- package/lib/browser/slot/SlotSubscriber.js +2 -1
- package/lib/browser/slot/SlothashSubscriber.d.ts +3 -2
- package/lib/browser/slot/SlothashSubscriber.js +11 -4
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +13 -5
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +1 -1
- package/lib/browser/swift/swiftOrderSubscriber.js +10 -5
- package/lib/browser/testClient.js +3 -2
- package/lib/browser/tokenFaucet.js +16 -2
- package/lib/browser/tx/baseTxSender.d.ts +4 -4
- package/lib/browser/tx/baseTxSender.js +5 -4
- package/lib/browser/tx/fastSingleTxSender.d.ts +3 -3
- package/lib/browser/tx/fastSingleTxSender.js +9 -5
- package/lib/browser/tx/reportTransactionError.d.ts +2 -2
- package/lib/browser/tx/reportTransactionError.js +5 -1
- package/lib/browser/tx/retryTxSender.d.ts +1 -1
- package/lib/browser/tx/retryTxSender.js +4 -2
- package/lib/browser/tx/txHandler.d.ts +7 -1
- package/lib/browser/tx/txHandler.js +54 -40
- package/lib/browser/tx/txParamProcessor.d.ts +4 -1
- package/lib/browser/tx/txParamProcessor.js +6 -0
- package/lib/browser/tx/types.d.ts +1 -1
- package/lib/browser/tx/whileValidTxSender.d.ts +1 -6
- package/lib/browser/tx/whileValidTxSender.js +35 -13
- package/lib/browser/types.d.ts +27 -70
- package/lib/browser/types.js +2 -2
- package/lib/browser/user.d.ts +21 -7
- package/lib/browser/user.js +156 -132
- package/lib/browser/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/browser/userMap/grpcSubscription.d.ts +1 -1
- package/lib/browser/userMap/referrerMap.js +10 -3
- package/lib/browser/userMap/revenueShareEscrowMap.js +4 -0
- package/lib/browser/userMap/userMap.d.ts +1 -1
- package/lib/browser/userMap/userMap.js +36 -23
- package/lib/browser/userMap/userStatsMap.d.ts +1 -1
- package/lib/browser/userMap/userStatsMap.js +18 -13
- package/lib/browser/userStats.d.ts +7 -2
- package/lib/browser/userStats.js +18 -4
- package/lib/browser/util/TransactionConfirmationManager.js +4 -2
- package/lib/browser/util/chainClock.d.ts +1 -1
- package/lib/browser/util/computeUnits.d.ts +1 -1
- package/lib/browser/util/computeUnits.js +6 -1
- package/lib/browser/velocityClient.d.ts +92 -34
- package/lib/browser/velocityClient.js +414 -280
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +5 -3
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserAccountSubscriber.js +4 -3
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +4 -3
- package/lib/node/accounts/bulkAccountLoader.d.ts +5 -5
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/bulkAccountLoader.js +12 -1
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcAccountSubscriber.js +8 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +13 -5
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +12 -8
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +8 -2
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +3 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +4 -3
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +16 -5
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +16 -5
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +8 -4
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +17 -11
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +6 -6
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
- package/lib/node/accounts/types.d.ts +4 -4
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/utils.d.ts +1 -0
- package/lib/node/accounts/utils.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +8 -1
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +17 -5
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +17 -6
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +14 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +9 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +0 -3
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
- package/lib/node/addresses/marketAddresses.js +3 -2
- package/lib/node/addresses/pda.d.ts +0 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +1 -14
- package/lib/node/adminClient.d.ts +24 -28
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +156 -157
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +6 -4
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/node/bankrun/bankrunConnection.d.ts +6 -4
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.js +69 -31
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +3 -2
- package/lib/node/clock/clockSubscriber.d.ts +6 -6
- package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.js +4 -3
- package/lib/node/config.d.ts +1 -1
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +8 -4
- package/lib/node/constants/index.d.ts +1 -2
- package/lib/node/constants/index.d.ts.map +1 -1
- package/lib/node/constants/index.js +1 -2
- package/lib/node/constants/numericConstants.d.ts +1 -3
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +3 -5
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +5 -1
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
- package/lib/node/core/instructions/perpOrders.d.ts +14 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
- package/lib/node/core/instructions/perpOrders.js +14 -0
- package/lib/node/core/remainingAccounts.d.ts +2 -2
- package/lib/node/core/remainingAccounts.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.js +2 -2
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +9 -1
- package/lib/node/dlob/DLOB.d.ts +6 -1
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +201 -138
- package/lib/node/dlob/DLOBNode.d.ts +5 -2
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +7 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +37 -32
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.js +8 -7
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +19 -12
- package/lib/node/events/eventList.d.ts +3 -3
- package/lib/node/events/eventList.d.ts.map +1 -1
- package/lib/node/events/eventList.js +4 -1
- package/lib/node/events/eventSubscriber.d.ts +5 -2
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +75 -26
- package/lib/node/events/eventsServerLogProvider.d.ts +2 -2
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
- package/lib/node/events/eventsServerLogProvider.js +15 -8
- package/lib/node/events/fetchLogs.d.ts +1 -1
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.js +4 -2
- package/lib/node/events/pollingLogProvider.d.ts +2 -2
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
- package/lib/node/events/pollingLogProvider.js +1 -0
- package/lib/node/events/txEventCache.d.ts +3 -3
- package/lib/node/events/txEventCache.d.ts.map +1 -1
- package/lib/node/events/txEventCache.js +6 -2
- package/lib/node/events/types.d.ts +2 -4
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +0 -2
- package/lib/node/events/webSocketLogProvider.d.ts +2 -2
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
- package/lib/node/events/webSocketLogProvider.js +5 -2
- package/lib/node/factory/bigNum.js +1 -1
- package/lib/node/idl/velocity.d.ts +1243 -1586
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +1234 -1577
- package/lib/node/index.d.ts +0 -2
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -2
- package/lib/node/jupiter/jupiterClient.d.ts +1 -1
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.js +18 -8
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marginCalculation.js +1 -0
- package/lib/node/math/amm.d.ts +31 -13
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +77 -22
- package/lib/node/math/bankruptcy.js +1 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +6 -6
- package/lib/node/math/insurance.d.ts +1 -1
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +4 -5
- package/lib/node/math/margin.d.ts +1 -9
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +3 -62
- package/lib/node/math/market.d.ts +4 -12
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +6 -40
- package/lib/node/math/oracles.d.ts +0 -3
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +1 -14
- package/lib/node/math/orders.d.ts +0 -5
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +2 -74
- package/lib/node/math/position.d.ts +1 -5
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +5 -10
- package/lib/node/math/repeg.d.ts +0 -1
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/repeg.js +1 -23
- package/lib/node/math/spotBalance.d.ts +4 -4
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +6 -6
- package/lib/node/math/spotMarket.d.ts +0 -6
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +1 -16
- package/lib/node/math/spotPosition.d.ts +4 -4
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/state.d.ts +0 -2
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/state.js +1 -9
- package/lib/node/math/superStake.d.ts +3 -53
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +16 -13
- package/lib/node/math/trade.d.ts +2 -2
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +6 -6
- package/lib/node/memcmp.d.ts +0 -1
- package/lib/node/memcmp.d.ts.map +1 -1
- package/lib/node/memcmp.js +1 -10
- package/lib/node/oracles/oracleClientCache.d.ts +1 -1
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +3 -2
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.js +9 -3
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +3 -2
- package/lib/node/oracles/utils.d.ts +4 -0
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/oracles/utils.js +9 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +8 -2
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +32 -8
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/pyth/types.d.ts +0 -1
- package/lib/node/pyth/types.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.d.ts +1 -1
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.js +2 -1
- package/lib/node/slot/SlothashSubscriber.d.ts +3 -2
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlothashSubscriber.js +11 -4
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +13 -5
- package/lib/node/swift/swiftOrderSubscriber.d.ts +1 -1
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +10 -5
- package/lib/node/testClient.js +3 -2
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +16 -2
- package/lib/node/tx/baseTxSender.d.ts +4 -4
- package/lib/node/tx/baseTxSender.d.ts.map +1 -1
- package/lib/node/tx/baseTxSender.js +5 -4
- package/lib/node/tx/fastSingleTxSender.d.ts +3 -3
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.js +9 -5
- package/lib/node/tx/reportTransactionError.d.ts +2 -2
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
- package/lib/node/tx/reportTransactionError.js +5 -1
- package/lib/node/tx/retryTxSender.d.ts +1 -1
- package/lib/node/tx/retryTxSender.d.ts.map +1 -1
- package/lib/node/tx/retryTxSender.js +4 -2
- package/lib/node/tx/txHandler.d.ts +9 -3
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +54 -40
- package/lib/node/tx/txParamProcessor.d.ts +4 -1
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
- package/lib/node/tx/txParamProcessor.js +6 -0
- package/lib/node/tx/types.d.ts +1 -1
- package/lib/node/tx/types.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.d.ts +1 -6
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.js +35 -13
- package/lib/node/types.d.ts +25 -68
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +2 -2
- package/lib/node/user.d.ts +21 -7
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +156 -132
- package/lib/node/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/userMap/grpcSubscription.d.ts +1 -1
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +10 -3
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +4 -0
- package/lib/node/userMap/userMap.d.ts +1 -1
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +36 -23
- package/lib/node/userMap/userStatsMap.d.ts +1 -1
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +18 -13
- package/lib/node/userStats.d.ts +7 -2
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +18 -4
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
- package/lib/node/util/TransactionConfirmationManager.js +4 -2
- package/lib/node/util/chainClock.d.ts +1 -1
- package/lib/node/util/chainClock.d.ts.map +1 -1
- package/lib/node/util/computeUnits.d.ts +1 -1
- package/lib/node/util/computeUnits.d.ts.map +1 -1
- package/lib/node/util/computeUnits.js +6 -1
- package/lib/node/velocityClient.d.ts +93 -35
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +414 -280
- package/package.json +5 -3
- package/src/accounts/basicUserAccountSubscriber.ts +7 -5
- package/src/accounts/basicUserStatsAccountSubscriber.ts +9 -5
- package/src/accounts/bulkAccountLoader.ts +20 -7
- package/src/accounts/grpcAccountSubscriber.ts +11 -3
- package/src/accounts/grpcMultiAccountSubscriber.ts +24 -9
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +16 -12
- package/src/accounts/grpcProgramAccountSubscriber.ts +11 -3
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +17 -7
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +66 -39
- package/src/accounts/laserProgramAccountSubscriber.ts +3 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +5 -3
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +8 -3
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -5
- package/src/accounts/pollingOracleAccountSubscriber.ts +17 -10
- package/src/accounts/pollingTokenAccountSubscriber.ts +17 -10
- package/src/accounts/pollingUserAccountSubscriber.ts +26 -20
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +12 -10
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +76 -30
- package/src/accounts/types.ts +6 -4
- package/src/accounts/utils.ts +10 -0
- package/src/accounts/webSocketAccountSubscriber.ts +23 -10
- package/src/accounts/webSocketAccountSubscriberV2.ts +23 -8
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +17 -2
- package/src/accounts/webSocketProgramAccountSubscriber.ts +29 -4
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +30 -4
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +29 -4
- package/src/accounts/webSocketUserAccountSubscriber.ts +11 -2
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +15 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +76 -48
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +74 -35
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +1 -6
- package/src/addresses/marketAddresses.ts +3 -2
- package/src/addresses/pda.ts +0 -25
- package/src/adminClient.ts +273 -303
- package/src/auctionSubscriber/auctionSubscriber.ts +7 -5
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -5
- package/src/bankrun/bankrunConnection.ts +83 -39
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +5 -4
- package/src/clock/clockSubscriber.ts +10 -9
- package/src/config.ts +8 -3
- package/src/constants/index.ts +1 -2
- package/src/constants/numericConstants.ts +3 -3
- package/src/constituentMap/constituentMap.ts +8 -1
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +4 -2
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +13 -4
- package/src/core/instructions/perpOrders.ts +14 -0
- package/src/core/remainingAccounts.ts +4 -4
- package/src/decode/user.ts +8 -1
- package/src/dlob/DLOB.ts +296 -172
- package/src/dlob/DLOBNode.ts +23 -3
- package/src/dlob/DLOBSubscriber.ts +51 -34
- package/src/dlob/NodeList.ts +8 -7
- package/src/dlob/orderBookLevels.ts +45 -25
- package/src/events/eventList.ts +4 -1
- package/src/events/eventSubscriber.ts +107 -49
- package/src/events/eventsServerLogProvider.ts +22 -13
- package/src/events/fetchLogs.ts +3 -3
- package/src/events/pollingLogProvider.ts +2 -2
- package/src/events/txEventCache.ts +8 -2
- package/src/events/types.ts +0 -8
- package/src/events/webSocketLogProvider.ts +5 -3
- package/src/factory/bigNum.ts +2 -2
- package/src/idl/velocity.json +1234 -1577
- package/src/idl/velocity.ts +1234 -1577
- package/src/index.ts +0 -2
- package/src/jupiter/jupiterClient.ts +30 -10
- package/src/marginCalculation.ts +1 -0
- package/src/math/amm.ts +188 -33
- package/src/math/bankruptcy.ts +1 -1
- package/src/math/funding.ts +7 -6
- package/src/math/insurance.ts +6 -8
- package/src/math/margin.ts +5 -112
- package/src/math/market.ts +6 -96
- package/src/math/oracles.ts +0 -17
- package/src/math/orders.ts +1 -110
- package/src/math/position.ts +4 -16
- package/src/math/repeg.ts +0 -29
- package/src/math/spotBalance.ts +14 -10
- package/src/math/spotMarket.ts +2 -28
- package/src/math/spotPosition.ts +4 -4
- package/src/math/state.ts +0 -8
- package/src/math/superStake.ts +19 -65
- package/src/math/trade.ts +2 -6
- package/src/memcmp.ts +0 -9
- package/src/oracles/prelaunchOracleClient.ts +7 -2
- package/src/oracles/pythClient.ts +12 -3
- package/src/oracles/pythLazerClient.ts +7 -2
- package/src/oracles/utils.ts +15 -0
- package/src/orderSubscriber/OrderSubscriber.ts +10 -4
- package/src/priorityFee/heliusPriorityFeeMethod.ts +1 -1
- package/src/priorityFee/priorityFeeSubscriber.ts +45 -9
- package/src/priorityFee/solanaPriorityFeeMethod.ts +1 -1
- package/src/pyth/types.ts +0 -2
- package/src/slot/SlotSubscriber.ts +3 -3
- package/src/slot/SlothashSubscriber.ts +17 -6
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +5 -6
- package/src/swift/signedMsgUserAccountSubscriber.ts +16 -8
- package/src/swift/swiftOrderSubscriber.ts +10 -9
- package/src/testClient.ts +2 -2
- package/src/tokenFaucet.ts +22 -3
- package/src/tx/baseTxSender.ts +10 -10
- package/src/tx/fastSingleTxSender.ts +12 -8
- package/src/tx/reportTransactionError.ts +12 -7
- package/src/tx/retryTxSender.ts +6 -4
- package/src/tx/txHandler.ts +88 -43
- package/src/tx/txParamProcessor.ts +18 -3
- package/src/tx/types.ts +1 -1
- package/src/tx/whileValidTxSender.ts +51 -22
- package/src/types.ts +39 -75
- package/src/user.ts +200 -152
- package/src/userMap/WebsocketSubscription.ts +1 -1
- package/src/userMap/grpcSubscription.ts +1 -1
- package/src/userMap/referrerMap.ts +13 -9
- package/src/userMap/revenueShareEscrowMap.ts +6 -1
- package/src/userMap/userMap.ts +43 -25
- package/src/userMap/userStatsMap.ts +32 -19
- package/src/userStats.ts +21 -8
- package/src/util/TransactionConfirmationManager.ts +10 -2
- package/src/util/chainClock.ts +1 -1
- package/src/util/computeUnits.ts +7 -3
- package/src/velocityClient.ts +536 -383
- package/tests/amm/test.ts +138 -0
- package/tests/dlob/helpers.ts +6 -1
- package/tsconfig.json +1 -0
- package/lib/browser/constants/insuranceFund.d.ts +0 -5
- package/lib/browser/constants/insuranceFund.js +0 -9
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +0 -37
- package/lib/browser/tx/forwardOnlyTxSender.js +0 -92
- package/lib/browser/util/tps.d.ts +0 -2
- package/lib/browser/util/tps.js +0 -16
- package/lib/node/constants/insuranceFund.d.ts +0 -6
- package/lib/node/constants/insuranceFund.d.ts.map +0 -1
- package/lib/node/constants/insuranceFund.js +0 -9
- package/lib/node/tx/forwardOnlyTxSender.d.ts +0 -38
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +0 -1
- package/lib/node/tx/forwardOnlyTxSender.js +0 -92
- package/lib/node/util/tps.d.ts +0 -3
- package/lib/node/util/tps.d.ts.map +0 -1
- package/lib/node/util/tps.js +0 -16
- package/src/constants/insuranceFund.ts +0 -8
- package/src/tx/forwardOnlyTxSender.ts +0 -145
- package/src/util/tps.ts +0 -27
|
@@ -25,6 +25,10 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
25
25
|
this.spotOracleStringMap = new Map();
|
|
26
26
|
this.oracles = new Map();
|
|
27
27
|
this.isSubscribing = false;
|
|
28
|
+
this.subscriptionPromiseResolver = () => { };
|
|
29
|
+
this.subscriptionPromise = new Promise((res) => {
|
|
30
|
+
this.subscriptionPromiseResolver = res;
|
|
31
|
+
});
|
|
28
32
|
this.isSubscribed = false;
|
|
29
33
|
this.program = program;
|
|
30
34
|
this.eventEmitter = new events_1.EventEmitter();
|
|
@@ -148,21 +152,39 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
148
152
|
this.eventEmitter.emit('error', error);
|
|
149
153
|
});
|
|
150
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Routes a freshly-decoded account into the correct container based on
|
|
157
|
+
* its poll key. Replaces dynamic `this[key]` indexing with explicit,
|
|
158
|
+
* type-checked dispatch.
|
|
159
|
+
*/
|
|
160
|
+
storeDecodedAccount(accountToPoll, account, slot) {
|
|
161
|
+
const dataAndSlot = { data: account, slot };
|
|
162
|
+
switch (accountToPoll.key) {
|
|
163
|
+
case 'perpMarket':
|
|
164
|
+
if (accountToPoll.mapKey !== undefined) {
|
|
165
|
+
this.perpMarket.set(accountToPoll.mapKey, dataAndSlot);
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
case 'spotMarket':
|
|
169
|
+
if (accountToPoll.mapKey !== undefined) {
|
|
170
|
+
this.spotMarket.set(accountToPoll.mapKey, dataAndSlot);
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
case 'state':
|
|
174
|
+
this.state = dataAndSlot;
|
|
175
|
+
break;
|
|
176
|
+
default: {
|
|
177
|
+
const _exhaustive = accountToPoll.key;
|
|
178
|
+
throw new Error(`Unhandled account poll key: ${String(_exhaustive)}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
151
182
|
async addAccountToAccountLoader(accountToPoll) {
|
|
152
183
|
accountToPoll.callbackId = await this.accountLoader.addAccount(accountToPoll.publicKey, (buffer, slot) => {
|
|
153
184
|
if (!buffer)
|
|
154
185
|
return;
|
|
155
186
|
const account = this.program.coder.accounts.decodeUnchecked(accountToPoll.key, buffer);
|
|
156
|
-
|
|
157
|
-
data: account,
|
|
158
|
-
slot,
|
|
159
|
-
};
|
|
160
|
-
if (accountToPoll.mapKey != undefined) {
|
|
161
|
-
this[accountToPoll.key].set(accountToPoll.mapKey, dataAndSlot);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
this[accountToPoll.key] = dataAndSlot;
|
|
165
|
-
}
|
|
187
|
+
this.storeDecodedAccount(accountToPoll, account, slot);
|
|
166
188
|
// @ts-ignore
|
|
167
189
|
this.eventEmitter.emit(accountToPoll.eventType, account);
|
|
168
190
|
this.eventEmitter.emit('update');
|
|
@@ -177,6 +199,8 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
177
199
|
oracleToPoll.callbackId = await this.accountLoader.addAccount(oracleToPoll.publicKey, (buffer, slot) => {
|
|
178
200
|
if (!buffer)
|
|
179
201
|
return;
|
|
202
|
+
if (!oracleClient)
|
|
203
|
+
return;
|
|
180
204
|
const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(buffer);
|
|
181
205
|
const dataAndSlot = {
|
|
182
206
|
data: oraclePriceData,
|
|
@@ -197,18 +221,7 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
197
221
|
const { buffer, slot } = bufferAndSlot;
|
|
198
222
|
if (buffer) {
|
|
199
223
|
const account = this.program.coder.accounts.decodeUnchecked(accountToPoll.key, buffer);
|
|
200
|
-
|
|
201
|
-
this[accountToPoll.key].set(accountToPoll.mapKey, {
|
|
202
|
-
data: account,
|
|
203
|
-
slot,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
this[accountToPoll.key] = {
|
|
208
|
-
data: account,
|
|
209
|
-
slot,
|
|
210
|
-
};
|
|
211
|
-
}
|
|
224
|
+
this.storeDecodedAccount(accountToPoll, account, slot);
|
|
212
225
|
}
|
|
213
226
|
}
|
|
214
227
|
for (const [_, oracleToPoll] of this.oraclesToPoll) {
|
|
@@ -219,6 +232,9 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
219
232
|
const { buffer, slot } = bufferAndSlot;
|
|
220
233
|
if (buffer) {
|
|
221
234
|
const oracleClient = this.oracleClientCache.get(oracleToPoll.source, this.program.provider.connection, this.program);
|
|
235
|
+
if (!oracleClient) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
222
238
|
const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(buffer);
|
|
223
239
|
this.oracles.set((0, oracleId_1.getOracleId)(oracleToPoll.publicKey, oracleToPoll.source), {
|
|
224
240
|
data: oraclePriceData,
|
|
@@ -252,6 +268,9 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
252
268
|
}
|
|
253
269
|
await this.addSpotMarketAccountToPoll(marketIndex);
|
|
254
270
|
const accountToPoll = this.accountsToPoll.get(marketPublicKey.toString());
|
|
271
|
+
if (!accountToPoll) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
255
274
|
await this.addAccountToAccountLoader(accountToPoll);
|
|
256
275
|
this.setSpotOracleMap();
|
|
257
276
|
return true;
|
|
@@ -263,6 +282,9 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
263
282
|
}
|
|
264
283
|
await this.addPerpMarketAccountToPoll(marketIndex);
|
|
265
284
|
const accountToPoll = this.accountsToPoll.get(marketPublicKey.toString());
|
|
285
|
+
if (!accountToPoll) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
266
288
|
await this.addAccountToAccountLoader(accountToPoll);
|
|
267
289
|
await this.setPerpOracleMap();
|
|
268
290
|
return true;
|
|
@@ -278,7 +300,9 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
278
300
|
if (!this.oraclesToPoll.has(oracleId)) {
|
|
279
301
|
this.addOracleToPoll(oracleInfo);
|
|
280
302
|
const oracleToPoll = this.oraclesToPoll.get(oracleId);
|
|
281
|
-
|
|
303
|
+
if (oracleToPoll) {
|
|
304
|
+
await this.addOracleToAccountLoader(oracleToPoll);
|
|
305
|
+
}
|
|
282
306
|
}
|
|
283
307
|
await this.pauseForOracleToBeAdded(3, oracleInfo.publicKey.toBase58());
|
|
284
308
|
return true;
|
|
@@ -338,8 +362,16 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
338
362
|
}
|
|
339
363
|
const { perpMarketIndexes, oracles } = (0, utils_1.findDelistedPerpMarketsAndOracles)(this.getMarketAccountsAndSlots(), this.getSpotMarketAccountsAndSlots());
|
|
340
364
|
for (const perpMarketIndex of perpMarketIndexes) {
|
|
341
|
-
const
|
|
342
|
-
|
|
365
|
+
const perpMarketData = this.perpMarket.get(perpMarketIndex);
|
|
366
|
+
if (!perpMarketData) {
|
|
367
|
+
throw new Error(`PollingVelocityClientAccountSubscriber: delisted perp market ${perpMarketIndex} not found in perpMarket map`);
|
|
368
|
+
}
|
|
369
|
+
const perpMarketPubkey = perpMarketData.data.pubkey;
|
|
370
|
+
const accountToPoll = this.accountsToPoll.get(perpMarketPubkey.toBase58());
|
|
371
|
+
if (!accountToPoll) {
|
|
372
|
+
throw new Error(`PollingVelocityClientAccountSubscriber: delisted perp market ${perpMarketIndex} not found in accountsToPoll map`);
|
|
373
|
+
}
|
|
374
|
+
const callbackId = accountToPoll.callbackId;
|
|
343
375
|
this.accountLoader.removeAccount(perpMarketPubkey, callbackId);
|
|
344
376
|
if (this.delistedMarketSetting === types_1.DelistedMarketSetting.Discard) {
|
|
345
377
|
this.perpMarket.delete(perpMarketIndex);
|
|
@@ -347,7 +379,11 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
347
379
|
}
|
|
348
380
|
for (const oracle of oracles) {
|
|
349
381
|
const oracleId = (0, oracleId_1.getOracleId)(oracle.publicKey, oracle.source);
|
|
350
|
-
const
|
|
382
|
+
const oracleToPoll = this.oraclesToPoll.get(oracleId);
|
|
383
|
+
if (!oracleToPoll) {
|
|
384
|
+
throw new Error(`PollingVelocityClientAccountSubscriber: delisted oracle ${oracleId} not found in oraclesToPoll map`);
|
|
385
|
+
}
|
|
386
|
+
const callbackId = oracleToPoll.callbackId;
|
|
351
387
|
this.accountLoader.removeAccount(oracle.publicKey, callbackId);
|
|
352
388
|
if (this.delistedMarketSetting === types_1.DelistedMarketSetting.Discard) {
|
|
353
389
|
this.oracles.delete(oracleId);
|
|
@@ -389,7 +425,7 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
389
425
|
const perpMarketAccount = this.getMarketAccountAndSlot(marketIndex);
|
|
390
426
|
const oracle = this.perpOracleMap.get(marketIndex);
|
|
391
427
|
const oracleId = this.perpOracleStringMap.get(marketIndex);
|
|
392
|
-
if (!perpMarketAccount || !oracle) {
|
|
428
|
+
if (!perpMarketAccount || !oracle || !oracleId) {
|
|
393
429
|
return undefined;
|
|
394
430
|
}
|
|
395
431
|
if (!perpMarketAccount.data.oracle.equals(oracle)) {
|
|
@@ -402,7 +438,7 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
402
438
|
const spotMarketAccount = this.getSpotMarketAccountAndSlot(marketIndex);
|
|
403
439
|
const oracle = this.spotOracleMap.get(marketIndex);
|
|
404
440
|
const oracleId = this.spotOracleStringMap.get(marketIndex);
|
|
405
|
-
if (!spotMarketAccount || !oracle) {
|
|
441
|
+
if (!spotMarketAccount || !oracle || !oracleId) {
|
|
406
442
|
return undefined;
|
|
407
443
|
}
|
|
408
444
|
if (!spotMarketAccount.data.oracle.equals(oracle)) {
|
|
@@ -85,7 +85,7 @@ export interface UserAccountSubscriber {
|
|
|
85
85
|
fetch(): Promise<void>;
|
|
86
86
|
updateData(userAccount: UserAccount, slot: number): void;
|
|
87
87
|
unsubscribe(): Promise<void>;
|
|
88
|
-
getUserAccountAndSlot(): DataAndSlot<UserAccount
|
|
88
|
+
getUserAccountAndSlot(): DataAndSlot<UserAccount> | undefined;
|
|
89
89
|
}
|
|
90
90
|
export interface TokenAccountEvents {
|
|
91
91
|
tokenAccountUpdate: (payload: Account) => void;
|
|
@@ -106,7 +106,7 @@ export interface InsuranceFundStakeAccountSubscriber {
|
|
|
106
106
|
subscribe(): Promise<boolean>;
|
|
107
107
|
fetch(): Promise<void>;
|
|
108
108
|
unsubscribe(): Promise<void>;
|
|
109
|
-
getInsuranceFundStakeAccountAndSlot(): DataAndSlot<InsuranceFundStake
|
|
109
|
+
getInsuranceFundStakeAccountAndSlot(): DataAndSlot<InsuranceFundStake> | undefined;
|
|
110
110
|
}
|
|
111
111
|
export interface InsuranceFundStakeAccountEvents {
|
|
112
112
|
insuranceFundStakeAccountUpdate: (payload: InsuranceFundStake) => void;
|
|
@@ -127,7 +127,7 @@ export interface OracleAccountSubscriber {
|
|
|
127
127
|
getOraclePriceData(): DataAndSlot<OraclePriceData>;
|
|
128
128
|
}
|
|
129
129
|
export type AccountToPoll = {
|
|
130
|
-
key:
|
|
130
|
+
key: 'state' | 'perpMarket' | 'spotMarket';
|
|
131
131
|
publicKey: PublicKey;
|
|
132
132
|
eventType: string;
|
|
133
133
|
callbackId?: string;
|
|
@@ -163,7 +163,7 @@ export interface UserStatsAccountSubscriber {
|
|
|
163
163
|
subscribe(userStatsAccount?: UserStatsAccount): Promise<boolean>;
|
|
164
164
|
fetch(): Promise<void>;
|
|
165
165
|
unsubscribe(): Promise<void>;
|
|
166
|
-
getUserStatsAccountAndSlot(): DataAndSlot<UserStatsAccount
|
|
166
|
+
getUserStatsAccountAndSlot(): DataAndSlot<UserStatsAccount> | undefined;
|
|
167
167
|
}
|
|
168
168
|
type BaseGrpcConfigs = {
|
|
169
169
|
endpoint: string;
|
|
@@ -2,6 +2,7 @@ import { DataAndSlot } from './types';
|
|
|
2
2
|
import { PerpMarketAccount, SpotMarketAccount } from '../types';
|
|
3
3
|
import { OracleInfo } from '../oracles/types';
|
|
4
4
|
export declare function capitalize(value: string): string;
|
|
5
|
+
export declare function assertDataAndSlot<T>(dataAndSlot: DataAndSlot<T> | undefined, message: string): DataAndSlot<T>;
|
|
5
6
|
export declare function findDelistedPerpMarketsAndOracles(perpMarkets: DataAndSlot<PerpMarketAccount>[], spotMarkets: DataAndSlot<SpotMarketAccount>[]): {
|
|
6
7
|
perpMarketIndexes: number[];
|
|
7
8
|
oracles: OracleInfo[];
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findDelistedPerpMarketsAndOracles = exports.capitalize = void 0;
|
|
3
|
+
exports.findDelistedPerpMarketsAndOracles = exports.assertDataAndSlot = exports.capitalize = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const oracleId_1 = require("../oracles/oracleId");
|
|
6
6
|
function capitalize(value) {
|
|
7
7
|
return value[0].toUpperCase() + value.slice(1);
|
|
8
8
|
}
|
|
9
9
|
exports.capitalize = capitalize;
|
|
10
|
+
function assertDataAndSlot(dataAndSlot, message) {
|
|
11
|
+
if (!dataAndSlot) {
|
|
12
|
+
throw new Error(message);
|
|
13
|
+
}
|
|
14
|
+
return dataAndSlot;
|
|
15
|
+
}
|
|
16
|
+
exports.assertDataAndSlot = assertDataAndSlot;
|
|
10
17
|
function findDelistedPerpMarketsAndOracles(perpMarkets, spotMarkets) {
|
|
11
18
|
const delistedPerpMarketIndexes = [];
|
|
12
19
|
const delistedOracles = [];
|
|
@@ -10,8 +10,10 @@ export declare class WebSocketAccountSubscriber<T> implements AccountSubscriber<
|
|
|
10
10
|
logAccountName: string;
|
|
11
11
|
program: VelocityProgram;
|
|
12
12
|
accountPublicKey: PublicKey;
|
|
13
|
-
decodeBufferFn
|
|
14
|
-
|
|
13
|
+
decodeBufferFn?: (buffer: Buffer) => T;
|
|
14
|
+
private _onChange?;
|
|
15
|
+
get onChange(): (data: T) => void;
|
|
16
|
+
set onChange(onChange: (data: T) => void);
|
|
15
17
|
listenerId?: number;
|
|
16
18
|
resubOpts?: ResubOpts;
|
|
17
19
|
commitment?: Commitment;
|
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebSocketAccountSubscriber = void 0;
|
|
4
4
|
class WebSocketAccountSubscriber {
|
|
5
|
+
get onChange() {
|
|
6
|
+
if (!this._onChange) {
|
|
7
|
+
throw new Error('onChange callback function must be set');
|
|
8
|
+
}
|
|
9
|
+
return this._onChange;
|
|
10
|
+
}
|
|
11
|
+
set onChange(onChange) {
|
|
12
|
+
this._onChange = onChange;
|
|
13
|
+
}
|
|
5
14
|
constructor(accountName, program, accountPublicKey, decodeBuffer, resubOpts, commitment) {
|
|
6
15
|
var _a;
|
|
7
16
|
this.isUnsubscribing = false;
|
|
@@ -11,7 +20,8 @@ class WebSocketAccountSubscriber {
|
|
|
11
20
|
this.accountPublicKey = accountPublicKey;
|
|
12
21
|
this.decodeBufferFn = decodeBuffer;
|
|
13
22
|
this.resubOpts = resubOpts;
|
|
14
|
-
if (((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs)
|
|
23
|
+
if (((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) != null &&
|
|
24
|
+
this.resubOpts.resubTimeoutMs < 1000) {
|
|
15
25
|
console.log(`resubTimeoutMs should be at least 1000ms to avoid spamming resub ${this.logAccountName}`);
|
|
16
26
|
}
|
|
17
27
|
this.receivingData = false;
|
|
@@ -54,12 +64,12 @@ class WebSocketAccountSubscriber {
|
|
|
54
64
|
}
|
|
55
65
|
this.dataAndSlot = {
|
|
56
66
|
data,
|
|
57
|
-
slot,
|
|
67
|
+
slot: newSlot,
|
|
58
68
|
};
|
|
59
69
|
}
|
|
60
70
|
setTimeout() {
|
|
61
71
|
var _a;
|
|
62
|
-
if (!this.
|
|
72
|
+
if (!this._onChange) {
|
|
63
73
|
throw new Error('onChange callback function must be set');
|
|
64
74
|
}
|
|
65
75
|
this.timeoutId = setTimeout(async () => {
|
|
@@ -90,8 +100,9 @@ class WebSocketAccountSubscriber {
|
|
|
90
100
|
}, (_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs);
|
|
91
101
|
}
|
|
92
102
|
async fetch() {
|
|
103
|
+
var _a;
|
|
93
104
|
const rpcResponse = await this.program.provider.connection.getAccountInfoAndContext(this.accountPublicKey, this.program.provider.opts.commitment);
|
|
94
|
-
this.handleRpcResponse(rpcResponse.context, rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value);
|
|
105
|
+
this.handleRpcResponse(rpcResponse.context, (_a = rpcResponse === null || rpcResponse === void 0 ? void 0 : rpcResponse.value) !== null && _a !== void 0 ? _a : undefined);
|
|
95
106
|
}
|
|
96
107
|
handleRpcResponse(context, accountInfo) {
|
|
97
108
|
const newSlot = context.slot;
|
|
@@ -136,7 +147,7 @@ class WebSocketAccountSubscriber {
|
|
|
136
147
|
return this.decodeBufferFn(buffer);
|
|
137
148
|
}
|
|
138
149
|
else {
|
|
139
|
-
return this.program.
|
|
150
|
+
return this.program.coder.accounts.decode(this.accountName, buffer);
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
153
|
unsubscribe(onResub = false) {
|
|
@@ -164,6 +175,7 @@ class WebSocketAccountSubscriber {
|
|
|
164
175
|
}
|
|
165
176
|
else {
|
|
166
177
|
this.isUnsubscribing = false;
|
|
178
|
+
return Promise.resolve();
|
|
167
179
|
}
|
|
168
180
|
}
|
|
169
181
|
}
|
|
@@ -59,8 +59,10 @@ export declare class WebSocketAccountSubscriberV2<T> implements AccountSubscribe
|
|
|
59
59
|
logAccountName: string;
|
|
60
60
|
program: VelocityProgram;
|
|
61
61
|
accountPublicKey: PublicKey;
|
|
62
|
-
decodeBufferFn
|
|
63
|
-
|
|
62
|
+
decodeBufferFn?: (buffer: Buffer) => T;
|
|
63
|
+
private _onChange?;
|
|
64
|
+
get onChange(): (data: T) => void;
|
|
65
|
+
set onChange(onChange: (data: T) => void);
|
|
64
66
|
listenerId?: number;
|
|
65
67
|
resubOpts: ResubOpts;
|
|
66
68
|
commitment?: Commitment;
|
|
@@ -56,6 +56,15 @@ const bs58_1 = __importDefault(require("bs58"));
|
|
|
56
56
|
* program provider’s RPC endpoint. Handles base58/base64 encoded data.
|
|
57
57
|
*/
|
|
58
58
|
class WebSocketAccountSubscriberV2 {
|
|
59
|
+
get onChange() {
|
|
60
|
+
if (!this._onChange) {
|
|
61
|
+
throw new Error('onChange callback function must be set');
|
|
62
|
+
}
|
|
63
|
+
return this._onChange;
|
|
64
|
+
}
|
|
65
|
+
set onChange(onChange) {
|
|
66
|
+
this._onChange = onChange;
|
|
67
|
+
}
|
|
59
68
|
/**
|
|
60
69
|
* Create a single-account WebSocket subscriber with optional polling fallback.
|
|
61
70
|
*
|
|
@@ -70,6 +79,7 @@ class WebSocketAccountSubscriberV2 {
|
|
|
70
79
|
* @param rpc Optional override/injection for testing.
|
|
71
80
|
*/
|
|
72
81
|
constructor(accountName, program, accountPublicKey, decodeBuffer, resubOpts, commitment, rpcSubscriptions, rpc) {
|
|
82
|
+
var _a;
|
|
73
83
|
this.isUnsubscribing = false;
|
|
74
84
|
this.accountName = accountName;
|
|
75
85
|
this.logAccountName = `${accountName}-${accountPublicKey.toBase58()}-ws-acct-subscriber-v2`;
|
|
@@ -81,11 +91,12 @@ class WebSocketAccountSubscriberV2 {
|
|
|
81
91
|
usePollingInsteadOfResub: true,
|
|
82
92
|
logResubMessages: false,
|
|
83
93
|
};
|
|
84
|
-
if (this.resubOpts.resubTimeoutMs
|
|
94
|
+
if (this.resubOpts.resubTimeoutMs != null &&
|
|
95
|
+
this.resubOpts.resubTimeoutMs < 1000) {
|
|
85
96
|
console.log(`resubTimeoutMs should be at least 1000ms to avoid spamming resub ${this.logAccountName}`);
|
|
86
97
|
}
|
|
87
98
|
this.receivingData = false;
|
|
88
|
-
if (['recent', 'single', 'singleGossip', 'root', 'max'].includes(this.program.provider.opts.commitment)) {
|
|
99
|
+
if (['recent', 'single', 'singleGossip', 'root', 'max'].includes((_a = this.program.provider.opts.commitment) !== null && _a !== void 0 ? _a : '')) {
|
|
89
100
|
console.warn(`using commitment ${this.program.provider.opts.commitment} that is not supported by gill, this may cause issues`);
|
|
90
101
|
}
|
|
91
102
|
this.commitment =
|
|
@@ -185,7 +196,7 @@ class WebSocketAccountSubscriberV2 {
|
|
|
185
196
|
}
|
|
186
197
|
this.dataAndSlot = {
|
|
187
198
|
data,
|
|
188
|
-
slot,
|
|
199
|
+
slot: newSlot,
|
|
189
200
|
};
|
|
190
201
|
}
|
|
191
202
|
setTimeout() {
|
|
@@ -194,7 +205,7 @@ class WebSocketAccountSubscriberV2 {
|
|
|
194
205
|
* `resubOpts.resubTimeoutMs` and `receivingData` is true, trigger either
|
|
195
206
|
* a polling loop or a resubscribe depending on options.
|
|
196
207
|
*/
|
|
197
|
-
if (!this.
|
|
208
|
+
if (!this._onChange) {
|
|
198
209
|
throw new Error('onChange callback function must be set');
|
|
199
210
|
}
|
|
200
211
|
this.timeoutId = setTimeout(async () => {
|
|
@@ -305,7 +316,7 @@ class WebSocketAccountSubscriberV2 {
|
|
|
305
316
|
slot: Number(rpcResponse.context.slot),
|
|
306
317
|
};
|
|
307
318
|
const accountInfo = rpcResponse.value;
|
|
308
|
-
this.handleRpcResponse({ slot: BigInt(context.slot) }, accountInfo);
|
|
319
|
+
this.handleRpcResponse({ slot: BigInt(context.slot) }, accountInfo !== null && accountInfo !== void 0 ? accountInfo : undefined);
|
|
309
320
|
}
|
|
310
321
|
handleRpcResponse(context, accountInfo) {
|
|
311
322
|
const newSlot = context.slot;
|
|
@@ -365,7 +376,7 @@ class WebSocketAccountSubscriberV2 {
|
|
|
365
376
|
return this.decodeBufferFn(buffer);
|
|
366
377
|
}
|
|
367
378
|
else {
|
|
368
|
-
return this.program.
|
|
379
|
+
return this.program.coder.accounts.decode((0, utils_1.capitalize)(this.accountName), buffer);
|
|
369
380
|
}
|
|
370
381
|
}
|
|
371
382
|
unsubscribe(onResub = false) {
|
|
@@ -12,12 +12,14 @@ export declare class WebSocketInsuranceFundStakeAccountSubscriber implements Ins
|
|
|
12
12
|
program: VelocityProgram;
|
|
13
13
|
eventEmitter: StrictEventEmitter<EventEmitter, InsuranceFundStakeAccountEvents>;
|
|
14
14
|
insuranceFundStakeAccountPublicKey: PublicKey;
|
|
15
|
-
|
|
15
|
+
private _insuranceFundStakeDataAccountSubscriber?;
|
|
16
|
+
get insuranceFundStakeDataAccountSubscriber(): AccountSubscriber<InsuranceFundStake>;
|
|
17
|
+
set insuranceFundStakeDataAccountSubscriber(subscriber: AccountSubscriber<InsuranceFundStake>);
|
|
16
18
|
constructor(program: VelocityProgram, insuranceFundStakeAccountPublicKey: PublicKey, resubTimeoutMs?: number, commitment?: Commitment);
|
|
17
19
|
subscribe(insuranceFundStakeAccount?: InsuranceFundStake): Promise<boolean>;
|
|
18
20
|
fetch(): Promise<void>;
|
|
19
21
|
unsubscribe(): Promise<void>;
|
|
20
22
|
assertIsSubscribed(): void;
|
|
21
|
-
getInsuranceFundStakeAccountAndSlot(): DataAndSlot<InsuranceFundStake
|
|
23
|
+
getInsuranceFundStakeAccountAndSlot(): DataAndSlot<InsuranceFundStake> | undefined;
|
|
22
24
|
updateData(insuranceFundStake: InsuranceFundStake, slot: number): void;
|
|
23
25
|
}
|
|
@@ -5,6 +5,15 @@ const types_1 = require("./types");
|
|
|
5
5
|
const events_1 = require("events");
|
|
6
6
|
const webSocketAccountSubscriber_1 = require("./webSocketAccountSubscriber");
|
|
7
7
|
class WebSocketInsuranceFundStakeAccountSubscriber {
|
|
8
|
+
get insuranceFundStakeDataAccountSubscriber() {
|
|
9
|
+
if (!this._insuranceFundStakeDataAccountSubscriber) {
|
|
10
|
+
throw new Error('insuranceFundStakeDataAccountSubscriber accessed before subscribe()');
|
|
11
|
+
}
|
|
12
|
+
return this._insuranceFundStakeDataAccountSubscriber;
|
|
13
|
+
}
|
|
14
|
+
set insuranceFundStakeDataAccountSubscriber(subscriber) {
|
|
15
|
+
this._insuranceFundStakeDataAccountSubscriber = subscriber;
|
|
16
|
+
}
|
|
8
17
|
constructor(program, insuranceFundStakeAccountPublicKey, resubTimeoutMs, commitment) {
|
|
9
18
|
this.isSubscribed = false;
|
|
10
19
|
this.program = program;
|
|
@@ -10,7 +10,9 @@ export declare class WebSocketProgramAccountSubscriber<T> implements ProgramAcco
|
|
|
10
10
|
bufferAndSlotMap: Map<string, BufferAndSlot>;
|
|
11
11
|
program: VelocityProgram;
|
|
12
12
|
decodeBuffer: (accountName: string, ix: Buffer) => T;
|
|
13
|
-
|
|
13
|
+
private _onChange?;
|
|
14
|
+
get onChange(): (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void;
|
|
15
|
+
set onChange(onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void);
|
|
14
16
|
listenerId?: number;
|
|
15
17
|
resubOpts?: ResubOpts;
|
|
16
18
|
isUnsubscribing: boolean;
|
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebSocketProgramAccountSubscriber = void 0;
|
|
4
4
|
class WebSocketProgramAccountSubscriber {
|
|
5
|
+
get onChange() {
|
|
6
|
+
if (!this._onChange) {
|
|
7
|
+
throw new Error('onChange callback function must be set');
|
|
8
|
+
}
|
|
9
|
+
return this._onChange;
|
|
10
|
+
}
|
|
11
|
+
set onChange(onChange) {
|
|
12
|
+
this._onChange = onChange;
|
|
13
|
+
}
|
|
5
14
|
constructor(subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
|
|
6
15
|
filters: [],
|
|
7
16
|
}, resubOpts) {
|
|
@@ -14,7 +23,8 @@ class WebSocketProgramAccountSubscriber {
|
|
|
14
23
|
this.program = program;
|
|
15
24
|
this.decodeBuffer = decodeBufferFn;
|
|
16
25
|
this.resubOpts = resubOpts;
|
|
17
|
-
if (((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs)
|
|
26
|
+
if (((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) != null &&
|
|
27
|
+
this.resubOpts.resubTimeoutMs < 1000) {
|
|
18
28
|
console.log('resubTimeoutMs should be at least 1000ms to avoid spamming resub');
|
|
19
29
|
}
|
|
20
30
|
this.options = options;
|
|
@@ -45,7 +55,7 @@ class WebSocketProgramAccountSubscriber {
|
|
|
45
55
|
}
|
|
46
56
|
setTimeout() {
|
|
47
57
|
var _a;
|
|
48
|
-
if (!this.
|
|
58
|
+
if (!this._onChange) {
|
|
49
59
|
throw new Error('onChange callback function must be set');
|
|
50
60
|
}
|
|
51
61
|
this.timeoutId = setTimeout(async () => {
|
|
@@ -97,7 +107,7 @@ class WebSocketProgramAccountSubscriber {
|
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
unsubscribe(onResub = false) {
|
|
100
|
-
if (!onResub) {
|
|
110
|
+
if (!onResub && this.resubOpts) {
|
|
101
111
|
this.resubOpts.resubTimeoutMs = undefined;
|
|
102
112
|
}
|
|
103
113
|
this.isUnsubscribing = true;
|
|
@@ -114,6 +124,7 @@ class WebSocketProgramAccountSubscriber {
|
|
|
114
124
|
}
|
|
115
125
|
else {
|
|
116
126
|
this.isUnsubscribing = false;
|
|
127
|
+
return Promise.resolve();
|
|
117
128
|
}
|
|
118
129
|
}
|
|
119
130
|
}
|
|
@@ -69,7 +69,9 @@ export declare class WebSocketProgramAccountsSubscriberV2<T> implements ProgramA
|
|
|
69
69
|
bufferAndSlotMap: Map<string, BufferAndSlot>;
|
|
70
70
|
program: VelocityProgram;
|
|
71
71
|
decodeBuffer: (accountName: string, ix: Buffer) => T;
|
|
72
|
-
|
|
72
|
+
private _onChange?;
|
|
73
|
+
get onChange(): (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void;
|
|
74
|
+
set onChange(onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void);
|
|
73
75
|
listenerId?: number;
|
|
74
76
|
resubOpts: ResubOpts;
|
|
75
77
|
isUnsubscribing: boolean;
|
|
@@ -67,6 +67,15 @@ const bs58_1 = __importDefault(require("bs58"));
|
|
|
67
67
|
* and processed concurrently.
|
|
68
68
|
*/
|
|
69
69
|
class WebSocketProgramAccountsSubscriberV2 {
|
|
70
|
+
get onChange() {
|
|
71
|
+
if (!this._onChange) {
|
|
72
|
+
throw new Error('onChange callback function must be set');
|
|
73
|
+
}
|
|
74
|
+
return this._onChange;
|
|
75
|
+
}
|
|
76
|
+
set onChange(onChange) {
|
|
77
|
+
this._onChange = onChange;
|
|
78
|
+
}
|
|
70
79
|
constructor(subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
|
|
71
80
|
filters: [],
|
|
72
81
|
}, resubOpts, accountsToMonitor // Optional list of accounts to poll
|
|
@@ -94,7 +103,8 @@ class WebSocketProgramAccountsSubscriberV2 {
|
|
|
94
103
|
usePollingInsteadOfResub: true,
|
|
95
104
|
logResubMessages: false,
|
|
96
105
|
};
|
|
97
|
-
if (((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs)
|
|
106
|
+
if (((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs) !== undefined &&
|
|
107
|
+
this.resubOpts.resubTimeoutMs < 1000) {
|
|
98
108
|
console.log('resubTimeoutMs should be at least 1000ms to avoid spamming resub');
|
|
99
109
|
}
|
|
100
110
|
this.options = options;
|
|
@@ -212,7 +222,7 @@ class WebSocketProgramAccountsSubscriberV2 {
|
|
|
212
222
|
}
|
|
213
223
|
setTimeout() {
|
|
214
224
|
var _a;
|
|
215
|
-
if (!this.
|
|
225
|
+
if (!this._onChange) {
|
|
216
226
|
throw new Error('onChange callback function must be set');
|
|
217
227
|
}
|
|
218
228
|
this.timeoutId = setTimeout(async () => {
|
|
@@ -262,7 +272,9 @@ class WebSocketProgramAccountsSubscriberV2 {
|
|
|
262
272
|
this.lastWsNotificationTime.set(accountIdString, Date.now());
|
|
263
273
|
// If this account was being polled, stop polling it if the buffer has changed
|
|
264
274
|
if (this.accountsCurrentlyPolling.has(accountIdString) &&
|
|
265
|
-
|
|
275
|
+
newBuffer &&
|
|
276
|
+
(!(existingBufferAndSlot === null || existingBufferAndSlot === void 0 ? void 0 : existingBufferAndSlot.buffer) ||
|
|
277
|
+
!newBuffer.equals(existingBufferAndSlot.buffer))) {
|
|
266
278
|
this.accountsCurrentlyPolling.delete(accountIdString);
|
|
267
279
|
// If no more accounts are being polled, stop batch polling
|
|
268
280
|
if (this.accountsCurrentlyPolling.size === 0 &&
|
|
@@ -69,7 +69,9 @@ export declare class WebSocketProgramAccountsSubscriberV2<T> implements ProgramA
|
|
|
69
69
|
bufferAndSlotMap: Map<string, BufferAndSlot>;
|
|
70
70
|
program: VelocityProgram;
|
|
71
71
|
decodeBuffer: (accountName: string, ix: Buffer) => T;
|
|
72
|
-
|
|
72
|
+
private _onChange?;
|
|
73
|
+
get onChange(): (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void;
|
|
74
|
+
set onChange(onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void);
|
|
73
75
|
listenerId?: number;
|
|
74
76
|
resubOpts: ResubOpts;
|
|
75
77
|
isUnsubscribing: boolean;
|
|
@@ -67,11 +67,19 @@ const bs58_1 = __importDefault(require("bs58"));
|
|
|
67
67
|
* and processed concurrently.
|
|
68
68
|
*/
|
|
69
69
|
class WebSocketProgramAccountsSubscriberV2 {
|
|
70
|
+
get onChange() {
|
|
71
|
+
if (!this._onChange) {
|
|
72
|
+
throw new Error('onChange callback function must be set');
|
|
73
|
+
}
|
|
74
|
+
return this._onChange;
|
|
75
|
+
}
|
|
76
|
+
set onChange(onChange) {
|
|
77
|
+
this._onChange = onChange;
|
|
78
|
+
}
|
|
70
79
|
constructor(subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
|
|
71
80
|
filters: [],
|
|
72
81
|
}, resubOpts, accountsToMonitor // Optional list of accounts to poll
|
|
73
82
|
) {
|
|
74
|
-
var _a;
|
|
75
83
|
this.bufferAndSlotMap = new Map();
|
|
76
84
|
this.isUnsubscribing = false;
|
|
77
85
|
this.receivingData = false;
|
|
@@ -94,7 +102,8 @@ class WebSocketProgramAccountsSubscriberV2 {
|
|
|
94
102
|
usePollingInsteadOfResub: true,
|
|
95
103
|
logResubMessages: false,
|
|
96
104
|
};
|
|
97
|
-
if (
|
|
105
|
+
if (this.resubOpts.resubTimeoutMs != null &&
|
|
106
|
+
this.resubOpts.resubTimeoutMs < 1000) {
|
|
98
107
|
console.log('resubTimeoutMs should be at least 1000ms to avoid spamming resub');
|
|
99
108
|
}
|
|
100
109
|
this.options = options;
|
|
@@ -212,7 +221,7 @@ class WebSocketProgramAccountsSubscriberV2 {
|
|
|
212
221
|
}
|
|
213
222
|
setTimeout() {
|
|
214
223
|
var _a;
|
|
215
|
-
if (!this.
|
|
224
|
+
if (!this._onChange) {
|
|
216
225
|
throw new Error('onChange callback function must be set');
|
|
217
226
|
}
|
|
218
227
|
this.timeoutId = setTimeout(async () => {
|
|
@@ -262,7 +271,8 @@ class WebSocketProgramAccountsSubscriberV2 {
|
|
|
262
271
|
this.lastWsNotificationTime.set(accountIdString, Date.now());
|
|
263
272
|
// If this account was being polled, stop polling it if the buffer has changed
|
|
264
273
|
if (this.accountsCurrentlyPolling.has(accountIdString) &&
|
|
265
|
-
!(existingBufferAndSlot === null || existingBufferAndSlot === void 0 ? void 0 : existingBufferAndSlot.buffer
|
|
274
|
+
(!(existingBufferAndSlot === null || existingBufferAndSlot === void 0 ? void 0 : existingBufferAndSlot.buffer) ||
|
|
275
|
+
(newBuffer != null && !existingBufferAndSlot.buffer.equals(newBuffer)))) {
|
|
266
276
|
this.accountsCurrentlyPolling.delete(accountIdString);
|
|
267
277
|
// If no more accounts are being polled, stop batch polling
|
|
268
278
|
if (this.accountsCurrentlyPolling.size === 0 &&
|
|
@@ -12,12 +12,14 @@ export declare class WebSocketUserAccountSubscriber implements UserAccountSubscr
|
|
|
12
12
|
program: VelocityProgram;
|
|
13
13
|
eventEmitter: StrictEventEmitter<EventEmitter, UserAccountEvents>;
|
|
14
14
|
userAccountPublicKey: PublicKey;
|
|
15
|
-
|
|
15
|
+
private _userDataAccountSubscriber?;
|
|
16
|
+
get userDataAccountSubscriber(): AccountSubscriber<UserAccount>;
|
|
17
|
+
set userDataAccountSubscriber(subscriber: AccountSubscriber<UserAccount>);
|
|
16
18
|
constructor(program: VelocityProgram, userAccountPublicKey: PublicKey, resubOpts?: ResubOpts, commitment?: Commitment);
|
|
17
19
|
subscribe(userAccount?: UserAccount): Promise<boolean>;
|
|
18
20
|
fetch(): Promise<void>;
|
|
19
21
|
unsubscribe(): Promise<void>;
|
|
20
22
|
assertIsSubscribed(): void;
|
|
21
|
-
getUserAccountAndSlot(): DataAndSlot<UserAccount
|
|
23
|
+
getUserAccountAndSlot(): DataAndSlot<UserAccount> | undefined;
|
|
22
24
|
updateData(userAccount: UserAccount, slot: number): void;
|
|
23
25
|
}
|