@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
|
@@ -30,6 +30,15 @@ import {
|
|
|
30
30
|
import { OracleClientCache } from '../oracles/oracleClientCache';
|
|
31
31
|
import { findDelistedPerpMarketsAndOracles } from './utils';
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* `VelocityClientAccountSubscriber` variant that, unlike `grpcVelocityClientAccountSubscriber`
|
|
35
|
+
* (one gRPC stream per account), multiplexes all perp markets onto one `grpcMultiAccountSubscriber`,
|
|
36
|
+
* all spot markets onto a second, and all oracles onto a third — three gRPC streams total instead
|
|
37
|
+
* of one per account. Lower connection/stream overhead at scale; `getOraclePriceDataAndSlot`
|
|
38
|
+
* relies on this class's own `oracleIdToOracleDataMap` rather than the multi-subscriber's account
|
|
39
|
+
* map, since a single oracle pubkey can back multiple `(pubkey, source)` oracle ids (e.g. a market
|
|
40
|
+
* pair sharing an underlying price feed).
|
|
41
|
+
*/
|
|
33
42
|
export class grpcVelocityClientAccountSubscriberV2
|
|
34
43
|
implements VelocityClientAccountSubscriber
|
|
35
44
|
{
|
|
@@ -73,6 +82,16 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
73
82
|
private subscriptionPromiseResolver: (val: boolean) => void = () => {};
|
|
74
83
|
private subscriptionPromise: Promise<boolean> = Promise.resolve(false);
|
|
75
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @param grpcConfigs gRPC Geyser endpoint/token/commitment config (Yellowstone or LaserStream).
|
|
87
|
+
* @param program Anchor program used to derive PDAs, decode accounts, and resolve oracle clients.
|
|
88
|
+
* @param perpMarketIndexes Perp market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
89
|
+
* @param spotMarketIndexes Spot market indexes to track, if `shouldFindAllMarketsAndOracles` is false.
|
|
90
|
+
* @param oracleInfos Oracles to track up front, if `shouldFindAllMarketsAndOracles` is false.
|
|
91
|
+
* @param shouldFindAllMarketsAndOracles If true, `subscribe()` first discovers every market/oracle from on-chain state.
|
|
92
|
+
* @param delistedMarketSetting Behavior applied to delisted perp markets/oracles after subscribing.
|
|
93
|
+
* @param resubOpts Resubscription watchdog options passed to the underlying multi-account subscribers.
|
|
94
|
+
*/
|
|
76
95
|
constructor(
|
|
77
96
|
grpcConfigs: GrpcConfigs,
|
|
78
97
|
program: VelocityProgram,
|
|
@@ -110,6 +129,14 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
110
129
|
.map((begin) => array.slice(begin, begin + size));
|
|
111
130
|
};
|
|
112
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Batch-fetches every tracked perp market, spot market, and oracle account via chunked
|
|
134
|
+
* `getMultipleAccountsInfo` calls (75 pubkeys per chunk) and stashes the decoded results in
|
|
135
|
+
* `initialPerpMarketAccountData`/`initialSpotMarketAccountData`/`initialOraclePriceData`, which
|
|
136
|
+
* the multi-account subscribers seed from before their gRPC streams deliver live data. Skips
|
|
137
|
+
* data already populated (e.g. by `findAllMarketAndOracles` when `shouldFindAllMarketsAndOracles`
|
|
138
|
+
* is set).
|
|
139
|
+
*/
|
|
113
140
|
async setInitialData(): Promise<void> {
|
|
114
141
|
const connection = this.program.provider.connection;
|
|
115
142
|
|
|
@@ -213,6 +240,12 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
213
240
|
);
|
|
214
241
|
}
|
|
215
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Records `_marketIndex` in `perpMarketIndexes` for bookkeeping. Note this does **not**
|
|
245
|
+
* actually add the account to the live `perpMarketsSubscriber` gRPC stream — unlike the
|
|
246
|
+
* WebSocket/per-account subscribers' `addPerpMarket`, no new subscription is created here.
|
|
247
|
+
* @param _marketIndex Perp market index to record.
|
|
248
|
+
*/
|
|
216
249
|
async addPerpMarket(_marketIndex: number): Promise<boolean> {
|
|
217
250
|
if (!this.perpMarketIndexes.includes(_marketIndex)) {
|
|
218
251
|
this.perpMarketIndexes = this.perpMarketIndexes.concat(_marketIndex);
|
|
@@ -220,10 +253,18 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
220
253
|
return true;
|
|
221
254
|
}
|
|
222
255
|
|
|
256
|
+
/** No-op; unlike `addPerpMarket`, does not even record the index. Always resolves `true`. */
|
|
223
257
|
async addSpotMarket(_marketIndex: number): Promise<boolean> {
|
|
224
258
|
return true;
|
|
225
259
|
}
|
|
226
260
|
|
|
261
|
+
/**
|
|
262
|
+
* Adds an oracle to `oracleInfos` and, if the oracle multi-subscriber's gRPC stream is already
|
|
263
|
+
* active, calls `oracleMultiSubscriber.addAccounts` to extend it. A no-op that resolves `true`
|
|
264
|
+
* immediately for the `PublicKey.default` sentinel (quote-asset "no oracle") or an oracle
|
|
265
|
+
* already tracked.
|
|
266
|
+
* @param oracleInfo Oracle pubkey and source to start tracking.
|
|
267
|
+
*/
|
|
227
268
|
async addOracle(oracleInfo: OracleInfo): Promise<boolean> {
|
|
228
269
|
if (this.resubOpts?.logResubMessages) {
|
|
229
270
|
console.log('[grpcVelocityClientAccountSubscriberV2] addOracle');
|
|
@@ -242,11 +283,32 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
242
283
|
}
|
|
243
284
|
|
|
244
285
|
this.oracleInfos = this.oracleInfos.concat(oracleInfo);
|
|
245
|
-
|
|
286
|
+
|
|
287
|
+
// extend the multi-subscriber's accountPropsMap alongside the pubkey filter, so the
|
|
288
|
+
// oracle decode path has the OracleInfo(s) it needs for the newly added feed (all infos
|
|
289
|
+
// sharing this pubkey, mirroring the fan-out map built in subscribeToOracles)
|
|
290
|
+
const pubkey = oracleInfo.publicKey.toBase58();
|
|
291
|
+
const infosForPubkey = this.oracleInfos.filter(
|
|
292
|
+
(o) => o.publicKey.toBase58() === pubkey
|
|
293
|
+
);
|
|
294
|
+
const accountProps = new Map<string, OracleInfo | OracleInfo[]>([
|
|
295
|
+
[pubkey, infosForPubkey],
|
|
296
|
+
]);
|
|
297
|
+
this.oracleMultiSubscriber?.addAccounts(
|
|
298
|
+
[oracleInfo.publicKey],
|
|
299
|
+
accountProps
|
|
300
|
+
);
|
|
246
301
|
|
|
247
302
|
return true;
|
|
248
303
|
}
|
|
249
304
|
|
|
305
|
+
/**
|
|
306
|
+
* Subscribes the `State` account (single-account gRPC subscriber), batch-seeds all market/
|
|
307
|
+
* oracle accounts via `setInitialData()`, then opens the three multiplexed
|
|
308
|
+
* `grpcMultiAccountSubscriber` streams (perp markets, spot markets, oracles). Applies
|
|
309
|
+
* `delistedMarketSetting` afterward. Idempotent: a no-op if already subscribed, and concurrent
|
|
310
|
+
* calls while a subscribe is in flight share the same result via `subscriptionPromise`.
|
|
311
|
+
*/
|
|
250
312
|
public async subscribe(): Promise<boolean> {
|
|
251
313
|
if (this.isSubscribed) {
|
|
252
314
|
return true;
|
|
@@ -262,6 +324,36 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
262
324
|
this.subscriptionPromiseResolver = res;
|
|
263
325
|
});
|
|
264
326
|
|
|
327
|
+
try {
|
|
328
|
+
return await this.subscribeInner();
|
|
329
|
+
} catch (err) {
|
|
330
|
+
// tear down any partially-created subscribers so a retry starts clean and doesn't
|
|
331
|
+
// stack duplicate gRPC streams / leak callbacks — unsubscribe() bails while
|
|
332
|
+
// isSubscribed is still false, so it can't recover these on its own
|
|
333
|
+
try {
|
|
334
|
+
await this.stateAccountSubscriber?.unsubscribe();
|
|
335
|
+
await this.oracleMultiSubscriber?.unsubscribe();
|
|
336
|
+
await this.perpMarketsSubscriber?.unsubscribe();
|
|
337
|
+
await this.spotMarketsSubscriber?.unsubscribe();
|
|
338
|
+
} catch (teardownErr) {
|
|
339
|
+
console.error(
|
|
340
|
+
'[grpcVelocityClientAccountSubscriberV2] cleanup after failed subscribe threw',
|
|
341
|
+
teardownErr
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
this.stateAccountSubscriber = undefined;
|
|
345
|
+
this.oracleMultiSubscriber = undefined;
|
|
346
|
+
this.perpMarketsSubscriber = undefined;
|
|
347
|
+
this.spotMarketsSubscriber = undefined;
|
|
348
|
+
|
|
349
|
+
// settle the shared promise so concurrent subscribe() callers don't hang forever
|
|
350
|
+
this.isSubscribing = false;
|
|
351
|
+
this.subscriptionPromiseResolver(false);
|
|
352
|
+
throw err;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
private async subscribeInner(): Promise<boolean> {
|
|
265
357
|
if (this.shouldFindAllMarketsAndOracles) {
|
|
266
358
|
const {
|
|
267
359
|
perpMarketIndexes,
|
|
@@ -328,6 +420,7 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
328
420
|
return true;
|
|
329
421
|
}
|
|
330
422
|
|
|
423
|
+
/** Fetches the `State` account and all three multiplexed subscribers (perp markets, spot markets, oracles) in sequence. */
|
|
331
424
|
public async fetch(): Promise<void> {
|
|
332
425
|
await this.stateAccountSubscriber?.fetch();
|
|
333
426
|
await this.perpMarketsSubscriber?.fetch();
|
|
@@ -335,6 +428,7 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
335
428
|
await this.oracleMultiSubscriber?.fetch();
|
|
336
429
|
}
|
|
337
430
|
|
|
431
|
+
/** Throws `NotSubscribedError` if `subscribe()` has not been called. */
|
|
338
432
|
private assertIsSubscribed(): void {
|
|
339
433
|
if (!this.isSubscribed) {
|
|
340
434
|
throw new NotSubscribedError(
|
|
@@ -343,21 +437,25 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
343
437
|
}
|
|
344
438
|
}
|
|
345
439
|
|
|
440
|
+
/** Throws `NotSubscribedError` if not subscribed. */
|
|
346
441
|
public getStateAccountAndSlot(): DataAndSlot<StateAccount> {
|
|
347
442
|
this.assertIsSubscribed();
|
|
348
443
|
return this.stateAccountSubscriber!.dataAndSlot!;
|
|
349
444
|
}
|
|
350
445
|
|
|
446
|
+
/** Returns every currently cached (loaded) perp market from the multiplexed subscriber. Does not throw `NotSubscribedError`. */
|
|
351
447
|
public getMarketAccountsAndSlots(): DataAndSlot<PerpMarketAccount>[] {
|
|
352
448
|
const map = this.perpMarketsSubscriber?.getAccountDataMap();
|
|
353
449
|
return Array.from(map?.values() ?? []);
|
|
354
450
|
}
|
|
355
451
|
|
|
452
|
+
/** Returns every currently cached (loaded) spot market from the multiplexed subscriber. Does not throw `NotSubscribedError`. */
|
|
356
453
|
public getSpotMarketAccountsAndSlots(): DataAndSlot<SpotMarketAccount>[] {
|
|
357
454
|
const map = this.spotMarketsSubscriber?.getAccountDataMap();
|
|
358
455
|
return Array.from(map?.values() ?? []);
|
|
359
456
|
}
|
|
360
457
|
|
|
458
|
+
/** Returns the cached perp market, or undefined if `marketIndex` isn't tracked (or hasn't loaded yet). Does not throw `NotSubscribedError`. */
|
|
361
459
|
getMarketAccountAndSlot(
|
|
362
460
|
marketIndex: number
|
|
363
461
|
): DataAndSlot<PerpMarketAccount> | undefined {
|
|
@@ -369,6 +467,7 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
369
467
|
return this.perpMarketsSubscriber?.getAccountData(accountPubkey);
|
|
370
468
|
}
|
|
371
469
|
|
|
470
|
+
/** Returns the cached spot market, or undefined if `marketIndex` isn't tracked (or hasn't loaded yet). Does not throw `NotSubscribedError`. */
|
|
372
471
|
getSpotMarketAccountAndSlot(
|
|
373
472
|
marketIndex: number
|
|
374
473
|
): DataAndSlot<SpotMarketAccount> | undefined {
|
|
@@ -380,6 +479,14 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
380
479
|
return this.spotMarketsSubscriber?.getAccountData(accountPubkey);
|
|
381
480
|
}
|
|
382
481
|
|
|
482
|
+
/**
|
|
483
|
+
* Looks up cached oracle price data by oracle id (see `getOracleId`), from this class's own
|
|
484
|
+
* `oracleIdToOracleDataMap` rather than `oracleMultiSubscriber.getAccountData` — a single
|
|
485
|
+
* oracle pubkey backing multiple oracle ids (e.g. shared price feeds) means the multi-subscriber's
|
|
486
|
+
* own account map cannot be trusted to disambiguate them correctly.
|
|
487
|
+
* @param oracleId Oracle id string from `getOracleId(publicKey, source)`.
|
|
488
|
+
* @returns Cached price data/slot, or undefined if not tracked. Throws `NotSubscribedError` if not subscribed.
|
|
489
|
+
*/
|
|
383
490
|
public getOraclePriceDataAndSlot(
|
|
384
491
|
oracleId: string
|
|
385
492
|
): DataAndSlot<OraclePriceData> | undefined {
|
|
@@ -389,6 +496,13 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
389
496
|
return this.oracleIdToOracleDataMap.get(oracleId);
|
|
390
497
|
}
|
|
391
498
|
|
|
499
|
+
/**
|
|
500
|
+
* Convenience lookup: resolves the oracle price data currently mapped to a perp market's
|
|
501
|
+
* oracle. If the cached market's oracle pubkey has drifted from (or isn't yet in)
|
|
502
|
+
* `perpOracleMap`, triggers a background `setPerpOracleMap()` refresh and still returns the
|
|
503
|
+
* (possibly stale) mapping for this call.
|
|
504
|
+
* @param marketIndex Perp market index whose oracle price to look up.
|
|
505
|
+
*/
|
|
392
506
|
public getOraclePriceDataAndSlotForPerpMarket(
|
|
393
507
|
marketIndex: number
|
|
394
508
|
): DataAndSlot<OraclePriceData> | undefined {
|
|
@@ -407,6 +521,13 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
407
521
|
return this.getOraclePriceDataAndSlot(oracleId);
|
|
408
522
|
}
|
|
409
523
|
|
|
524
|
+
/**
|
|
525
|
+
* Convenience lookup: resolves the oracle price data currently mapped to a spot market's
|
|
526
|
+
* oracle. If the cached market's oracle pubkey has drifted from (or isn't yet in)
|
|
527
|
+
* `spotOracleMap`, triggers a background `setSpotOracleMap()` refresh and still returns the
|
|
528
|
+
* (possibly stale) mapping for this call.
|
|
529
|
+
* @param marketIndex Spot market index whose oracle price to look up.
|
|
530
|
+
*/
|
|
410
531
|
public getOraclePriceDataAndSlotForSpotMarket(
|
|
411
532
|
marketIndex: number
|
|
412
533
|
): DataAndSlot<OraclePriceData> | undefined {
|
|
@@ -425,6 +546,7 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
425
546
|
return this.getOraclePriceDataAndSlot(oracleId);
|
|
426
547
|
}
|
|
427
548
|
|
|
549
|
+
/** Rebuilds `perpOracleMap`/`perpOracleStringMap` from currently cached perp markets, calling `addOracle` for any oracle not yet tracked by `oracleMultiSubscriber`. */
|
|
428
550
|
async setPerpOracleMap() {
|
|
429
551
|
const perpMarketsMap = this.perpMarketsSubscriber?.getAccountDataMap();
|
|
430
552
|
const perpMarkets = Array.from(perpMarketsMap?.values() ?? []);
|
|
@@ -451,6 +573,7 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
451
573
|
await Promise.all(addOraclePromises);
|
|
452
574
|
}
|
|
453
575
|
|
|
576
|
+
/** Rebuilds `spotOracleMap`/`spotOracleStringMap` from currently cached spot markets, calling `addOracle` for any oracle not yet tracked by `oracleMultiSubscriber`. */
|
|
454
577
|
async setSpotOracleMap() {
|
|
455
578
|
const spotMarketsMap = this.spotMarketsSubscriber?.getAccountDataMap();
|
|
456
579
|
const spotMarkets = Array.from(spotMarketsMap?.values() ?? []);
|
|
@@ -477,6 +600,12 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
477
600
|
await Promise.all(addOraclePromises);
|
|
478
601
|
}
|
|
479
602
|
|
|
603
|
+
/**
|
|
604
|
+
* Creates `perpMarketsSubscriber` (a `grpcMultiAccountSubscriber<PerpMarketAccount>`), seeds
|
|
605
|
+
* it with `initialPerpMarketAccountData`, and subscribes it to every tracked perp market
|
|
606
|
+
* pubkey in one gRPC stream. Registers an `onUnsubscribe` handler that automatically
|
|
607
|
+
* re-invokes this method to resubscribe if the underlying stream drops.
|
|
608
|
+
*/
|
|
480
609
|
async subscribeToPerpMarketAccounts(): Promise<boolean> {
|
|
481
610
|
if (this.resubOpts?.logResubMessages) {
|
|
482
611
|
console.log(
|
|
@@ -544,6 +673,12 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
544
673
|
return true;
|
|
545
674
|
}
|
|
546
675
|
|
|
676
|
+
/**
|
|
677
|
+
* Creates `spotMarketsSubscriber` (a `grpcMultiAccountSubscriber<SpotMarketAccount>`), seeds
|
|
678
|
+
* it with `initialSpotMarketAccountData`, and subscribes it to every tracked spot market
|
|
679
|
+
* pubkey in one gRPC stream. Registers an `onUnsubscribe` handler that automatically
|
|
680
|
+
* re-invokes this method to resubscribe if the underlying stream drops.
|
|
681
|
+
*/
|
|
547
682
|
async subscribeToSpotMarketAccounts(): Promise<boolean> {
|
|
548
683
|
if (this.resubOpts?.logResubMessages) {
|
|
549
684
|
console.log(
|
|
@@ -611,6 +746,15 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
611
746
|
return true;
|
|
612
747
|
}
|
|
613
748
|
|
|
749
|
+
/**
|
|
750
|
+
* Creates `oracleMultiSubscriber` (a `grpcMultiAccountSubscriber<OraclePriceData, OracleInfo>`)
|
|
751
|
+
* and subscribes it to every distinct oracle pubkey in one gRPC stream, decoding buffers with
|
|
752
|
+
* the source-appropriate `OracleClient`. Because multiple `(pubkey, source)` oracle ids can
|
|
753
|
+
* share one pubkey, `oraclePubkeyToInfosMap` fans a single decode out to every matching
|
|
754
|
+
* `OracleInfo`, and results are additionally indexed into `oracleIdToOracleDataMap` (by oracle
|
|
755
|
+
* id, not pubkey) for `getOraclePriceDataAndSlot` to read. Registers an `onUnsubscribe` handler
|
|
756
|
+
* that automatically re-invokes this method to resubscribe if the underlying stream drops.
|
|
757
|
+
*/
|
|
614
758
|
async subscribeToOracles(): Promise<boolean> {
|
|
615
759
|
if (this.resubOpts?.logResubMessages) {
|
|
616
760
|
console.log('grpcVelocityClientAccountSubscriberV2 subscribeToOracles');
|
|
@@ -706,6 +850,14 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
706
850
|
return true;
|
|
707
851
|
}
|
|
708
852
|
|
|
853
|
+
/**
|
|
854
|
+
* Applies `delistedMarketSetting` to any perp market currently `status: delisted` (and its
|
|
855
|
+
* oracle, if not shared with a live spot market) by removing its pubkey from the relevant
|
|
856
|
+
* `grpcMultiAccountSubscriber` via `removeAccounts`. A no-op if the setting is `Subscribe`.
|
|
857
|
+
* Unlike the WebSocket/polling variants, this does not distinguish `Unsubscribe` from
|
|
858
|
+
* `Discard` — both remove the account from the multiplexed stream (there is no per-account
|
|
859
|
+
* "keep last known data, stop streaming" state to preserve at this granularity).
|
|
860
|
+
*/
|
|
709
861
|
async handleDelistedMarkets(): Promise<void> {
|
|
710
862
|
if (this.delistedMarketSetting === DelistedMarketSetting.Subscribe) {
|
|
711
863
|
return;
|
|
@@ -743,12 +895,14 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
743
895
|
}
|
|
744
896
|
}
|
|
745
897
|
|
|
898
|
+
/** Clears the seed data stashed by `setInitialData()` once the multi-account subscribers have consumed it, freeing the memory. */
|
|
746
899
|
removeInitialData() {
|
|
747
900
|
this.initialPerpMarketAccountData = new Map();
|
|
748
901
|
this.initialSpotMarketAccountData = new Map();
|
|
749
902
|
this.initialOraclePriceData = new Map();
|
|
750
903
|
}
|
|
751
904
|
|
|
905
|
+
/** Tears down `oracleMultiSubscriber`'s gRPC stream, if active, and clears the reference. */
|
|
752
906
|
async unsubscribeFromOracles(): Promise<void> {
|
|
753
907
|
if (this.oracleMultiSubscriber) {
|
|
754
908
|
await this.oracleMultiSubscriber.unsubscribe();
|
|
@@ -757,6 +911,11 @@ export class grpcVelocityClientAccountSubscriberV2
|
|
|
757
911
|
}
|
|
758
912
|
}
|
|
759
913
|
|
|
914
|
+
/**
|
|
915
|
+
* Tears down the `State` subscriber and all three multiplexed subscribers (perp markets, spot
|
|
916
|
+
* markets, oracles), then clears every internal map to avoid holding stale references. A no-op
|
|
917
|
+
* if not subscribed.
|
|
918
|
+
*/
|
|
760
919
|
async unsubscribe(): Promise<void> {
|
|
761
920
|
if (!this.isSubscribed) {
|
|
762
921
|
return;
|
|
@@ -18,6 +18,14 @@ import {
|
|
|
18
18
|
type LaserCommitment =
|
|
19
19
|
(typeof LaserCommitmentLevel)[keyof typeof LaserCommitmentLevel];
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* `ProgramAccountSubscriber` that streams every account owned by the program (optionally filtered
|
|
23
|
+
* by `memcmp`) via Helius LaserStream instead of `connection.onProgramAccountChange`. Extends
|
|
24
|
+
* `WebSocketProgramAccountSubscriber` to reuse its per-account buffering/decode/resub-timer logic
|
|
25
|
+
* (`handleRpcResponse`, `bufferAndSlotMap`) — only the transport (`subscribe`/`unsubscribe`) is
|
|
26
|
+
* replaced. Construct via the static `create` factory, not the constructor directly, since it
|
|
27
|
+
* dynamically loads the optional `helius-laserstream` peer dependency and its enums.
|
|
28
|
+
*/
|
|
21
29
|
export class LaserstreamProgramAccountSubscriber<
|
|
22
30
|
T,
|
|
23
31
|
> extends WebSocketProgramAccountSubscriber<T> {
|
|
@@ -59,6 +67,19 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
59
67
|
this.commitmentLevel = this.toLaserCommitment(commitmentLevel);
|
|
60
68
|
}
|
|
61
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Loads the optional `helius-laserstream` module, builds its `LaserstreamConfig` (forcing zstd
|
|
72
|
+
* compression and a 1GB max receive message size), and constructs a
|
|
73
|
+
* `LaserstreamProgramAccountSubscriber`. Does not itself start streaming — call
|
|
74
|
+
* `subscribe(onChange)` on the result.
|
|
75
|
+
* @param grpcConfigs LaserStream endpoint/token/commitment config; `enableReconnect` maps to up to 10 reconnect attempts (0 if unset).
|
|
76
|
+
* @param subscriptionName Human-readable name for logging.
|
|
77
|
+
* @param accountDiscriminator Anchor account type name passed to `decodeBufferFn` for each update.
|
|
78
|
+
* @param program Anchor program whose accounts to stream (filtered to `program.programId` as owner).
|
|
79
|
+
* @param decodeBufferFn Decode function for each account's raw buffer.
|
|
80
|
+
* @param options `filters` (memcmp) narrowing which program accounts are streamed; empty streams every account owned by the program.
|
|
81
|
+
* @param resubOpts Resubscription watchdog options; omit to disable the inactivity timer.
|
|
82
|
+
*/
|
|
62
83
|
public static async create<U>(
|
|
63
84
|
grpcConfigs: LaserGrpcConfigs,
|
|
64
85
|
subscriptionName: string,
|
|
@@ -102,6 +123,14 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
102
123
|
);
|
|
103
124
|
}
|
|
104
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Opens a LaserStream `accounts` subscription filtered to `program.programId` as owner
|
|
128
|
+
* (further narrowed by the `filters` passed to `create`). Idempotent: a no-op if already
|
|
129
|
+
* subscribed or mid-unsubscribe. Does not perform an initial fetch — the caller must fetch any
|
|
130
|
+
* pre-existing matching accounts separately if needed. Throws if the LaserStream client fails
|
|
131
|
+
* to start.
|
|
132
|
+
* @param onChange Invoked once per changed account with its pubkey, decoded data, the notification's `Context` (slot only), and the raw buffer.
|
|
133
|
+
*/
|
|
105
134
|
async subscribe(
|
|
106
135
|
onChange: (
|
|
107
136
|
accountId: PublicKey,
|
|
@@ -198,6 +227,10 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
198
227
|
}
|
|
199
228
|
}
|
|
200
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Cancels the LaserStream and clears any pending resub timeout.
|
|
232
|
+
* @param onResub Internal flag set to `true` when called as part of an automatic resubscribe cycle, which preserves `resubOpts.resubTimeoutMs` instead of clearing it. Callers should omit this.
|
|
233
|
+
*/
|
|
201
234
|
public async unsubscribe(onResub = false): Promise<void> {
|
|
202
235
|
if (!onResub && this.resubOpts) {
|
|
203
236
|
this.resubOpts.resubTimeoutMs = undefined;
|
|
@@ -218,6 +251,7 @@ export class LaserstreamProgramAccountSubscriber<
|
|
|
218
251
|
}
|
|
219
252
|
}
|
|
220
253
|
|
|
254
|
+
/** Coerces a commitment level (string name, numeric enum value, or undefined) into a LaserStream `LaserCommitmentLevel`, defaulting to `CONFIRMED`. */
|
|
221
255
|
public toLaserCommitment(
|
|
222
256
|
level: string | number | undefined
|
|
223
257
|
): LaserCommitment {
|
|
@@ -16,6 +16,13 @@ export class OneShotUserAccountSubscriber
|
|
|
16
16
|
program: VelocityProgram;
|
|
17
17
|
commitment: Commitment;
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @param program Anchor program used for the one-off `fetchAndContext` call.
|
|
21
|
+
* @param userAccountPublicKey Address of the `UserAccount` to fetch.
|
|
22
|
+
* @param data Optional pre-fetched account data to seed with, skipping the RPC call entirely.
|
|
23
|
+
* @param slot Slot `data` was observed at, if provided.
|
|
24
|
+
* @param commitment Commitment for the fetch; defaults to `'confirmed'`.
|
|
25
|
+
*/
|
|
19
26
|
public constructor(
|
|
20
27
|
program: VelocityProgram,
|
|
21
28
|
userAccountPublicKey: PublicKey,
|
|
@@ -28,6 +35,12 @@ export class OneShotUserAccountSubscriber
|
|
|
28
35
|
this.commitment = commitment ?? 'confirmed';
|
|
29
36
|
}
|
|
30
37
|
|
|
38
|
+
/**
|
|
39
|
+
* If `userAccount` is supplied, seeds directly with no RPC call. Otherwise fetches once via
|
|
40
|
+
* `fetchIfUnloaded()` if no data is cached yet. Always resolves `true` — there is no
|
|
41
|
+
* persistent subscription to fail.
|
|
42
|
+
* @param userAccount Optional pre-fetched account data to seed with instead of fetching.
|
|
43
|
+
*/
|
|
31
44
|
async subscribe(userAccount?: UserAccount): Promise<boolean> {
|
|
32
45
|
if (userAccount) {
|
|
33
46
|
this.user = { data: userAccount, slot: this.user?.slot ?? 0 };
|
|
@@ -41,12 +54,18 @@ export class OneShotUserAccountSubscriber
|
|
|
41
54
|
return true;
|
|
42
55
|
}
|
|
43
56
|
|
|
57
|
+
/** Fetches via `fetch()` only if no data is cached yet; otherwise a no-op. */
|
|
44
58
|
async fetchIfUnloaded(): Promise<void> {
|
|
45
59
|
if (!this.user) {
|
|
46
60
|
await this.fetch();
|
|
47
61
|
}
|
|
48
62
|
}
|
|
49
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Fetches the account once via `program.account.user.fetchAndContext`, applying it only if
|
|
66
|
+
* the response's slot is newer than what's cached. Logs and swallows errors (e.g. account not
|
|
67
|
+
* yet initialized) rather than throwing.
|
|
68
|
+
*/
|
|
50
69
|
async fetch(): Promise<void> {
|
|
51
70
|
try {
|
|
52
71
|
const dataAndContext = await (
|
|
@@ -16,6 +16,13 @@ export class OneShotUserStatsAccountSubscriber
|
|
|
16
16
|
program: VelocityProgram;
|
|
17
17
|
commitment: Commitment;
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @param program Anchor program used for the one-off `fetchAndContext` call.
|
|
21
|
+
* @param userStatsAccountPublicKey Address of the `UserStatsAccount` to fetch.
|
|
22
|
+
* @param data Optional pre-fetched account data to seed with, skipping the RPC call entirely.
|
|
23
|
+
* @param slot Slot `data` was observed at, if provided.
|
|
24
|
+
* @param commitment Commitment for the fetch; defaults to `'confirmed'`.
|
|
25
|
+
*/
|
|
19
26
|
public constructor(
|
|
20
27
|
program: VelocityProgram,
|
|
21
28
|
userStatsAccountPublicKey: PublicKey,
|
|
@@ -28,6 +35,12 @@ export class OneShotUserStatsAccountSubscriber
|
|
|
28
35
|
this.commitment = commitment ?? 'confirmed';
|
|
29
36
|
}
|
|
30
37
|
|
|
38
|
+
/**
|
|
39
|
+
* If `userStatsAccount` is supplied, seeds directly with no RPC call. Otherwise fetches once
|
|
40
|
+
* via `fetchIfUnloaded()` if no data is cached yet. Always resolves `true` — there is no
|
|
41
|
+
* persistent subscription to fail.
|
|
42
|
+
* @param userStatsAccount Optional pre-fetched account data to seed with instead of fetching.
|
|
43
|
+
*/
|
|
31
44
|
async subscribe(userStatsAccount?: UserStatsAccount): Promise<boolean> {
|
|
32
45
|
if (userStatsAccount) {
|
|
33
46
|
this.userStats = {
|
|
@@ -44,12 +57,18 @@ export class OneShotUserStatsAccountSubscriber
|
|
|
44
57
|
return true;
|
|
45
58
|
}
|
|
46
59
|
|
|
60
|
+
/** Fetches via `fetch()` only if no data is cached yet; otherwise a no-op. */
|
|
47
61
|
async fetchIfUnloaded(): Promise<void> {
|
|
48
62
|
if (!this.userStats) {
|
|
49
63
|
await this.fetch();
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Fetches the account once via `program.account.userStats.fetchAndContext`, applying it only
|
|
69
|
+
* if the response's slot is newer than what's cached. Logs and swallows errors (e.g. account
|
|
70
|
+
* not yet initialized) rather than throwing.
|
|
71
|
+
*/
|
|
53
72
|
async fetch(): Promise<void> {
|
|
54
73
|
try {
|
|
55
74
|
const dataAndContext = await (
|
|
@@ -11,6 +11,11 @@ import { PublicKey } from '@solana/web3.js';
|
|
|
11
11
|
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
12
12
|
import { InsuranceFundStake } from '../types';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* `InsuranceFundStakeAccountSubscriber` backed by a shared `BulkAccountLoader` instead of a
|
|
16
|
+
* dedicated WebSocket subscription, mirroring `PollingUserAccountSubscriber` for
|
|
17
|
+
* `InsuranceFundStake` accounts.
|
|
18
|
+
*/
|
|
14
19
|
export class PollingInsuranceFundStakeAccountSubscriber
|
|
15
20
|
implements InsuranceFundStakeAccountSubscriber
|
|
16
21
|
{
|
|
@@ -28,6 +33,11 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
28
33
|
|
|
29
34
|
insuranceFundStakeAccountAndSlot?: DataAndSlot<InsuranceFundStake>;
|
|
30
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @param program Anchor program used for the one-off `fetch()` fallback and account decoding.
|
|
38
|
+
* @param publicKey Address of the `InsuranceFundStake` account to track.
|
|
39
|
+
* @param accountLoader Shared `BulkAccountLoader` this subscriber registers its callback with.
|
|
40
|
+
*/
|
|
31
41
|
public constructor(
|
|
32
42
|
program: VelocityProgram,
|
|
33
43
|
publicKey: PublicKey,
|
|
@@ -40,6 +50,13 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
40
50
|
this.eventEmitter = new EventEmitter();
|
|
41
51
|
}
|
|
42
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Registers this account with the shared `BulkAccountLoader`. Note this does not wait for an
|
|
55
|
+
* initial fetch to land before returning `isSubscribed = true`, unlike the analogous
|
|
56
|
+
* `PollingUserAccountSubscriber.subscribe`; call `fetchIfUnloaded()` explicitly if data is
|
|
57
|
+
* needed immediately. Idempotent: a no-op if already subscribed.
|
|
58
|
+
* @param insuranceFundStake Optional pre-fetched account data to seed with (at slot 0) instead of an immediate fetch.
|
|
59
|
+
*/
|
|
43
60
|
async subscribe(insuranceFundStake?: InsuranceFundStake): Promise<boolean> {
|
|
44
61
|
if (this.isSubscribed) {
|
|
45
62
|
return true;
|
|
@@ -62,6 +79,7 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
62
79
|
return true;
|
|
63
80
|
}
|
|
64
81
|
|
|
82
|
+
/** Registers this account and an error callback with the `BulkAccountLoader`. A no-op if already registered. */
|
|
65
83
|
async addToAccountLoader(): Promise<void> {
|
|
66
84
|
if (this.callbackId) {
|
|
67
85
|
return;
|
|
@@ -96,12 +114,14 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
96
114
|
});
|
|
97
115
|
}
|
|
98
116
|
|
|
117
|
+
/** Fetches via `fetch()` only if no data is cached yet; otherwise a no-op. */
|
|
99
118
|
async fetchIfUnloaded(): Promise<void> {
|
|
100
119
|
if (!this.doesAccountExist()) {
|
|
101
120
|
await this.fetch();
|
|
102
121
|
}
|
|
103
122
|
}
|
|
104
123
|
|
|
124
|
+
/** Fetches the account once directly via `program.account.insuranceFundStake.fetchAndContext` (independent of the account loader's poll cycle), applying it only if the response's slot is newer than what's cached. Logs and swallows errors rather than throwing. */
|
|
105
125
|
async fetch(): Promise<void> {
|
|
106
126
|
try {
|
|
107
127
|
const dataAndContext = await (
|
|
@@ -128,12 +148,14 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
128
148
|
}
|
|
129
149
|
}
|
|
130
150
|
|
|
151
|
+
/** Type predicate: true once `insuranceFundStakeAccountAndSlot` has loaded, narrowing it to non-undefined. */
|
|
131
152
|
doesAccountExist(): this is {
|
|
132
153
|
insuranceFundStakeAccountAndSlot: DataAndSlot<InsuranceFundStake>;
|
|
133
154
|
} {
|
|
134
155
|
return this.insuranceFundStakeAccountAndSlot !== undefined;
|
|
135
156
|
}
|
|
136
157
|
|
|
158
|
+
/** Unregisters this account (and its error callback) from the `BulkAccountLoader`. A no-op if not subscribed. */
|
|
137
159
|
async unsubscribe(): Promise<void> {
|
|
138
160
|
if (!this.isSubscribed) {
|
|
139
161
|
return;
|
|
@@ -151,6 +173,7 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
151
173
|
this.isSubscribed = false;
|
|
152
174
|
}
|
|
153
175
|
|
|
176
|
+
/** Throws `NotSubscribedError` if `subscribe()` has not been called. */
|
|
154
177
|
assertIsSubscribed(): void {
|
|
155
178
|
if (!this.isSubscribed) {
|
|
156
179
|
throw new NotSubscribedError(
|
|
@@ -159,6 +182,7 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
159
182
|
}
|
|
160
183
|
}
|
|
161
184
|
|
|
185
|
+
/** Throws `NotSubscribedError` if not subscribed. Returns undefined only if subscribed but no data has loaded yet. */
|
|
162
186
|
public getInsuranceFundStakeAccountAndSlot():
|
|
163
187
|
| DataAndSlot<InsuranceFundStake>
|
|
164
188
|
| undefined {
|
|
@@ -166,10 +190,17 @@ export class PollingInsuranceFundStakeAccountSubscriber
|
|
|
166
190
|
return this.insuranceFundStakeAccountAndSlot;
|
|
167
191
|
}
|
|
168
192
|
|
|
193
|
+
/** True once account data has been loaded, independent of `isSubscribed`. */
|
|
169
194
|
didSubscriptionSucceed(): boolean {
|
|
170
195
|
return !!this.insuranceFundStakeAccountAndSlot;
|
|
171
196
|
}
|
|
172
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Applies an externally-obtained account update if `slot` is newer than the currently cached
|
|
200
|
+
* slot (strictly newer — unlike most other subscribers here, an equal slot is not accepted).
|
|
201
|
+
* @param insuranceFundStake Decoded account data to apply.
|
|
202
|
+
* @param slot Slot the data was observed at.
|
|
203
|
+
*/
|
|
173
204
|
public updateData(
|
|
174
205
|
insuranceFundStake: InsuranceFundStake,
|
|
175
206
|
slot: number
|