@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
package/lib/node/wallet.d.ts
CHANGED
|
@@ -1,17 +1,54 @@
|
|
|
1
1
|
import { Keypair, PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
2
2
|
import { IWallet, IVersionedWallet } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Local-keypair implementation of `IWallet`/`IVersionedWallet` that signs directly with an
|
|
5
|
+
* in-memory `Keypair` (no external wallet/RPC round-trip). Suitable for keeper bots, scripts, and
|
|
6
|
+
* tests; not for browser dapps holding user funds.
|
|
7
|
+
*/
|
|
3
8
|
export declare class Wallet implements IWallet, IVersionedWallet {
|
|
4
9
|
readonly payer: Keypair;
|
|
5
10
|
constructor(payer: Keypair);
|
|
11
|
+
/**
|
|
12
|
+
* Partially signs a legacy `Transaction` with this wallet's keypair, leaving any other
|
|
13
|
+
* required signatures untouched.
|
|
14
|
+
* @param tx - Transaction to sign; mutated in place.
|
|
15
|
+
* @returns The same transaction instance, now signed by `payer`.
|
|
16
|
+
*/
|
|
6
17
|
signTransaction(tx: Transaction): Promise<Transaction>;
|
|
18
|
+
/**
|
|
19
|
+
* Signs a `VersionedTransaction` with this wallet's keypair.
|
|
20
|
+
* @param tx - Transaction to sign; mutated in place.
|
|
21
|
+
* @returns The same transaction instance, now signed by `payer`.
|
|
22
|
+
*/
|
|
7
23
|
signVersionedTransaction(tx: VersionedTransaction): Promise<VersionedTransaction>;
|
|
24
|
+
/**
|
|
25
|
+
* Partially signs a batch of legacy `Transaction`s with this wallet's keypair.
|
|
26
|
+
* @param txs - Transactions to sign; each is mutated in place.
|
|
27
|
+
* @returns The same transaction instances, now signed by `payer`.
|
|
28
|
+
*/
|
|
8
29
|
signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Signs a batch of `VersionedTransaction`s with this wallet's keypair.
|
|
32
|
+
* @param txs - Transactions to sign; each is mutated in place.
|
|
33
|
+
* @returns The same transaction instances, now signed by `payer`.
|
|
34
|
+
*/
|
|
9
35
|
signAllVersionedTransactions(txs: VersionedTransaction[]): Promise<VersionedTransaction[]>;
|
|
36
|
+
/** The wallet's public key, i.e. `payer.publicKey`. */
|
|
10
37
|
get publicKey(): PublicKey;
|
|
11
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* `Wallet` variant that additionally supports raw message signing (`signMessage`), needed for
|
|
41
|
+
* flows like swift/signed-message orders that sign an ed25519 payload outside of a transaction.
|
|
42
|
+
*/
|
|
12
43
|
export declare class WalletV2 extends Wallet {
|
|
13
44
|
readonly payer: Keypair;
|
|
14
45
|
constructor(payer: Keypair);
|
|
46
|
+
/**
|
|
47
|
+
* Signs an arbitrary message with this wallet's ed25519 secret key (detached signature, not a
|
|
48
|
+
* transaction).
|
|
49
|
+
* @param message - Raw bytes to sign.
|
|
50
|
+
* @returns The 64-byte detached ed25519 signature.
|
|
51
|
+
*/
|
|
15
52
|
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
16
53
|
}
|
|
17
54
|
//# sourceMappingURL=wallet.d.ts.map
|
package/lib/node/wallet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,OAAO,EACP,SAAS,EACT,WAAW,EACX,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGpD,qBAAa,MAAO,YAAW,OAAO,EAAE,gBAAgB;IAC3C,QAAQ,CAAC,KAAK,EAAE,OAAO;gBAAd,KAAK,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,OAAO,EACP,SAAS,EACT,WAAW,EACX,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGpD;;;;GAIG;AACH,qBAAa,MAAO,YAAW,OAAO,EAAE,gBAAgB;IAC3C,QAAQ,CAAC,KAAK,EAAE,OAAO;gBAAd,KAAK,EAAE,OAAO;IAEnC;;;;;OAKG;IACG,eAAe,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAK5D;;;;OAIG;IACG,wBAAwB,CAC7B,EAAE,EAAE,oBAAoB,GACtB,OAAO,CAAC,oBAAoB,CAAC;IAKhC;;;;OAIG;IACG,mBAAmB,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAOrE;;;;OAIG;IACG,4BAA4B,CACjC,GAAG,EAAE,oBAAoB,EAAE,GACzB,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAOlC,uDAAuD;IACvD,IAAI,SAAS,IAAI,SAAS,CAEzB;CACD;AAED;;;GAGG;AACH,qBAAa,QAAS,SAAQ,MAAM;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO;gBAAd,KAAK,EAAE,OAAO;IAInC;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAG3D"}
|
package/lib/node/wallet.js
CHANGED
|
@@ -5,40 +5,77 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WalletV2 = exports.Wallet = void 0;
|
|
7
7
|
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
8
|
+
/**
|
|
9
|
+
* Local-keypair implementation of `IWallet`/`IVersionedWallet` that signs directly with an
|
|
10
|
+
* in-memory `Keypair` (no external wallet/RPC round-trip). Suitable for keeper bots, scripts, and
|
|
11
|
+
* tests; not for browser dapps holding user funds.
|
|
12
|
+
*/
|
|
8
13
|
class Wallet {
|
|
9
14
|
constructor(payer) {
|
|
10
15
|
this.payer = payer;
|
|
11
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Partially signs a legacy `Transaction` with this wallet's keypair, leaving any other
|
|
19
|
+
* required signatures untouched.
|
|
20
|
+
* @param tx - Transaction to sign; mutated in place.
|
|
21
|
+
* @returns The same transaction instance, now signed by `payer`.
|
|
22
|
+
*/
|
|
12
23
|
async signTransaction(tx) {
|
|
13
24
|
tx.partialSign(this.payer);
|
|
14
25
|
return tx;
|
|
15
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Signs a `VersionedTransaction` with this wallet's keypair.
|
|
29
|
+
* @param tx - Transaction to sign; mutated in place.
|
|
30
|
+
* @returns The same transaction instance, now signed by `payer`.
|
|
31
|
+
*/
|
|
16
32
|
async signVersionedTransaction(tx) {
|
|
17
33
|
tx.sign([this.payer]);
|
|
18
34
|
return tx;
|
|
19
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Partially signs a batch of legacy `Transaction`s with this wallet's keypair.
|
|
38
|
+
* @param txs - Transactions to sign; each is mutated in place.
|
|
39
|
+
* @returns The same transaction instances, now signed by `payer`.
|
|
40
|
+
*/
|
|
20
41
|
async signAllTransactions(txs) {
|
|
21
42
|
return txs.map((t) => {
|
|
22
43
|
t.partialSign(this.payer);
|
|
23
44
|
return t;
|
|
24
45
|
});
|
|
25
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Signs a batch of `VersionedTransaction`s with this wallet's keypair.
|
|
49
|
+
* @param txs - Transactions to sign; each is mutated in place.
|
|
50
|
+
* @returns The same transaction instances, now signed by `payer`.
|
|
51
|
+
*/
|
|
26
52
|
async signAllVersionedTransactions(txs) {
|
|
27
53
|
return txs.map((t) => {
|
|
28
54
|
t.sign([this.payer]);
|
|
29
55
|
return t;
|
|
30
56
|
});
|
|
31
57
|
}
|
|
58
|
+
/** The wallet's public key, i.e. `payer.publicKey`. */
|
|
32
59
|
get publicKey() {
|
|
33
60
|
return this.payer.publicKey;
|
|
34
61
|
}
|
|
35
62
|
}
|
|
36
63
|
exports.Wallet = Wallet;
|
|
64
|
+
/**
|
|
65
|
+
* `Wallet` variant that additionally supports raw message signing (`signMessage`), needed for
|
|
66
|
+
* flows like swift/signed-message orders that sign an ed25519 payload outside of a transaction.
|
|
67
|
+
*/
|
|
37
68
|
class WalletV2 extends Wallet {
|
|
38
69
|
constructor(payer) {
|
|
39
70
|
super(payer);
|
|
40
71
|
this.payer = payer;
|
|
41
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Signs an arbitrary message with this wallet's ed25519 secret key (detached signature, not a
|
|
75
|
+
* transaction).
|
|
76
|
+
* @param message - Raw bytes to sign.
|
|
77
|
+
* @returns The 64-byte detached ed25519 signature.
|
|
78
|
+
*/
|
|
42
79
|
async signMessage(message) {
|
|
43
80
|
return Buffer.from(tweetnacl_1.default.sign.detached(message, this.payer.secretKey));
|
|
44
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velocity-exchange/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"main": "lib/node/index.js",
|
|
5
5
|
"types": "lib/node/index.d.ts",
|
|
6
6
|
"module": "./lib/browser/index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"test:inspect": "mocha --inspect-brk -r ts-node/register tests/**/*.ts",
|
|
20
20
|
"test:bignum": "mocha -r ts-node/register tests/bn/**/*.ts",
|
|
21
21
|
"test:ci": "mocha -r ts-node/register tests/ci/**/*.ts",
|
|
22
|
+
"test:parity": "mocha -r ts-node/register 'tests/sdkParity/**/*.ts' 'tests/oracles/**/*.ts' 'tests/amm/**/*.ts' 'tests/builder/**/*.ts' 'tests/liquidation/**/*.ts' 'tests/exchangeStatus/**/*.ts' 'tests/spot/**/*.ts' 'tests/user/**/*.ts' tests/dlob/tickSizeStandardization.ts",
|
|
22
23
|
"test:dlob": "mocha -r ts-node/register tests/dlob/**/*.ts",
|
|
23
24
|
"test:events": "mocha -r ts-node/register tests/events/**/*.ts",
|
|
24
25
|
"test:velocitycore": "bun test tests/VelocityCore",
|
|
@@ -18,6 +18,11 @@ export class BasicUserAccountSubscriber implements UserAccountSubscriber {
|
|
|
18
18
|
|
|
19
19
|
user?: DataAndSlot<UserAccount>;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @param userAccountPublicKey Address of the `UserAccount` this subscriber represents (not fetched — used only for identity).
|
|
23
|
+
* @param data Optional decoded account data to seed with; if omitted, `getUserAccountAndSlot()` returns undefined until `updateData` is called.
|
|
24
|
+
* @param slot Slot `data` was observed at; defaults to 0 (the seeded sentinel) if omitted.
|
|
25
|
+
*/
|
|
21
26
|
public constructor(
|
|
22
27
|
userAccountPublicKey: PublicKey,
|
|
23
28
|
data?: UserAccount,
|
|
@@ -31,26 +36,39 @@ export class BasicUserAccountSubscriber implements UserAccountSubscriber {
|
|
|
31
36
|
this.user = data ? { data, slot: slot ?? 0 } : undefined;
|
|
32
37
|
}
|
|
33
38
|
|
|
39
|
+
/** No-op; this subscriber never performs network I/O. Always resolves `true` since `isSubscribed` is already `true` from construction. */
|
|
34
40
|
async subscribe(_userAccount?: UserAccount): Promise<boolean> {
|
|
35
41
|
return true;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
async addToAccountLoader(): Promise<void> {}
|
|
39
45
|
|
|
46
|
+
/** No-op; this subscriber never fetches. Data only changes via `updateData`. */
|
|
40
47
|
async fetch(): Promise<void> {}
|
|
41
48
|
|
|
49
|
+
/** Type predicate: true once `user` has been seeded or set via `updateData`, narrowing `this.user` to non-undefined. */
|
|
42
50
|
doesAccountExist(): this is { user: DataAndSlot<UserAccount> } {
|
|
43
51
|
return this.user !== undefined;
|
|
44
52
|
}
|
|
45
53
|
|
|
54
|
+
/** No-op; there is no live subscription to tear down. */
|
|
46
55
|
async unsubscribe(): Promise<void> {}
|
|
47
56
|
|
|
57
|
+
/** No-op; this subscriber is always considered subscribed and never throws `NotSubscribedError`. */
|
|
48
58
|
assertIsSubscribed(): void {}
|
|
49
59
|
|
|
60
|
+
/** Returns the currently cached data/slot, or undefined if never seeded/updated. Never throws (unlike other implementations, this subscriber has no "not subscribed" state). */
|
|
50
61
|
public getUserAccountAndSlot(): DataAndSlot<UserAccount> | undefined {
|
|
51
62
|
return this.user;
|
|
52
63
|
}
|
|
53
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Applies an externally-obtained account update if `slot` is not older than the currently
|
|
67
|
+
* cached slot, emitting `userAccountUpdate`/`update` on acceptance. This is the only way this
|
|
68
|
+
* subscriber's data changes after construction.
|
|
69
|
+
* @param userAccount Decoded account data to apply.
|
|
70
|
+
* @param slot Slot the data was observed at.
|
|
71
|
+
*/
|
|
54
72
|
public updateData(userAccount: UserAccount, slot: number): void {
|
|
55
73
|
if (!this.user || slot >= this.user.slot) {
|
|
56
74
|
this.user = { data: userAccount, slot };
|
|
@@ -24,6 +24,11 @@ export class BasicUserStatsAccountSubscriber
|
|
|
24
24
|
|
|
25
25
|
userStats?: DataAndSlot<UserStatsAccount>;
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @param userStatsAccountPublicKey Address of the `UserStatsAccount` this subscriber represents (not fetched — used only for identity).
|
|
29
|
+
* @param data Optional decoded account data to seed with; if omitted, `getUserStatsAccountAndSlot()` returns undefined until `updateData` is called.
|
|
30
|
+
* @param slot Slot `data` was observed at; defaults to 0 (the seeded sentinel) if omitted.
|
|
31
|
+
*/
|
|
27
32
|
public constructor(
|
|
28
33
|
userStatsAccountPublicKey: PublicKey,
|
|
29
34
|
data?: UserStatsAccount,
|
|
@@ -37,28 +42,41 @@ export class BasicUserStatsAccountSubscriber
|
|
|
37
42
|
this.userStats = data ? { data, slot: slot ?? 0 } : undefined;
|
|
38
43
|
}
|
|
39
44
|
|
|
45
|
+
/** No-op; this subscriber never performs network I/O. Always resolves `true` since `isSubscribed` is already `true` from construction. */
|
|
40
46
|
async subscribe(_userStatsAccount?: UserStatsAccount): Promise<boolean> {
|
|
41
47
|
return true;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
async addToAccountLoader(): Promise<void> {}
|
|
45
51
|
|
|
52
|
+
/** No-op; this subscriber never fetches. Data only changes via `updateData`. */
|
|
46
53
|
async fetch(): Promise<void> {}
|
|
47
54
|
|
|
55
|
+
/** Type predicate: true once `userStats` has been seeded or set via `updateData`, narrowing `this.userStats` to non-undefined. */
|
|
48
56
|
doesAccountExist(): this is { userStats: DataAndSlot<UserStatsAccount> } {
|
|
49
57
|
return this.userStats !== undefined;
|
|
50
58
|
}
|
|
51
59
|
|
|
60
|
+
/** No-op; there is no live subscription to tear down. */
|
|
52
61
|
async unsubscribe(): Promise<void> {}
|
|
53
62
|
|
|
63
|
+
/** No-op; this subscriber is always considered subscribed and never throws `NotSubscribedError`. */
|
|
54
64
|
assertIsSubscribed(): void {}
|
|
55
65
|
|
|
66
|
+
/** Returns the currently cached data/slot, or undefined if never seeded/updated. Never throws (unlike other implementations, this subscriber has no "not subscribed" state). */
|
|
56
67
|
public getUserStatsAccountAndSlot():
|
|
57
68
|
| DataAndSlot<UserStatsAccount>
|
|
58
69
|
| undefined {
|
|
59
70
|
return this.userStats;
|
|
60
71
|
}
|
|
61
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Applies an externally-obtained account update if `slot` is not older than the currently
|
|
75
|
+
* cached slot, emitting `userStatsAccountUpdate`/`update` on acceptance. This is the only way
|
|
76
|
+
* this subscriber's data changes after construction.
|
|
77
|
+
* @param userStatsAccount Decoded account data to apply.
|
|
78
|
+
* @param slot Slot the data was observed at.
|
|
79
|
+
*/
|
|
62
80
|
public updateData(userStatsAccount: UserStatsAccount, slot: number): void {
|
|
63
81
|
if (!this.userStats || slot >= this.userStats.slot) {
|
|
64
82
|
this.userStats = { data: userStatsAccount, slot };
|
|
@@ -5,6 +5,7 @@ import { promiseTimeout } from '../util/promiseTimeout';
|
|
|
5
5
|
import { Connection } from '../bankrun/bankrunConnection';
|
|
6
6
|
import { GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE } from '../constants/numericConstants';
|
|
7
7
|
|
|
8
|
+
/** An account registered with a `BulkAccountLoader`, along with every callback subscribed to its updates (keyed by callback id). */
|
|
8
9
|
export type AccountToLoad = {
|
|
9
10
|
publicKey: PublicKey;
|
|
10
11
|
callbacks: Map<string, (buffer: Buffer, slot: number) => void>;
|
|
@@ -12,6 +13,17 @@ export type AccountToLoad = {
|
|
|
12
13
|
|
|
13
14
|
const oneMinute = 60 * 1000;
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Batches many accounts behind a single periodic `getMultipleAccounts` RPC poll instead of one
|
|
18
|
+
* WebSocket subscription per account. Multiple independent callbacks (e.g. from different
|
|
19
|
+
* `PollingUserAccountSubscriber`/`PollingVelocityClientAccountSubscriber` instances) can register
|
|
20
|
+
* against the same `publicKey`; polling starts automatically on the first `addAccount` and stops
|
|
21
|
+
* when the last callback for the last account is removed. A buffer is only re-delivered to
|
|
22
|
+
* callbacks when its slot is not older than the last-seen slot for that account and its bytes
|
|
23
|
+
* actually changed, so a callback never observes a stale or duplicate update. `load()` calls are
|
|
24
|
+
* coalesced: concurrent callers share one in-flight RPC batch rather than issuing redundant
|
|
25
|
+
* requests.
|
|
26
|
+
*/
|
|
15
27
|
export class BulkAccountLoader {
|
|
16
28
|
connection: Connection;
|
|
17
29
|
commitment: Commitment;
|
|
@@ -26,6 +38,11 @@ export class BulkAccountLoader {
|
|
|
26
38
|
lastTimeLoadingPromiseCleared = Date.now();
|
|
27
39
|
mostRecentSlot = 0;
|
|
28
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @param connection Connection (or bankrun-compatible shim) used for the batched `getMultipleAccounts` polls.
|
|
43
|
+
* @param commitment Commitment level applied to every poll.
|
|
44
|
+
* @param pollingFrequency Poll interval in ms; `0` disables automatic polling (`startPolling` becomes a no-op), useful when the loader is driven manually via `load()`.
|
|
45
|
+
*/
|
|
29
46
|
public constructor(
|
|
30
47
|
connection: Connection,
|
|
31
48
|
commitment: Commitment,
|
|
@@ -36,6 +53,15 @@ export class BulkAccountLoader {
|
|
|
36
53
|
this.pollingFrequency = pollingFrequency;
|
|
37
54
|
}
|
|
38
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Registers a callback to be invoked whenever `publicKey`'s account data changes on a poll.
|
|
58
|
+
* Multiple callbacks may be registered for the same account. Starts polling automatically if
|
|
59
|
+
* this is the loader's first account. Awaits any in-flight `load()` before returning so a
|
|
60
|
+
* caller can immediately follow with its own `load()` without racing the poll interval.
|
|
61
|
+
* @param publicKey Account to track.
|
|
62
|
+
* @param callback Invoked with the raw account buffer and the slot it was fetched at whenever the buffer changes at a non-decreasing slot.
|
|
63
|
+
* @returns A callback id to pass to `removeAccount` later.
|
|
64
|
+
*/
|
|
39
65
|
public async addAccount(
|
|
40
66
|
publicKey: PublicKey,
|
|
41
67
|
callback: (buffer: Buffer, slot: number) => void
|
|
@@ -73,6 +99,13 @@ export class BulkAccountLoader {
|
|
|
73
99
|
return callbackId;
|
|
74
100
|
}
|
|
75
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Unregisters a callback previously returned by `addAccount`. Once an account has no
|
|
104
|
+
* remaining callbacks, its cached buffer/slot is dropped and it stops being polled; if no
|
|
105
|
+
* accounts remain at all, polling stops entirely. A no-op if `callbackId` is undefined.
|
|
106
|
+
* @param publicKey Account the callback was registered against.
|
|
107
|
+
* @param callbackId Id returned by `addAccount`.
|
|
108
|
+
*/
|
|
76
109
|
public removeAccount(
|
|
77
110
|
publicKey: PublicKey,
|
|
78
111
|
callbackId: string | undefined
|
|
@@ -94,12 +127,18 @@ export class BulkAccountLoader {
|
|
|
94
127
|
}
|
|
95
128
|
}
|
|
96
129
|
|
|
130
|
+
/**
|
|
131
|
+
* Registers a callback invoked whenever a `load()` batch throws (e.g. RPC failure or timeout).
|
|
132
|
+
* The loader continues polling afterward; errors do not stop the interval.
|
|
133
|
+
* @returns A callback id to pass to `removeErrorCallbacks` later.
|
|
134
|
+
*/
|
|
97
135
|
public addErrorCallbacks(callback: (error: Error) => void): string {
|
|
98
136
|
const callbackId = uuidv4();
|
|
99
137
|
this.errorCallbacks.set(callbackId, callback);
|
|
100
138
|
return callbackId;
|
|
101
139
|
}
|
|
102
140
|
|
|
141
|
+
/** Unregisters an error callback previously returned by `addErrorCallbacks`. A no-op if `callbackId` is undefined. */
|
|
103
142
|
public removeErrorCallbacks(callbackId: string | undefined): void {
|
|
104
143
|
if (callbackId === undefined) {
|
|
105
144
|
return;
|
|
@@ -114,6 +153,14 @@ export class BulkAccountLoader {
|
|
|
114
153
|
.map((begin) => array.slice(begin, begin + size));
|
|
115
154
|
}
|
|
116
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Fetches every registered account in one or more chunked, concurrent `getMultipleAccounts`
|
|
158
|
+
* batches (via `loadChunk`) and dispatches changed accounts to their callbacks. Concurrent
|
|
159
|
+
* calls while a load is already in flight share that same in-flight promise rather than
|
|
160
|
+
* issuing a duplicate RPC batch, unless the previous load has been running for over a minute
|
|
161
|
+
* (treated as stuck and restarted). On failure, invokes every registered error callback
|
|
162
|
+
* instead of throwing.
|
|
163
|
+
*/
|
|
117
164
|
public async load(): Promise<void> {
|
|
118
165
|
if (this.loadPromise) {
|
|
119
166
|
const now = Date.now();
|
|
@@ -265,14 +312,17 @@ export class BulkAccountLoader {
|
|
|
265
312
|
}
|
|
266
313
|
}
|
|
267
314
|
|
|
315
|
+
/** Returns the last-fetched raw buffer/slot for `publicKey`, or undefined if it has never been loaded. */
|
|
268
316
|
public getBufferAndSlot(publicKey: PublicKey): BufferAndSlot | undefined {
|
|
269
317
|
return this.bufferAndSlotMap.get(publicKey.toString());
|
|
270
318
|
}
|
|
271
319
|
|
|
320
|
+
/** Returns the highest slot number observed across any account fetched by this loader so far. */
|
|
272
321
|
public getSlot(): number {
|
|
273
322
|
return this.mostRecentSlot;
|
|
274
323
|
}
|
|
275
324
|
|
|
325
|
+
/** Starts the polling interval if not already running and `pollingFrequency !== 0`. Called automatically by `addAccount`. */
|
|
276
326
|
public startPolling(): void {
|
|
277
327
|
if (this.intervalId) {
|
|
278
328
|
return;
|
|
@@ -285,6 +335,7 @@ export class BulkAccountLoader {
|
|
|
285
335
|
);
|
|
286
336
|
}
|
|
287
337
|
|
|
338
|
+
/** Stops the polling interval, if running. Called automatically by `removeAccount` once no accounts remain. */
|
|
288
339
|
public stopPolling(): void {
|
|
289
340
|
if (this.intervalId) {
|
|
290
341
|
clearInterval(this.intervalId);
|
|
@@ -296,6 +347,7 @@ export class BulkAccountLoader {
|
|
|
296
347
|
console.log(msg);
|
|
297
348
|
}
|
|
298
349
|
|
|
350
|
+
/** Restarts polling at a new interval (ms), preserving all registered accounts and callbacks. */
|
|
299
351
|
public updatePollingFrequency(pollingFrequency: number): void {
|
|
300
352
|
this.stopPolling();
|
|
301
353
|
this.pollingFrequency = pollingFrequency;
|
|
@@ -3,8 +3,15 @@ import { BulkAccountLoader } from './bulkAccountLoader';
|
|
|
3
3
|
import { PollingUserStatsAccountSubscriber } from './pollingUserStatsAccountSubscriber';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Subscribes many `UserStats`s that share a single `BulkAccountLoader` in one batched round trip,
|
|
7
|
+
* instead of each `UserStats.subscribe()` triggering its own `addAccount`/`load()`. Registers
|
|
8
|
+
* every account's `PollingUserStatsAccountSubscriber` with the loader first, issues one `load()`
|
|
9
|
+
* to seed all of them from a single batched `getMultipleAccounts` call, and only then calls
|
|
10
|
+
* `userStat.subscribe()` (which becomes a fast no-op fetch since data is already cached). If
|
|
11
|
+
* `userStats` is empty, still calls `accountLoader.load()` so any other accounts already
|
|
12
|
+
* registered on the loader get polled.
|
|
13
|
+
* @param userStats `UserStats` instances to subscribe; each must already be constructed with a `PollingUserStatsAccountSubscriber`.
|
|
14
|
+
* @param accountLoader Shared `BulkAccountLoader` batching the underlying RPC polls.
|
|
8
15
|
*/
|
|
9
16
|
export async function bulkPollingUserStatsSubscribe(
|
|
10
17
|
userStats: UserStats[],
|
|
@@ -3,8 +3,14 @@ import { BulkAccountLoader } from './bulkAccountLoader';
|
|
|
3
3
|
import { PollingUserAccountSubscriber } from './pollingUserAccountSubscriber';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Subscribes many `User`s that share a single `BulkAccountLoader` in one batched round trip,
|
|
7
|
+
* instead of each `User.subscribe()` triggering its own `addAccount`/`load()`. Registers every
|
|
8
|
+
* user's `PollingUserAccountSubscriber` with the loader first, issues one `load()` to seed all of
|
|
9
|
+
* them from a single batched `getMultipleAccounts` call, and only then calls `user.subscribe()`
|
|
10
|
+
* (which becomes a fast no-op fetch since data is already cached). If `users` is empty, still
|
|
11
|
+
* calls `accountLoader.load()` so any other accounts already registered on the loader get polled.
|
|
12
|
+
* @param users Users to subscribe; each must already be constructed with a `PollingUserAccountSubscriber`.
|
|
13
|
+
* @param accountLoader Shared `BulkAccountLoader` batching the underlying RPC polls.
|
|
8
14
|
*/
|
|
9
15
|
export async function bulkPollingUserSubscribe(
|
|
10
16
|
users: User[],
|
|
@@ -3,6 +3,15 @@ import { BulkAccountLoader } from './bulkAccountLoader';
|
|
|
3
3
|
import { Commitment, Connection, PublicKey } from '@solana/web3.js';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* `BulkAccountLoader` variant where each account can be polled at its own cadence instead of a
|
|
8
|
+
* single shared `pollingFrequency`. Overrides the base class's single `setInterval` with a
|
|
9
|
+
* per-account `accountFrequencies` map: `handleAccountLoading()` only includes an account in a
|
|
10
|
+
* given tick if `Date.now() - lastPollingTime >= frequency` for that account, then delegates to
|
|
11
|
+
* the inherited chunked `loadChunk` for the actual `getMultipleAccounts` batch. The interval
|
|
12
|
+
* itself always runs at the fastest frequency across all registered accounts (see `startPolling`),
|
|
13
|
+
* so slower accounts simply get skipped on ticks that fire before they're due.
|
|
14
|
+
*/
|
|
6
15
|
export class CustomizedCadenceBulkAccountLoader extends BulkAccountLoader {
|
|
7
16
|
private customIntervalId: NodeJS.Timeout | null;
|
|
8
17
|
private currentPollingFrequency: number | null;
|
|
@@ -10,6 +19,11 @@ export class CustomizedCadenceBulkAccountLoader extends BulkAccountLoader {
|
|
|
10
19
|
private lastPollingTimes: Map<string, number>;
|
|
11
20
|
private defaultPollingFrequency: number;
|
|
12
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @param connection Connection used for the batched `getMultipleAccounts` polls.
|
|
24
|
+
* @param commitment Commitment level applied to every poll.
|
|
25
|
+
* @param defaultPollingFrequency Polling cadence in ms (see base `BulkAccountLoader`) used for any account added without an explicit `customPollingFrequency`, and as the floor when computing the shared interval in `startPolling`.
|
|
26
|
+
*/
|
|
13
27
|
constructor(
|
|
14
28
|
connection: Connection,
|
|
15
29
|
commitment: Commitment,
|
|
@@ -47,6 +61,7 @@ export class CustomizedCadenceBulkAccountLoader extends BulkAccountLoader {
|
|
|
47
61
|
return accountsToLoad;
|
|
48
62
|
}
|
|
49
63
|
|
|
64
|
+
/** Immediately runs one due-account loading pass, bypassing the interval timer. Unlike the base class's `load()`, this does not force-load every registered account — only those currently due per their own cadence. */
|
|
50
65
|
public async load(): Promise<void> {
|
|
51
66
|
return this.handleAccountLoading();
|
|
52
67
|
}
|
|
@@ -149,6 +164,14 @@ export class CustomizedCadenceBulkAccountLoader extends BulkAccountLoader {
|
|
|
149
164
|
return callbackId;
|
|
150
165
|
}
|
|
151
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Unregisters a callback previously returned by `addAccount`. Once an account has no
|
|
169
|
+
* remaining callbacks, its cached buffer/slot and cadence bookkeeping (`accountFrequencies`,
|
|
170
|
+
* `lastPollingTimes`) are dropped; if no accounts remain at all, polling stops entirely,
|
|
171
|
+
* otherwise polling is restarted in case the removed account held the fastest cadence.
|
|
172
|
+
* @param publicKey Account the callback was registered against.
|
|
173
|
+
* @param callbackId Id returned by `addAccount`.
|
|
174
|
+
*/
|
|
152
175
|
public removeAccount(publicKey: PublicKey, callbackId: string): void {
|
|
153
176
|
const existingAccountToLoad = this.accountsToLoad.get(publicKey.toString());
|
|
154
177
|
|
|
@@ -172,11 +195,18 @@ export class CustomizedCadenceBulkAccountLoader extends BulkAccountLoader {
|
|
|
172
195
|
}
|
|
173
196
|
}
|
|
174
197
|
|
|
198
|
+
/** Returns the polling cadence in ms currently set for `publicKey` (custom or default), or `null` if the account isn't registered. */
|
|
175
199
|
public getAccountCadence(publicKey: PublicKey): number | null {
|
|
176
200
|
const key = publicKey.toBase58();
|
|
177
201
|
return this.accountFrequencies.get(key) || null;
|
|
178
202
|
}
|
|
179
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Starts the shared interval timer, ticking at the fastest cadence among all registered
|
|
206
|
+
* accounts (or `defaultPollingFrequency` if none are registered). Each tick runs
|
|
207
|
+
* `handleAccountLoading()`, which loads only the accounts due at that moment. A no-op if
|
|
208
|
+
* already running; call `stopPolling()` first to pick up a new minimum frequency.
|
|
209
|
+
*/
|
|
180
210
|
public startPolling(): void {
|
|
181
211
|
if (this.customIntervalId) {
|
|
182
212
|
return;
|
|
@@ -196,6 +226,7 @@ export class CustomizedCadenceBulkAccountLoader extends BulkAccountLoader {
|
|
|
196
226
|
}, minFrequency);
|
|
197
227
|
}
|
|
198
228
|
|
|
229
|
+
/** Stops the shared interval timer (and the base class's, via `super.stopPolling()`) and clears `lastPollingTimes` so every account is treated as due again once polling restarts. */
|
|
199
230
|
public stopPolling(): void {
|
|
200
231
|
super.stopPolling();
|
|
201
232
|
|
|
@@ -207,6 +238,12 @@ export class CustomizedCadenceBulkAccountLoader extends BulkAccountLoader {
|
|
|
207
238
|
this.lastPollingTimes.clear();
|
|
208
239
|
}
|
|
209
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Clears all per-account cadence bookkeeping. Because `getAccountsToLoad()` only considers
|
|
243
|
+
* accounts with an entry in `accountFrequencies`, this stops polling for every registered
|
|
244
|
+
* account until a cadence is re-established via `setCustomPollingFrequency` or `addAccount`.
|
|
245
|
+
* Registered accounts/callbacks themselves are untouched.
|
|
246
|
+
*/
|
|
210
247
|
public clearAccountFrequencies(): void {
|
|
211
248
|
this.accountFrequencies.clear();
|
|
212
249
|
}
|
package/src/accounts/fetch.ts
CHANGED
|
@@ -13,6 +13,15 @@ import {
|
|
|
13
13
|
} from '../addresses/pda';
|
|
14
14
|
import { VelocityProgram } from '../config';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Fetches every `UserAccount` (sub-account) belonging to `authority`, from sub-account id `0`
|
|
18
|
+
* up to `limit - 1`, in a single batched `getMultipleAccountsInfo` RPC call.
|
|
19
|
+
* @param connection Connection used for the batched fetch.
|
|
20
|
+
* @param program Anchor program used to derive PDAs and decode account data.
|
|
21
|
+
* @param authority Wallet/authority pubkey whose sub-accounts to fetch.
|
|
22
|
+
* @param limit Number of sub-account ids to check, starting at 0. Defaults to 8.
|
|
23
|
+
* @returns One entry per sub-account id in order; `undefined` where no account exists at that id.
|
|
24
|
+
*/
|
|
16
25
|
export async function fetchUserAccounts(
|
|
17
26
|
connection: Connection,
|
|
18
27
|
program: VelocityProgram,
|
|
@@ -29,6 +38,15 @@ export async function fetchUserAccounts(
|
|
|
29
38
|
return fetchUserAccountsUsingKeys(connection, program, userAccountPublicKeys);
|
|
30
39
|
}
|
|
31
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Fetches and decodes a specific list of `UserAccount` pubkeys in one batched
|
|
43
|
+
* `getMultipleAccountsInfo` RPC call. Unlike `fetchUserAccounts`, the caller supplies the exact
|
|
44
|
+
* addresses rather than deriving them by sub-account id.
|
|
45
|
+
* @param connection Connection used for the batched fetch.
|
|
46
|
+
* @param program Anchor program used to decode account data.
|
|
47
|
+
* @param userAccountPublicKeys Addresses to fetch, in order.
|
|
48
|
+
* @returns One entry per input pubkey, in the same order; `undefined` where no account exists at that address.
|
|
49
|
+
*/
|
|
32
50
|
export async function fetchUserAccountsUsingKeys(
|
|
33
51
|
connection: Connection,
|
|
34
52
|
program: VelocityProgram,
|
|
@@ -50,6 +68,13 @@ export async function fetchUserAccountsUsingKeys(
|
|
|
50
68
|
});
|
|
51
69
|
}
|
|
52
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Fetches and decodes the `UserStatsAccount` for `authority`, if one exists.
|
|
73
|
+
* @param connection Connection used for the fetch.
|
|
74
|
+
* @param program Anchor program used to derive the PDA and decode account data.
|
|
75
|
+
* @param authority Wallet/authority pubkey the stats account belongs to.
|
|
76
|
+
* @returns The decoded account, or `undefined` if it hasn't been initialized on-chain.
|
|
77
|
+
*/
|
|
53
78
|
export async function fetchUserStatsAccount(
|
|
54
79
|
connection: Connection,
|
|
55
80
|
program: VelocityProgram,
|
|
@@ -72,6 +97,14 @@ export async function fetchUserStatsAccount(
|
|
|
72
97
|
: undefined;
|
|
73
98
|
}
|
|
74
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Fetches and decodes the `RevenueShareAccount` for `authority` (tracks referral/builder revenue
|
|
102
|
+
* share balances), if one exists.
|
|
103
|
+
* @param connection Connection used for the fetch.
|
|
104
|
+
* @param program Anchor program used to derive the PDA and decode account data.
|
|
105
|
+
* @param authority Wallet/authority pubkey the revenue share account belongs to.
|
|
106
|
+
* @returns The decoded account, or `null` if it hasn't been initialized on-chain.
|
|
107
|
+
*/
|
|
75
108
|
export async function fetchRevenueShareAccount(
|
|
76
109
|
connection: Connection,
|
|
77
110
|
program: VelocityProgram,
|
|
@@ -91,6 +124,14 @@ export async function fetchRevenueShareAccount(
|
|
|
91
124
|
) as RevenueShareAccount;
|
|
92
125
|
}
|
|
93
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Fetches and decodes the `RevenueShareEscrowAccount` for `authority` (holds escrowed
|
|
129
|
+
* revenue-share amounts pending distribution), if one exists.
|
|
130
|
+
* @param connection Connection used for the fetch.
|
|
131
|
+
* @param program Anchor program used to derive the PDA and decode account data.
|
|
132
|
+
* @param authority Wallet/authority pubkey the escrow account belongs to.
|
|
133
|
+
* @returns The decoded account, or `null` if it hasn't been initialized on-chain.
|
|
134
|
+
*/
|
|
94
135
|
export async function fetchRevenueShareEscrowAccount(
|
|
95
136
|
connection: Connection,
|
|
96
137
|
program: VelocityProgram,
|
|
@@ -115,11 +156,20 @@ export async function fetchRevenueShareEscrowAccount(
|
|
|
115
156
|
return escrowAccount;
|
|
116
157
|
}
|
|
117
158
|
|
|
159
|
+
/** Options accepted by `fetchAccount`/`fetchAccounts`. */
|
|
118
160
|
export type FetchAccountOptions = {
|
|
161
|
+
/** Commitment level for the underlying `getAccountInfo`/`getMultipleAccountsInfo` call; defaults to the connection's configured commitment if omitted. */
|
|
119
162
|
commitment?: Parameters<Connection['getAccountInfo']>[1];
|
|
120
163
|
};
|
|
121
164
|
|
|
122
|
-
/**
|
|
165
|
+
/**
|
|
166
|
+
* Fetches an account's raw data buffer without decoding it (no Anchor coder involved), for
|
|
167
|
+
* callers that only need the bytes.
|
|
168
|
+
* @param connection Connection used for the fetch.
|
|
169
|
+
* @param publicKey Account address to fetch.
|
|
170
|
+
* @param opts Optional commitment override.
|
|
171
|
+
* @returns The raw account data, or `null` if the account doesn't exist.
|
|
172
|
+
*/
|
|
123
173
|
export async function fetchAccount(
|
|
124
174
|
connection: Connection,
|
|
125
175
|
publicKey: PublicKey,
|
|
@@ -129,7 +179,14 @@ export async function fetchAccount(
|
|
|
129
179
|
return info?.data ?? null;
|
|
130
180
|
}
|
|
131
181
|
|
|
132
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* Batch variant of `fetchAccount` — fetches raw data buffers for multiple accounts in one
|
|
184
|
+
* `getMultipleAccountsInfo` call.
|
|
185
|
+
* @param connection Connection used for the fetch.
|
|
186
|
+
* @param publicKeys Account addresses to fetch, in order.
|
|
187
|
+
* @param opts Optional commitment override.
|
|
188
|
+
* @returns One entry per input pubkey, in the same order; `null` where the account doesn't exist.
|
|
189
|
+
*/
|
|
133
190
|
export async function fetchAccounts(
|
|
134
191
|
connection: Connection,
|
|
135
192
|
publicKeys: PublicKey[],
|