@velocity-exchange/sdk 0.2.5 → 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 +93 -0
- package/README.md +3 -3
- 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 +2139 -5
- package/lib/browser/adminClient.js +2173 -11
- 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 +50 -1
- package/lib/browser/idl/velocity.json +50 -1
- 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 +92 -0
- package/lib/browser/math/exchangeStatus.js +111 -1
- 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 -7
- package/lib/browser/math/orders.js +133 -18
- 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 +32 -1
- 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 +129 -7
- 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 +67 -2
- 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/swift/swiftOrderSubscriber.js +2 -2
- package/lib/browser/tokenFaucet.d.ts +2 -2
- package/lib/browser/tokenFaucet.js +11 -4
- 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 +786 -13
- package/lib/browser/types.js +133 -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 +3323 -216
- package/lib/browser/velocityClient.js +3428 -249
- 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 +2139 -5
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +2173 -11
- 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 +50 -1
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +50 -1
- 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 +92 -0
- package/lib/node/math/exchangeStatus.d.ts.map +1 -1
- package/lib/node/math/exchangeStatus.js +111 -1
- 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 -7
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +133 -18
- 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 +32 -1
- 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 +129 -7
- 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 +67 -2
- 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/swift/swiftOrderSubscriber.js +2 -2
- package/lib/node/tokenFaucet.d.ts +2 -2
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +11 -4
- 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 +786 -13
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +133 -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 +3323 -216
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +3428 -249
- 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 +2184 -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 +50 -1
- package/src/idl/velocity.ts +50 -1
- 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 +125 -0
- 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 +144 -18
- 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 +32 -1
- 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 +131 -7
- 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 +74 -2
- 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/swift/swiftOrderSubscriber.ts +2 -2
- package/src/tokenFaucet.ts +10 -7
- 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 +783 -22
- 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 +3456 -254
- 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/helpers.ts +1 -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
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* EventSubscriber — streams and parses Velocity program events from transaction logs.
|
|
4
|
-
*
|
|
5
|
-
* Decodes all program events (OrderActionRecord, DepositRecord, LiquidationRecord,
|
|
6
|
-
* FundingPaymentRecord, etc.) from `state/events.rs` into typed TypeScript objects.
|
|
7
|
-
* Supports WebSocket and polling log providers; events are surfaced via an EventEmitter.
|
|
8
|
-
* See `events/types.ts` for the full event type union and `events/parse.ts` for log parsing.
|
|
9
|
-
*/
|
|
10
2
|
import { Connection, TransactionSignature } from '@solana/web3.js';
|
|
11
3
|
import { Program } from '../isomorphic/anchor';
|
|
12
4
|
import { EventSubscriptionOptions, EventType, WrappedEvents, EventMap, EventSubscriberEvents, LogProviderType } from './types';
|
|
13
5
|
import { EventList } from './eventList';
|
|
14
6
|
import { EventEmitter } from 'events';
|
|
15
7
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
8
|
+
/**
|
|
9
|
+
* EventSubscriber — streams and decodes Velocity program events from
|
|
10
|
+
* transaction logs (all records emitted via `emit!` from `state/events.rs`:
|
|
11
|
+
* `DepositRecord`, `OrderActionRecord`, `LiquidationRecord`,
|
|
12
|
+
* `FundingPaymentRecord`, etc. — see `EventMap` for the full set), via a
|
|
13
|
+
* pluggable `LogProvider` (websocket, polling, or the Velocity events server),
|
|
14
|
+
* and surfaces them both through per-type `EventList`s and a `'newEvent'`
|
|
15
|
+
* `eventEmitter`.
|
|
16
|
+
*
|
|
17
|
+
* Ordering and dedup: each decoded event is tagged with `slot` and a
|
|
18
|
+
* `txSigIndex` (its position among decoded events within the same
|
|
19
|
+
* transaction); the per-event-type `EventList`s use these to sort either by
|
|
20
|
+
* blockchain order (slot, then `txSigIndex`) or by client arrival order, per
|
|
21
|
+
* `EventSubscriptionOptions.orderBy`. Whole transactions are deduped by
|
|
22
|
+
* signature via an internal LRU (`TxEventCache`, sized by `options.maxTx`):
|
|
23
|
+
* a transaction already in the cache is skipped entirely on a subsequent
|
|
24
|
+
* delivery from the *same* log provider, which protects against a
|
|
25
|
+
* websocket/polling provider redelivering the same tx. Events pushed by the
|
|
26
|
+
* events-server provider bypass this cache (it dedups upstream and supplies
|
|
27
|
+
* an authoritative `txSigIndex`). Event names are also normalized from the
|
|
28
|
+
* `@coral-xyz/anchor` 0.32+ camelCase IDL form back to the PascalCase used by
|
|
29
|
+
* `EventType`/`EventMap` before being matched against the subscribed types.
|
|
30
|
+
*/
|
|
16
31
|
export declare class EventSubscriber {
|
|
17
32
|
private connection;
|
|
18
33
|
private program;
|
|
19
34
|
private options;
|
|
20
35
|
private address;
|
|
21
36
|
private eventListMap;
|
|
37
|
+
/** Case-insensitive lookup from decoded (camelCase) IDL event names to subscribed `EventType` keys. */
|
|
38
|
+
private eventTypeByLowercaseName;
|
|
22
39
|
private txEventCache;
|
|
23
40
|
private awaitTxPromises;
|
|
24
41
|
private awaitTxResolver;
|
|
@@ -29,9 +46,15 @@ export declare class EventSubscriber {
|
|
|
29
46
|
private lastSeenBlockTime;
|
|
30
47
|
lastSeenTxSig: string | undefined;
|
|
31
48
|
private get logProvider();
|
|
49
|
+
/**
|
|
50
|
+
* @param connection RPC connection used by the polling/websocket log providers and by `fetchPreviousTx`.
|
|
51
|
+
* @param program Anchor `Program` whose IDL coder decodes event logs (see `parse.ts`).
|
|
52
|
+
* @param options Subscription options; merged over `DefaultEventSubscriptionOptions` so any field left unset uses the default.
|
|
53
|
+
*/
|
|
32
54
|
constructor(connection: Connection, program: Program, options?: EventSubscriptionOptions);
|
|
33
55
|
private getLogProviderConfig;
|
|
34
56
|
private getEventTypes;
|
|
57
|
+
/** The `LogProviderType` currently in use. May differ from the configured type after a fallback failover (see `updateFallbackProviderType`). */
|
|
35
58
|
get currentProviderType(): LogProviderType;
|
|
36
59
|
private initializeLogProvider;
|
|
37
60
|
private populateInitialEventListMap;
|
|
@@ -40,19 +63,73 @@ export declare class EventSubscriber {
|
|
|
40
63
|
* could be improved to try the original type again after some cooldown.
|
|
41
64
|
*/
|
|
42
65
|
private updateFallbackProviderType;
|
|
66
|
+
/**
|
|
67
|
+
* Starts streaming events via the configured `LogProvider`. Idempotent —
|
|
68
|
+
* returns `true` immediately if already subscribed. (Re)initializes the
|
|
69
|
+
* per-event-type `EventList`s, so any events retained from a prior
|
|
70
|
+
* subscribe/unsubscribe cycle are discarded. For streaming providers
|
|
71
|
+
* (websocket, events-server), also wires up automatic failover: if the
|
|
72
|
+
* provider emits more than `maxReconnectAttempts` (default `Infinity`,
|
|
73
|
+
* i.e. never) reconnect attempts, the subscriber tears down and
|
|
74
|
+
* reinitializes with the next provider in the fallback chain
|
|
75
|
+
* (events-server → websocket → polling; polling has no further fallback).
|
|
76
|
+
* Does not itself backfill history — call `fetchPreviousTx` for that.
|
|
77
|
+
* @returns `true` once subscribed, or `false` if an error occurred while starting the subscription (logged to console, not thrown).
|
|
78
|
+
*/
|
|
43
79
|
subscribe(): Promise<boolean>;
|
|
44
80
|
private handleTxLogs;
|
|
81
|
+
/**
|
|
82
|
+
* Backfills historical events by walking transactions for `address` via
|
|
83
|
+
* `getSignaturesForAddress`/`getTransaction`, newest-first, until either
|
|
84
|
+
* `options.untilTx` is reached or `options.maxTx` transactions have been
|
|
85
|
+
* fetched. Each fetched transaction is decoded and inserted into the
|
|
86
|
+
* event lists exactly like a live update, so `newEvent` fires for
|
|
87
|
+
* backfilled events too. No-ops if neither `untilTx` is set nor
|
|
88
|
+
* `fetchMax` is true — the subscriber does not backfill by default.
|
|
89
|
+
* @param fetchMax If true, backfill up to `maxTx` transactions even without an `untilTx` cutoff.
|
|
90
|
+
*/
|
|
45
91
|
fetchPreviousTx(fetchMax?: boolean): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Stops the log provider and clears all in-memory state: the per-event-type
|
|
94
|
+
* `EventList`s, the `TxEventCache`, and any pending `awaitTx` promises
|
|
95
|
+
* (which are left unresolved/unrejected — callers awaiting a tx signature
|
|
96
|
+
* across an unsubscribe will hang).
|
|
97
|
+
* @returns Whatever the underlying `LogProvider.unsubscribe` returns.
|
|
98
|
+
*/
|
|
46
99
|
unsubscribe(): Promise<boolean>;
|
|
47
100
|
private parseEventsFromLogs;
|
|
101
|
+
/**
|
|
102
|
+
* Resolves once the subscriber has observed and decoded events for `txSig`
|
|
103
|
+
* (immediately if it's already in the `TxEventCache`). Useful for waiting
|
|
104
|
+
* on the events of a transaction the caller just sent, before reading them
|
|
105
|
+
* via `getEventsByTx`. Never rejects; a transaction that never arrives
|
|
106
|
+
* (e.g. it failed, or the subscriber isn't subscribed) leaves the returned
|
|
107
|
+
* promise pending forever.
|
|
108
|
+
* @param txSig Signature to wait for.
|
|
109
|
+
* @returns A promise that resolves (with no value) once that transaction's events have been processed.
|
|
110
|
+
*/
|
|
48
111
|
awaitTx(txSig: TransactionSignature): Promise<void>;
|
|
49
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Returns the live `EventList` for `eventType` — the ordered, size-bounded
|
|
114
|
+
* (`maxEventsPerType`) linked list the subscriber inserts new events into.
|
|
115
|
+
* Prefer this over `getEventsArray` to iterate without copying.
|
|
116
|
+
* @param eventType Event type to look up; must be one of `options.eventTypes` (subscribed types).
|
|
117
|
+
* @returns The `EventList` for that type, or `undefined` if `eventType` was never subscribed (list not yet populated by `subscribe()`).
|
|
118
|
+
*/
|
|
119
|
+
getEventList<Type extends keyof EventMap>(eventType: Type): EventList<Type> | undefined;
|
|
50
120
|
/**
|
|
51
121
|
* This requires the EventList be cast to an array, which requires reallocation of memory.
|
|
52
122
|
* Would bias to using getEventList over getEvents
|
|
53
123
|
*
|
|
54
|
-
* @param eventType
|
|
124
|
+
* @param eventType Event type to snapshot.
|
|
125
|
+
* @returns All currently retained events of that type, in the `EventList`'s sort order (see `EventSubscriptionOptions.orderBy`/`orderDir`).
|
|
126
|
+
* @throws If `eventType` has no `EventList` (i.e. it isn't in `options.eventTypes`).
|
|
55
127
|
*/
|
|
56
128
|
getEventsArray<Type extends EventType>(eventType: Type): EventMap[Type][];
|
|
129
|
+
/**
|
|
130
|
+
* Looks up the decoded events previously observed for a transaction.
|
|
131
|
+
* @param txSig Transaction signature to look up.
|
|
132
|
+
* @returns The wrapped events emitted by that transaction, or `undefined` if the transaction has aged out of the `TxEventCache` (bounded by `options.maxTx`) or was never observed.
|
|
133
|
+
*/
|
|
57
134
|
getEventsByTx(txSig: TransactionSignature): WrappedEvents | undefined;
|
|
58
135
|
}
|
|
@@ -11,6 +11,29 @@ const events_1 = require("events");
|
|
|
11
11
|
const sort_1 = require("./sort");
|
|
12
12
|
const parse_1 = require("./parse");
|
|
13
13
|
const eventsServerLogProvider_1 = require("./eventsServerLogProvider");
|
|
14
|
+
/**
|
|
15
|
+
* EventSubscriber — streams and decodes Velocity program events from
|
|
16
|
+
* transaction logs (all records emitted via `emit!` from `state/events.rs`:
|
|
17
|
+
* `DepositRecord`, `OrderActionRecord`, `LiquidationRecord`,
|
|
18
|
+
* `FundingPaymentRecord`, etc. — see `EventMap` for the full set), via a
|
|
19
|
+
* pluggable `LogProvider` (websocket, polling, or the Velocity events server),
|
|
20
|
+
* and surfaces them both through per-type `EventList`s and a `'newEvent'`
|
|
21
|
+
* `eventEmitter`.
|
|
22
|
+
*
|
|
23
|
+
* Ordering and dedup: each decoded event is tagged with `slot` and a
|
|
24
|
+
* `txSigIndex` (its position among decoded events within the same
|
|
25
|
+
* transaction); the per-event-type `EventList`s use these to sort either by
|
|
26
|
+
* blockchain order (slot, then `txSigIndex`) or by client arrival order, per
|
|
27
|
+
* `EventSubscriptionOptions.orderBy`. Whole transactions are deduped by
|
|
28
|
+
* signature via an internal LRU (`TxEventCache`, sized by `options.maxTx`):
|
|
29
|
+
* a transaction already in the cache is skipped entirely on a subsequent
|
|
30
|
+
* delivery from the *same* log provider, which protects against a
|
|
31
|
+
* websocket/polling provider redelivering the same tx. Events pushed by the
|
|
32
|
+
* events-server provider bypass this cache (it dedups upstream and supplies
|
|
33
|
+
* an authoritative `txSigIndex`). Event names are also normalized from the
|
|
34
|
+
* `@coral-xyz/anchor` 0.32+ camelCase IDL form back to the PascalCase used by
|
|
35
|
+
* `EventType`/`EventMap` before being matched against the subscribed types.
|
|
36
|
+
*/
|
|
14
37
|
class EventSubscriber {
|
|
15
38
|
get logProvider() {
|
|
16
39
|
if (!this._logProvider) {
|
|
@@ -18,11 +41,18 @@ class EventSubscriber {
|
|
|
18
41
|
}
|
|
19
42
|
return this._logProvider;
|
|
20
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* @param connection RPC connection used by the polling/websocket log providers and by `fetchPreviousTx`.
|
|
46
|
+
* @param program Anchor `Program` whose IDL coder decodes event logs (see `parse.ts`).
|
|
47
|
+
* @param options Subscription options; merged over `DefaultEventSubscriptionOptions` so any field left unset uses the default.
|
|
48
|
+
*/
|
|
21
49
|
constructor(connection, program, options = types_1.DefaultEventSubscriptionOptions) {
|
|
22
50
|
var _a;
|
|
23
51
|
this.connection = connection;
|
|
24
52
|
this.program = program;
|
|
25
53
|
this.options = options;
|
|
54
|
+
/** Case-insensitive lookup from decoded (camelCase) IDL event names to subscribed `EventType` keys. */
|
|
55
|
+
this.eventTypeByLowercaseName = new Map();
|
|
26
56
|
this.awaitTxPromises = new Map();
|
|
27
57
|
this.awaitTxResolver = new Map();
|
|
28
58
|
this.options = Object.assign({}, types_1.DefaultEventSubscriptionOptions, options);
|
|
@@ -45,6 +75,7 @@ class EventSubscriber {
|
|
|
45
75
|
}
|
|
46
76
|
return this.options.eventTypes;
|
|
47
77
|
}
|
|
78
|
+
/** The `LogProviderType` currently in use. May differ from the configured type after a fallback failover (see `updateFallbackProviderType`). */
|
|
48
79
|
get currentProviderType() {
|
|
49
80
|
return this._currentProviderType;
|
|
50
81
|
}
|
|
@@ -90,6 +121,7 @@ class EventSubscriber {
|
|
|
90
121
|
}
|
|
91
122
|
for (const eventType of this.getEventTypes()) {
|
|
92
123
|
this.eventListMap.set(eventType, new eventList_1.EventList(eventType, maxEventsPerType, (0, sort_1.getSortFn)(orderBy, orderDir), orderDir));
|
|
124
|
+
this.eventTypeByLowercaseName.set(eventType.toLowerCase(), eventType);
|
|
93
125
|
}
|
|
94
126
|
}
|
|
95
127
|
/**
|
|
@@ -113,6 +145,19 @@ class EventSubscriber {
|
|
|
113
145
|
console.log(`EventSubscriber: Failing over providerType ${this._currentProviderType} to ${nextProviderType}`);
|
|
114
146
|
this._currentProviderType = nextProviderType;
|
|
115
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Starts streaming events via the configured `LogProvider`. Idempotent —
|
|
150
|
+
* returns `true` immediately if already subscribed. (Re)initializes the
|
|
151
|
+
* per-event-type `EventList`s, so any events retained from a prior
|
|
152
|
+
* subscribe/unsubscribe cycle are discarded. For streaming providers
|
|
153
|
+
* (websocket, events-server), also wires up automatic failover: if the
|
|
154
|
+
* provider emits more than `maxReconnectAttempts` (default `Infinity`,
|
|
155
|
+
* i.e. never) reconnect attempts, the subscriber tears down and
|
|
156
|
+
* reinitializes with the next provider in the fallback chain
|
|
157
|
+
* (events-server → websocket → polling; polling has no further fallback).
|
|
158
|
+
* Does not itself backfill history — call `fetchPreviousTx` for that.
|
|
159
|
+
* @returns `true` once subscribed, or `false` if an error occurred while starting the subscription (logged to console, not thrown).
|
|
160
|
+
*/
|
|
116
161
|
async subscribe() {
|
|
117
162
|
var _a;
|
|
118
163
|
try {
|
|
@@ -186,6 +231,16 @@ class EventSubscriber {
|
|
|
186
231
|
}
|
|
187
232
|
this.txEventCache.add(txSig, wrappedEvents);
|
|
188
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Backfills historical events by walking transactions for `address` via
|
|
236
|
+
* `getSignaturesForAddress`/`getTransaction`, newest-first, until either
|
|
237
|
+
* `options.untilTx` is reached or `options.maxTx` transactions have been
|
|
238
|
+
* fetched. Each fetched transaction is decoded and inserted into the
|
|
239
|
+
* event lists exactly like a live update, so `newEvent` fires for
|
|
240
|
+
* backfilled events too. No-ops if neither `untilTx` is set nor
|
|
241
|
+
* `fetchMax` is true — the subscriber does not backfill by default.
|
|
242
|
+
* @param fetchMax If true, backfill up to `maxTx` transactions even without an `untilTx` cutoff.
|
|
243
|
+
*/
|
|
189
244
|
async fetchPreviousTx(fetchMax) {
|
|
190
245
|
if (!this.options.untilTx && !fetchMax) {
|
|
191
246
|
return;
|
|
@@ -211,6 +266,13 @@ class EventSubscriber {
|
|
|
211
266
|
}
|
|
212
267
|
}
|
|
213
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Stops the log provider and clears all in-memory state: the per-event-type
|
|
271
|
+
* `EventList`s, the `TxEventCache`, and any pending `awaitTx` promises
|
|
272
|
+
* (which are left unresolved/unrejected — callers awaiting a tx signature
|
|
273
|
+
* across an unsubscribe will hang).
|
|
274
|
+
* @returns Whatever the underlying `LogProvider.unsubscribe` returns.
|
|
275
|
+
*/
|
|
214
276
|
async unsubscribe() {
|
|
215
277
|
this.eventListMap.clear();
|
|
216
278
|
this.txEventCache.clear();
|
|
@@ -224,15 +286,14 @@ class EventSubscriber {
|
|
|
224
286
|
const events = (0, parse_1.parseLogs)(this.program, logs);
|
|
225
287
|
let runningEventIndex = 0;
|
|
226
288
|
for (const event of events) {
|
|
227
|
-
// @coral-xyz/anchor 0.32+ converts IDL names to camelCase;
|
|
228
|
-
//
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (expectRecordType) {
|
|
289
|
+
// @coral-xyz/anchor 0.32+ converts IDL names to camelCase; match
|
|
290
|
+
// case-insensitively so names with leading acronyms (LPSwapRecord →
|
|
291
|
+
// lpSwapRecord) still resolve to their PascalCase EventType keys.
|
|
292
|
+
const eventType = this.eventTypeByLowercaseName.get(event.name.toLowerCase());
|
|
293
|
+
if (eventType) {
|
|
233
294
|
event.data.txSig = txSig;
|
|
234
295
|
event.data.slot = slot;
|
|
235
|
-
event.data.eventType =
|
|
296
|
+
event.data.eventType = eventType;
|
|
236
297
|
event.data.txSigIndex =
|
|
237
298
|
txSigIndex !== undefined ? txSigIndex : runningEventIndex;
|
|
238
299
|
records.push(event.data);
|
|
@@ -241,6 +302,16 @@ class EventSubscriber {
|
|
|
241
302
|
}
|
|
242
303
|
return records;
|
|
243
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Resolves once the subscriber has observed and decoded events for `txSig`
|
|
307
|
+
* (immediately if it's already in the `TxEventCache`). Useful for waiting
|
|
308
|
+
* on the events of a transaction the caller just sent, before reading them
|
|
309
|
+
* via `getEventsByTx`. Never rejects; a transaction that never arrives
|
|
310
|
+
* (e.g. it failed, or the subscriber isn't subscribed) leaves the returned
|
|
311
|
+
* promise pending forever.
|
|
312
|
+
* @param txSig Signature to wait for.
|
|
313
|
+
* @returns A promise that resolves (with no value) once that transaction's events have been processed.
|
|
314
|
+
*/
|
|
244
315
|
awaitTx(txSig) {
|
|
245
316
|
const existingPromise = this.awaitTxPromises.get(txSig);
|
|
246
317
|
if (existingPromise !== undefined) {
|
|
@@ -255,6 +326,13 @@ class EventSubscriber {
|
|
|
255
326
|
this.awaitTxPromises.set(txSig, promise);
|
|
256
327
|
return promise;
|
|
257
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Returns the live `EventList` for `eventType` — the ordered, size-bounded
|
|
331
|
+
* (`maxEventsPerType`) linked list the subscriber inserts new events into.
|
|
332
|
+
* Prefer this over `getEventsArray` to iterate without copying.
|
|
333
|
+
* @param eventType Event type to look up; must be one of `options.eventTypes` (subscribed types).
|
|
334
|
+
* @returns The `EventList` for that type, or `undefined` if `eventType` was never subscribed (list not yet populated by `subscribe()`).
|
|
335
|
+
*/
|
|
258
336
|
getEventList(eventType) {
|
|
259
337
|
return this.eventListMap.get(eventType);
|
|
260
338
|
}
|
|
@@ -262,7 +340,9 @@ class EventSubscriber {
|
|
|
262
340
|
* This requires the EventList be cast to an array, which requires reallocation of memory.
|
|
263
341
|
* Would bias to using getEventList over getEvents
|
|
264
342
|
*
|
|
265
|
-
* @param eventType
|
|
343
|
+
* @param eventType Event type to snapshot.
|
|
344
|
+
* @returns All currently retained events of that type, in the `EventList`'s sort order (see `EventSubscriptionOptions.orderBy`/`orderDir`).
|
|
345
|
+
* @throws If `eventType` has no `EventList` (i.e. it isn't in `options.eventTypes`).
|
|
266
346
|
*/
|
|
267
347
|
getEventsArray(eventType) {
|
|
268
348
|
const eventList = this.eventListMap.get(eventType);
|
|
@@ -271,6 +351,11 @@ class EventSubscriber {
|
|
|
271
351
|
}
|
|
272
352
|
return eventList.toArray();
|
|
273
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Looks up the decoded events previously observed for a transaction.
|
|
356
|
+
* @param txSig Transaction signature to look up.
|
|
357
|
+
* @returns The wrapped events emitted by that transaction, or `undefined` if the transaction has aged out of the `TxEventCache` (bounded by `options.maxTx`) or was never observed.
|
|
358
|
+
*/
|
|
274
359
|
getEventsByTx(txSig) {
|
|
275
360
|
return this.txEventCache.get(txSig);
|
|
276
361
|
}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { logProviderCallback, EventType, LogProvider } from './types';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
|
+
/**
|
|
5
|
+
* `LogProvider` backed by the Velocity-hosted events server: a websocket
|
|
6
|
+
* that pushes pre-parsed events per subscribed channel (event type),
|
|
7
|
+
* optionally filtered to one user account, instead of raw RPC logs. Expects
|
|
8
|
+
* a heartbeat message on channel `'heartbeat'` at least every
|
|
9
|
+
* `EVENT_SERVER_HEARTBEAT_INTERVAL_MS` (5s); if none arrives within 3 missed
|
|
10
|
+
* intervals it closes and resubscribes, emitting `'reconnect'` on
|
|
11
|
+
* `eventEmitter` with the attempt count. Each received event is repackaged
|
|
12
|
+
* as a synthetic 3-line log array (`invoke` / raw log / `success`) so it can
|
|
13
|
+
* be run back through the same `parseLogs` pipeline as RPC-sourced logs.
|
|
14
|
+
*/
|
|
4
15
|
export declare class EventsServerLogProvider implements LogProvider {
|
|
5
16
|
private readonly url;
|
|
6
17
|
private readonly eventTypes;
|
|
@@ -13,9 +24,20 @@ export declare class EventsServerLogProvider implements LogProvider {
|
|
|
13
24
|
private timeoutId?;
|
|
14
25
|
private reconnectAttempts;
|
|
15
26
|
eventEmitter: EventEmitter;
|
|
27
|
+
/**
|
|
28
|
+
* @param url Websocket URL of the Velocity events server.
|
|
29
|
+
* @param eventTypes Event type channels to subscribe to (one `subscribe` message sent per type on connect).
|
|
30
|
+
* @param userAccount If provided, scopes the subscription server-side to events for this user account (base58 pubkey string).
|
|
31
|
+
*/
|
|
16
32
|
constructor(url: string, eventTypes: EventType[], userAccount?: string | undefined);
|
|
17
33
|
isSubscribed(): boolean;
|
|
34
|
+
/** Opens the websocket and sends a `subscribe` message per configured event type once connected. `skipHistory` is accepted for `LogProvider` interface compatibility but has no effect (the server only ever pushes new events). Always resolves `true`; malformed inbound messages are caught and logged, not thrown. */
|
|
18
35
|
subscribe(callback: logProviderCallback): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Closes the websocket and clears the heartbeat timeout.
|
|
38
|
+
* @param external Whether this is a caller-initiated unsubscribe rather than an internal one during a reconnect cycle.
|
|
39
|
+
* @returns Always resolves `true`.
|
|
40
|
+
*/
|
|
19
41
|
unsubscribe(external?: boolean): Promise<boolean>;
|
|
20
42
|
private setTimeout;
|
|
21
43
|
}
|
|
@@ -12,7 +12,23 @@ else {
|
|
|
12
12
|
}
|
|
13
13
|
const EVENT_SERVER_HEARTBEAT_INTERVAL_MS = 5000;
|
|
14
14
|
const ALLOWED_MISSED_HEARTBEATS = 3;
|
|
15
|
+
/**
|
|
16
|
+
* `LogProvider` backed by the Velocity-hosted events server: a websocket
|
|
17
|
+
* that pushes pre-parsed events per subscribed channel (event type),
|
|
18
|
+
* optionally filtered to one user account, instead of raw RPC logs. Expects
|
|
19
|
+
* a heartbeat message on channel `'heartbeat'` at least every
|
|
20
|
+
* `EVENT_SERVER_HEARTBEAT_INTERVAL_MS` (5s); if none arrives within 3 missed
|
|
21
|
+
* intervals it closes and resubscribes, emitting `'reconnect'` on
|
|
22
|
+
* `eventEmitter` with the attempt count. Each received event is repackaged
|
|
23
|
+
* as a synthetic 3-line log array (`invoke` / raw log / `success`) so it can
|
|
24
|
+
* be run back through the same `parseLogs` pipeline as RPC-sourced logs.
|
|
25
|
+
*/
|
|
15
26
|
class EventsServerLogProvider {
|
|
27
|
+
/**
|
|
28
|
+
* @param url Websocket URL of the Velocity events server.
|
|
29
|
+
* @param eventTypes Event type channels to subscribe to (one `subscribe` message sent per type on connect).
|
|
30
|
+
* @param userAccount If provided, scopes the subscription server-side to events for this user account (base58 pubkey string).
|
|
31
|
+
*/
|
|
16
32
|
constructor(url, eventTypes, userAccount) {
|
|
17
33
|
this.url = url;
|
|
18
34
|
this.eventTypes = eventTypes;
|
|
@@ -26,12 +42,18 @@ class EventsServerLogProvider {
|
|
|
26
42
|
isSubscribed() {
|
|
27
43
|
return this.ws !== undefined;
|
|
28
44
|
}
|
|
45
|
+
/** Opens the websocket and sends a `subscribe` message per configured event type once connected. `skipHistory` is accepted for `LogProvider` interface compatibility but has no effect (the server only ever pushes new events). Always resolves `true`; malformed inbound messages are caught and logged, not thrown. */
|
|
29
46
|
async subscribe(callback) {
|
|
30
47
|
if (this.ws !== undefined) {
|
|
31
48
|
return true;
|
|
32
49
|
}
|
|
33
50
|
const ws = new WebSocketImpl(this.url);
|
|
34
51
|
this.ws = ws;
|
|
52
|
+
// reset teardown flags for a fresh subscription cycle — the `ws !== undefined`
|
|
53
|
+
// unsubscribe path (e.g. a heartbeat-timeout resubscribe) leaves isUnsubscribing
|
|
54
|
+
// set, which would otherwise disable the watchdog and reconnect on this new socket
|
|
55
|
+
this.isUnsubscribing = false;
|
|
56
|
+
this.externalUnsubscribe = false;
|
|
35
57
|
this.callback = callback;
|
|
36
58
|
ws.addEventListener('open', () => {
|
|
37
59
|
for (const channel of this.eventTypes) {
|
|
@@ -87,6 +109,11 @@ class EventsServerLogProvider {
|
|
|
87
109
|
this.setTimeout();
|
|
88
110
|
return true;
|
|
89
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Closes the websocket and clears the heartbeat timeout.
|
|
114
|
+
* @param external Whether this is a caller-initiated unsubscribe rather than an internal one during a reconnect cycle.
|
|
115
|
+
* @returns Always resolves `true`.
|
|
116
|
+
*/
|
|
90
117
|
async unsubscribe(external = false) {
|
|
91
118
|
this.isUnsubscribing = true;
|
|
92
119
|
this.externalUnsubscribe = external;
|
|
@@ -14,12 +14,43 @@ type FetchLogsResponse = {
|
|
|
14
14
|
transactionLogs: Log[];
|
|
15
15
|
mostRecentBlockTime: number | undefined;
|
|
16
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Fetches raw transaction logs for `address`, newest-first from
|
|
19
|
+
* `getSignaturesForAddress` then batch-fetched via `getTransaction`. Used by
|
|
20
|
+
* both `PollingLogProvider` (incremental polling) and
|
|
21
|
+
* `EventSubscriber.fetchPreviousTx` (historical backfill). Failed
|
|
22
|
+
* transactions (with an `err`) are filtered out before fetching logs.
|
|
23
|
+
* @param connection RPC connection.
|
|
24
|
+
* @param address Account/program address to fetch signatures for.
|
|
25
|
+
* @param finality Commitment for both the signature list and the transaction fetches.
|
|
26
|
+
* @param beforeTx Only return signatures older than this one (pagination cursor).
|
|
27
|
+
* @param untilTx Stop at (exclusive of) this signature.
|
|
28
|
+
* @param limit Max signatures to request from `getSignaturesForAddress`; RPC default applies if omitted.
|
|
29
|
+
* @param batchSize Number of `getTransaction` calls batched per RPC round-trip; defaults to 25.
|
|
30
|
+
* @returns `undefined` if no non-failed signatures were found in range; otherwise the transaction logs plus the earliest/most-recent signature, slot, and block time observed, for use as the next `beforeTx`/`mostRecentSeenTx` cursor.
|
|
31
|
+
*/
|
|
17
32
|
export declare function fetchLogs(connection: Connection, address: PublicKey, finality: Finality, beforeTx?: TransactionSignature, untilTx?: TransactionSignature, limit?: number, batchSize?: number): Promise<FetchLogsResponse | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Fetches `getTransaction` for a batch of signatures in a single RPC batch
|
|
35
|
+
* request, with a 10-second overall timeout.
|
|
36
|
+
* @param connection RPC connection.
|
|
37
|
+
* @param signatures Signatures to fetch (fetched as `maxSupportedTransactionVersion: 0`).
|
|
38
|
+
* @param finality Commitment to fetch each transaction at.
|
|
39
|
+
* @returns One `Log` per signature that returned a result (signatures the RPC couldn't resolve are silently dropped, not padded with placeholders).
|
|
40
|
+
* @throws (rejects) if the batch RPC call doesn't complete within 10 seconds.
|
|
41
|
+
*/
|
|
18
42
|
export declare function fetchTransactionLogs(connection: Connection, signatures: TransactionSignature[], finality: Finality): Promise<Log[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Standalone helper to decode events out of an already-fetched transaction or
|
|
45
|
+
* log object, without going through `EventSubscriber`. Useful for one-off
|
|
46
|
+
* decoding (e.g. re-parsing a transaction fetched elsewhere).
|
|
47
|
+
*/
|
|
19
48
|
export declare class LogParser {
|
|
20
49
|
private program;
|
|
21
50
|
constructor(program: Program);
|
|
51
|
+
/** Decodes the events emitted in a fetched `TransactionResponse`. Assigns `txSigIndex` by decode order (0-based), not by any provider-supplied index. */
|
|
22
52
|
parseEventsFromTransaction(transaction: TransactionResponse): WrappedEvents;
|
|
53
|
+
/** Decodes the events in a `{ txSig, slot, logs }` log object. Returns an empty array if `logs` is falsy. Assigns `txSigIndex` by decode order (0-based). */
|
|
23
54
|
parseEventsFromLogs(event: Log): WrappedEvents;
|
|
24
55
|
}
|
|
25
56
|
export {};
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.LogParser = exports.fetchTransactionLogs = exports.fetchLogs = void 0;
|
|
5
|
+
const types_1 = require("./types");
|
|
4
6
|
const promiseTimeout_1 = require("../util/promiseTimeout");
|
|
5
7
|
const parse_1 = require("./parse");
|
|
8
|
+
/**
|
|
9
|
+
* Case-insensitive lookup from decoded (camelCase) IDL event names to
|
|
10
|
+
* PascalCase `EventType` keys, mirroring `EventSubscriber`'s
|
|
11
|
+
* `eventTypeByLowercaseName` — `@coral-xyz/anchor` 0.32+ decodes event names
|
|
12
|
+
* in camelCase, but the rest of the SDK keys off the PascalCase `EventType`.
|
|
13
|
+
*/
|
|
14
|
+
const eventTypeByLowercaseName = new Map(((_a = types_1.DefaultEventSubscriptionOptions.eventTypes) !== null && _a !== void 0 ? _a : []).map((eventType) => [
|
|
15
|
+
eventType.toLowerCase(),
|
|
16
|
+
eventType,
|
|
17
|
+
]));
|
|
6
18
|
function mapTransactionResponseToLog(transaction) {
|
|
7
19
|
var _a, _b;
|
|
8
20
|
return {
|
|
@@ -11,6 +23,21 @@ function mapTransactionResponseToLog(transaction) {
|
|
|
11
23
|
logs: (_b = (_a = transaction.meta) === null || _a === void 0 ? void 0 : _a.logMessages) !== null && _b !== void 0 ? _b : [],
|
|
12
24
|
};
|
|
13
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Fetches raw transaction logs for `address`, newest-first from
|
|
28
|
+
* `getSignaturesForAddress` then batch-fetched via `getTransaction`. Used by
|
|
29
|
+
* both `PollingLogProvider` (incremental polling) and
|
|
30
|
+
* `EventSubscriber.fetchPreviousTx` (historical backfill). Failed
|
|
31
|
+
* transactions (with an `err`) are filtered out before fetching logs.
|
|
32
|
+
* @param connection RPC connection.
|
|
33
|
+
* @param address Account/program address to fetch signatures for.
|
|
34
|
+
* @param finality Commitment for both the signature list and the transaction fetches.
|
|
35
|
+
* @param beforeTx Only return signatures older than this one (pagination cursor).
|
|
36
|
+
* @param untilTx Stop at (exclusive of) this signature.
|
|
37
|
+
* @param limit Max signatures to request from `getSignaturesForAddress`; RPC default applies if omitted.
|
|
38
|
+
* @param batchSize Number of `getTransaction` calls batched per RPC round-trip; defaults to 25.
|
|
39
|
+
* @returns `undefined` if no non-failed signatures were found in range; otherwise the transaction logs plus the earliest/most-recent signature, slot, and block time observed, for use as the next `beforeTx`/`mostRecentSeenTx` cursor.
|
|
40
|
+
*/
|
|
14
41
|
async function fetchLogs(connection, address, finality, beforeTx, untilTx, limit, batchSize = 25) {
|
|
15
42
|
var _a;
|
|
16
43
|
const signatures = await connection.getSignaturesForAddress(address, {
|
|
@@ -39,6 +66,15 @@ async function fetchLogs(connection, address, finality, beforeTx, untilTx, limit
|
|
|
39
66
|
};
|
|
40
67
|
}
|
|
41
68
|
exports.fetchLogs = fetchLogs;
|
|
69
|
+
/**
|
|
70
|
+
* Fetches `getTransaction` for a batch of signatures in a single RPC batch
|
|
71
|
+
* request, with a 10-second overall timeout.
|
|
72
|
+
* @param connection RPC connection.
|
|
73
|
+
* @param signatures Signatures to fetch (fetched as `maxSupportedTransactionVersion: 0`).
|
|
74
|
+
* @param finality Commitment to fetch each transaction at.
|
|
75
|
+
* @returns One `Log` per signature that returned a result (signatures the RPC couldn't resolve are silently dropped, not padded with placeholders).
|
|
76
|
+
* @throws (rejects) if the batch RPC call doesn't complete within 10 seconds.
|
|
77
|
+
*/
|
|
42
78
|
async function fetchTransactionLogs(connection, signatures, finality) {
|
|
43
79
|
const requests = new Array();
|
|
44
80
|
for (const signature of signatures) {
|
|
@@ -73,15 +109,23 @@ function chunk(array, size) {
|
|
|
73
109
|
.map((_, index) => index * size)
|
|
74
110
|
.map((begin) => array.slice(begin, begin + size));
|
|
75
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Standalone helper to decode events out of an already-fetched transaction or
|
|
114
|
+
* log object, without going through `EventSubscriber`. Useful for one-off
|
|
115
|
+
* decoding (e.g. re-parsing a transaction fetched elsewhere).
|
|
116
|
+
*/
|
|
76
117
|
class LogParser {
|
|
77
118
|
constructor(program) {
|
|
78
119
|
this.program = program;
|
|
79
120
|
}
|
|
121
|
+
/** Decodes the events emitted in a fetched `TransactionResponse`. Assigns `txSigIndex` by decode order (0-based), not by any provider-supplied index. */
|
|
80
122
|
parseEventsFromTransaction(transaction) {
|
|
81
123
|
const transactionLogObject = mapTransactionResponseToLog(transaction);
|
|
82
124
|
return this.parseEventsFromLogs(transactionLogObject);
|
|
83
125
|
}
|
|
126
|
+
/** Decodes the events in a `{ txSig, slot, logs }` log object. Returns an empty array if `logs` is falsy. Assigns `txSigIndex` by decode order (0-based). */
|
|
84
127
|
parseEventsFromLogs(event) {
|
|
128
|
+
var _a;
|
|
85
129
|
const records = [];
|
|
86
130
|
if (!event.logs)
|
|
87
131
|
return records;
|
|
@@ -89,7 +133,8 @@ class LogParser {
|
|
|
89
133
|
for (const eventLog of (0, parse_1.parseLogs)(this.program, event.logs)) {
|
|
90
134
|
eventLog.data.txSig = event.txSig;
|
|
91
135
|
eventLog.data.slot = event.slot;
|
|
92
|
-
eventLog.data.eventType =
|
|
136
|
+
eventLog.data.eventType =
|
|
137
|
+
(_a = eventTypeByLowercaseName.get(eventLog.name.toLowerCase())) !== null && _a !== void 0 ? _a : eventLog.name;
|
|
93
138
|
eventLog.data.txSigIndex = runningEventIndex;
|
|
94
139
|
// @ts-ignore
|
|
95
140
|
records.push(eventLog.data);
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import { Program, Event } from '../isomorphic/anchor';
|
|
2
2
|
import { CuUsageEvent } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Decodes Anchor events from a transaction's raw log lines. Walks the log
|
|
5
|
+
* lines tracking the CPI call stack so only `msg!`/`sol_log_data` lines
|
|
6
|
+
* logged while the Velocity program is the currently-executing program are
|
|
7
|
+
* treated as candidate events; lines after `'Log truncated'` are ignored
|
|
8
|
+
* (the RPC node cut off the log before printing exceeded 10KB).
|
|
9
|
+
* @param program Anchor `Program` whose IDL coder decodes the event discriminator/payload.
|
|
10
|
+
* @param logs Raw `logMessages` for one transaction.
|
|
11
|
+
* @param programId Program ID whose logs are decoded; defaults to the Velocity program.
|
|
12
|
+
* @returns Decoded Anchor `Event`s in log order (does not include `slot`/`txSig`/`txSigIndex` — callers such as `EventSubscriber` attach those).
|
|
13
|
+
*/
|
|
3
14
|
export declare function parseLogs(program: Program, logs: string[], programId?: string): Event[];
|
|
15
|
+
/** Same as `parseLogs`, but also returns the raw log line each event was decoded from (parallel-indexed to `events`), for callers that need to keep the original log text. */
|
|
4
16
|
export declare function parseLogsWithRaw(program: Program, logs: string[], programId?: string): {
|
|
5
17
|
events: Event[];
|
|
6
18
|
rawLogs: string[];
|
|
7
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Extracts per-instruction compute-unit usage from a transaction's raw logs
|
|
22
|
+
* by matching `Program log: Instruction: <name>` and
|
|
23
|
+
* `Program <id> consumed N of M compute units` lines while `programId` is
|
|
24
|
+
* the currently-executing program. Unlike `parseLogs`, this is not decoding
|
|
25
|
+
* a real on-chain `#[event]` — `CuUsage` is a synthetic event shape for
|
|
26
|
+
* client-side profiling.
|
|
27
|
+
* @param logs Raw `logMessages` for one transaction.
|
|
28
|
+
* @param programId Program ID whose CU consumption is measured; defaults to the Velocity program.
|
|
29
|
+
* @returns One `Event<CuUsage>` per top-level instruction invoking that program, in log order. `cuUsage` is in compute units.
|
|
30
|
+
*/
|
|
8
31
|
export declare function parseLogsForCuUsage(logs: string[], programId?: string): Event<any, CuUsageEvent>[];
|
|
@@ -8,11 +8,23 @@ const PROGRAM_DATA = 'Program data: ';
|
|
|
8
8
|
const PROGRAM_LOG_START_INDEX = PROGRAM_LOG.length;
|
|
9
9
|
const PROGRAM_DATA_START_INDEX = PROGRAM_DATA.length;
|
|
10
10
|
const PROGRAM_INSTRUCTION_START_INDEX = PROGRAM_INSTRUCTION.length;
|
|
11
|
+
/**
|
|
12
|
+
* Decodes Anchor events from a transaction's raw log lines. Walks the log
|
|
13
|
+
* lines tracking the CPI call stack so only `msg!`/`sol_log_data` lines
|
|
14
|
+
* logged while the Velocity program is the currently-executing program are
|
|
15
|
+
* treated as candidate events; lines after `'Log truncated'` are ignored
|
|
16
|
+
* (the RPC node cut off the log before printing exceeded 10KB).
|
|
17
|
+
* @param program Anchor `Program` whose IDL coder decodes the event discriminator/payload.
|
|
18
|
+
* @param logs Raw `logMessages` for one transaction.
|
|
19
|
+
* @param programId Program ID whose logs are decoded; defaults to the Velocity program.
|
|
20
|
+
* @returns Decoded Anchor `Event`s in log order (does not include `slot`/`txSig`/`txSigIndex` — callers such as `EventSubscriber` attach those).
|
|
21
|
+
*/
|
|
11
22
|
function parseLogs(program, logs, programId = velocityProgramId) {
|
|
12
23
|
const { events } = parseLogsWithRaw(program, logs, programId);
|
|
13
24
|
return events;
|
|
14
25
|
}
|
|
15
26
|
exports.parseLogs = parseLogs;
|
|
27
|
+
/** Same as `parseLogs`, but also returns the raw log line each event was decoded from (parallel-indexed to `events`), for callers that need to keep the original log text. */
|
|
16
28
|
function parseLogsWithRaw(program, logs, programId = velocityProgramId) {
|
|
17
29
|
const events = [];
|
|
18
30
|
const rawLogs = [];
|
|
@@ -119,6 +131,17 @@ class ExecutionContext {
|
|
|
119
131
|
this.ixStack.pop();
|
|
120
132
|
}
|
|
121
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Extracts per-instruction compute-unit usage from a transaction's raw logs
|
|
136
|
+
* by matching `Program log: Instruction: <name>` and
|
|
137
|
+
* `Program <id> consumed N of M compute units` lines while `programId` is
|
|
138
|
+
* the currently-executing program. Unlike `parseLogs`, this is not decoding
|
|
139
|
+
* a real on-chain `#[event]` — `CuUsage` is a synthetic event shape for
|
|
140
|
+
* client-side profiling.
|
|
141
|
+
* @param logs Raw `logMessages` for one transaction.
|
|
142
|
+
* @param programId Program ID whose CU consumption is measured; defaults to the Velocity program.
|
|
143
|
+
* @returns One `Event<CuUsage>` per top-level instruction invoking that program, in log order. `cuUsage` is in compute units.
|
|
144
|
+
*/
|
|
122
145
|
function parseLogsForCuUsage(logs, programId = velocityProgramId) {
|
|
123
146
|
const cuUsageEvents = [];
|
|
124
147
|
const execution = new ExecutionContext();
|