@velocity-exchange/sdk 0.3.0 → 0.4.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 +51 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.js +18 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +18 -0
- package/lib/browser/accounts/bulkAccountLoader.d.ts +52 -0
- package/lib/browser/accounts/bulkAccountLoader.js +51 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +9 -2
- package/lib/browser/accounts/bulkUserStatsSubscription.js +9 -2
- package/lib/browser/accounts/bulkUserSubscription.d.ts +8 -2
- package/lib/browser/accounts/bulkUserSubscription.js +8 -2
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.js +37 -0
- package/lib/browser/accounts/fetch.d.ts +59 -2
- package/lib/browser/accounts/fetch.js +57 -2
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +30 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +30 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +118 -37
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +40 -12
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +33 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +15 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.js +15 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +15 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +34 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +34 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +19 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +21 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +22 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +32 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +22 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
- package/lib/browser/accounts/testBulkAccountLoader.d.ts +8 -0
- package/lib/browser/accounts/testBulkAccountLoader.js +8 -0
- package/lib/browser/accounts/types.d.ts +149 -0
- package/lib/browser/accounts/types.js +13 -0
- package/lib/browser/accounts/utils.d.ts +18 -0
- package/lib/browser/accounts/utils.js +32 -16
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +41 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.js +41 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +31 -23
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +36 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +26 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +33 -0
- package/lib/browser/addresses/marketAddresses.d.ts +10 -0
- package/lib/browser/addresses/marketAddresses.js +10 -0
- package/lib/browser/addresses/pda.d.ts +214 -2
- package/lib/browser/addresses/pda.js +217 -5
- package/lib/browser/adminClient.d.ts +2136 -4
- package/lib/browser/adminClient.js +2150 -4
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
- package/lib/browser/auctionSubscriber/index.d.ts +6 -0
- package/lib/browser/auctionSubscriber/index.js +6 -0
- package/lib/browser/auctionSubscriber/types.d.ts +7 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +33 -0
- package/lib/browser/blockhashSubscriber/index.d.ts +5 -0
- package/lib/browser/blockhashSubscriber/index.js +5 -0
- package/lib/browser/blockhashSubscriber/types.d.ts +5 -0
- package/lib/browser/clock/clockSubscriber.d.ts +24 -0
- package/lib/browser/clock/clockSubscriber.js +22 -0
- package/lib/browser/config.d.ts +58 -4
- package/lib/browser/config.js +88 -21
- package/lib/browser/constants/numericConstants.d.ts +67 -0
- package/lib/browser/constants/numericConstants.js +68 -1
- package/lib/browser/constants/perpMarkets.d.ts +10 -0
- package/lib/browser/constants/perpMarkets.js +40 -908
- package/lib/browser/constants/spotMarkets.d.ts +13 -0
- package/lib/browser/constants/spotMarkets.js +16 -742
- package/lib/browser/constants/txConstants.d.ts +1 -0
- package/lib/browser/constants/txConstants.js +1 -0
- package/lib/browser/core/VelocityCore.d.ts +285 -8
- package/lib/browser/core/VelocityCore.js +281 -8
- package/lib/browser/core/instructions/deposit.d.ts +22 -0
- package/lib/browser/core/instructions/deposit.js +22 -0
- package/lib/browser/core/instructions/fill.d.ts +17 -0
- package/lib/browser/core/instructions/fill.js +17 -0
- package/lib/browser/core/instructions/funding.d.ts +12 -0
- package/lib/browser/core/instructions/funding.js +12 -0
- package/lib/browser/core/instructions/liquidation.d.ts +18 -0
- package/lib/browser/core/instructions/liquidation.js +18 -0
- package/lib/browser/core/instructions/orders.d.ts +28 -0
- package/lib/browser/core/instructions/orders.js +28 -0
- package/lib/browser/core/instructions/perpOrders.d.ts +106 -0
- package/lib/browser/core/instructions/perpOrders.js +106 -0
- package/lib/browser/core/instructions/settlement.d.ts +14 -0
- package/lib/browser/core/instructions/settlement.js +14 -0
- package/lib/browser/core/instructions/trigger.d.ts +15 -0
- package/lib/browser/core/instructions/trigger.js +15 -0
- package/lib/browser/core/instructions/withdraw.d.ts +21 -0
- package/lib/browser/core/instructions/withdraw.js +21 -0
- package/lib/browser/core/remainingAccounts.d.ts +47 -3
- package/lib/browser/core/remainingAccounts.js +20 -0
- package/lib/browser/core/signedMsg.d.ts +38 -0
- package/lib/browser/core/signedMsg.js +33 -0
- package/lib/browser/decode/customCoder.d.ts +39 -3
- package/lib/browser/decode/customCoder.js +45 -3
- package/lib/browser/decode/user.d.ts +22 -0
- package/lib/browser/decode/user.js +22 -0
- package/lib/browser/dlob/DLOB.d.ts +502 -53
- package/lib/browser/dlob/DLOB.js +540 -98
- package/lib/browser/dlob/DLOBNode.d.ts +86 -4
- package/lib/browser/dlob/DLOBNode.js +37 -4
- package/lib/browser/dlob/DLOBSubscriber.d.ts +39 -12
- package/lib/browser/dlob/DLOBSubscriber.js +42 -12
- package/lib/browser/dlob/NodeList.d.ts +69 -0
- package/lib/browser/dlob/NodeList.js +66 -0
- package/lib/browser/dlob/orderBookLevels.d.ts +106 -13
- package/lib/browser/dlob/orderBookLevels.js +84 -14
- package/lib/browser/dlob/types.d.ts +15 -0
- package/lib/browser/events/eventList.d.ts +14 -0
- package/lib/browser/events/eventList.js +14 -0
- package/lib/browser/events/eventSubscriber.d.ts +87 -10
- package/lib/browser/events/eventSubscriber.js +93 -8
- package/lib/browser/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/browser/events/eventsServerLogProvider.js +27 -0
- package/lib/browser/events/fetchLogs.d.ts +31 -0
- package/lib/browser/events/fetchLogs.js +46 -1
- package/lib/browser/events/parse.d.ts +23 -0
- package/lib/browser/events/parse.js +23 -0
- package/lib/browser/events/pollingLogProvider.d.ts +24 -0
- package/lib/browser/events/pollingLogProvider.js +24 -0
- package/lib/browser/events/sort.d.ts +11 -0
- package/lib/browser/events/sort.js +12 -0
- package/lib/browser/events/txEventCache.d.ts +13 -3
- package/lib/browser/events/txEventCache.js +19 -7
- package/lib/browser/events/types.d.ts +118 -2
- package/lib/browser/events/types.js +11 -0
- package/lib/browser/events/webSocketLogProvider.d.ts +23 -0
- package/lib/browser/events/webSocketLogProvider.js +28 -0
- package/lib/browser/factory/oracleClient.js +2 -2
- package/lib/browser/idl/velocity.d.ts +4 -4
- package/lib/browser/idl/velocity.json +4 -4
- package/lib/browser/keypair.d.ts +8 -0
- package/lib/browser/keypair.js +8 -0
- package/lib/browser/marginCalculation.d.ts +134 -2
- package/lib/browser/marginCalculation.js +121 -0
- package/lib/browser/math/amm.d.ts +348 -29
- package/lib/browser/math/amm.js +310 -32
- package/lib/browser/math/auction.d.ts +95 -19
- package/lib/browser/math/auction.js +118 -28
- package/lib/browser/math/bankruptcy.d.ts +46 -0
- package/lib/browser/math/bankruptcy.js +89 -1
- package/lib/browser/math/builder.d.ts +64 -8
- package/lib/browser/math/builder.js +71 -9
- package/lib/browser/math/conversion.d.ts +21 -0
- package/lib/browser/math/conversion.js +21 -0
- package/lib/browser/math/exchangeStatus.d.ts +91 -0
- package/lib/browser/math/exchangeStatus.js +106 -3
- package/lib/browser/math/funding.d.ts +57 -20
- package/lib/browser/math/funding.js +63 -23
- package/lib/browser/math/insurance.d.ts +62 -0
- package/lib/browser/math/insurance.js +62 -0
- package/lib/browser/math/liquidation.d.ts +127 -11
- package/lib/browser/math/liquidation.js +182 -19
- package/lib/browser/math/margin.d.ts +79 -13
- package/lib/browser/math/margin.js +80 -14
- package/lib/browser/math/market.d.ts +135 -15
- package/lib/browser/math/market.js +145 -17
- package/lib/browser/math/oracles.d.ts +113 -0
- package/lib/browser/math/oracles.js +118 -1
- package/lib/browser/math/orders.d.ts +115 -10
- package/lib/browser/math/orders.js +130 -19
- package/lib/browser/math/position.d.ts +80 -33
- package/lib/browser/math/position.js +80 -33
- package/lib/browser/math/repeg.d.ts +48 -10
- package/lib/browser/math/repeg.js +48 -10
- package/lib/browser/math/spotBalance.d.ts +200 -5
- package/lib/browser/math/spotBalance.js +239 -10
- package/lib/browser/math/spotMarket.d.ts +36 -3
- package/lib/browser/math/spotMarket.js +36 -3
- package/lib/browser/math/spotPosition.d.ts +72 -0
- package/lib/browser/math/spotPosition.js +62 -0
- package/lib/browser/math/state.d.ts +31 -0
- package/lib/browser/math/state.js +31 -0
- package/lib/browser/math/superStake.d.ts +126 -2
- package/lib/browser/math/superStake.js +123 -3
- package/lib/browser/math/tiers.d.ts +29 -0
- package/lib/browser/math/tiers.js +29 -0
- package/lib/browser/math/trade.d.ts +102 -51
- package/lib/browser/math/trade.js +101 -55
- package/lib/browser/math/utils.d.ts +71 -9
- package/lib/browser/math/utils.js +71 -9
- package/lib/browser/memcmp.d.ts +94 -0
- package/lib/browser/memcmp.js +103 -2
- package/lib/browser/oracles/oracleClientCache.d.ts +16 -0
- package/lib/browser/oracles/oracleClientCache.js +16 -0
- package/lib/browser/oracles/oracleId.d.ts +31 -0
- package/lib/browser/oracles/oracleId.js +39 -8
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +20 -0
- package/lib/browser/oracles/prelaunchOracleClient.js +20 -0
- package/lib/browser/oracles/pythClient.d.ts +31 -0
- package/lib/browser/oracles/pythClient.js +32 -1
- package/lib/browser/oracles/pythLazerClient.d.ts +34 -0
- package/lib/browser/oracles/pythLazerClient.js +35 -1
- package/lib/browser/oracles/quoteAssetOracleClient.d.ts +18 -0
- package/lib/browser/oracles/quoteAssetOracleClient.js +18 -0
- package/lib/browser/oracles/strictOraclePrice.d.ts +21 -0
- package/lib/browser/oracles/strictOraclePrice.js +21 -0
- package/lib/browser/oracles/types.d.ts +45 -0
- package/lib/browser/oracles/utils.d.ts +20 -0
- package/lib/browser/oracles/utils.js +20 -0
- package/lib/browser/orderParams.d.ts +42 -4
- package/lib/browser/orderParams.js +42 -4
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +56 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.js +56 -0
- package/lib/browser/orderSubscriber/PollingSubscription.d.ts +11 -0
- package/lib/browser/orderSubscriber/PollingSubscription.js +11 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +18 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +18 -0
- package/lib/browser/orderSubscriber/grpcSubscription.d.ts +16 -0
- package/lib/browser/orderSubscriber/grpcSubscription.js +16 -0
- package/lib/browser/orderSubscriber/types.d.ts +9 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.js +1 -0
- package/lib/browser/priorityFee/averageStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/averageStrategy.js +1 -0
- package/lib/browser/priorityFee/ewmaStrategy.d.ts +10 -0
- package/lib/browser/priorityFee/ewmaStrategy.js +10 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +9 -2
- package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.js +1 -0
- package/lib/browser/priorityFee/maxStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/maxStrategy.js +1 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +39 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +39 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +21 -2
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +10 -0
- package/lib/browser/priorityFee/types.d.ts +32 -0
- package/lib/browser/priorityFee/types.js +5 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +8 -0
- package/lib/browser/slot/SlotSubscriber.d.ts +18 -0
- package/lib/browser/slot/SlotSubscriber.js +16 -0
- package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/browser/slot/SlothashSubscriber.js +25 -1
- package/lib/browser/tx/baseTxSender.d.ts +163 -0
- package/lib/browser/tx/baseTxSender.js +174 -6
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
- package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/browser/tx/fastSingleTxSender.d.ts +47 -0
- package/lib/browser/tx/fastSingleTxSender.js +48 -1
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +48 -0
- package/lib/browser/tx/forwardOnlyTxSender.js +48 -0
- package/lib/browser/tx/reportTransactionError.d.ts +18 -6
- package/lib/browser/tx/reportTransactionError.js +18 -6
- package/lib/browser/tx/retryTxSender.d.ts +40 -0
- package/lib/browser/tx/retryTxSender.js +39 -0
- package/lib/browser/tx/txHandler.d.ts +146 -35
- package/lib/browser/tx/txHandler.js +132 -32
- package/lib/browser/tx/txParamProcessor.d.ts +47 -0
- package/lib/browser/tx/txParamProcessor.js +47 -0
- package/lib/browser/tx/types.d.ts +46 -0
- package/lib/browser/tx/types.js +5 -0
- package/lib/browser/tx/utils.d.ts +26 -0
- package/lib/browser/tx/utils.js +26 -0
- package/lib/browser/tx/whileValidTxSender.d.ts +82 -0
- package/lib/browser/tx/whileValidTxSender.js +81 -0
- package/lib/browser/types.d.ts +781 -13
- package/lib/browser/types.js +126 -9
- package/lib/browser/user.d.ts +645 -84
- package/lib/browser/user.js +779 -96
- package/lib/browser/userMap/PollingSubscription.d.ts +10 -0
- package/lib/browser/userMap/PollingSubscription.js +14 -2
- package/lib/browser/userMap/WebsocketSubscription.d.ts +9 -0
- package/lib/browser/userMap/WebsocketSubscription.js +9 -0
- package/lib/browser/userMap/grpcSubscription.d.ts +8 -0
- package/lib/browser/userMap/grpcSubscription.js +8 -0
- package/lib/browser/userMap/referrerMap.d.ts +72 -2
- package/lib/browser/userMap/referrerMap.js +84 -2
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +37 -10
- package/lib/browser/userMap/revenueShareEscrowMap.js +38 -11
- package/lib/browser/userMap/userMap.d.ts +81 -3
- package/lib/browser/userMap/userMap.js +81 -4
- package/lib/browser/userMap/userMapConfig.d.ts +23 -0
- package/lib/browser/userMap/userStatsMap.d.ts +22 -0
- package/lib/browser/userMap/userStatsMap.js +22 -0
- package/lib/browser/userName.d.ts +16 -0
- package/lib/browser/userName.js +16 -0
- package/lib/browser/userStats.d.ts +28 -1
- package/lib/browser/userStats.js +28 -1
- package/lib/browser/util/TransactionConfirmationManager.d.ts +33 -0
- package/lib/browser/util/TransactionConfirmationManager.js +33 -0
- package/lib/browser/util/chainClock.d.ts +24 -0
- package/lib/browser/util/chainClock.js +20 -0
- package/lib/browser/util/computeUnits.d.ts +32 -0
- package/lib/browser/util/computeUnits.js +32 -0
- package/lib/browser/util/digest.d.ts +17 -0
- package/lib/browser/util/digest.js +17 -0
- package/lib/browser/util/ed25519Utils.d.ts +12 -2
- package/lib/browser/util/ed25519Utils.js +12 -2
- package/lib/browser/util/promiseTimeout.d.ts +9 -0
- package/lib/browser/util/promiseTimeout.js +9 -0
- package/lib/browser/velocityClient.d.ts +3322 -215
- package/lib/browser/velocityClient.js +3412 -245
- package/lib/browser/wallet.d.ts +37 -0
- package/lib/browser/wallet.js +37 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserAccountSubscriber.js +18 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +18 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts +52 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/bulkAccountLoader.js +51 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts +9 -2
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts.map +1 -1
- package/lib/node/accounts/bulkUserStatsSubscription.js +9 -2
- package/lib/node/accounts/bulkUserSubscription.d.ts +8 -2
- package/lib/node/accounts/bulkUserSubscription.d.ts.map +1 -1
- package/lib/node/accounts/bulkUserSubscription.js +8 -2
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.js +37 -0
- package/lib/node/accounts/fetch.d.ts +59 -2
- package/lib/node/accounts/fetch.d.ts.map +1 -1
- package/lib/node/accounts/fetch.js +57 -2
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcAccountSubscriber.js +30 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +118 -37
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +40 -12
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +33 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +15 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserAccountSubscriber.js +15 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +15 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +34 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +34 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +21 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +22 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +32 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +22 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
- package/lib/node/accounts/testBulkAccountLoader.d.ts +8 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/testBulkAccountLoader.js +8 -0
- package/lib/node/accounts/types.d.ts +149 -0
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/types.js +13 -0
- package/lib/node/accounts/utils.d.ts +18 -0
- package/lib/node/accounts/utils.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +32 -16
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +41 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +41 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +31 -23
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +36 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +26 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +33 -0
- package/lib/node/addresses/marketAddresses.d.ts +10 -0
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
- package/lib/node/addresses/marketAddresses.js +10 -0
- package/lib/node/addresses/pda.d.ts +214 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +217 -5
- package/lib/node/adminClient.d.ts +2136 -4
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +2150 -4
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
- package/lib/node/auctionSubscriber/index.d.ts +6 -0
- package/lib/node/auctionSubscriber/index.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/index.js +6 -0
- package/lib/node/auctionSubscriber/types.d.ts +7 -0
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +33 -0
- package/lib/node/blockhashSubscriber/index.d.ts +5 -0
- package/lib/node/blockhashSubscriber/index.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/index.js +5 -0
- package/lib/node/blockhashSubscriber/types.d.ts +5 -0
- package/lib/node/blockhashSubscriber/types.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.d.ts +24 -0
- package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.js +22 -0
- package/lib/node/config.d.ts +58 -4
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +88 -21
- package/lib/node/constants/numericConstants.d.ts +67 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +68 -1
- package/lib/node/constants/perpMarkets.d.ts +10 -0
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +40 -908
- package/lib/node/constants/spotMarkets.d.ts +13 -0
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +16 -742
- package/lib/node/constants/txConstants.d.ts +1 -0
- package/lib/node/constants/txConstants.d.ts.map +1 -1
- package/lib/node/constants/txConstants.js +1 -0
- package/lib/node/core/VelocityCore.d.ts +285 -8
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +281 -8
- package/lib/node/core/instructions/deposit.d.ts +22 -0
- package/lib/node/core/instructions/deposit.d.ts.map +1 -1
- package/lib/node/core/instructions/deposit.js +22 -0
- package/lib/node/core/instructions/fill.d.ts +17 -0
- package/lib/node/core/instructions/fill.d.ts.map +1 -1
- package/lib/node/core/instructions/fill.js +17 -0
- package/lib/node/core/instructions/funding.d.ts +12 -0
- package/lib/node/core/instructions/funding.d.ts.map +1 -1
- package/lib/node/core/instructions/funding.js +12 -0
- package/lib/node/core/instructions/liquidation.d.ts +18 -0
- package/lib/node/core/instructions/liquidation.d.ts.map +1 -1
- package/lib/node/core/instructions/liquidation.js +18 -0
- package/lib/node/core/instructions/orders.d.ts +28 -0
- package/lib/node/core/instructions/orders.d.ts.map +1 -1
- package/lib/node/core/instructions/orders.js +28 -0
- package/lib/node/core/instructions/perpOrders.d.ts +106 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
- package/lib/node/core/instructions/perpOrders.js +106 -0
- package/lib/node/core/instructions/settlement.d.ts +14 -0
- package/lib/node/core/instructions/settlement.d.ts.map +1 -1
- package/lib/node/core/instructions/settlement.js +14 -0
- package/lib/node/core/instructions/trigger.d.ts +15 -0
- package/lib/node/core/instructions/trigger.d.ts.map +1 -1
- package/lib/node/core/instructions/trigger.js +15 -0
- package/lib/node/core/instructions/withdraw.d.ts +21 -0
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/core/instructions/withdraw.js +21 -0
- package/lib/node/core/remainingAccounts.d.ts +47 -3
- package/lib/node/core/remainingAccounts.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.js +20 -0
- package/lib/node/core/signedMsg.d.ts +38 -0
- package/lib/node/core/signedMsg.d.ts.map +1 -1
- package/lib/node/core/signedMsg.js +33 -0
- package/lib/node/decode/customCoder.d.ts +39 -3
- package/lib/node/decode/customCoder.d.ts.map +1 -1
- package/lib/node/decode/customCoder.js +45 -3
- package/lib/node/decode/user.d.ts +22 -0
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +22 -0
- package/lib/node/dlob/DLOB.d.ts +502 -53
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +540 -98
- package/lib/node/dlob/DLOBNode.d.ts +86 -4
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +37 -4
- package/lib/node/dlob/DLOBSubscriber.d.ts +39 -12
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +42 -12
- package/lib/node/dlob/NodeList.d.ts +69 -0
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.js +66 -0
- package/lib/node/dlob/orderBookLevels.d.ts +106 -13
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +84 -14
- package/lib/node/dlob/types.d.ts +15 -0
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/events/eventList.d.ts +14 -0
- package/lib/node/events/eventList.d.ts.map +1 -1
- package/lib/node/events/eventList.js +14 -0
- package/lib/node/events/eventSubscriber.d.ts +87 -10
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +93 -8
- package/lib/node/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
- package/lib/node/events/eventsServerLogProvider.js +27 -0
- package/lib/node/events/fetchLogs.d.ts +31 -0
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.js +46 -1
- package/lib/node/events/parse.d.ts +23 -0
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/events/parse.js +23 -0
- package/lib/node/events/pollingLogProvider.d.ts +24 -0
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
- package/lib/node/events/pollingLogProvider.js +24 -0
- package/lib/node/events/sort.d.ts +11 -0
- package/lib/node/events/sort.d.ts.map +1 -1
- package/lib/node/events/sort.js +12 -0
- package/lib/node/events/txEventCache.d.ts +13 -3
- package/lib/node/events/txEventCache.d.ts.map +1 -1
- package/lib/node/events/txEventCache.js +19 -7
- package/lib/node/events/types.d.ts +118 -2
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +11 -0
- package/lib/node/events/webSocketLogProvider.d.ts +23 -0
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
- package/lib/node/events/webSocketLogProvider.js +28 -0
- package/lib/node/factory/oracleClient.js +2 -2
- package/lib/node/idl/velocity.d.ts +4 -4
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +4 -4
- package/lib/node/keypair.d.ts +8 -0
- package/lib/node/keypair.d.ts.map +1 -1
- package/lib/node/keypair.js +8 -0
- package/lib/node/marginCalculation.d.ts +134 -2
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marginCalculation.js +121 -0
- package/lib/node/math/amm.d.ts +348 -29
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +310 -32
- package/lib/node/math/auction.d.ts +95 -19
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +118 -28
- package/lib/node/math/bankruptcy.d.ts +46 -0
- package/lib/node/math/bankruptcy.d.ts.map +1 -1
- package/lib/node/math/bankruptcy.js +89 -1
- package/lib/node/math/builder.d.ts +64 -8
- package/lib/node/math/builder.d.ts.map +1 -1
- package/lib/node/math/builder.js +71 -9
- package/lib/node/math/conversion.d.ts +21 -0
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/conversion.js +21 -0
- package/lib/node/math/exchangeStatus.d.ts +91 -0
- package/lib/node/math/exchangeStatus.d.ts.map +1 -1
- package/lib/node/math/exchangeStatus.js +106 -3
- package/lib/node/math/funding.d.ts +57 -20
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +63 -23
- package/lib/node/math/insurance.d.ts +62 -0
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +62 -0
- package/lib/node/math/liquidation.d.ts +127 -11
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/liquidation.js +182 -19
- package/lib/node/math/margin.d.ts +79 -13
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +80 -14
- package/lib/node/math/market.d.ts +135 -15
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +145 -17
- package/lib/node/math/oracles.d.ts +113 -0
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +118 -1
- package/lib/node/math/orders.d.ts +115 -10
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +130 -19
- package/lib/node/math/position.d.ts +80 -33
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +80 -33
- package/lib/node/math/repeg.d.ts +48 -10
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/repeg.js +48 -10
- package/lib/node/math/spotBalance.d.ts +200 -5
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +239 -10
- package/lib/node/math/spotMarket.d.ts +36 -3
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +36 -3
- package/lib/node/math/spotPosition.d.ts +72 -0
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/spotPosition.js +62 -0
- package/lib/node/math/state.d.ts +31 -0
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/state.js +31 -0
- package/lib/node/math/superStake.d.ts +126 -2
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +123 -3
- package/lib/node/math/tiers.d.ts +29 -0
- package/lib/node/math/tiers.d.ts.map +1 -1
- package/lib/node/math/tiers.js +29 -0
- package/lib/node/math/trade.d.ts +102 -51
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +101 -55
- package/lib/node/math/utils.d.ts +71 -9
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/math/utils.js +71 -9
- package/lib/node/memcmp.d.ts +94 -0
- package/lib/node/memcmp.d.ts.map +1 -1
- package/lib/node/memcmp.js +103 -2
- package/lib/node/oracles/oracleClientCache.d.ts +16 -0
- package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
- package/lib/node/oracles/oracleClientCache.js +16 -0
- package/lib/node/oracles/oracleId.d.ts +31 -0
- package/lib/node/oracles/oracleId.d.ts.map +1 -1
- package/lib/node/oracles/oracleId.js +39 -8
- package/lib/node/oracles/prelaunchOracleClient.d.ts +20 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +20 -0
- package/lib/node/oracles/pythClient.d.ts +31 -0
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.js +32 -1
- package/lib/node/oracles/pythLazerClient.d.ts +34 -0
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +35 -1
- package/lib/node/oracles/quoteAssetOracleClient.d.ts +18 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/quoteAssetOracleClient.js +18 -0
- package/lib/node/oracles/strictOraclePrice.d.ts +21 -0
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/strictOraclePrice.js +21 -0
- package/lib/node/oracles/types.d.ts +45 -0
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +20 -0
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/oracles/utils.js +20 -0
- package/lib/node/orderParams.d.ts +42 -4
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderParams.js +42 -4
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +56 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +56 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts +11 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/PollingSubscription.js +11 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +18 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/WebsocketSubscription.js +18 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts +16 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +16 -0
- package/lib/node/orderSubscriber/types.d.ts +9 -0
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/averageOverSlotsStrategy.js +1 -0
- package/lib/node/priorityFee/averageStrategy.d.ts +1 -0
- package/lib/node/priorityFee/averageStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/averageStrategy.js +1 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts +10 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/ewmaStrategy.js +10 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/heliusPriorityFeeMethod.js +9 -2
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/maxOverSlotsStrategy.js +1 -0
- package/lib/node/priorityFee/maxStrategy.d.ts +1 -0
- package/lib/node/priorityFee/maxStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/maxStrategy.js +1 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +39 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +39 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +21 -2
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/solanaPriorityFeeMethod.js +10 -0
- package/lib/node/priorityFee/types.d.ts +32 -0
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/types.js +5 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.js +8 -0
- package/lib/node/slot/SlotSubscriber.d.ts +18 -0
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.js +16 -0
- package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlothashSubscriber.js +25 -1
- package/lib/node/tx/baseTxSender.d.ts +163 -0
- package/lib/node/tx/baseTxSender.d.ts.map +1 -1
- package/lib/node/tx/baseTxSender.js +174 -6
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts.map +1 -1
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts.map +1 -1
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.d.ts +47 -0
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.js +48 -1
- package/lib/node/tx/forwardOnlyTxSender.d.ts +48 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -1
- package/lib/node/tx/forwardOnlyTxSender.js +48 -0
- package/lib/node/tx/reportTransactionError.d.ts +18 -6
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
- package/lib/node/tx/reportTransactionError.js +18 -6
- package/lib/node/tx/retryTxSender.d.ts +40 -0
- package/lib/node/tx/retryTxSender.d.ts.map +1 -1
- package/lib/node/tx/retryTxSender.js +39 -0
- package/lib/node/tx/txHandler.d.ts +146 -35
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +132 -32
- package/lib/node/tx/txParamProcessor.d.ts +47 -0
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
- package/lib/node/tx/txParamProcessor.js +47 -0
- package/lib/node/tx/types.d.ts +46 -0
- package/lib/node/tx/types.d.ts.map +1 -1
- package/lib/node/tx/types.js +5 -0
- package/lib/node/tx/utils.d.ts +26 -0
- package/lib/node/tx/utils.d.ts.map +1 -1
- package/lib/node/tx/utils.js +26 -0
- package/lib/node/tx/whileValidTxSender.d.ts +82 -0
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.js +81 -0
- package/lib/node/types.d.ts +781 -13
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +126 -9
- package/lib/node/user.d.ts +645 -84
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +779 -96
- package/lib/node/userMap/PollingSubscription.d.ts +10 -0
- package/lib/node/userMap/PollingSubscription.d.ts.map +1 -1
- package/lib/node/userMap/PollingSubscription.js +14 -2
- package/lib/node/userMap/WebsocketSubscription.d.ts +9 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/userMap/WebsocketSubscription.js +9 -0
- package/lib/node/userMap/grpcSubscription.d.ts +8 -0
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
- package/lib/node/userMap/grpcSubscription.js +8 -0
- package/lib/node/userMap/referrerMap.d.ts +72 -2
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +84 -2
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +37 -10
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +38 -11
- package/lib/node/userMap/userMap.d.ts +81 -3
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +81 -4
- package/lib/node/userMap/userMapConfig.d.ts +23 -0
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +22 -0
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +22 -0
- package/lib/node/userName.d.ts +16 -0
- package/lib/node/userName.d.ts.map +1 -1
- package/lib/node/userName.js +16 -0
- package/lib/node/userStats.d.ts +28 -1
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +28 -1
- package/lib/node/util/TransactionConfirmationManager.d.ts +33 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
- package/lib/node/util/TransactionConfirmationManager.js +33 -0
- package/lib/node/util/chainClock.d.ts +24 -0
- package/lib/node/util/chainClock.d.ts.map +1 -1
- package/lib/node/util/chainClock.js +20 -0
- package/lib/node/util/computeUnits.d.ts +32 -0
- package/lib/node/util/computeUnits.d.ts.map +1 -1
- package/lib/node/util/computeUnits.js +32 -0
- package/lib/node/util/digest.d.ts +17 -0
- package/lib/node/util/digest.d.ts.map +1 -1
- package/lib/node/util/digest.js +17 -0
- package/lib/node/util/ed25519Utils.d.ts +12 -2
- package/lib/node/util/ed25519Utils.d.ts.map +1 -1
- package/lib/node/util/ed25519Utils.js +12 -2
- package/lib/node/util/promiseTimeout.d.ts +9 -0
- package/lib/node/util/promiseTimeout.d.ts.map +1 -1
- package/lib/node/util/promiseTimeout.js +9 -0
- package/lib/node/velocityClient.d.ts +3322 -215
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +3412 -245
- package/lib/node/wallet.d.ts +37 -0
- package/lib/node/wallet.d.ts.map +1 -1
- package/lib/node/wallet.js +37 -0
- package/package.json +2 -1
- package/src/accounts/basicUserAccountSubscriber.ts +18 -0
- package/src/accounts/basicUserStatsAccountSubscriber.ts +18 -0
- package/src/accounts/bulkAccountLoader.ts +52 -0
- package/src/accounts/bulkUserStatsSubscription.ts +9 -2
- package/src/accounts/bulkUserSubscription.ts +8 -2
- package/src/accounts/customizedCadenceBulkAccountLoader.ts +37 -0
- package/src/accounts/fetch.ts +59 -2
- package/src/accounts/grpcAccountSubscriber.ts +30 -0
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +16 -0
- package/src/accounts/grpcMultiAccountSubscriber.ts +121 -38
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +49 -11
- package/src/accounts/grpcProgramAccountSubscriber.ts +33 -0
- package/src/accounts/grpcUserAccountSubscriber.ts +15 -0
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +15 -0
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +41 -0
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +160 -1
- package/src/accounts/laserProgramAccountSubscriber.ts +34 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +19 -0
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +19 -0
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +31 -0
- package/src/accounts/pollingOracleAccountSubscriber.ts +21 -2
- package/src/accounts/pollingTokenAccountSubscriber.ts +22 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +32 -0
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +22 -0
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +84 -1
- package/src/accounts/testBulkAccountLoader.ts +8 -0
- package/src/accounts/types.ts +149 -0
- package/src/accounts/utils.ts +42 -24
- package/src/accounts/webSocketAccountSubscriber.ts +41 -0
- package/src/accounts/webSocketAccountSubscriberV2.ts +31 -23
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +27 -0
- package/src/accounts/webSocketProgramAccountSubscriber.ts +36 -0
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +26 -0
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +21 -0
- package/src/accounts/webSocketUserAccountSubscriber.ts +26 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +20 -0
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +127 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +110 -0
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +33 -0
- package/src/addresses/marketAddresses.ts +10 -0
- package/src/addresses/pda.ts +228 -12
- package/src/adminClient.ts +2156 -4
- package/src/auctionSubscriber/auctionSubscriber.ts +15 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +19 -0
- package/src/auctionSubscriber/index.ts +6 -0
- package/src/auctionSubscriber/types.ts +7 -0
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +33 -0
- package/src/blockhashSubscriber/index.ts +5 -0
- package/src/blockhashSubscriber/types.ts +5 -4
- package/src/clock/clockSubscriber.ts +24 -0
- package/src/config.ts +109 -22
- package/src/constants/numericConstants.ts +70 -0
- package/src/constants/perpMarkets.ts +45 -960
- package/src/constants/spotMarkets.ts +23 -793
- package/src/constants/txConstants.ts +1 -0
- package/src/core/VelocityCore.ts +286 -8
- package/src/core/instructions/deposit.ts +22 -0
- package/src/core/instructions/fill.ts +17 -0
- package/src/core/instructions/funding.ts +12 -0
- package/src/core/instructions/liquidation.ts +18 -0
- package/src/core/instructions/orders.ts +28 -0
- package/src/core/instructions/perpOrders.ts +106 -0
- package/src/core/instructions/settlement.ts +14 -0
- package/src/core/instructions/trigger.ts +15 -0
- package/src/core/instructions/withdraw.ts +21 -0
- package/src/core/remainingAccounts.ts +47 -3
- package/src/core/signedMsg.ts +38 -0
- package/src/decode/customCoder.ts +46 -3
- package/src/decode/user.ts +22 -0
- package/src/dlob/DLOB.ts +668 -97
- package/src/dlob/DLOBNode.ts +98 -6
- package/src/dlob/DLOBSubscriber.ts +49 -12
- package/src/dlob/NodeList.ts +69 -0
- package/src/dlob/orderBookLevels.ts +108 -14
- package/src/dlob/types.ts +15 -0
- package/src/events/eventList.ts +14 -0
- package/src/events/eventSubscriber.ts +100 -19
- package/src/events/eventsServerLogProvider.ts +28 -0
- package/src/events/fetchLogs.ts +52 -2
- package/src/events/parse.ts +23 -0
- package/src/events/pollingLogProvider.ts +24 -0
- package/src/events/sort.ts +12 -0
- package/src/events/txEventCache.ts +19 -7
- package/src/events/types.ts +131 -11
- package/src/events/webSocketLogProvider.ts +29 -0
- package/src/factory/oracleClient.ts +2 -2
- package/src/idl/velocity.json +4 -4
- package/src/idl/velocity.ts +4 -4
- package/src/keypair.ts +8 -0
- package/src/marginCalculation.ts +153 -2
- package/src/math/amm.ts +371 -36
- package/src/math/auction.ts +139 -30
- package/src/math/bankruptcy.ts +104 -1
- package/src/math/builder.ts +74 -8
- package/src/math/conversion.ts +21 -0
- package/src/math/exchangeStatus.ts +117 -2
- package/src/math/funding.ts +63 -23
- package/src/math/insurance.ts +62 -0
- package/src/math/liquidation.ts +227 -17
- package/src/math/margin.ts +80 -14
- package/src/math/market.ts +148 -17
- package/src/math/oracles.ts +124 -0
- package/src/math/orders.ts +141 -19
- package/src/math/position.ts +80 -33
- package/src/math/repeg.ts +48 -10
- package/src/math/spotBalance.ts +252 -12
- package/src/math/spotMarket.ts +36 -3
- package/src/math/spotPosition.ts +72 -0
- package/src/math/state.ts +31 -0
- package/src/math/superStake.ts +126 -3
- package/src/math/tiers.ts +29 -0
- package/src/math/trade.ts +125 -55
- package/src/math/utils.ts +71 -9
- package/src/memcmp.ts +104 -2
- package/src/oracles/oracleClientCache.ts +16 -0
- package/src/oracles/oracleId.ts +39 -6
- package/src/oracles/prelaunchOracleClient.ts +20 -0
- package/src/oracles/pythClient.ts +32 -1
- package/src/oracles/pythLazerClient.ts +35 -1
- package/src/oracles/quoteAssetOracleClient.ts +18 -0
- package/src/oracles/strictOraclePrice.ts +21 -0
- package/src/oracles/types.ts +45 -0
- package/src/oracles/utils.ts +20 -0
- package/src/orderParams.ts +42 -4
- package/src/orderSubscriber/OrderSubscriber.ts +56 -0
- package/src/orderSubscriber/PollingSubscription.ts +11 -0
- package/src/orderSubscriber/WebsocketSubscription.ts +18 -0
- package/src/orderSubscriber/grpcSubscription.ts +16 -0
- package/src/orderSubscriber/types.ts +9 -0
- package/src/priorityFee/averageOverSlotsStrategy.ts +1 -0
- package/src/priorityFee/averageStrategy.ts +1 -0
- package/src/priorityFee/ewmaStrategy.ts +10 -0
- package/src/priorityFee/heliusPriorityFeeMethod.ts +13 -2
- package/src/priorityFee/maxOverSlotsStrategy.ts +1 -0
- package/src/priorityFee/maxStrategy.ts +1 -0
- package/src/priorityFee/priorityFeeSubscriber.ts +39 -0
- package/src/priorityFee/priorityFeeSubscriberMap.ts +21 -2
- package/src/priorityFee/solanaPriorityFeeMethod.ts +12 -0
- package/src/priorityFee/types.ts +33 -15
- package/src/priorityFee/velocityPriorityFeeMethod.ts +11 -0
- package/src/slot/SlotSubscriber.ts +18 -0
- package/src/slot/SlothashSubscriber.ts +27 -1
- package/src/tx/baseTxSender.ts +185 -5
- package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +12 -0
- package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +15 -0
- package/src/tx/blockhashFetcher/types.ts +4 -0
- package/src/tx/fastSingleTxSender.ts +58 -4
- package/src/tx/forwardOnlyTxSender.ts +48 -0
- package/src/tx/reportTransactionError.ts +18 -6
- package/src/tx/retryTxSender.ts +40 -0
- package/src/tx/txHandler.ts +146 -35
- package/src/tx/txParamProcessor.ts +47 -0
- package/src/tx/types.ts +46 -0
- package/src/tx/utils.ts +26 -0
- package/src/tx/whileValidTxSender.ts +82 -0
- package/src/types.ts +777 -24
- package/src/user.ts +869 -110
- package/src/userMap/PollingSubscription.ts +16 -2
- package/src/userMap/WebsocketSubscription.ts +9 -0
- package/src/userMap/grpcSubscription.ts +8 -0
- package/src/userMap/referrerMap.ts +92 -3
- package/src/userMap/revenueShareEscrowMap.ts +38 -11
- package/src/userMap/userMap.ts +82 -4
- package/src/userMap/userMapConfig.ts +23 -10
- package/src/userMap/userStatsMap.ts +22 -0
- package/src/userName.ts +16 -0
- package/src/userStats.ts +28 -1
- package/src/util/TransactionConfirmationManager.ts +33 -0
- package/src/util/chainClock.ts +24 -0
- package/src/util/computeUnits.ts +32 -0
- package/src/util/digest.ts +17 -0
- package/src/util/ed25519Utils.ts +12 -2
- package/src/util/promiseTimeout.ts +9 -0
- package/src/velocityClient.ts +3439 -249
- package/src/wallet.ts +37 -0
- package/tests/VelocityCore/builder_escrow.test.ts +121 -0
- package/tests/amm/test.ts +102 -0
- package/tests/builder/builderFee.test.ts +42 -0
- package/tests/dlob/tickSizeStandardization.ts +545 -0
- package/tests/exchangeStatus/test.ts +45 -0
- package/tests/liquidation/test.ts +125 -0
- package/tests/oracles/mmOracleGate.test.ts +379 -0
- package/tests/oracles/pythPegSnap.test.ts +76 -0
- package/tests/sdkParity/enumParity.test.ts +84 -0
- package/tests/sdkParity/marginCategoryFill.test.ts +143 -0
- package/tests/sdkParity/memcmpOffsets.test.ts +139 -0
- package/tests/spot/test.ts +55 -0
- package/tests/user/bankruptcy.ts +165 -0
- package/tests/user/feeAndWithdrawLimits.ts +284 -0
- package/tests/user/getMarginCalculation.ts +226 -1
- package/tests/user/test.ts +8 -4
|
@@ -2,12 +2,53 @@ import { WebSocketVelocityClientAccountSubscriber } from './webSocketVelocityCli
|
|
|
2
2
|
import { OracleInfo } from '../oracles/types';
|
|
3
3
|
import { VelocityProgram } from '../config';
|
|
4
4
|
import { DelistedMarketSetting, GrpcConfigs, ResubOpts } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* `VelocityClientAccountSubscriber` variant of `WebSocketVelocityClientAccountSubscriber` that
|
|
7
|
+
* subscribes each per-account subscriber via `grpcAccountSubscriber.create` (gRPC Geyser stream)
|
|
8
|
+
* instead of `connection.onAccountChange`. Reuses the parent class's `setInitialData`/oracle-map/
|
|
9
|
+
* delisted-market logic verbatim; only the account-subscription creation is overridden.
|
|
10
|
+
*/
|
|
5
11
|
export declare class grpcVelocityClientAccountSubscriber extends WebSocketVelocityClientAccountSubscriber {
|
|
6
12
|
private grpcConfigs;
|
|
13
|
+
/**
|
|
14
|
+
* @param grpcConfigs gRPC Geyser endpoint/token/commitment config (Yellowstone or LaserStream).
|
|
15
|
+
* @param program Anchor program used to derive PDAs, decode accounts, and resolve oracle clients.
|
|
16
|
+
* @param perpMarketIndexes Perp market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
17
|
+
* @param spotMarketIndexes Spot market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
18
|
+
* @param oracleInfos Oracles to track up front, if `shouldFindAllMarketsAndOracles` is false.
|
|
19
|
+
* @param shouldFindAllMarketsAndOracles If true, `subscribe()` first discovers every market/oracle from on-chain state.
|
|
20
|
+
* @param delistedMarketSetting Behavior applied to delisted perp markets/oracles after subscribing.
|
|
21
|
+
* @param resubOpts Resubscription watchdog options passed to every per-account subscriber.
|
|
22
|
+
*/
|
|
7
23
|
constructor(grpcConfigs: GrpcConfigs, program: VelocityProgram, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], shouldFindAllMarketsAndOracles: boolean, delistedMarketSetting: DelistedMarketSetting, resubOpts?: ResubOpts);
|
|
24
|
+
/**
|
|
25
|
+
* Subscribes the `State` account via gRPC, batch-seeds all market/oracle accounts via
|
|
26
|
+
* `setInitialData()` (inherited RPC-based batch fetch), then subscribes every per-account gRPC
|
|
27
|
+
* subscriber for perp markets, spot markets, and oracles. Applies `delistedMarketSetting`
|
|
28
|
+
* afterward. Idempotent: a no-op if already subscribed, and concurrent calls while a subscribe
|
|
29
|
+
* is in flight share the same result via `subscriptionPromise`.
|
|
30
|
+
*/
|
|
8
31
|
subscribe(): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Creates and subscribes a `grpcAccountSubscriber` for one spot market, seeding it from
|
|
34
|
+
* `initialSpotMarketAccountData` if available.
|
|
35
|
+
* @param marketIndex Spot market index to subscribe.
|
|
36
|
+
*/
|
|
9
37
|
subscribeToSpotMarketAccount(marketIndex: number): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates and subscribes a `grpcAccountSubscriber` for one perp market, seeding it from
|
|
40
|
+
* `initialPerpMarketAccountData` if available. Unlike the parent class's WebSocket variant,
|
|
41
|
+
* does not call `ensureAccountFetched` — the gRPC subscriber's own initial `fetch()` (inside
|
|
42
|
+
* `subscribe`) is relied on directly.
|
|
43
|
+
* @param marketIndex Perp market index to subscribe.
|
|
44
|
+
*/
|
|
10
45
|
subscribeToPerpMarketAccount(marketIndex: number): Promise<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Creates and subscribes a `grpcAccountSubscriber` for one oracle, decoding buffers with the
|
|
48
|
+
* source-appropriate `OracleClient`. Seeds from `initialOraclePriceData` if available.
|
|
49
|
+
* @param oracleInfo Oracle pubkey and source to subscribe.
|
|
50
|
+
* @returns `false` if no `OracleClient` is registered for `oracleInfo.source`; otherwise `true`.
|
|
51
|
+
*/
|
|
11
52
|
subscribeToOracle(oracleInfo: OracleInfo): Promise<boolean>;
|
|
12
53
|
}
|
|
13
54
|
//# sourceMappingURL=grpcVelocityClientAccountSubscriber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpcVelocityClientAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcVelocityClientAccountSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EAAE,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAA2B,eAAe,EAAE,MAAM,WAAW,CAAC;AAMrE,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKxE,qBAAa,mCAAoC,SAAQ,wCAAwC;IAChG,OAAO,CAAC,WAAW,CAAc;
|
|
1
|
+
{"version":3,"file":"grpcVelocityClientAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcVelocityClientAccountSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EAAE,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAA2B,eAAe,EAAE,MAAM,WAAW,CAAC;AAMrE,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKxE;;;;;GAKG;AACH,qBAAa,mCAAoC,SAAQ,wCAAwC;IAChG,OAAO,CAAC,WAAW,CAAc;IAEjC;;;;;;;;;OASG;gBAEF,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,eAAe,EACxB,iBAAiB,EAAE,MAAM,EAAE,EAC3B,iBAAiB,EAAE,MAAM,EAAE,EAC3B,WAAW,EAAE,UAAU,EAAE,EACzB,8BAA8B,EAAE,OAAO,EACvC,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,CAAC,EAAE,SAAS;IActB;;;;;;OAMG;IACU,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAmF1C;;;;OAIG;IACY,4BAA4B,CAC1C,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC;IA2BnB;;;;;;OAMG;IACG,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA2BzE;;;;;OAKG;IACG,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;CAsCjE"}
|
|
@@ -6,11 +6,34 @@ const config_1 = require("../config");
|
|
|
6
6
|
const pda_1 = require("../addresses/pda");
|
|
7
7
|
const grpcAccountSubscriber_1 = require("./grpcAccountSubscriber");
|
|
8
8
|
const oracleId_1 = require("../oracles/oracleId");
|
|
9
|
+
/**
|
|
10
|
+
* `VelocityClientAccountSubscriber` variant of `WebSocketVelocityClientAccountSubscriber` that
|
|
11
|
+
* subscribes each per-account subscriber via `grpcAccountSubscriber.create` (gRPC Geyser stream)
|
|
12
|
+
* instead of `connection.onAccountChange`. Reuses the parent class's `setInitialData`/oracle-map/
|
|
13
|
+
* delisted-market logic verbatim; only the account-subscription creation is overridden.
|
|
14
|
+
*/
|
|
9
15
|
class grpcVelocityClientAccountSubscriber extends webSocketVelocityClientAccountSubscriber_1.WebSocketVelocityClientAccountSubscriber {
|
|
16
|
+
/**
|
|
17
|
+
* @param grpcConfigs gRPC Geyser endpoint/token/commitment config (Yellowstone or LaserStream).
|
|
18
|
+
* @param program Anchor program used to derive PDAs, decode accounts, and resolve oracle clients.
|
|
19
|
+
* @param perpMarketIndexes Perp market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
20
|
+
* @param spotMarketIndexes Spot market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
21
|
+
* @param oracleInfos Oracles to track up front, if `shouldFindAllMarketsAndOracles` is false.
|
|
22
|
+
* @param shouldFindAllMarketsAndOracles If true, `subscribe()` first discovers every market/oracle from on-chain state.
|
|
23
|
+
* @param delistedMarketSetting Behavior applied to delisted perp markets/oracles after subscribing.
|
|
24
|
+
* @param resubOpts Resubscription watchdog options passed to every per-account subscriber.
|
|
25
|
+
*/
|
|
10
26
|
constructor(grpcConfigs, program, perpMarketIndexes, spotMarketIndexes, oracleInfos, shouldFindAllMarketsAndOracles, delistedMarketSetting, resubOpts) {
|
|
11
27
|
super(program, perpMarketIndexes, spotMarketIndexes, oracleInfos, shouldFindAllMarketsAndOracles, delistedMarketSetting, resubOpts);
|
|
12
28
|
this.grpcConfigs = grpcConfigs;
|
|
13
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Subscribes the `State` account via gRPC, batch-seeds all market/oracle accounts via
|
|
32
|
+
* `setInitialData()` (inherited RPC-based batch fetch), then subscribes every per-account gRPC
|
|
33
|
+
* subscriber for perp markets, spot markets, and oracles. Applies `delistedMarketSetting`
|
|
34
|
+
* afterward. Idempotent: a no-op if already subscribed, and concurrent calls while a subscribe
|
|
35
|
+
* is in flight share the same result via `subscriptionPromise`.
|
|
36
|
+
*/
|
|
14
37
|
async subscribe() {
|
|
15
38
|
if (this.isSubscribed) {
|
|
16
39
|
return true;
|
|
@@ -59,6 +82,11 @@ class grpcVelocityClientAccountSubscriber extends webSocketVelocityClientAccount
|
|
|
59
82
|
this.removeInitialData();
|
|
60
83
|
return true;
|
|
61
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Creates and subscribes a `grpcAccountSubscriber` for one spot market, seeding it from
|
|
87
|
+
* `initialSpotMarketAccountData` if available.
|
|
88
|
+
* @param marketIndex Spot market index to subscribe.
|
|
89
|
+
*/
|
|
62
90
|
async subscribeToSpotMarketAccount(marketIndex) {
|
|
63
91
|
var _a;
|
|
64
92
|
const marketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
|
|
@@ -74,6 +102,13 @@ class grpcVelocityClientAccountSubscriber extends webSocketVelocityClientAccount
|
|
|
74
102
|
this.spotMarketAccountSubscribers.set(marketIndex, accountSubscriber);
|
|
75
103
|
return true;
|
|
76
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Creates and subscribes a `grpcAccountSubscriber` for one perp market, seeding it from
|
|
107
|
+
* `initialPerpMarketAccountData` if available. Unlike the parent class's WebSocket variant,
|
|
108
|
+
* does not call `ensureAccountFetched` — the gRPC subscriber's own initial `fetch()` (inside
|
|
109
|
+
* `subscribe`) is relied on directly.
|
|
110
|
+
* @param marketIndex Perp market index to subscribe.
|
|
111
|
+
*/
|
|
77
112
|
async subscribeToPerpMarketAccount(marketIndex) {
|
|
78
113
|
var _a;
|
|
79
114
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
@@ -89,6 +124,12 @@ class grpcVelocityClientAccountSubscriber extends webSocketVelocityClientAccount
|
|
|
89
124
|
this.perpMarketAccountSubscribers.set(marketIndex, accountSubscriber);
|
|
90
125
|
return true;
|
|
91
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Creates and subscribes a `grpcAccountSubscriber` for one oracle, decoding buffers with the
|
|
129
|
+
* source-appropriate `OracleClient`. Seeds from `initialOraclePriceData` if available.
|
|
130
|
+
* @param oracleInfo Oracle pubkey and source to subscribe.
|
|
131
|
+
* @returns `false` if no `OracleClient` is registered for `oracleInfo.source`; otherwise `true`.
|
|
132
|
+
*/
|
|
92
133
|
async subscribeToOracle(oracleInfo) {
|
|
93
134
|
var _a;
|
|
94
135
|
const oracleId = (0, oracleId_1.getOracleId)(oracleInfo.publicKey, oracleInfo.source);
|
|
@@ -7,6 +7,15 @@ import { VelocityProgram } from '../config';
|
|
|
7
7
|
import { AccountSubscriber, DataAndSlot, DelistedMarketSetting, VelocityClientAccountEvents, VelocityClientAccountSubscriber, GrpcConfigs, ResubOpts } from './types';
|
|
8
8
|
import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types';
|
|
9
9
|
import { OracleClientCache } from '../oracles/oracleClientCache';
|
|
10
|
+
/**
|
|
11
|
+
* `VelocityClientAccountSubscriber` variant that, unlike `grpcVelocityClientAccountSubscriber`
|
|
12
|
+
* (one gRPC stream per account), multiplexes all perp markets onto one `grpcMultiAccountSubscriber`,
|
|
13
|
+
* all spot markets onto a second, and all oracles onto a third — three gRPC streams total instead
|
|
14
|
+
* of one per account. Lower connection/stream overhead at scale; `getOraclePriceDataAndSlot`
|
|
15
|
+
* relies on this class's own `oracleIdToOracleDataMap` rather than the multi-subscriber's account
|
|
16
|
+
* map, since a single oracle pubkey can back multiple `(pubkey, source)` oracle ids (e.g. a market
|
|
17
|
+
* pair sharing an underlying price feed).
|
|
18
|
+
*/
|
|
10
19
|
export declare class grpcVelocityClientAccountSubscriberV2 implements VelocityClientAccountSubscriber {
|
|
11
20
|
private grpcConfigs;
|
|
12
21
|
private perpMarketsSubscriber?;
|
|
@@ -36,31 +45,138 @@ export declare class grpcVelocityClientAccountSubscriberV2 implements VelocityCl
|
|
|
36
45
|
private resubOpts?;
|
|
37
46
|
private subscriptionPromiseResolver;
|
|
38
47
|
private subscriptionPromise;
|
|
48
|
+
/**
|
|
49
|
+
* @param grpcConfigs gRPC Geyser endpoint/token/commitment config (Yellowstone or LaserStream).
|
|
50
|
+
* @param program Anchor program used to derive PDAs, decode accounts, and resolve oracle clients.
|
|
51
|
+
* @param perpMarketIndexes Perp market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
52
|
+
* @param spotMarketIndexes Spot market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
53
|
+
* @param oracleInfos Oracles to track up front, if `shouldFindAllMarketsAndOracles` is false.
|
|
54
|
+
* @param shouldFindAllMarketsAndOracles If true, `subscribe()` first discovers every market/oracle from on-chain state.
|
|
55
|
+
* @param delistedMarketSetting Behavior applied to delisted perp markets/oracles after subscribing.
|
|
56
|
+
* @param resubOpts Resubscription watchdog options passed to the underlying multi-account subscribers.
|
|
57
|
+
*/
|
|
39
58
|
constructor(grpcConfigs: GrpcConfigs, program: VelocityProgram, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], shouldFindAllMarketsAndOracles: boolean, delistedMarketSetting: DelistedMarketSetting, resubOpts?: ResubOpts);
|
|
40
59
|
chunks: <T>(array: readonly T[], size: number) => T[][];
|
|
60
|
+
/**
|
|
61
|
+
* Batch-fetches every tracked perp market, spot market, and oracle account via chunked
|
|
62
|
+
* `getMultipleAccountsInfo` calls (75 pubkeys per chunk) and stashes the decoded results in
|
|
63
|
+
* `initialPerpMarketAccountData`/`initialSpotMarketAccountData`/`initialOraclePriceData`, which
|
|
64
|
+
* the multi-account subscribers seed from before their gRPC streams deliver live data. Skips
|
|
65
|
+
* data already populated (e.g. by `findAllMarketAndOracles` when `shouldFindAllMarketsAndOracles`
|
|
66
|
+
* is set).
|
|
67
|
+
*/
|
|
41
68
|
setInitialData(): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Records `_marketIndex` in `perpMarketIndexes` for bookkeeping. Note this does **not**
|
|
71
|
+
* actually add the account to the live `perpMarketsSubscriber` gRPC stream — unlike the
|
|
72
|
+
* WebSocket/per-account subscribers' `addPerpMarket`, no new subscription is created here.
|
|
73
|
+
* @param _marketIndex Perp market index to record.
|
|
74
|
+
*/
|
|
42
75
|
addPerpMarket(_marketIndex: number): Promise<boolean>;
|
|
76
|
+
/** No-op; unlike `addPerpMarket`, does not even record the index. Always resolves `true`. */
|
|
43
77
|
addSpotMarket(_marketIndex: number): Promise<boolean>;
|
|
78
|
+
/**
|
|
79
|
+
* Adds an oracle to `oracleInfos` and, if the oracle multi-subscriber's gRPC stream is already
|
|
80
|
+
* active, calls `oracleMultiSubscriber.addAccounts` to extend it. A no-op that resolves `true`
|
|
81
|
+
* immediately for the `PublicKey.default` sentinel (quote-asset "no oracle") or an oracle
|
|
82
|
+
* already tracked.
|
|
83
|
+
* @param oracleInfo Oracle pubkey and source to start tracking.
|
|
84
|
+
*/
|
|
44
85
|
addOracle(oracleInfo: OracleInfo): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Subscribes the `State` account (single-account gRPC subscriber), batch-seeds all market/
|
|
88
|
+
* oracle accounts via `setInitialData()`, then opens the three multiplexed
|
|
89
|
+
* `grpcMultiAccountSubscriber` streams (perp markets, spot markets, oracles). Applies
|
|
90
|
+
* `delistedMarketSetting` afterward. Idempotent: a no-op if already subscribed, and concurrent
|
|
91
|
+
* calls while a subscribe is in flight share the same result via `subscriptionPromise`.
|
|
92
|
+
*/
|
|
45
93
|
subscribe(): Promise<boolean>;
|
|
94
|
+
private subscribeInner;
|
|
95
|
+
/** Fetches the `State` account and all three multiplexed subscribers (perp markets, spot markets, oracles) in sequence. */
|
|
46
96
|
fetch(): Promise<void>;
|
|
97
|
+
/** Throws `NotSubscribedError` if `subscribe()` has not been called. */
|
|
47
98
|
private assertIsSubscribed;
|
|
99
|
+
/** Throws `NotSubscribedError` if not subscribed. */
|
|
48
100
|
getStateAccountAndSlot(): DataAndSlot<StateAccount>;
|
|
101
|
+
/** Returns every currently cached (loaded) perp market from the multiplexed subscriber. Does not throw `NotSubscribedError`. */
|
|
49
102
|
getMarketAccountsAndSlots(): DataAndSlot<PerpMarketAccount>[];
|
|
103
|
+
/** Returns every currently cached (loaded) spot market from the multiplexed subscriber. Does not throw `NotSubscribedError`. */
|
|
50
104
|
getSpotMarketAccountsAndSlots(): DataAndSlot<SpotMarketAccount>[];
|
|
105
|
+
/** Returns the cached perp market, or undefined if `marketIndex` isn't tracked (or hasn't loaded yet). Does not throw `NotSubscribedError`. */
|
|
51
106
|
getMarketAccountAndSlot(marketIndex: number): DataAndSlot<PerpMarketAccount> | undefined;
|
|
107
|
+
/** Returns the cached spot market, or undefined if `marketIndex` isn't tracked (or hasn't loaded yet). Does not throw `NotSubscribedError`. */
|
|
52
108
|
getSpotMarketAccountAndSlot(marketIndex: number): DataAndSlot<SpotMarketAccount> | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Looks up cached oracle price data by oracle id (see `getOracleId`), from this class's own
|
|
111
|
+
* `oracleIdToOracleDataMap` rather than `oracleMultiSubscriber.getAccountData` — a single
|
|
112
|
+
* oracle pubkey backing multiple oracle ids (e.g. shared price feeds) means the multi-subscriber's
|
|
113
|
+
* own account map cannot be trusted to disambiguate them correctly.
|
|
114
|
+
* @param oracleId Oracle id string from `getOracleId(publicKey, source)`.
|
|
115
|
+
* @returns Cached price data/slot, or undefined if not tracked. Throws `NotSubscribedError` if not subscribed.
|
|
116
|
+
*/
|
|
53
117
|
getOraclePriceDataAndSlot(oracleId: string): DataAndSlot<OraclePriceData> | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Convenience lookup: resolves the oracle price data currently mapped to a perp market's
|
|
120
|
+
* oracle. If the cached market's oracle pubkey has drifted from (or isn't yet in)
|
|
121
|
+
* `perpOracleMap`, triggers a background `setPerpOracleMap()` refresh and still returns the
|
|
122
|
+
* (possibly stale) mapping for this call.
|
|
123
|
+
* @param marketIndex Perp market index whose oracle price to look up.
|
|
124
|
+
*/
|
|
54
125
|
getOraclePriceDataAndSlotForPerpMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Convenience lookup: resolves the oracle price data currently mapped to a spot market's
|
|
128
|
+
* oracle. If the cached market's oracle pubkey has drifted from (or isn't yet in)
|
|
129
|
+
* `spotOracleMap`, triggers a background `setSpotOracleMap()` refresh and still returns the
|
|
130
|
+
* (possibly stale) mapping for this call.
|
|
131
|
+
* @param marketIndex Spot market index whose oracle price to look up.
|
|
132
|
+
*/
|
|
55
133
|
getOraclePriceDataAndSlotForSpotMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
|
|
134
|
+
/** Rebuilds `perpOracleMap`/`perpOracleStringMap` from currently cached perp markets, calling `addOracle` for any oracle not yet tracked by `oracleMultiSubscriber`. */
|
|
56
135
|
setPerpOracleMap(): Promise<void>;
|
|
136
|
+
/** Rebuilds `spotOracleMap`/`spotOracleStringMap` from currently cached spot markets, calling `addOracle` for any oracle not yet tracked by `oracleMultiSubscriber`. */
|
|
57
137
|
setSpotOracleMap(): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Creates `perpMarketsSubscriber` (a `grpcMultiAccountSubscriber<PerpMarketAccount>`), seeds
|
|
140
|
+
* it with `initialPerpMarketAccountData`, and subscribes it to every tracked perp market
|
|
141
|
+
* pubkey in one gRPC stream. Registers an `onUnsubscribe` handler that automatically
|
|
142
|
+
* re-invokes this method to resubscribe if the underlying stream drops.
|
|
143
|
+
*/
|
|
58
144
|
subscribeToPerpMarketAccounts(): Promise<boolean>;
|
|
145
|
+
/**
|
|
146
|
+
* Creates `spotMarketsSubscriber` (a `grpcMultiAccountSubscriber<SpotMarketAccount>`), seeds
|
|
147
|
+
* it with `initialSpotMarketAccountData`, and subscribes it to every tracked spot market
|
|
148
|
+
* pubkey in one gRPC stream. Registers an `onUnsubscribe` handler that automatically
|
|
149
|
+
* re-invokes this method to resubscribe if the underlying stream drops.
|
|
150
|
+
*/
|
|
59
151
|
subscribeToSpotMarketAccounts(): Promise<boolean>;
|
|
152
|
+
/**
|
|
153
|
+
* Creates `oracleMultiSubscriber` (a `grpcMultiAccountSubscriber<OraclePriceData, OracleInfo>`)
|
|
154
|
+
* and subscribes it to every distinct oracle pubkey in one gRPC stream, decoding buffers with
|
|
155
|
+
* the source-appropriate `OracleClient`. Because multiple `(pubkey, source)` oracle ids can
|
|
156
|
+
* share one pubkey, `oraclePubkeyToInfosMap` fans a single decode out to every matching
|
|
157
|
+
* `OracleInfo`, and results are additionally indexed into `oracleIdToOracleDataMap` (by oracle
|
|
158
|
+
* id, not pubkey) for `getOraclePriceDataAndSlot` to read. Registers an `onUnsubscribe` handler
|
|
159
|
+
* that automatically re-invokes this method to resubscribe if the underlying stream drops.
|
|
160
|
+
*/
|
|
60
161
|
subscribeToOracles(): Promise<boolean>;
|
|
162
|
+
/**
|
|
163
|
+
* Applies `delistedMarketSetting` to any perp market currently `status: delisted` (and its
|
|
164
|
+
* oracle, if not shared with a live spot market) by removing its pubkey from the relevant
|
|
165
|
+
* `grpcMultiAccountSubscriber` via `removeAccounts`. A no-op if the setting is `Subscribe`.
|
|
166
|
+
* Unlike the WebSocket/polling variants, this does not distinguish `Unsubscribe` from
|
|
167
|
+
* `Discard` — both remove the account from the multiplexed stream (there is no per-account
|
|
168
|
+
* "keep last known data, stop streaming" state to preserve at this granularity).
|
|
169
|
+
*/
|
|
61
170
|
handleDelistedMarkets(): Promise<void>;
|
|
171
|
+
/** Clears the seed data stashed by `setInitialData()` once the multi-account subscribers have consumed it, freeing the memory. */
|
|
62
172
|
removeInitialData(): void;
|
|
173
|
+
/** Tears down `oracleMultiSubscriber`'s gRPC stream, if active, and clears the reference. */
|
|
63
174
|
unsubscribeFromOracles(): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Tears down the `State` subscriber and all three multiplexed subscribers (perp markets, spot
|
|
177
|
+
* markets, oracles), then clears every internal map to avoid holding stale references. A no-op
|
|
178
|
+
* if not subscribed.
|
|
179
|
+
*/
|
|
64
180
|
unsubscribe(): Promise<void>;
|
|
65
181
|
}
|
|
66
182
|
//# sourceMappingURL=grpcVelocityClientAccountSubscriberV2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpcVelocityClientAccountSubscriberV2.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcVelocityClientAccountSubscriberV2.ts"],"names":[],"mappings":";AAAA,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAA2B,eAAe,EAAE,MAAM,WAAW,CAAC;AAQrE,OAAO,EACN,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,2BAA2B,EAC3B,+BAA+B,EAE/B,WAAW,EACX,SAAS,EACT,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,qBAAa,qCACZ,YAAW,+BAA+B;IAE1C,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,qBAAqB,CAAC,CAAgD;IAC9E,OAAO,CAAC,qBAAqB,CAAC,CAAgD;IAC9E,OAAO,CAAC,qBAAqB,CAAC,CAG5B;IACF,OAAO,CAAC,iCAAiC,CAA6B;IACtE,OAAO,CAAC,iCAAiC,CAA6B;IACtE,OAAO,CAAC,qBAAqB,CAAwB;IAE9C,YAAY,EAAE,kBAAkB,CACtC,YAAY,EACZ,2BAA2B,CAC3B,CAAC;IACK,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,eAAe,CAAC;IACzB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,8BAA8B,EAAE,OAAO,CAAC;IACxC,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7D,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7D,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACrD,aAAa,yBAAgC;IAC7C,mBAAmB,sBAA6B;IAChD,aAAa,yBAAgC;IAC7C,mBAAmB,sBAA6B;IACvD,OAAO,CAAC,uBAAuB,CAG3B;IACG,sBAAsB,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAChE,iBAAiB,oBAA2B;IAC5C,OAAO,CAAC,SAAS,CAAC,CAAY;IAE9B,OAAO,CAAC,2BAA2B,CAAoC;IACvE,OAAO,CAAC,mBAAmB,CAA4C;
|
|
1
|
+
{"version":3,"file":"grpcVelocityClientAccountSubscriberV2.d.ts","sourceRoot":"","sources":["../../../src/accounts/grpcVelocityClientAccountSubscriberV2.ts"],"names":[],"mappings":";AAAA,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAA2B,eAAe,EAAE,MAAM,WAAW,CAAC;AAQrE,OAAO,EACN,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,2BAA2B,EAC3B,+BAA+B,EAE/B,WAAW,EACX,SAAS,EACT,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE;;;;;;;;GAQG;AACH,qBAAa,qCACZ,YAAW,+BAA+B;IAE1C,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,qBAAqB,CAAC,CAAgD;IAC9E,OAAO,CAAC,qBAAqB,CAAC,CAAgD;IAC9E,OAAO,CAAC,qBAAqB,CAAC,CAG5B;IACF,OAAO,CAAC,iCAAiC,CAA6B;IACtE,OAAO,CAAC,iCAAiC,CAA6B;IACtE,OAAO,CAAC,qBAAqB,CAAwB;IAE9C,YAAY,EAAE,kBAAkB,CACtC,YAAY,EACZ,2BAA2B,CAC3B,CAAC;IACK,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,eAAe,CAAC;IACzB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,8BAA8B,EAAE,OAAO,CAAC;IACxC,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7D,4BAA4B,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC7D,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACrD,aAAa,yBAAgC;IAC7C,mBAAmB,sBAA6B;IAChD,aAAa,yBAAgC;IAC7C,mBAAmB,sBAA6B;IACvD,OAAO,CAAC,uBAAuB,CAG3B;IACG,sBAAsB,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAChE,iBAAiB,oBAA2B;IAC5C,OAAO,CAAC,SAAS,CAAC,CAAY;IAE9B,OAAO,CAAC,2BAA2B,CAAoC;IACvE,OAAO,CAAC,mBAAmB,CAA4C;IAEvE;;;;;;;;;OASG;gBAEF,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,eAAe,EACxB,iBAAiB,EAAE,MAAM,EAAE,EAC3B,iBAAiB,EAAE,MAAM,EAAE,EAC3B,WAAW,EAAE,UAAU,EAAE,EACzB,8BAA8B,EAAE,OAAO,EACvC,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,CAAC,EAAE,SAAS;IAsBtB,MAAM,aAAc,SAAS,CAAC,EAAE,QAAQ,MAAM,KAAG,CAAC,EAAE,EAAE,CAKpD;IAEF;;;;;;;OAOG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAuGrC;;;;;OAKG;IACG,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO3D,6FAA6F;IACvF,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D;;;;;;OAMG;IACG,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAqCzD;;;;;;OAMG;IACU,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;YA4C5B,cAAc;IAmE5B,2HAA2H;IAC9G,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOnC,wEAAwE;IACxE,OAAO,CAAC,kBAAkB;IAQ1B,qDAAqD;IAC9C,sBAAsB,IAAI,WAAW,CAAC,YAAY,CAAC;IAK1D,gIAAgI;IACzH,yBAAyB,IAAI,WAAW,CAAC,iBAAiB,CAAC,EAAE;IAKpE,gIAAgI;IACzH,6BAA6B,IAAI,WAAW,CAAC,iBAAiB,CAAC,EAAE;IAKxE,+IAA+I;IAC/I,uBAAuB,CACtB,WAAW,EAAE,MAAM,GACjB,WAAW,CAAC,iBAAiB,CAAC,GAAG,SAAS;IAS7C,+IAA+I;IAC/I,2BAA2B,CAC1B,WAAW,EAAE,MAAM,GACjB,WAAW,CAAC,iBAAiB,CAAC,GAAG,SAAS;IAS7C;;;;;;;OAOG;IACI,yBAAyB,CAC/B,QAAQ,EAAE,MAAM,GACd,WAAW,CAAC,eAAe,CAAC,GAAG,SAAS;IAO3C;;;;;;OAMG;IACI,sCAAsC,CAC5C,WAAW,EAAE,MAAM,GACjB,WAAW,CAAC,eAAe,CAAC,GAAG,SAAS;IAgB3C;;;;;;OAMG;IACI,sCAAsC,CAC5C,WAAW,EAAE,MAAM,GACjB,WAAW,CAAC,eAAe,CAAC,GAAG,SAAS;IAgB3C,wKAAwK;IAClK,gBAAgB;IA0BtB,wKAAwK;IAClK,gBAAgB;IA0BtB;;;;;OAKG;IACG,6BAA6B,IAAI,OAAO,CAAC,OAAO,CAAC;IAmEvD;;;;;OAKG;IACG,6BAA6B,IAAI,OAAO,CAAC,OAAO,CAAC;IAmEvD;;;;;;;;OAQG;IACG,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IA+F5C;;;;;;;OAOG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAqC5C,kIAAkI;IAClI,iBAAiB;IAMjB,6FAA6F;IACvF,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ7C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAsBlC"}
|
|
@@ -11,7 +11,26 @@ const grpcMultiAccountSubscriber_1 = require("./grpcMultiAccountSubscriber");
|
|
|
11
11
|
const oracleId_1 = require("../oracles/oracleId");
|
|
12
12
|
const oracleClientCache_1 = require("../oracles/oracleClientCache");
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
|
+
/**
|
|
15
|
+
* `VelocityClientAccountSubscriber` variant that, unlike `grpcVelocityClientAccountSubscriber`
|
|
16
|
+
* (one gRPC stream per account), multiplexes all perp markets onto one `grpcMultiAccountSubscriber`,
|
|
17
|
+
* all spot markets onto a second, and all oracles onto a third — three gRPC streams total instead
|
|
18
|
+
* of one per account. Lower connection/stream overhead at scale; `getOraclePriceDataAndSlot`
|
|
19
|
+
* relies on this class's own `oracleIdToOracleDataMap` rather than the multi-subscriber's account
|
|
20
|
+
* map, since a single oracle pubkey can back multiple `(pubkey, source)` oracle ids (e.g. a market
|
|
21
|
+
* pair sharing an underlying price feed).
|
|
22
|
+
*/
|
|
14
23
|
class grpcVelocityClientAccountSubscriberV2 {
|
|
24
|
+
/**
|
|
25
|
+
* @param grpcConfigs gRPC Geyser endpoint/token/commitment config (Yellowstone or LaserStream).
|
|
26
|
+
* @param program Anchor program used to derive PDAs, decode accounts, and resolve oracle clients.
|
|
27
|
+
* @param perpMarketIndexes Perp market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
28
|
+
* @param spotMarketIndexes Spot market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
29
|
+
* @param oracleInfos Oracles to track up front, if `shouldFindAllMarketsAndOracles` is false.
|
|
30
|
+
* @param shouldFindAllMarketsAndOracles If true, `subscribe()` first discovers every market/oracle from on-chain state.
|
|
31
|
+
* @param delistedMarketSetting Behavior applied to delisted perp markets/oracles after subscribing.
|
|
32
|
+
* @param resubOpts Resubscription watchdog options passed to the underlying multi-account subscribers.
|
|
33
|
+
*/
|
|
15
34
|
constructor(grpcConfigs, program, perpMarketIndexes, spotMarketIndexes, oracleInfos, shouldFindAllMarketsAndOracles, delistedMarketSetting, resubOpts) {
|
|
16
35
|
this.perpMarketIndexToAccountPubkeyMap = new Map();
|
|
17
36
|
this.spotMarketIndexToAccountPubkeyMap = new Map();
|
|
@@ -48,6 +67,14 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
48
67
|
this.resubOpts = resubOpts;
|
|
49
68
|
this.delistedMarketSetting = delistedMarketSetting;
|
|
50
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Batch-fetches every tracked perp market, spot market, and oracle account via chunked
|
|
72
|
+
* `getMultipleAccountsInfo` calls (75 pubkeys per chunk) and stashes the decoded results in
|
|
73
|
+
* `initialPerpMarketAccountData`/`initialSpotMarketAccountData`/`initialOraclePriceData`, which
|
|
74
|
+
* the multi-account subscribers seed from before their gRPC streams deliver live data. Skips
|
|
75
|
+
* data already populated (e.g. by `findAllMarketAndOracles` when `shouldFindAllMarketsAndOracles`
|
|
76
|
+
* is set).
|
|
77
|
+
*/
|
|
51
78
|
async setInitialData() {
|
|
52
79
|
const connection = this.program.provider.connection;
|
|
53
80
|
if (!this.initialPerpMarketAccountData ||
|
|
@@ -93,15 +120,29 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
93
120
|
return result;
|
|
94
121
|
}, []));
|
|
95
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Records `_marketIndex` in `perpMarketIndexes` for bookkeeping. Note this does **not**
|
|
125
|
+
* actually add the account to the live `perpMarketsSubscriber` gRPC stream — unlike the
|
|
126
|
+
* WebSocket/per-account subscribers' `addPerpMarket`, no new subscription is created here.
|
|
127
|
+
* @param _marketIndex Perp market index to record.
|
|
128
|
+
*/
|
|
96
129
|
async addPerpMarket(_marketIndex) {
|
|
97
130
|
if (!this.perpMarketIndexes.includes(_marketIndex)) {
|
|
98
131
|
this.perpMarketIndexes = this.perpMarketIndexes.concat(_marketIndex);
|
|
99
132
|
}
|
|
100
133
|
return true;
|
|
101
134
|
}
|
|
135
|
+
/** No-op; unlike `addPerpMarket`, does not even record the index. Always resolves `true`. */
|
|
102
136
|
async addSpotMarket(_marketIndex) {
|
|
103
137
|
return true;
|
|
104
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Adds an oracle to `oracleInfos` and, if the oracle multi-subscriber's gRPC stream is already
|
|
141
|
+
* active, calls `oracleMultiSubscriber.addAccounts` to extend it. A no-op that resolves `true`
|
|
142
|
+
* immediately for the `PublicKey.default` sentinel (quote-asset "no oracle") or an oracle
|
|
143
|
+
* already tracked.
|
|
144
|
+
* @param oracleInfo Oracle pubkey and source to start tracking.
|
|
145
|
+
*/
|
|
105
146
|
async addOracle(oracleInfo) {
|
|
106
147
|
var _a, _c;
|
|
107
148
|
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
|
|
@@ -116,10 +157,26 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
116
157
|
return true; // Already exists, don't add duplicate
|
|
117
158
|
}
|
|
118
159
|
this.oracleInfos = this.oracleInfos.concat(oracleInfo);
|
|
119
|
-
|
|
160
|
+
// extend the multi-subscriber's accountPropsMap alongside the pubkey filter, so the
|
|
161
|
+
// oracle decode path has the OracleInfo(s) it needs for the newly added feed (all infos
|
|
162
|
+
// sharing this pubkey, mirroring the fan-out map built in subscribeToOracles)
|
|
163
|
+
const pubkey = oracleInfo.publicKey.toBase58();
|
|
164
|
+
const infosForPubkey = this.oracleInfos.filter((o) => o.publicKey.toBase58() === pubkey);
|
|
165
|
+
const accountProps = new Map([
|
|
166
|
+
[pubkey, infosForPubkey],
|
|
167
|
+
]);
|
|
168
|
+
(_c = this.oracleMultiSubscriber) === null || _c === void 0 ? void 0 : _c.addAccounts([oracleInfo.publicKey], accountProps);
|
|
120
169
|
return true;
|
|
121
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Subscribes the `State` account (single-account gRPC subscriber), batch-seeds all market/
|
|
173
|
+
* oracle accounts via `setInitialData()`, then opens the three multiplexed
|
|
174
|
+
* `grpcMultiAccountSubscriber` streams (perp markets, spot markets, oracles). Applies
|
|
175
|
+
* `delistedMarketSetting` afterward. Idempotent: a no-op if already subscribed, and concurrent
|
|
176
|
+
* calls while a subscribe is in flight share the same result via `subscriptionPromise`.
|
|
177
|
+
*/
|
|
122
178
|
async subscribe() {
|
|
179
|
+
var _a, _c, _d, _e;
|
|
123
180
|
if (this.isSubscribed) {
|
|
124
181
|
return true;
|
|
125
182
|
}
|
|
@@ -130,6 +187,33 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
130
187
|
this.subscriptionPromise = new Promise((res) => {
|
|
131
188
|
this.subscriptionPromiseResolver = res;
|
|
132
189
|
});
|
|
190
|
+
try {
|
|
191
|
+
return await this.subscribeInner();
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
// tear down any partially-created subscribers so a retry starts clean and doesn't
|
|
195
|
+
// stack duplicate gRPC streams / leak callbacks — unsubscribe() bails while
|
|
196
|
+
// isSubscribed is still false, so it can't recover these on its own
|
|
197
|
+
try {
|
|
198
|
+
await ((_a = this.stateAccountSubscriber) === null || _a === void 0 ? void 0 : _a.unsubscribe());
|
|
199
|
+
await ((_c = this.oracleMultiSubscriber) === null || _c === void 0 ? void 0 : _c.unsubscribe());
|
|
200
|
+
await ((_d = this.perpMarketsSubscriber) === null || _d === void 0 ? void 0 : _d.unsubscribe());
|
|
201
|
+
await ((_e = this.spotMarketsSubscriber) === null || _e === void 0 ? void 0 : _e.unsubscribe());
|
|
202
|
+
}
|
|
203
|
+
catch (teardownErr) {
|
|
204
|
+
console.error('[grpcVelocityClientAccountSubscriberV2] cleanup after failed subscribe threw', teardownErr);
|
|
205
|
+
}
|
|
206
|
+
this.stateAccountSubscriber = undefined;
|
|
207
|
+
this.oracleMultiSubscriber = undefined;
|
|
208
|
+
this.perpMarketsSubscriber = undefined;
|
|
209
|
+
this.spotMarketsSubscriber = undefined;
|
|
210
|
+
// settle the shared promise so concurrent subscribe() callers don't hang forever
|
|
211
|
+
this.isSubscribing = false;
|
|
212
|
+
this.subscriptionPromiseResolver(false);
|
|
213
|
+
throw err;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async subscribeInner() {
|
|
133
217
|
if (this.shouldFindAllMarketsAndOracles) {
|
|
134
218
|
const { perpMarketIndexes, perpMarketAccounts, spotMarketIndexes, spotMarketAccounts, oracleInfos, } = await (0, config_1.findAllMarketAndOracles)(this.program);
|
|
135
219
|
this.perpMarketIndexes = perpMarketIndexes;
|
|
@@ -165,6 +249,7 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
165
249
|
this.removeInitialData();
|
|
166
250
|
return true;
|
|
167
251
|
}
|
|
252
|
+
/** Fetches the `State` account and all three multiplexed subscribers (perp markets, spot markets, oracles) in sequence. */
|
|
168
253
|
async fetch() {
|
|
169
254
|
var _a, _c, _d, _e;
|
|
170
255
|
await ((_a = this.stateAccountSubscriber) === null || _a === void 0 ? void 0 : _a.fetch());
|
|
@@ -172,25 +257,30 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
172
257
|
await ((_d = this.spotMarketsSubscriber) === null || _d === void 0 ? void 0 : _d.fetch());
|
|
173
258
|
await ((_e = this.oracleMultiSubscriber) === null || _e === void 0 ? void 0 : _e.fetch());
|
|
174
259
|
}
|
|
260
|
+
/** Throws `NotSubscribedError` if `subscribe()` has not been called. */
|
|
175
261
|
assertIsSubscribed() {
|
|
176
262
|
if (!this.isSubscribed) {
|
|
177
263
|
throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
|
|
178
264
|
}
|
|
179
265
|
}
|
|
266
|
+
/** Throws `NotSubscribedError` if not subscribed. */
|
|
180
267
|
getStateAccountAndSlot() {
|
|
181
268
|
this.assertIsSubscribed();
|
|
182
269
|
return this.stateAccountSubscriber.dataAndSlot;
|
|
183
270
|
}
|
|
271
|
+
/** Returns every currently cached (loaded) perp market from the multiplexed subscriber. Does not throw `NotSubscribedError`. */
|
|
184
272
|
getMarketAccountsAndSlots() {
|
|
185
273
|
var _a, _c;
|
|
186
274
|
const map = (_a = this.perpMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountDataMap();
|
|
187
275
|
return Array.from((_c = map === null || map === void 0 ? void 0 : map.values()) !== null && _c !== void 0 ? _c : []);
|
|
188
276
|
}
|
|
277
|
+
/** Returns every currently cached (loaded) spot market from the multiplexed subscriber. Does not throw `NotSubscribedError`. */
|
|
189
278
|
getSpotMarketAccountsAndSlots() {
|
|
190
279
|
var _a, _c;
|
|
191
280
|
const map = (_a = this.spotMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountDataMap();
|
|
192
281
|
return Array.from((_c = map === null || map === void 0 ? void 0 : map.values()) !== null && _c !== void 0 ? _c : []);
|
|
193
282
|
}
|
|
283
|
+
/** Returns the cached perp market, or undefined if `marketIndex` isn't tracked (or hasn't loaded yet). Does not throw `NotSubscribedError`. */
|
|
194
284
|
getMarketAccountAndSlot(marketIndex) {
|
|
195
285
|
var _a;
|
|
196
286
|
const accountPubkey = this.perpMarketIndexToAccountPubkeyMap.get(marketIndex);
|
|
@@ -199,6 +289,7 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
199
289
|
}
|
|
200
290
|
return (_a = this.perpMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountData(accountPubkey);
|
|
201
291
|
}
|
|
292
|
+
/** Returns the cached spot market, or undefined if `marketIndex` isn't tracked (or hasn't loaded yet). Does not throw `NotSubscribedError`. */
|
|
202
293
|
getSpotMarketAccountAndSlot(marketIndex) {
|
|
203
294
|
var _a;
|
|
204
295
|
const accountPubkey = this.spotMarketIndexToAccountPubkeyMap.get(marketIndex);
|
|
@@ -207,12 +298,27 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
207
298
|
}
|
|
208
299
|
return (_a = this.spotMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountData(accountPubkey);
|
|
209
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Looks up cached oracle price data by oracle id (see `getOracleId`), from this class's own
|
|
303
|
+
* `oracleIdToOracleDataMap` rather than `oracleMultiSubscriber.getAccountData` — a single
|
|
304
|
+
* oracle pubkey backing multiple oracle ids (e.g. shared price feeds) means the multi-subscriber's
|
|
305
|
+
* own account map cannot be trusted to disambiguate them correctly.
|
|
306
|
+
* @param oracleId Oracle id string from `getOracleId(publicKey, source)`.
|
|
307
|
+
* @returns Cached price data/slot, or undefined if not tracked. Throws `NotSubscribedError` if not subscribed.
|
|
308
|
+
*/
|
|
210
309
|
getOraclePriceDataAndSlot(oracleId) {
|
|
211
310
|
this.assertIsSubscribed();
|
|
212
311
|
// we need to rely on a map we store in this class because the grpcMultiAccountSubscriber does not track a mapping or oracle ID.
|
|
213
312
|
// DO NOT call getAccountData on the oracleMultiSubscriber, it will not return the correct data in certain cases(BONK spot and perp market subscribed too at once).
|
|
214
313
|
return this.oracleIdToOracleDataMap.get(oracleId);
|
|
215
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Convenience lookup: resolves the oracle price data currently mapped to a perp market's
|
|
317
|
+
* oracle. If the cached market's oracle pubkey has drifted from (or isn't yet in)
|
|
318
|
+
* `perpOracleMap`, triggers a background `setPerpOracleMap()` refresh and still returns the
|
|
319
|
+
* (possibly stale) mapping for this call.
|
|
320
|
+
* @param marketIndex Perp market index whose oracle price to look up.
|
|
321
|
+
*/
|
|
216
322
|
getOraclePriceDataAndSlotForPerpMarket(marketIndex) {
|
|
217
323
|
const perpMarketAccount = this.getMarketAccountAndSlot(marketIndex);
|
|
218
324
|
const oracle = this.perpOracleMap.get(marketIndex);
|
|
@@ -226,6 +332,13 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
226
332
|
}
|
|
227
333
|
return this.getOraclePriceDataAndSlot(oracleId);
|
|
228
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Convenience lookup: resolves the oracle price data currently mapped to a spot market's
|
|
337
|
+
* oracle. If the cached market's oracle pubkey has drifted from (or isn't yet in)
|
|
338
|
+
* `spotOracleMap`, triggers a background `setSpotOracleMap()` refresh and still returns the
|
|
339
|
+
* (possibly stale) mapping for this call.
|
|
340
|
+
* @param marketIndex Spot market index whose oracle price to look up.
|
|
341
|
+
*/
|
|
229
342
|
getOraclePriceDataAndSlotForSpotMarket(marketIndex) {
|
|
230
343
|
const spotMarketAccount = this.getSpotMarketAccountAndSlot(marketIndex);
|
|
231
344
|
const oracle = this.spotOracleMap.get(marketIndex);
|
|
@@ -239,6 +352,7 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
239
352
|
}
|
|
240
353
|
return this.getOraclePriceDataAndSlot(oracleId);
|
|
241
354
|
}
|
|
355
|
+
/** Rebuilds `perpOracleMap`/`perpOracleStringMap` from currently cached perp markets, calling `addOracle` for any oracle not yet tracked by `oracleMultiSubscriber`. */
|
|
242
356
|
async setPerpOracleMap() {
|
|
243
357
|
var _a, _c, _d;
|
|
244
358
|
const perpMarketsMap = (_a = this.perpMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountDataMap();
|
|
@@ -263,6 +377,7 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
263
377
|
}
|
|
264
378
|
await Promise.all(addOraclePromises);
|
|
265
379
|
}
|
|
380
|
+
/** Rebuilds `spotOracleMap`/`spotOracleStringMap` from currently cached spot markets, calling `addOracle` for any oracle not yet tracked by `oracleMultiSubscriber`. */
|
|
266
381
|
async setSpotOracleMap() {
|
|
267
382
|
var _a, _c, _d;
|
|
268
383
|
const spotMarketsMap = (_a = this.spotMarketsSubscriber) === null || _a === void 0 ? void 0 : _a.getAccountDataMap();
|
|
@@ -287,6 +402,12 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
287
402
|
}
|
|
288
403
|
await Promise.all(addOraclePromises);
|
|
289
404
|
}
|
|
405
|
+
/**
|
|
406
|
+
* Creates `perpMarketsSubscriber` (a `grpcMultiAccountSubscriber<PerpMarketAccount>`), seeds
|
|
407
|
+
* it with `initialPerpMarketAccountData`, and subscribes it to every tracked perp market
|
|
408
|
+
* pubkey in one gRPC stream. Registers an `onUnsubscribe` handler that automatically
|
|
409
|
+
* re-invokes this method to resubscribe if the underlying stream drops.
|
|
410
|
+
*/
|
|
290
411
|
async subscribeToPerpMarketAccounts() {
|
|
291
412
|
var _a;
|
|
292
413
|
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
|
|
@@ -322,6 +443,12 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
322
443
|
});
|
|
323
444
|
return true;
|
|
324
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* Creates `spotMarketsSubscriber` (a `grpcMultiAccountSubscriber<SpotMarketAccount>`), seeds
|
|
448
|
+
* it with `initialSpotMarketAccountData`, and subscribes it to every tracked spot market
|
|
449
|
+
* pubkey in one gRPC stream. Registers an `onUnsubscribe` handler that automatically
|
|
450
|
+
* re-invokes this method to resubscribe if the underlying stream drops.
|
|
451
|
+
*/
|
|
325
452
|
async subscribeToSpotMarketAccounts() {
|
|
326
453
|
var _a;
|
|
327
454
|
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
|
|
@@ -357,6 +484,15 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
357
484
|
});
|
|
358
485
|
return true;
|
|
359
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* Creates `oracleMultiSubscriber` (a `grpcMultiAccountSubscriber<OraclePriceData, OracleInfo>`)
|
|
489
|
+
* and subscribes it to every distinct oracle pubkey in one gRPC stream, decoding buffers with
|
|
490
|
+
* the source-appropriate `OracleClient`. Because multiple `(pubkey, source)` oracle ids can
|
|
491
|
+
* share one pubkey, `oraclePubkeyToInfosMap` fans a single decode out to every matching
|
|
492
|
+
* `OracleInfo`, and results are additionally indexed into `oracleIdToOracleDataMap` (by oracle
|
|
493
|
+
* id, not pubkey) for `getOraclePriceDataAndSlot` to read. Registers an `onUnsubscribe` handler
|
|
494
|
+
* that automatically re-invokes this method to resubscribe if the underlying stream drops.
|
|
495
|
+
*/
|
|
360
496
|
async subscribeToOracles() {
|
|
361
497
|
var _a;
|
|
362
498
|
if ((_a = this.resubOpts) === null || _a === void 0 ? void 0 : _a.logResubMessages) {
|
|
@@ -418,6 +554,14 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
418
554
|
});
|
|
419
555
|
return true;
|
|
420
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* Applies `delistedMarketSetting` to any perp market currently `status: delisted` (and its
|
|
559
|
+
* oracle, if not shared with a live spot market) by removing its pubkey from the relevant
|
|
560
|
+
* `grpcMultiAccountSubscriber` via `removeAccounts`. A no-op if the setting is `Subscribe`.
|
|
561
|
+
* Unlike the WebSocket/polling variants, this does not distinguish `Unsubscribe` from
|
|
562
|
+
* `Discard` — both remove the account from the multiplexed stream (there is no per-account
|
|
563
|
+
* "keep last known data, stop streaming" state to preserve at this granularity).
|
|
564
|
+
*/
|
|
421
565
|
async handleDelistedMarkets() {
|
|
422
566
|
var _a, _c, _d, _e;
|
|
423
567
|
if (this.delistedMarketSetting === types_1.DelistedMarketSetting.Subscribe) {
|
|
@@ -442,11 +586,13 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
442
586
|
await ((_e = this.oracleMultiSubscriber) === null || _e === void 0 ? void 0 : _e.removeAccounts(oraclePubkeysToRemove));
|
|
443
587
|
}
|
|
444
588
|
}
|
|
589
|
+
/** Clears the seed data stashed by `setInitialData()` once the multi-account subscribers have consumed it, freeing the memory. */
|
|
445
590
|
removeInitialData() {
|
|
446
591
|
this.initialPerpMarketAccountData = new Map();
|
|
447
592
|
this.initialSpotMarketAccountData = new Map();
|
|
448
593
|
this.initialOraclePriceData = new Map();
|
|
449
594
|
}
|
|
595
|
+
/** Tears down `oracleMultiSubscriber`'s gRPC stream, if active, and clears the reference. */
|
|
450
596
|
async unsubscribeFromOracles() {
|
|
451
597
|
if (this.oracleMultiSubscriber) {
|
|
452
598
|
await this.oracleMultiSubscriber.unsubscribe();
|
|
@@ -454,6 +600,11 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
454
600
|
return;
|
|
455
601
|
}
|
|
456
602
|
}
|
|
603
|
+
/**
|
|
604
|
+
* Tears down the `State` subscriber and all three multiplexed subscribers (perp markets, spot
|
|
605
|
+
* markets, oracles), then clears every internal map to avoid holding stale references. A no-op
|
|
606
|
+
* if not subscribed.
|
|
607
|
+
*/
|
|
457
608
|
async unsubscribe() {
|
|
458
609
|
var _a, _c, _d;
|
|
459
610
|
if (!this.isSubscribed) {
|