@velocity-exchange/sdk 0.1.0 → 0.2.1
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 +4 -32
- 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 -29
- 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 +8 -5
- package/lib/browser/bankrun/bankrunConnection.js +92 -32
- 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 -2
- package/lib/browser/constants/numericConstants.js +7 -5
- package/lib/browser/constants/spotMarkets.d.ts +0 -1
- 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/VelocityCore.d.ts +0 -1
- package/lib/browser/core/instructions/deposit.d.ts +0 -1
- package/lib/browser/core/instructions/perpOrders.d.ts +14 -0
- package/lib/browser/core/instructions/perpOrders.js +14 -0
- package/lib/browser/core/instructions/withdraw.d.ts +0 -1
- 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 -2
- package/lib/browser/dlob/DLOB.js +201 -138
- package/lib/browser/dlob/DLOBNode.d.ts +5 -3
- package/lib/browser/dlob/DLOBNode.js +7 -0
- package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -1
- package/lib/browser/dlob/DLOBSubscriber.js +37 -32
- package/lib/browser/dlob/NodeList.d.ts +0 -1
- package/lib/browser/dlob/NodeList.js +8 -7
- package/lib/browser/dlob/orderBookLevels.d.ts +0 -1
- package/lib/browser/dlob/orderBookLevels.js +19 -12
- package/lib/browser/events/eventList.d.ts +3 -3
- 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 +2 -2
- 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 +2 -2
- package/lib/browser/events/pollingLogProvider.js +1 -0
- package/lib/browser/events/txEventCache.d.ts +3 -3
- 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 +2 -2
- package/lib/browser/events/webSocketLogProvider.js +5 -2
- package/lib/browser/factory/bigNum.d.ts +0 -1
- 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/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/browser/jupiter/jupiterClient.d.ts +1 -2
- package/lib/browser/jupiter/jupiterClient.js +18 -8
- package/lib/browser/marginCalculation.d.ts +0 -1
- package/lib/browser/marginCalculation.js +1 -0
- package/lib/browser/marinade/index.d.ts +2 -3
- package/lib/browser/marinade/index.js +5 -0
- package/lib/browser/math/amm.d.ts +31 -14
- package/lib/browser/math/amm.js +77 -22
- package/lib/browser/math/auction.d.ts +0 -1
- package/lib/browser/math/bankruptcy.js +1 -1
- package/lib/browser/math/conversion.d.ts +0 -1
- package/lib/browser/math/funding.d.ts +0 -1
- package/lib/browser/math/funding.js +6 -6
- package/lib/browser/math/insurance.d.ts +1 -2
- package/lib/browser/math/insurance.js +4 -5
- package/lib/browser/math/liquidation.d.ts +0 -1
- package/lib/browser/math/margin.d.ts +1 -10
- package/lib/browser/math/margin.js +3 -62
- package/lib/browser/math/market.d.ts +4 -13
- package/lib/browser/math/market.js +6 -40
- package/lib/browser/math/oracles.d.ts +0 -4
- package/lib/browser/math/oracles.js +1 -14
- package/lib/browser/math/orders.d.ts +0 -6
- package/lib/browser/math/orders.js +2 -74
- package/lib/browser/math/position.d.ts +1 -6
- package/lib/browser/math/position.js +5 -10
- package/lib/browser/math/repeg.d.ts +0 -2
- package/lib/browser/math/repeg.js +1 -23
- package/lib/browser/math/spotBalance.d.ts +4 -5
- package/lib/browser/math/spotBalance.js +6 -6
- package/lib/browser/math/spotMarket.d.ts +0 -7
- package/lib/browser/math/spotMarket.js +1 -16
- package/lib/browser/math/spotPosition.d.ts +4 -5
- package/lib/browser/math/state.d.ts +0 -3
- package/lib/browser/math/state.js +1 -9
- package/lib/browser/math/superStake.d.ts +3 -54
- package/lib/browser/math/superStake.js +16 -13
- package/lib/browser/math/trade.d.ts +2 -3
- package/lib/browser/math/trade.js +6 -6
- package/lib/browser/math/utils.d.ts +0 -1
- package/lib/browser/memcmp.d.ts +0 -1
- package/lib/browser/memcmp.js +1 -10
- package/lib/browser/oracles/oracleClientCache.d.ts +1 -1
- package/lib/browser/oracles/prelaunchOracleClient.js +3 -2
- package/lib/browser/oracles/pythClient.d.ts +0 -1
- package/lib/browser/oracles/pythClient.js +9 -3
- package/lib/browser/oracles/pythLazerClient.d.ts +0 -1
- package/lib/browser/oracles/pythLazerClient.js +3 -2
- package/lib/browser/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/browser/oracles/types.d.ts +0 -1
- package/lib/browser/oracles/utils.d.ts +4 -1
- package/lib/browser/oracles/utils.js +9 -1
- package/lib/browser/orderParams.d.ts +0 -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/swap/UnifiedSwapClient.d.ts +0 -1
- 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/titan/titanClient.d.ts +0 -1
- package/lib/browser/tokenFaucet.d.ts +0 -1
- 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 +9 -3
- 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 +25 -69
- package/lib/browser/types.js +2 -2
- package/lib/browser/user.d.ts +21 -8
- 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 +93 -36
- 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 -29
- 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 +8 -5
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.js +92 -32
- 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 -2
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +7 -5
- package/lib/node/constants/spotMarkets.d.ts +0 -1
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- 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/VelocityCore.d.ts +0 -1
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/instructions/deposit.d.ts +0 -1
- package/lib/node/core/instructions/deposit.d.ts.map +1 -1
- 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/instructions/withdraw.d.ts +0 -1
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- 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 -2
- 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 -3
- 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 +0 -1
- 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 +0 -1
- 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 +0 -1
- 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.d.ts +0 -1
- package/lib/node/factory/bigNum.d.ts.map +1 -1
- 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/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.d.ts +1 -2
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.js +18 -8
- package/lib/node/marginCalculation.d.ts +0 -1
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marginCalculation.js +1 -0
- package/lib/node/marinade/index.d.ts +2 -3
- package/lib/node/marinade/index.d.ts.map +1 -1
- package/lib/node/marinade/index.js +5 -0
- package/lib/node/math/amm.d.ts +31 -14
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +77 -22
- package/lib/node/math/auction.d.ts +0 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/bankruptcy.js +1 -1
- package/lib/node/math/conversion.d.ts +0 -1
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/funding.d.ts +0 -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 -2
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +4 -5
- package/lib/node/math/liquidation.d.ts +0 -1
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/margin.d.ts +1 -10
- 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 -13
- 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 -4
- 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 -6
- 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 -6
- 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 -2
- 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 -5
- 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 -7
- 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 -5
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/state.d.ts +0 -3
- 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 -54
- 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 -3
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +6 -6
- package/lib/node/math/utils.d.ts +0 -1
- package/lib/node/math/utils.d.ts.map +1 -1
- 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 +0 -1
- 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 +0 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +3 -2
- package/lib/node/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/types.d.ts +0 -1
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +4 -1
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/oracles/utils.js +9 -1
- package/lib/node/orderParams.d.ts +0 -1
- package/lib/node/orderParams.d.ts.map +1 -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/swap/UnifiedSwapClient.d.ts +0 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- 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/titan/titanClient.d.ts +0 -1
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/tokenFaucet.d.ts +0 -1
- 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 -69
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +2 -2
- package/lib/node/user.d.ts +21 -8
- 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 -36
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +414 -280
- package/package.json +15 -8
- 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 +110 -40
- 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 +8 -4
- 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/marinade/index.ts +11 -2
- 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 +14 -10
- package/src/userMap/revenueShareEscrowMap.ts +8 -3
- 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/VelocityCore/remainingAccounts.test.ts +4 -5
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +19 -11
- package/tests/amm/test.ts +300 -95
- package/tests/decode/userAccountBufferStrings.ts +100 -100
- package/tests/dlob/helpers.ts +162 -173
- package/tests/dlob/test.ts +155 -106
- package/tests/tx/TransactionConfirmationManager.test.ts +9 -2
- package/tests/user/getMarginCalculation.ts +1 -1
- package/tests/user/helpers.ts +3 -4
- package/tests/user/marginCalculations.test.ts +2 -2
- package/tests/user/test.ts +3 -3
- package/tsconfig.browser.json +3 -1
- package/tsconfig.json +21 -2
- package/.yarn/install-state.gz +0 -0
- package/VERSION +0 -1
- package/bun.lock +0 -1885
- 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/scripts/updateVersion.js +0 -28
- package/src/constants/insuranceFund.ts +0 -8
- package/src/tx/forwardOnlyTxSender.ts +0 -145
- package/src/util/tps.ts +0 -27
- package/tests/decode/phoenix.ts +0 -71
|
@@ -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
|
}
|
|
@@ -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 WebSocketUserAccountSubscriber {
|
|
8
|
+
get userDataAccountSubscriber() {
|
|
9
|
+
if (!this._userDataAccountSubscriber) {
|
|
10
|
+
throw new Error('userDataAccountSubscriber accessed before subscribe()');
|
|
11
|
+
}
|
|
12
|
+
return this._userDataAccountSubscriber;
|
|
13
|
+
}
|
|
14
|
+
set userDataAccountSubscriber(subscriber) {
|
|
15
|
+
this._userDataAccountSubscriber = subscriber;
|
|
16
|
+
}
|
|
8
17
|
constructor(program, userAccountPublicKey, resubOpts, commitment) {
|
|
9
18
|
this.isSubscribed = false;
|
|
10
19
|
this.program = program;
|
|
@@ -12,11 +12,13 @@ export declare class WebSocketUserStatsAccountSubscriber implements UserStatsAcc
|
|
|
12
12
|
program: VelocityProgram;
|
|
13
13
|
eventEmitter: StrictEventEmitter<EventEmitter, UserStatsAccountEvents>;
|
|
14
14
|
userStatsAccountPublicKey: PublicKey;
|
|
15
|
-
|
|
15
|
+
private _userStatsAccountSubscriber?;
|
|
16
|
+
get userStatsAccountSubscriber(): AccountSubscriber<UserStatsAccount>;
|
|
17
|
+
set userStatsAccountSubscriber(subscriber: AccountSubscriber<UserStatsAccount>);
|
|
16
18
|
constructor(program: VelocityProgram, userStatsAccountPublicKey: PublicKey, resubOpts?: ResubOpts, commitment?: Commitment);
|
|
17
19
|
subscribe(userStatsAccount?: UserStatsAccount): Promise<boolean>;
|
|
18
20
|
fetch(): Promise<void>;
|
|
19
21
|
unsubscribe(): Promise<void>;
|
|
20
22
|
assertIsSubscribed(): void;
|
|
21
|
-
getUserStatsAccountAndSlot(): DataAndSlot<UserStatsAccount
|
|
23
|
+
getUserStatsAccountAndSlot(): DataAndSlot<UserStatsAccount> | undefined;
|
|
22
24
|
}
|
|
@@ -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 WebSocketUserStatsAccountSubscriber {
|
|
8
|
+
get userStatsAccountSubscriber() {
|
|
9
|
+
if (!this._userStatsAccountSubscriber) {
|
|
10
|
+
throw new Error('userStatsAccountSubscriber accessed before subscribe()');
|
|
11
|
+
}
|
|
12
|
+
return this._userStatsAccountSubscriber;
|
|
13
|
+
}
|
|
14
|
+
set userStatsAccountSubscriber(subscriber) {
|
|
15
|
+
this._userStatsAccountSubscriber = subscriber;
|
|
16
|
+
}
|
|
8
17
|
constructor(program, userStatsAccountPublicKey, resubOpts, commitment) {
|
|
9
18
|
this.isSubscribed = false;
|
|
10
19
|
this.program = program;
|
|
@@ -31,14 +31,14 @@ export declare class WebSocketVelocityClientAccountSubscriber implements Velocit
|
|
|
31
31
|
spotOracleStringMap: Map<number, string>;
|
|
32
32
|
oracleSubscribers: Map<string, AccountSubscriber<OraclePriceData>>;
|
|
33
33
|
delistedMarketSetting: DelistedMarketSetting;
|
|
34
|
-
initialPerpMarketAccountData
|
|
35
|
-
initialSpotMarketAccountData
|
|
36
|
-
initialOraclePriceData
|
|
34
|
+
initialPerpMarketAccountData?: Map<number, PerpMarketAccount>;
|
|
35
|
+
initialSpotMarketAccountData?: Map<number, SpotMarketAccount>;
|
|
36
|
+
initialOraclePriceData?: Map<string, OraclePriceData>;
|
|
37
37
|
customPerpMarketAccountSubscriber?: new (accountName: string, program: VelocityProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, commitment?: Commitment) => AccountSubscriber<any>;
|
|
38
38
|
customOracleAccountSubscriber?: new (accountName: string, program: VelocityProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, commitment?: Commitment) => AccountSubscriber<any>;
|
|
39
39
|
protected isSubscribing: boolean;
|
|
40
|
-
protected subscriptionPromise: Promise<boolean>;
|
|
41
40
|
protected subscriptionPromiseResolver: (val: boolean) => void;
|
|
41
|
+
protected subscriptionPromise: Promise<boolean>;
|
|
42
42
|
constructor(program: VelocityProgram, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], shouldFindAllMarketsAndOracles: boolean, delistedMarketSetting: DelistedMarketSetting, resubOpts?: ResubOpts, commitment?: Commitment, customPerpMarketAccountSubscriber?: new (accountName: string, program: VelocityProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, commitment?: Commitment) => WebSocketAccountSubscriberV2<any> | WebSocketAccountSubscriber<any>, customOracleAccountSubscriber?: new (accountName: string, program: VelocityProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, commitment?: Commitment) => WebSocketAccountSubscriberV2<any> | WebSocketAccountSubscriber<any>);
|
|
43
43
|
subscribe(): Promise<boolean>;
|
|
44
44
|
chunks: <T>(array: readonly T[], size: number) => T[][];
|
|
@@ -42,6 +42,8 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
42
42
|
this.spotOracleStringMap = new Map();
|
|
43
43
|
this.oracleSubscribers = new Map();
|
|
44
44
|
this.isSubscribing = false;
|
|
45
|
+
this.subscriptionPromiseResolver = () => { };
|
|
46
|
+
this.subscriptionPromise = Promise.resolve(false);
|
|
45
47
|
this.chunks = (array, size) => {
|
|
46
48
|
return new Array(Math.ceil(array.length / size))
|
|
47
49
|
.fill(null)
|
|
@@ -135,11 +137,15 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
135
137
|
const oracleAccountPubkeyChunks = this.chunks(this.oracleInfos.map((oracleInfo) => oracleInfo.publicKey), 75);
|
|
136
138
|
const oracleAccountInfos = (await Promise.all(oracleAccountPubkeyChunks.map((oracleAccountPublicKeysChunk) => connection.getMultipleAccountsInfo(oracleAccountPublicKeysChunk)))).flat();
|
|
137
139
|
this.initialOraclePriceData = new Map(this.oracleInfos.reduce((result, oracleInfo, i) => {
|
|
138
|
-
|
|
140
|
+
const oracleAccountInfo = oracleAccountInfos[i];
|
|
141
|
+
if (!oracleAccountInfo) {
|
|
139
142
|
return result;
|
|
140
143
|
}
|
|
141
144
|
const oracleClient = this.oracleClientCache.get(oracleInfo.source, connection, this.program);
|
|
142
|
-
|
|
145
|
+
if (!oracleClient) {
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
const oraclePriceData = oracleClient.getOraclePriceDataFromBuffer(oracleAccountInfo.data);
|
|
143
149
|
result.push([
|
|
144
150
|
(0, oracleId_1.getOracleId)(oracleInfo.publicKey, oracleInfo.source),
|
|
145
151
|
oraclePriceData,
|
|
@@ -157,10 +163,11 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
157
163
|
return true;
|
|
158
164
|
}
|
|
159
165
|
async subscribeToPerpMarketAccount(marketIndex) {
|
|
166
|
+
var _a;
|
|
160
167
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
161
168
|
const AccountSubscriberClass = this.customPerpMarketAccountSubscriber || webSocketAccountSubscriber_1.WebSocketAccountSubscriber;
|
|
162
169
|
const accountSubscriber = new AccountSubscriberClass('perpMarket', this.program, perpMarketPublicKey, undefined, this.resubOpts, this.commitment);
|
|
163
|
-
const initialPerpMarketData = this.initialPerpMarketAccountData.get(marketIndex);
|
|
170
|
+
const initialPerpMarketData = (_a = this.initialPerpMarketAccountData) === null || _a === void 0 ? void 0 : _a.get(marketIndex);
|
|
164
171
|
if (initialPerpMarketData) {
|
|
165
172
|
accountSubscriber.setData(initialPerpMarketData);
|
|
166
173
|
}
|
|
@@ -177,9 +184,10 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
177
184
|
return true;
|
|
178
185
|
}
|
|
179
186
|
async subscribeToSpotMarketAccount(marketIndex) {
|
|
187
|
+
var _a;
|
|
180
188
|
const marketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
|
|
181
189
|
const accountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('spotMarket', this.program, marketPublicKey, undefined, this.resubOpts, this.commitment);
|
|
182
|
-
const initialSpotMarketData = this.initialSpotMarketAccountData.get(marketIndex);
|
|
190
|
+
const initialSpotMarketData = (_a = this.initialSpotMarketAccountData) === null || _a === void 0 ? void 0 : _a.get(marketIndex);
|
|
183
191
|
if (initialSpotMarketData) {
|
|
184
192
|
accountSubscriber.setData(initialSpotMarketData);
|
|
185
193
|
}
|
|
@@ -198,13 +206,17 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
198
206
|
return true;
|
|
199
207
|
}
|
|
200
208
|
async subscribeToOracle(oracleInfo) {
|
|
209
|
+
var _a;
|
|
201
210
|
const oracleId = (0, oracleId_1.getOracleId)(oracleInfo.publicKey, oracleInfo.source);
|
|
202
211
|
const client = this.oracleClientCache.get(oracleInfo.source, this.program.provider.connection, this.program);
|
|
212
|
+
if (!client) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
203
215
|
const AccountSubscriberClass = this.customOracleAccountSubscriber || webSocketAccountSubscriber_1.WebSocketAccountSubscriber;
|
|
204
216
|
const accountSubscriber = new AccountSubscriberClass('oracle', this.program, oracleInfo.publicKey, (buffer) => {
|
|
205
217
|
return client.getOraclePriceDataFromBuffer(buffer);
|
|
206
218
|
}, this.resubOpts, this.commitment);
|
|
207
|
-
const initialOraclePriceData = this.initialOraclePriceData.get(oracleId);
|
|
219
|
+
const initialOraclePriceData = (_a = this.initialOraclePriceData) === null || _a === void 0 ? void 0 : _a.get(oracleId);
|
|
208
220
|
if (initialOraclePriceData) {
|
|
209
221
|
accountSubscriber.setData(initialOraclePriceData);
|
|
210
222
|
}
|
|
@@ -229,16 +241,20 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
229
241
|
if (!this.isSubscribed) {
|
|
230
242
|
return;
|
|
231
243
|
}
|
|
244
|
+
if (!this.stateAccountSubscriber) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
232
247
|
const promises = [this.stateAccountSubscriber.fetch()]
|
|
233
248
|
.concat(Array.from(this.perpMarketAccountSubscribers.values()).map((subscriber) => subscriber.fetch()))
|
|
234
249
|
.concat(Array.from(this.spotMarketAccountSubscribers.values()).map((subscriber) => subscriber.fetch()));
|
|
235
250
|
await Promise.all(promises);
|
|
236
251
|
}
|
|
237
252
|
async unsubscribe() {
|
|
253
|
+
var _a;
|
|
238
254
|
if (!this.isSubscribed) {
|
|
239
255
|
return;
|
|
240
256
|
}
|
|
241
|
-
await this.stateAccountSubscriber.unsubscribe();
|
|
257
|
+
await ((_a = this.stateAccountSubscriber) === null || _a === void 0 ? void 0 : _a.unsubscribe());
|
|
242
258
|
await this.unsubscribeFromMarketAccounts();
|
|
243
259
|
await this.unsubscribeFromSpotMarketAccounts();
|
|
244
260
|
await this.unsubscribeFromOracles();
|
|
@@ -315,21 +331,21 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
315
331
|
await Promise.all(addOraclePromises);
|
|
316
332
|
}
|
|
317
333
|
async handleDelistedMarkets() {
|
|
334
|
+
var _a, _b;
|
|
318
335
|
if (this.delistedMarketSetting === types_1.DelistedMarketSetting.Subscribe) {
|
|
319
336
|
return;
|
|
320
337
|
}
|
|
321
338
|
const { perpMarketIndexes, oracles } = (0, utils_1.findDelistedPerpMarketsAndOracles)(this.getMarketAccountsAndSlots(), this.getSpotMarketAccountsAndSlots());
|
|
322
339
|
for (const perpMarketIndex of perpMarketIndexes) {
|
|
323
|
-
await this.perpMarketAccountSubscribers
|
|
324
|
-
.get(perpMarketIndex)
|
|
325
|
-
.unsubscribe();
|
|
340
|
+
await ((_a = this.perpMarketAccountSubscribers
|
|
341
|
+
.get(perpMarketIndex)) === null || _a === void 0 ? void 0 : _a.unsubscribe());
|
|
326
342
|
if (this.delistedMarketSetting === types_1.DelistedMarketSetting.Discard) {
|
|
327
343
|
this.perpMarketAccountSubscribers.delete(perpMarketIndex);
|
|
328
344
|
}
|
|
329
345
|
}
|
|
330
346
|
for (const oracle of oracles) {
|
|
331
347
|
const oracleId = (0, oracleId_1.getOracleId)(oracle.publicKey, oracle.source);
|
|
332
|
-
await this.oracleSubscribers.get(oracleId).unsubscribe();
|
|
348
|
+
await ((_b = this.oracleSubscribers.get(oracleId)) === null || _b === void 0 ? void 0 : _b.unsubscribe());
|
|
333
349
|
if (this.delistedMarketSetting === types_1.DelistedMarketSetting.Discard) {
|
|
334
350
|
this.oracleSubscribers.delete(oracleId);
|
|
335
351
|
}
|
|
@@ -341,24 +357,36 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
341
357
|
}
|
|
342
358
|
}
|
|
343
359
|
getStateAccountAndSlot() {
|
|
360
|
+
var _a;
|
|
344
361
|
this.assertIsSubscribed();
|
|
345
|
-
|
|
362
|
+
const dataAndSlot = (_a = this.stateAccountSubscriber) === null || _a === void 0 ? void 0 : _a.dataAndSlot;
|
|
363
|
+
if (!dataAndSlot) {
|
|
364
|
+
throw new Error('State account data not available');
|
|
365
|
+
}
|
|
366
|
+
return dataAndSlot;
|
|
346
367
|
}
|
|
347
368
|
getMarketAccountAndSlot(marketIndex) {
|
|
369
|
+
var _a;
|
|
348
370
|
this.assertIsSubscribed();
|
|
349
|
-
return this.perpMarketAccountSubscribers.get(marketIndex).dataAndSlot;
|
|
371
|
+
return (_a = this.perpMarketAccountSubscribers.get(marketIndex)) === null || _a === void 0 ? void 0 : _a.dataAndSlot;
|
|
350
372
|
}
|
|
351
373
|
getMarketAccountsAndSlots() {
|
|
352
|
-
return Array.from(this.perpMarketAccountSubscribers.values())
|
|
374
|
+
return Array.from(this.perpMarketAccountSubscribers.values())
|
|
375
|
+
.map((subscriber) => subscriber.dataAndSlot)
|
|
376
|
+
.filter((dataAndSlot) => dataAndSlot !== undefined);
|
|
353
377
|
}
|
|
354
378
|
getSpotMarketAccountAndSlot(marketIndex) {
|
|
379
|
+
var _a;
|
|
355
380
|
this.assertIsSubscribed();
|
|
356
|
-
return this.spotMarketAccountSubscribers.get(marketIndex).dataAndSlot;
|
|
381
|
+
return (_a = this.spotMarketAccountSubscribers.get(marketIndex)) === null || _a === void 0 ? void 0 : _a.dataAndSlot;
|
|
357
382
|
}
|
|
358
383
|
getSpotMarketAccountsAndSlots() {
|
|
359
|
-
return Array.from(this.spotMarketAccountSubscribers.values())
|
|
384
|
+
return Array.from(this.spotMarketAccountSubscribers.values())
|
|
385
|
+
.map((subscriber) => subscriber.dataAndSlot)
|
|
386
|
+
.filter((dataAndSlot) => dataAndSlot !== undefined);
|
|
360
387
|
}
|
|
361
388
|
getOraclePriceDataAndSlot(oracleId) {
|
|
389
|
+
var _a;
|
|
362
390
|
this.assertIsSubscribed();
|
|
363
391
|
if (oracleId === ORACLE_DEFAULT_ID) {
|
|
364
392
|
return {
|
|
@@ -366,7 +394,7 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
366
394
|
slot: 0,
|
|
367
395
|
};
|
|
368
396
|
}
|
|
369
|
-
return this.oracleSubscribers.get(oracleId).dataAndSlot;
|
|
397
|
+
return (_a = this.oracleSubscribers.get(oracleId)) === null || _a === void 0 ? void 0 : _a.dataAndSlot;
|
|
370
398
|
}
|
|
371
399
|
getOraclePriceDataAndSlotForPerpMarket(marketIndex) {
|
|
372
400
|
const perpMarketAccount = this.getMarketAccountAndSlot(marketIndex);
|
|
@@ -375,8 +403,8 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
375
403
|
if (!perpMarketAccount || !oracleId) {
|
|
376
404
|
return undefined;
|
|
377
405
|
}
|
|
378
|
-
if (!perpMarketAccount.data.oracle.equals(oracle)) {
|
|
379
|
-
// If the oracle has changed
|
|
406
|
+
if (!oracle || !perpMarketAccount.data.oracle.equals(oracle)) {
|
|
407
|
+
// If the oracle has changed (or not yet cached), update the oracle map in background
|
|
380
408
|
this.setPerpOracleMap();
|
|
381
409
|
}
|
|
382
410
|
return this.getOraclePriceDataAndSlot(oracleId);
|
|
@@ -388,8 +416,8 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
388
416
|
if (!spotMarketAccount || !oracleId) {
|
|
389
417
|
return undefined;
|
|
390
418
|
}
|
|
391
|
-
if (!spotMarketAccount.data.oracle.equals(oracle)) {
|
|
392
|
-
// If the oracle has changed
|
|
419
|
+
if (!oracle || !spotMarketAccount.data.oracle.equals(oracle)) {
|
|
420
|
+
// If the oracle has changed (or not yet cached), update the oracle map in background
|
|
393
421
|
this.setSpotOracleMap();
|
|
394
422
|
}
|
|
395
423
|
return this.getOraclePriceDataAndSlot(oracleId);
|