@velocity-exchange/sdk 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -32
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +5 -3
- package/lib/browser/accounts/basicUserAccountSubscriber.js +4 -3
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +4 -3
- package/lib/browser/accounts/bulkAccountLoader.d.ts +5 -5
- package/lib/browser/accounts/bulkAccountLoader.js +12 -1
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcAccountSubscriber.js +8 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +13 -5
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +12 -8
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +8 -2
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +3 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +4 -3
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +16 -5
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +16 -5
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +8 -4
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +17 -11
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +6 -6
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
- package/lib/browser/accounts/types.d.ts +4 -4
- package/lib/browser/accounts/utils.d.ts +1 -0
- package/lib/browser/accounts/utils.js +8 -1
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketAccountSubscriber.js +17 -5
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +17 -6
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +14 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +9 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +0 -3
- package/lib/browser/addresses/marketAddresses.js +3 -2
- package/lib/browser/addresses/pda.d.ts +0 -2
- package/lib/browser/addresses/pda.js +1 -14
- package/lib/browser/adminClient.d.ts +24 -29
- package/lib/browser/adminClient.js +156 -157
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +6 -4
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/browser/bankrun/bankrunConnection.d.ts +8 -5
- package/lib/browser/bankrun/bankrunConnection.js +92 -32
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +3 -2
- package/lib/browser/clock/clockSubscriber.d.ts +6 -6
- package/lib/browser/clock/clockSubscriber.js +4 -3
- package/lib/browser/config.d.ts +1 -1
- package/lib/browser/config.js +8 -4
- package/lib/browser/constants/index.d.ts +1 -2
- package/lib/browser/constants/index.js +1 -2
- package/lib/browser/constants/numericConstants.d.ts +1 -2
- package/lib/browser/constants/numericConstants.js +7 -5
- package/lib/browser/constants/spotMarkets.d.ts +0 -1
- package/lib/browser/constituentMap/constituentMap.js +5 -1
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
- package/lib/browser/core/VelocityCore.d.ts +0 -1
- package/lib/browser/core/instructions/deposit.d.ts +0 -1
- package/lib/browser/core/instructions/perpOrders.d.ts +14 -0
- package/lib/browser/core/instructions/perpOrders.js +14 -0
- package/lib/browser/core/instructions/withdraw.d.ts +0 -1
- package/lib/browser/core/remainingAccounts.d.ts +2 -2
- package/lib/browser/core/remainingAccounts.js +2 -2
- package/lib/browser/decode/user.js +9 -1
- package/lib/browser/dlob/DLOB.d.ts +6 -2
- package/lib/browser/dlob/DLOB.js +201 -138
- package/lib/browser/dlob/DLOBNode.d.ts +5 -3
- package/lib/browser/dlob/DLOBNode.js +7 -0
- package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -1
- package/lib/browser/dlob/DLOBSubscriber.js +37 -32
- package/lib/browser/dlob/NodeList.d.ts +0 -1
- package/lib/browser/dlob/NodeList.js +8 -7
- package/lib/browser/dlob/orderBookLevels.d.ts +0 -1
- package/lib/browser/dlob/orderBookLevels.js +19 -12
- package/lib/browser/events/eventList.d.ts +3 -3
- package/lib/browser/events/eventList.js +4 -1
- package/lib/browser/events/eventSubscriber.d.ts +5 -2
- package/lib/browser/events/eventSubscriber.js +75 -26
- package/lib/browser/events/eventsServerLogProvider.d.ts +2 -2
- package/lib/browser/events/eventsServerLogProvider.js +15 -8
- package/lib/browser/events/fetchLogs.d.ts +1 -1
- package/lib/browser/events/fetchLogs.js +4 -2
- package/lib/browser/events/pollingLogProvider.d.ts +2 -2
- package/lib/browser/events/pollingLogProvider.js +1 -0
- package/lib/browser/events/txEventCache.d.ts +3 -3
- package/lib/browser/events/txEventCache.js +6 -2
- package/lib/browser/events/types.d.ts +2 -4
- package/lib/browser/events/types.js +0 -2
- package/lib/browser/events/webSocketLogProvider.d.ts +2 -2
- package/lib/browser/events/webSocketLogProvider.js +5 -2
- package/lib/browser/factory/bigNum.d.ts +0 -1
- package/lib/browser/factory/bigNum.js +1 -1
- package/lib/browser/idl/velocity.d.ts +1243 -1586
- package/lib/browser/idl/velocity.json +1234 -1577
- package/lib/browser/index.d.ts +0 -2
- package/lib/browser/index.js +0 -2
- package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/browser/jupiter/jupiterClient.d.ts +1 -2
- package/lib/browser/jupiter/jupiterClient.js +18 -8
- package/lib/browser/marginCalculation.d.ts +0 -1
- package/lib/browser/marginCalculation.js +1 -0
- package/lib/browser/marinade/index.d.ts +2 -3
- package/lib/browser/marinade/index.js +5 -0
- package/lib/browser/math/amm.d.ts +31 -14
- package/lib/browser/math/amm.js +77 -22
- package/lib/browser/math/auction.d.ts +0 -1
- package/lib/browser/math/bankruptcy.js +1 -1
- package/lib/browser/math/conversion.d.ts +0 -1
- package/lib/browser/math/funding.d.ts +0 -1
- package/lib/browser/math/funding.js +6 -6
- package/lib/browser/math/insurance.d.ts +1 -2
- package/lib/browser/math/insurance.js +4 -5
- package/lib/browser/math/liquidation.d.ts +0 -1
- package/lib/browser/math/margin.d.ts +1 -10
- package/lib/browser/math/margin.js +3 -62
- package/lib/browser/math/market.d.ts +4 -13
- package/lib/browser/math/market.js +6 -40
- package/lib/browser/math/oracles.d.ts +0 -4
- package/lib/browser/math/oracles.js +1 -14
- package/lib/browser/math/orders.d.ts +0 -6
- package/lib/browser/math/orders.js +2 -74
- package/lib/browser/math/position.d.ts +1 -6
- package/lib/browser/math/position.js +5 -10
- package/lib/browser/math/repeg.d.ts +0 -2
- package/lib/browser/math/repeg.js +1 -23
- package/lib/browser/math/spotBalance.d.ts +4 -5
- package/lib/browser/math/spotBalance.js +6 -6
- package/lib/browser/math/spotMarket.d.ts +0 -7
- package/lib/browser/math/spotMarket.js +1 -16
- package/lib/browser/math/spotPosition.d.ts +4 -5
- package/lib/browser/math/state.d.ts +0 -3
- package/lib/browser/math/state.js +1 -9
- package/lib/browser/math/superStake.d.ts +3 -54
- package/lib/browser/math/superStake.js +16 -13
- package/lib/browser/math/trade.d.ts +2 -3
- package/lib/browser/math/trade.js +6 -6
- package/lib/browser/math/utils.d.ts +0 -1
- package/lib/browser/memcmp.d.ts +0 -1
- package/lib/browser/memcmp.js +1 -10
- package/lib/browser/oracles/oracleClientCache.d.ts +1 -1
- package/lib/browser/oracles/prelaunchOracleClient.js +3 -2
- package/lib/browser/oracles/pythClient.d.ts +0 -1
- package/lib/browser/oracles/pythClient.js +9 -3
- package/lib/browser/oracles/pythLazerClient.d.ts +0 -1
- package/lib/browser/oracles/pythLazerClient.js +3 -2
- package/lib/browser/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/browser/oracles/types.d.ts +0 -1
- package/lib/browser/oracles/utils.d.ts +4 -1
- package/lib/browser/oracles/utils.js +9 -1
- package/lib/browser/orderParams.d.ts +0 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +1 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -2
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +32 -8
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/pyth/types.d.ts +0 -1
- package/lib/browser/slot/SlotSubscriber.d.ts +1 -1
- package/lib/browser/slot/SlotSubscriber.js +2 -1
- package/lib/browser/slot/SlothashSubscriber.d.ts +3 -2
- package/lib/browser/slot/SlothashSubscriber.js +11 -4
- package/lib/browser/swap/UnifiedSwapClient.d.ts +0 -1
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +13 -5
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +1 -1
- package/lib/browser/swift/swiftOrderSubscriber.js +10 -5
- package/lib/browser/testClient.js +3 -2
- package/lib/browser/titan/titanClient.d.ts +0 -1
- package/lib/browser/tokenFaucet.d.ts +0 -1
- package/lib/browser/tokenFaucet.js +16 -2
- package/lib/browser/tx/baseTxSender.d.ts +4 -4
- package/lib/browser/tx/baseTxSender.js +5 -4
- package/lib/browser/tx/fastSingleTxSender.d.ts +3 -3
- package/lib/browser/tx/fastSingleTxSender.js +9 -5
- package/lib/browser/tx/reportTransactionError.d.ts +2 -2
- package/lib/browser/tx/reportTransactionError.js +5 -1
- package/lib/browser/tx/retryTxSender.d.ts +1 -1
- package/lib/browser/tx/retryTxSender.js +4 -2
- package/lib/browser/tx/txHandler.d.ts +9 -3
- package/lib/browser/tx/txHandler.js +54 -40
- package/lib/browser/tx/txParamProcessor.d.ts +4 -1
- package/lib/browser/tx/txParamProcessor.js +6 -0
- package/lib/browser/tx/types.d.ts +1 -1
- package/lib/browser/tx/whileValidTxSender.d.ts +1 -6
- package/lib/browser/tx/whileValidTxSender.js +35 -13
- package/lib/browser/types.d.ts +25 -69
- package/lib/browser/types.js +2 -2
- package/lib/browser/user.d.ts +21 -8
- package/lib/browser/user.js +156 -132
- package/lib/browser/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/browser/userMap/grpcSubscription.d.ts +1 -1
- package/lib/browser/userMap/referrerMap.js +10 -3
- package/lib/browser/userMap/revenueShareEscrowMap.js +4 -0
- package/lib/browser/userMap/userMap.d.ts +1 -1
- package/lib/browser/userMap/userMap.js +36 -23
- package/lib/browser/userMap/userStatsMap.d.ts +1 -1
- package/lib/browser/userMap/userStatsMap.js +18 -13
- package/lib/browser/userStats.d.ts +7 -2
- package/lib/browser/userStats.js +18 -4
- package/lib/browser/util/TransactionConfirmationManager.js +4 -2
- package/lib/browser/util/chainClock.d.ts +1 -1
- package/lib/browser/util/computeUnits.d.ts +1 -1
- package/lib/browser/util/computeUnits.js +6 -1
- package/lib/browser/velocityClient.d.ts +93 -36
- package/lib/browser/velocityClient.js +414 -280
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +5 -3
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserAccountSubscriber.js +4 -3
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +4 -3
- package/lib/node/accounts/bulkAccountLoader.d.ts +5 -5
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/bulkAccountLoader.js +12 -1
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcAccountSubscriber.js +8 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +13 -5
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +12 -8
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +8 -2
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +3 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +4 -3
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +16 -5
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +16 -5
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +8 -4
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +17 -11
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +6 -6
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
- package/lib/node/accounts/types.d.ts +4 -4
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/utils.d.ts +1 -0
- package/lib/node/accounts/utils.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +8 -1
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +17 -5
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +17 -6
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +14 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +9 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +0 -3
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
- package/lib/node/addresses/marketAddresses.js +3 -2
- package/lib/node/addresses/pda.d.ts +0 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +1 -14
- package/lib/node/adminClient.d.ts +24 -29
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +156 -157
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +6 -4
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/node/bankrun/bankrunConnection.d.ts +8 -5
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.js +92 -32
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +3 -2
- package/lib/node/clock/clockSubscriber.d.ts +6 -6
- package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.js +4 -3
- package/lib/node/config.d.ts +1 -1
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +8 -4
- package/lib/node/constants/index.d.ts +1 -2
- package/lib/node/constants/index.d.ts.map +1 -1
- package/lib/node/constants/index.js +1 -2
- package/lib/node/constants/numericConstants.d.ts +1 -2
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +7 -5
- package/lib/node/constants/spotMarkets.d.ts +0 -1
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +5 -1
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
- package/lib/node/core/VelocityCore.d.ts +0 -1
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/instructions/deposit.d.ts +0 -1
- package/lib/node/core/instructions/deposit.d.ts.map +1 -1
- package/lib/node/core/instructions/perpOrders.d.ts +14 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
- package/lib/node/core/instructions/perpOrders.js +14 -0
- package/lib/node/core/instructions/withdraw.d.ts +0 -1
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.d.ts +2 -2
- package/lib/node/core/remainingAccounts.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.js +2 -2
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +9 -1
- package/lib/node/dlob/DLOB.d.ts +6 -2
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +201 -138
- package/lib/node/dlob/DLOBNode.d.ts +5 -3
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +7 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts +0 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +37 -32
- package/lib/node/dlob/NodeList.d.ts +0 -1
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.js +8 -7
- package/lib/node/dlob/orderBookLevels.d.ts +0 -1
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +19 -12
- package/lib/node/events/eventList.d.ts +3 -3
- package/lib/node/events/eventList.d.ts.map +1 -1
- package/lib/node/events/eventList.js +4 -1
- package/lib/node/events/eventSubscriber.d.ts +5 -2
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +75 -26
- package/lib/node/events/eventsServerLogProvider.d.ts +2 -2
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
- package/lib/node/events/eventsServerLogProvider.js +15 -8
- package/lib/node/events/fetchLogs.d.ts +1 -1
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.js +4 -2
- package/lib/node/events/pollingLogProvider.d.ts +2 -2
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
- package/lib/node/events/pollingLogProvider.js +1 -0
- package/lib/node/events/txEventCache.d.ts +3 -3
- package/lib/node/events/txEventCache.d.ts.map +1 -1
- package/lib/node/events/txEventCache.js +6 -2
- package/lib/node/events/types.d.ts +2 -4
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +0 -2
- package/lib/node/events/webSocketLogProvider.d.ts +2 -2
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
- package/lib/node/events/webSocketLogProvider.js +5 -2
- package/lib/node/factory/bigNum.d.ts +0 -1
- package/lib/node/factory/bigNum.d.ts.map +1 -1
- package/lib/node/factory/bigNum.js +1 -1
- package/lib/node/idl/velocity.d.ts +1243 -1586
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +1234 -1577
- package/lib/node/index.d.ts +0 -2
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -2
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.d.ts +1 -2
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.js +18 -8
- package/lib/node/marginCalculation.d.ts +0 -1
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marginCalculation.js +1 -0
- package/lib/node/marinade/index.d.ts +2 -3
- package/lib/node/marinade/index.d.ts.map +1 -1
- package/lib/node/marinade/index.js +5 -0
- package/lib/node/math/amm.d.ts +31 -14
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +77 -22
- package/lib/node/math/auction.d.ts +0 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/bankruptcy.js +1 -1
- package/lib/node/math/conversion.d.ts +0 -1
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/funding.d.ts +0 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +6 -6
- package/lib/node/math/insurance.d.ts +1 -2
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +4 -5
- package/lib/node/math/liquidation.d.ts +0 -1
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/margin.d.ts +1 -10
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +3 -62
- package/lib/node/math/market.d.ts +4 -13
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +6 -40
- package/lib/node/math/oracles.d.ts +0 -4
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +1 -14
- package/lib/node/math/orders.d.ts +0 -6
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +2 -74
- package/lib/node/math/position.d.ts +1 -6
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +5 -10
- package/lib/node/math/repeg.d.ts +0 -2
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/repeg.js +1 -23
- package/lib/node/math/spotBalance.d.ts +4 -5
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +6 -6
- package/lib/node/math/spotMarket.d.ts +0 -7
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +1 -16
- package/lib/node/math/spotPosition.d.ts +4 -5
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/state.d.ts +0 -3
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/state.js +1 -9
- package/lib/node/math/superStake.d.ts +3 -54
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +16 -13
- package/lib/node/math/trade.d.ts +2 -3
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +6 -6
- package/lib/node/math/utils.d.ts +0 -1
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/memcmp.d.ts +0 -1
- package/lib/node/memcmp.d.ts.map +1 -1
- package/lib/node/memcmp.js +1 -10
- package/lib/node/oracles/oracleClientCache.d.ts +1 -1
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +3 -2
- package/lib/node/oracles/pythClient.d.ts +0 -1
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.js +9 -3
- package/lib/node/oracles/pythLazerClient.d.ts +0 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +3 -2
- package/lib/node/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/types.d.ts +0 -1
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +4 -1
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/oracles/utils.js +9 -1
- package/lib/node/orderParams.d.ts +0 -1
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +8 -2
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +32 -8
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/pyth/types.d.ts +0 -1
- package/lib/node/pyth/types.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.d.ts +1 -1
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.js +2 -1
- package/lib/node/slot/SlothashSubscriber.d.ts +3 -2
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlothashSubscriber.js +11 -4
- package/lib/node/swap/UnifiedSwapClient.d.ts +0 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +13 -5
- package/lib/node/swift/swiftOrderSubscriber.d.ts +1 -1
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +10 -5
- package/lib/node/testClient.js +3 -2
- package/lib/node/titan/titanClient.d.ts +0 -1
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/tokenFaucet.d.ts +0 -1
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +16 -2
- package/lib/node/tx/baseTxSender.d.ts +4 -4
- package/lib/node/tx/baseTxSender.d.ts.map +1 -1
- package/lib/node/tx/baseTxSender.js +5 -4
- package/lib/node/tx/fastSingleTxSender.d.ts +3 -3
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.js +9 -5
- package/lib/node/tx/reportTransactionError.d.ts +2 -2
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
- package/lib/node/tx/reportTransactionError.js +5 -1
- package/lib/node/tx/retryTxSender.d.ts +1 -1
- package/lib/node/tx/retryTxSender.d.ts.map +1 -1
- package/lib/node/tx/retryTxSender.js +4 -2
- package/lib/node/tx/txHandler.d.ts +9 -3
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +54 -40
- package/lib/node/tx/txParamProcessor.d.ts +4 -1
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
- package/lib/node/tx/txParamProcessor.js +6 -0
- package/lib/node/tx/types.d.ts +1 -1
- package/lib/node/tx/types.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.d.ts +1 -6
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.js +35 -13
- package/lib/node/types.d.ts +25 -69
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +2 -2
- package/lib/node/user.d.ts +21 -8
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +156 -132
- package/lib/node/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/userMap/grpcSubscription.d.ts +1 -1
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +10 -3
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +4 -0
- package/lib/node/userMap/userMap.d.ts +1 -1
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +36 -23
- package/lib/node/userMap/userStatsMap.d.ts +1 -1
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +18 -13
- package/lib/node/userStats.d.ts +7 -2
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +18 -4
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
- package/lib/node/util/TransactionConfirmationManager.js +4 -2
- package/lib/node/util/chainClock.d.ts +1 -1
- package/lib/node/util/chainClock.d.ts.map +1 -1
- package/lib/node/util/computeUnits.d.ts +1 -1
- package/lib/node/util/computeUnits.d.ts.map +1 -1
- package/lib/node/util/computeUnits.js +6 -1
- package/lib/node/velocityClient.d.ts +93 -36
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +414 -280
- package/package.json +15 -8
- package/src/accounts/basicUserAccountSubscriber.ts +7 -5
- package/src/accounts/basicUserStatsAccountSubscriber.ts +9 -5
- package/src/accounts/bulkAccountLoader.ts +20 -7
- package/src/accounts/grpcAccountSubscriber.ts +11 -3
- package/src/accounts/grpcMultiAccountSubscriber.ts +24 -9
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +16 -12
- package/src/accounts/grpcProgramAccountSubscriber.ts +11 -3
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +17 -7
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +66 -39
- package/src/accounts/laserProgramAccountSubscriber.ts +3 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +5 -3
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +8 -3
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -5
- package/src/accounts/pollingOracleAccountSubscriber.ts +17 -10
- package/src/accounts/pollingTokenAccountSubscriber.ts +17 -10
- package/src/accounts/pollingUserAccountSubscriber.ts +26 -20
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +12 -10
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +76 -30
- package/src/accounts/types.ts +6 -4
- package/src/accounts/utils.ts +10 -0
- package/src/accounts/webSocketAccountSubscriber.ts +23 -10
- package/src/accounts/webSocketAccountSubscriberV2.ts +23 -8
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +17 -2
- package/src/accounts/webSocketProgramAccountSubscriber.ts +29 -4
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +30 -4
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +29 -4
- package/src/accounts/webSocketUserAccountSubscriber.ts +11 -2
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +15 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +76 -48
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +74 -35
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +1 -6
- package/src/addresses/marketAddresses.ts +3 -2
- package/src/addresses/pda.ts +0 -25
- package/src/adminClient.ts +273 -303
- package/src/auctionSubscriber/auctionSubscriber.ts +7 -5
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -5
- package/src/bankrun/bankrunConnection.ts +110 -40
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +5 -4
- package/src/clock/clockSubscriber.ts +10 -9
- package/src/config.ts +8 -3
- package/src/constants/index.ts +1 -2
- package/src/constants/numericConstants.ts +8 -4
- package/src/constituentMap/constituentMap.ts +8 -1
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +4 -2
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +13 -4
- package/src/core/instructions/perpOrders.ts +14 -0
- package/src/core/remainingAccounts.ts +4 -4
- package/src/decode/user.ts +8 -1
- package/src/dlob/DLOB.ts +296 -172
- package/src/dlob/DLOBNode.ts +23 -3
- package/src/dlob/DLOBSubscriber.ts +51 -34
- package/src/dlob/NodeList.ts +8 -7
- package/src/dlob/orderBookLevels.ts +45 -25
- package/src/events/eventList.ts +4 -1
- package/src/events/eventSubscriber.ts +107 -49
- package/src/events/eventsServerLogProvider.ts +22 -13
- package/src/events/fetchLogs.ts +3 -3
- package/src/events/pollingLogProvider.ts +2 -2
- package/src/events/txEventCache.ts +8 -2
- package/src/events/types.ts +0 -8
- package/src/events/webSocketLogProvider.ts +5 -3
- package/src/factory/bigNum.ts +2 -2
- package/src/idl/velocity.json +1234 -1577
- package/src/idl/velocity.ts +1234 -1577
- package/src/index.ts +0 -2
- package/src/jupiter/jupiterClient.ts +30 -10
- package/src/marginCalculation.ts +1 -0
- package/src/marinade/index.ts +11 -2
- package/src/math/amm.ts +188 -33
- package/src/math/bankruptcy.ts +1 -1
- package/src/math/funding.ts +7 -6
- package/src/math/insurance.ts +6 -8
- package/src/math/margin.ts +5 -112
- package/src/math/market.ts +6 -96
- package/src/math/oracles.ts +0 -17
- package/src/math/orders.ts +1 -110
- package/src/math/position.ts +4 -16
- package/src/math/repeg.ts +0 -29
- package/src/math/spotBalance.ts +14 -10
- package/src/math/spotMarket.ts +2 -28
- package/src/math/spotPosition.ts +4 -4
- package/src/math/state.ts +0 -8
- package/src/math/superStake.ts +19 -65
- package/src/math/trade.ts +2 -6
- package/src/memcmp.ts +0 -9
- package/src/oracles/prelaunchOracleClient.ts +7 -2
- package/src/oracles/pythClient.ts +12 -3
- package/src/oracles/pythLazerClient.ts +7 -2
- package/src/oracles/utils.ts +15 -0
- package/src/orderSubscriber/OrderSubscriber.ts +10 -4
- package/src/priorityFee/heliusPriorityFeeMethod.ts +1 -1
- package/src/priorityFee/priorityFeeSubscriber.ts +45 -9
- package/src/priorityFee/solanaPriorityFeeMethod.ts +1 -1
- package/src/pyth/types.ts +0 -2
- package/src/slot/SlotSubscriber.ts +3 -3
- package/src/slot/SlothashSubscriber.ts +17 -6
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +5 -6
- package/src/swift/signedMsgUserAccountSubscriber.ts +16 -8
- package/src/swift/swiftOrderSubscriber.ts +10 -9
- package/src/testClient.ts +2 -2
- package/src/tokenFaucet.ts +22 -3
- package/src/tx/baseTxSender.ts +10 -10
- package/src/tx/fastSingleTxSender.ts +12 -8
- package/src/tx/reportTransactionError.ts +12 -7
- package/src/tx/retryTxSender.ts +6 -4
- package/src/tx/txHandler.ts +88 -43
- package/src/tx/txParamProcessor.ts +18 -3
- package/src/tx/types.ts +1 -1
- package/src/tx/whileValidTxSender.ts +51 -22
- package/src/types.ts +39 -75
- package/src/user.ts +200 -152
- package/src/userMap/WebsocketSubscription.ts +1 -1
- package/src/userMap/grpcSubscription.ts +1 -1
- package/src/userMap/referrerMap.ts +14 -10
- package/src/userMap/revenueShareEscrowMap.ts +8 -3
- package/src/userMap/userMap.ts +43 -25
- package/src/userMap/userStatsMap.ts +32 -19
- package/src/userStats.ts +21 -8
- package/src/util/TransactionConfirmationManager.ts +10 -2
- package/src/util/chainClock.ts +1 -1
- package/src/util/computeUnits.ts +7 -3
- package/src/velocityClient.ts +536 -383
- package/tests/VelocityCore/remainingAccounts.test.ts +4 -5
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +19 -11
- package/tests/amm/test.ts +300 -95
- package/tests/decode/userAccountBufferStrings.ts +100 -100
- package/tests/dlob/helpers.ts +162 -173
- package/tests/dlob/test.ts +155 -106
- package/tests/tx/TransactionConfirmationManager.test.ts +9 -2
- package/tests/user/getMarginCalculation.ts +1 -1
- package/tests/user/helpers.ts +3 -4
- package/tests/user/marginCalculations.test.ts +2 -2
- package/tests/user/test.ts +3 -3
- package/tsconfig.browser.json +3 -1
- package/tsconfig.json +21 -2
- package/.yarn/install-state.gz +0 -0
- package/VERSION +0 -1
- package/bun.lock +0 -1885
- package/lib/browser/constants/insuranceFund.d.ts +0 -5
- package/lib/browser/constants/insuranceFund.js +0 -9
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +0 -37
- package/lib/browser/tx/forwardOnlyTxSender.js +0 -92
- package/lib/browser/util/tps.d.ts +0 -2
- package/lib/browser/util/tps.js +0 -16
- package/lib/node/constants/insuranceFund.d.ts +0 -6
- package/lib/node/constants/insuranceFund.d.ts.map +0 -1
- package/lib/node/constants/insuranceFund.js +0 -9
- package/lib/node/tx/forwardOnlyTxSender.d.ts +0 -38
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +0 -1
- package/lib/node/tx/forwardOnlyTxSender.js +0 -92
- package/lib/node/util/tps.d.ts +0 -3
- package/lib/node/util/tps.d.ts.map +0 -1
- package/lib/node/util/tps.js +0 -16
- package/scripts/updateVersion.js +0 -28
- package/src/constants/insuranceFund.ts +0 -8
- package/src/tx/forwardOnlyTxSender.ts +0 -145
- package/src/util/tps.ts +0 -27
- package/tests/decode/phoenix.ts +0 -71
|
@@ -70,8 +70,10 @@ class RetryTxSender extends baseTxSender_1.BaseTxSender {
|
|
|
70
70
|
try {
|
|
71
71
|
const result = await this.confirmTransaction(txid, opts.commitment);
|
|
72
72
|
(_b = this.txSigCache) === null || _b === void 0 ? void 0 : _b.set(txid, true);
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
if (result) {
|
|
74
|
+
await this.checkConfirmationResultForError(txid, result.value);
|
|
75
|
+
slot = (_c = result.context) === null || _c === void 0 ? void 0 : _c.slot;
|
|
76
|
+
}
|
|
75
77
|
// eslint-disable-next-line no-useless-catch
|
|
76
78
|
}
|
|
77
79
|
catch (e) {
|
|
@@ -17,7 +17,7 @@ export type TxBuildingProps = {
|
|
|
17
17
|
instructions: TransactionInstruction | TransactionInstruction[];
|
|
18
18
|
txVersion: TransactionVersion;
|
|
19
19
|
connection: Connection;
|
|
20
|
-
preFlightCommitment
|
|
20
|
+
preFlightCommitment?: Commitment;
|
|
21
21
|
fetchAllMarketLookupTableAccounts: () => Promise<AddressLookupTableAccount[]>;
|
|
22
22
|
lookupTables?: AddressLookupTableAccount[];
|
|
23
23
|
forceVersionedTransaction?: boolean;
|
|
@@ -73,7 +73,13 @@ export declare class TxHandler {
|
|
|
73
73
|
getLatestBlockhashForTransaction(): Promise<Readonly<{
|
|
74
74
|
blockhash: string;
|
|
75
75
|
lastValidBlockHeight: number;
|
|
76
|
-
}
|
|
76
|
+
}> | undefined>;
|
|
77
|
+
/**
|
|
78
|
+
* Resolves a usable recent blockhash, preferring a caller-provided one and
|
|
79
|
+
* otherwise fetching the latest. Throws if no blockhash can be obtained,
|
|
80
|
+
* since a transaction cannot be built or signed without one.
|
|
81
|
+
*/
|
|
82
|
+
private resolveRecentBlockhash;
|
|
77
83
|
/**
|
|
78
84
|
* Applies recent blockhash and signs a given transaction
|
|
79
85
|
* @param tx
|
|
@@ -109,7 +115,7 @@ export declare class TxHandler {
|
|
|
109
115
|
*/
|
|
110
116
|
buildBulkTransactions(props: Omit<TxBuildingProps, 'instructions'> & {
|
|
111
117
|
instructions: (TransactionInstruction | TransactionInstruction[])[];
|
|
112
|
-
}): Promise<(Transaction | VersionedTransaction)[]>;
|
|
118
|
+
}): Promise<(Transaction | VersionedTransaction | undefined)[]>;
|
|
113
119
|
/**
|
|
114
120
|
*
|
|
115
121
|
* @param instructions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../../src/tx/txHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACN,yBAAyB,EACzB,8BAA8B,EAC9B,UAAU,EAEV,cAAc,EACd,UAAU,EAGV,MAAM,EACN,4BAA4B,EAC5B,WAAW,EACX,sBAAsB,EAEtB,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAEN,2BAA2B,EAC3B,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,QA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S = 2000; // Reuse blockhashes within this ti
|
|
|
39
39
|
*/
|
|
40
40
|
class TxHandler {
|
|
41
41
|
constructor(props) {
|
|
42
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
42
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
43
43
|
this.blockHashToLastValidBlockHeightLookup = {};
|
|
44
44
|
this.returnBlockHeightsWithSignedTxCallbackData = false;
|
|
45
|
-
this.blockhashCommitment = config_1.DEFAULT_CONFIRMATION_OPTS.commitment;
|
|
45
|
+
this.blockhashCommitment = (_a = config_1.DEFAULT_CONFIRMATION_OPTS.commitment) !== null && _a !== void 0 ? _a : 'confirmed';
|
|
46
46
|
this.getProps = (wallet, confirmationOpts) => [wallet !== null && wallet !== void 0 ? wallet : this.wallet, confirmationOpts !== null && confirmationOpts !== void 0 ? confirmationOpts : this.confirmationOptions];
|
|
47
47
|
this.connection = props.connection;
|
|
48
48
|
this.wallet = props.wallet;
|
|
49
49
|
this.confirmationOptions = props.confirmationOptions;
|
|
50
50
|
this.blockhashCommitment =
|
|
51
|
-
(
|
|
52
|
-
this.blockHashFetcher = ((
|
|
53
|
-
? new cachedBlockhashFetcher_1.CachedBlockhashFetcher(this.connection, this.blockhashCommitment, (
|
|
51
|
+
(_f = (_e = (_c = (_b = props.confirmationOptions) === null || _b === void 0 ? void 0 : _b.preflightCommitment) !== null && _c !== void 0 ? _c : (_d = props === null || props === void 0 ? void 0 : props.connection) === null || _d === void 0 ? void 0 : _d.commitment) !== null && _e !== void 0 ? _e : this.blockhashCommitment) !== null && _f !== void 0 ? _f : 'confirmed';
|
|
52
|
+
this.blockHashFetcher = ((_g = props === null || props === void 0 ? void 0 : props.config) === null || _g === void 0 ? void 0 : _g.blockhashCachingEnabled)
|
|
53
|
+
? new cachedBlockhashFetcher_1.CachedBlockhashFetcher(this.connection, this.blockhashCommitment, (_k = (_j = (_h = props === null || props === void 0 ? void 0 : props.config) === null || _h === void 0 ? void 0 : _h.blockhashCachingConfig) === null || _j === void 0 ? void 0 : _j.retryCount) !== null && _k !== void 0 ? _k : BLOCKHASH_FETCH_RETRY_COUNT, (_o = (_m = (_l = props === null || props === void 0 ? void 0 : props.config) === null || _l === void 0 ? void 0 : _l.blockhashCachingConfig) === null || _m === void 0 ? void 0 : _m.retrySleepTimeMs) !== null && _o !== void 0 ? _o : BLOCKHASH_FETCH_RETRY_SLEEP, (_r = (_q = (_p = props === null || props === void 0 ? void 0 : props.config) === null || _p === void 0 ? void 0 : _p.blockhashCachingConfig) === null || _q === void 0 ? void 0 : _q.staleCacheTimeMs) !== null && _r !== void 0 ? _r : RECENT_BLOCKHASH_STALE_TIME_MS)
|
|
54
54
|
: new baseBlockhashFetcher_1.BaseBlockhashFetcher(this.connection, this.blockhashCommitment);
|
|
55
55
|
// #Optionals
|
|
56
56
|
this.returnBlockHeightsWithSignedTxCallbackData =
|
|
57
|
-
(
|
|
58
|
-
this.onSignedCb = (
|
|
59
|
-
this.preSignedCb = (
|
|
57
|
+
(_t = (_s = props.opts) === null || _s === void 0 ? void 0 : _s.returnBlockHeightsWithSignedTxCallbackData) !== null && _t !== void 0 ? _t : false;
|
|
58
|
+
this.onSignedCb = (_u = props.opts) === null || _u === void 0 ? void 0 : _u.onSignedCb;
|
|
59
|
+
this.preSignedCb = (_v = props.opts) === null || _v === void 0 ? void 0 : _v.preSignedCb;
|
|
60
60
|
}
|
|
61
61
|
getWallet() {
|
|
62
62
|
return this.wallet;
|
|
@@ -80,6 +80,18 @@ class TxHandler {
|
|
|
80
80
|
async getLatestBlockhashForTransaction() {
|
|
81
81
|
return this.blockHashFetcher.getLatestBlockhash();
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Resolves a usable recent blockhash, preferring a caller-provided one and
|
|
85
|
+
* otherwise fetching the latest. Throws if no blockhash can be obtained,
|
|
86
|
+
* since a transaction cannot be built or signed without one.
|
|
87
|
+
*/
|
|
88
|
+
async resolveRecentBlockhash(recentBlockhash) {
|
|
89
|
+
const resolved = recentBlockhash !== null && recentBlockhash !== void 0 ? recentBlockhash : (await this.getLatestBlockhashForTransaction());
|
|
90
|
+
if (!resolved) {
|
|
91
|
+
throw new Error('TxHandler: failed to fetch a recent blockhash');
|
|
92
|
+
}
|
|
93
|
+
return resolved;
|
|
94
|
+
}
|
|
83
95
|
/**
|
|
84
96
|
* Applies recent blockhash and signs a given transaction
|
|
85
97
|
* @param tx
|
|
@@ -96,14 +108,12 @@ class TxHandler {
|
|
|
96
108
|
}
|
|
97
109
|
[wallet, confirmationOpts] = this.getProps(wallet, confirmationOpts);
|
|
98
110
|
tx.feePayer = wallet.publicKey;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
tx.recentBlockhash = recentBlockhash.blockhash;
|
|
103
|
-
this.addHashAndExpiryToLookup(recentBlockhash);
|
|
111
|
+
const resolvedBlockhash = await this.resolveRecentBlockhash(recentBlockhash);
|
|
112
|
+
tx.recentBlockhash = resolvedBlockhash.blockhash;
|
|
113
|
+
this.addHashAndExpiryToLookup(resolvedBlockhash);
|
|
104
114
|
const signedTx = await this.signTx(tx, additionalSigners);
|
|
105
115
|
// @ts-ignore
|
|
106
|
-
signedTx.SIGNATURE_BLOCK_AND_EXPIRY =
|
|
116
|
+
signedTx.SIGNATURE_BLOCK_AND_EXPIRY = resolvedBlockhash;
|
|
107
117
|
return signedTx;
|
|
108
118
|
}
|
|
109
119
|
isVersionedTransaction(tx) {
|
|
@@ -117,16 +127,21 @@ class TxHandler {
|
|
|
117
127
|
return bs58_1.default.encode(Buffer.from(signedTx.signatures[0]));
|
|
118
128
|
}
|
|
119
129
|
else {
|
|
120
|
-
|
|
130
|
+
const signature = signedTx.signature;
|
|
131
|
+
if (!signature) {
|
|
132
|
+
throw new Error('TxHandler: cannot derive txSig from an unsigned legacy transaction');
|
|
133
|
+
}
|
|
134
|
+
return bs58_1.default.encode(Buffer.from(signature));
|
|
121
135
|
}
|
|
122
136
|
}
|
|
123
137
|
getBlockhashFromSignedTx(signedTx) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
138
|
+
const blockHash = this.isVersionedTransaction(signedTx)
|
|
139
|
+
? signedTx.message.recentBlockhash
|
|
140
|
+
: signedTx.recentBlockhash;
|
|
141
|
+
if (!blockHash) {
|
|
142
|
+
throw new Error('TxHandler: signed transaction is missing a recentBlockhash');
|
|
129
143
|
}
|
|
144
|
+
return blockHash;
|
|
130
145
|
}
|
|
131
146
|
async signTx(tx, additionalSigners, wallet) {
|
|
132
147
|
var _a;
|
|
@@ -180,7 +195,7 @@ class TxHandler {
|
|
|
180
195
|
if (this.onSignedCb) {
|
|
181
196
|
this.onSignedCb(txData);
|
|
182
197
|
}
|
|
183
|
-
return;
|
|
198
|
+
return [];
|
|
184
199
|
}
|
|
185
200
|
const signedTxData = txData.map((tx) => {
|
|
186
201
|
const lastValidBlockHeight = this.blockHashToLastValidBlockHeightLookup[tx.blockHash];
|
|
@@ -200,7 +215,7 @@ class TxHandler {
|
|
|
200
215
|
* @returns
|
|
201
216
|
*/
|
|
202
217
|
async getProcessedTransactionParams(txBuildingProps) {
|
|
203
|
-
var _a, _b;
|
|
218
|
+
var _a, _b, _c, _d, _e, _f;
|
|
204
219
|
const baseTxParams = {
|
|
205
220
|
computeUnits: (_a = txBuildingProps === null || txBuildingProps === void 0 ? void 0 : txBuildingProps.txParams) === null || _a === void 0 ? void 0 : _a.computeUnits,
|
|
206
221
|
computeUnitsPrice: (_b = txBuildingProps === null || txBuildingProps === void 0 ? void 0 : txBuildingProps.txParams) === null || _b === void 0 ? void 0 : _b.computeUnitsPrice,
|
|
@@ -216,11 +231,10 @@ class TxHandler {
|
|
|
216
231
|
});
|
|
217
232
|
},
|
|
218
233
|
processConfig: {
|
|
219
|
-
useSimulatedComputeUnits: txBuildingProps.txParams.useSimulatedComputeUnits,
|
|
220
|
-
computeUnitsBufferMultiplier: txBuildingProps.txParams.computeUnitsBufferMultiplier,
|
|
221
|
-
useSimulatedComputeUnitsForCUPriceCalculation: txBuildingProps.txParams
|
|
222
|
-
|
|
223
|
-
getCUPriceFromComputeUnits: txBuildingProps.txParams.getCUPriceFromComputeUnits,
|
|
234
|
+
useSimulatedComputeUnits: (_c = txBuildingProps.txParams) === null || _c === void 0 ? void 0 : _c.useSimulatedComputeUnits,
|
|
235
|
+
computeUnitsBufferMultiplier: (_d = txBuildingProps.txParams) === null || _d === void 0 ? void 0 : _d.computeUnitsBufferMultiplier,
|
|
236
|
+
useSimulatedComputeUnitsForCUPriceCalculation: (_e = txBuildingProps.txParams) === null || _e === void 0 ? void 0 : _e.useSimulatedComputeUnitsForCUPriceCalculation,
|
|
237
|
+
getCUPriceFromComputeUnits: (_f = txBuildingProps.txParams) === null || _f === void 0 ? void 0 : _f.getCUPriceFromComputeUnits,
|
|
224
238
|
},
|
|
225
239
|
processParams: {
|
|
226
240
|
connection: this.connection,
|
|
@@ -270,8 +284,7 @@ class TxHandler {
|
|
|
270
284
|
* @returns
|
|
271
285
|
*/
|
|
272
286
|
async buildBulkTransactions(props) {
|
|
273
|
-
|
|
274
|
-
const recentBlockhash = (_a = props === null || props === void 0 ? void 0 : props.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.getLatestBlockhashForTransaction());
|
|
287
|
+
const recentBlockhash = await this.resolveRecentBlockhash(props === null || props === void 0 ? void 0 : props.recentBlockhash);
|
|
275
288
|
return await Promise.all(props.instructions.map((ix) => {
|
|
276
289
|
if (!ix)
|
|
277
290
|
return undefined;
|
|
@@ -292,7 +305,6 @@ class TxHandler {
|
|
|
292
305
|
* @returns
|
|
293
306
|
*/
|
|
294
307
|
async buildTransaction(props) {
|
|
295
|
-
var _a;
|
|
296
308
|
const { txVersion, txParams, connection: _connection, preFlightCommitment: _preFlightCommitment, fetchAllMarketLookupTableAccounts, forceVersionedTransaction, instructions, } = props;
|
|
297
309
|
let { lookupTables } = props;
|
|
298
310
|
const marketLookupTables = await fetchAllMarketLookupTableAccounts();
|
|
@@ -339,7 +351,9 @@ class TxHandler {
|
|
|
339
351
|
// # Create Tx Instructions
|
|
340
352
|
const allIx = [];
|
|
341
353
|
const computeUnits = baseTxParams === null || baseTxParams === void 0 ? void 0 : baseTxParams.computeUnits;
|
|
342
|
-
if (computeUnits
|
|
354
|
+
if (computeUnits !== undefined &&
|
|
355
|
+
computeUnits > 0 &&
|
|
356
|
+
!hasSetComputeUnitLimitIx) {
|
|
343
357
|
allIx.push(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
344
358
|
units: computeUnits,
|
|
345
359
|
}));
|
|
@@ -350,13 +364,15 @@ class TxHandler {
|
|
|
350
364
|
microLamports: 0,
|
|
351
365
|
}));
|
|
352
366
|
}
|
|
353
|
-
else if (computeUnitsPrice
|
|
367
|
+
else if (computeUnitsPrice !== undefined &&
|
|
368
|
+
computeUnitsPrice > 0 &&
|
|
369
|
+
!hasSetComputeUnitPriceIx) {
|
|
354
370
|
allIx.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
355
371
|
microLamports: computeUnitsPrice,
|
|
356
372
|
}));
|
|
357
373
|
}
|
|
358
374
|
allIx.push(...instructionsToUse);
|
|
359
|
-
const recentBlockhash = (
|
|
375
|
+
const recentBlockhash = await this.resolveRecentBlockhash(props === null || props === void 0 ? void 0 : props.recentBlockhash);
|
|
360
376
|
// # Create and return Transaction
|
|
361
377
|
if (txVersion === 'legacy') {
|
|
362
378
|
if (forceVersionedTransaction) {
|
|
@@ -399,17 +415,15 @@ class TxHandler {
|
|
|
399
415
|
*/
|
|
400
416
|
async getPreparedAndSignedLegacyTransactionMap(txsMap, wallet, commitment, recentBlockhash) {
|
|
401
417
|
var _a, _b;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
: await this.getLatestBlockhashForTransaction();
|
|
405
|
-
this.addHashAndExpiryToLookup(recentBlockhash);
|
|
418
|
+
const resolvedBlockhash = await this.resolveRecentBlockhash(recentBlockhash);
|
|
419
|
+
this.addHashAndExpiryToLookup(resolvedBlockhash);
|
|
406
420
|
for (const tx of Object.values(txsMap)) {
|
|
407
421
|
if (!tx)
|
|
408
422
|
continue;
|
|
409
|
-
tx.recentBlockhash =
|
|
423
|
+
tx.recentBlockhash = resolvedBlockhash.blockhash;
|
|
410
424
|
tx.feePayer = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.publicKey) !== null && _a !== void 0 ? _a : (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.publicKey;
|
|
411
425
|
// @ts-ignore
|
|
412
|
-
tx.SIGNATURE_BLOCK_AND_EXPIRY =
|
|
426
|
+
tx.SIGNATURE_BLOCK_AND_EXPIRY = resolvedBlockhash;
|
|
413
427
|
}
|
|
414
428
|
return this.getSignedTransactionMap(txsMap, wallet);
|
|
415
429
|
}
|
|
@@ -429,7 +443,7 @@ class TxHandler {
|
|
|
429
443
|
acc[key] = undefined;
|
|
430
444
|
return acc;
|
|
431
445
|
}, {});
|
|
432
|
-
const filteredTxEntries = txsToSignEntries.filter((
|
|
446
|
+
const filteredTxEntries = txsToSignEntries.filter((entry) => !!entry[1]);
|
|
433
447
|
// Extra handling for legacy transactions
|
|
434
448
|
for (const [_key, tx] of filteredTxEntries) {
|
|
435
449
|
if (this.isLegacyTransaction(tx)) {
|
|
@@ -10,8 +10,11 @@ export declare class TransactionParamProcessor {
|
|
|
10
10
|
private static getComputeUnitsFromSim;
|
|
11
11
|
static getTxSimComputeUnits(tx: VersionedTransaction, connection: Connection, bufferMultiplier: number, // Making this a mandatory param to force the user to remember that simulated CU's can be inaccurate and a buffer should be applied
|
|
12
12
|
lowerBoundCu?: number, simulatedTx?: SimulatedTransactionResponse): Promise<{
|
|
13
|
-
success:
|
|
13
|
+
success: true;
|
|
14
14
|
computeUnits: number;
|
|
15
|
+
} | {
|
|
16
|
+
success: false;
|
|
17
|
+
computeUnits: undefined;
|
|
15
18
|
}>;
|
|
16
19
|
static process(props: {
|
|
17
20
|
baseTxParams: BaseTxParams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txParamProcessor.d.ts","sourceRoot":"","sources":["../../../src/tx/txParamProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EAEV,4BAA4B,EAC5B,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAO5D,KAAK,wBAAwB,GAAG;IAC/B,QAAQ,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,qBAAa,yBAAyB;mBAChB,sBAAsB;WAUvB,oBAAoB,CACvC,EAAE,EAAE,oBAAoB,EACxB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,MAAM,EAAE,mIAAmI;IAC7J,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,4BAA4B,GACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"txParamProcessor.d.ts","sourceRoot":"","sources":["../../../src/tx/txParamProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EAEV,4BAA4B,EAC5B,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAO5D,KAAK,wBAAwB,GAAG;IAC/B,QAAQ,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,qBAAa,yBAAyB;mBAChB,sBAAsB;WAUvB,oBAAoB,CACvC,EAAE,EAAE,oBAAoB,EACxB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,MAAM,EAAE,mIAAmI;IAC7J,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,4BAA4B,GACxC,OAAO,CACP;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GACvC;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,YAAY,EAAE,SAAS,CAAA;KAAE,CAC7C;WAuDY,OAAO,CAAC,KAAK,EAAE;QAC3B,YAAY,EAAE,YAAY,CAAC;QAC3B,aAAa,EAAE,kBAAkB,CAAC;QAClC,aAAa,EAAE;YACd,UAAU,EAAE,UAAU,CAAC;YACvB,WAAW,CAAC,EAAE,4BAA4B,CAAC;SAC3C,CAAC;QACF,SAAS,EAAE,CACV,oBAAoB,EAAE,wBAAwB,KAC1C,OAAO,CAAC,oBAAoB,CAAC,CAAC;KACnC,GAAG,OAAO,CAAC,YAAY,CAAC;CAwEzB"}
|
|
@@ -32,6 +32,9 @@ class TransactionParamProcessor {
|
|
|
32
32
|
throw (_b = simTxResult === null || simTxResult === void 0 ? void 0 : simTxResult.value) === null || _b === void 0 ? void 0 : _b.err;
|
|
33
33
|
}
|
|
34
34
|
const computeUnits = await this.getComputeUnitsFromSim(simTxResult);
|
|
35
|
+
if (computeUnits === undefined) {
|
|
36
|
+
throw new Error('TransactionParamProcessor: simulation did not return units consumed');
|
|
37
|
+
}
|
|
35
38
|
// Apply the buffer, but round down to the MAX_COMPUTE_UNITS, and round up to the nearest whole number
|
|
36
39
|
let bufferedComputeUnits = Math.ceil(Math.min(computeUnits * bufferMultiplier, MAX_COMPUTE_UNITS));
|
|
37
40
|
// If a lower bound CU is passed then enforce it
|
|
@@ -81,6 +84,9 @@ class TransactionParamProcessor {
|
|
|
81
84
|
throw new Error(`encountered useSimulatedComputeUnitsForFees=true, but getComputeUnitPriceFromUnitsToUse helper method is undefined`);
|
|
82
85
|
}
|
|
83
86
|
const simulatedComputeUnits = finalTxParams.computeUnits;
|
|
87
|
+
if (simulatedComputeUnits === undefined) {
|
|
88
|
+
throw new Error(`encountered useSimulatedComputeUnitsForFees=true, but simulated compute units are unavailable (simulation likely failed)`);
|
|
89
|
+
}
|
|
84
90
|
const computeUnitPrice = processConfig.getCUPriceFromComputeUnits(simulatedComputeUnits);
|
|
85
91
|
console.debug(`🔧:: Adjusting compute unit price for simulated compute unit budget :: ${finalTxParams.computeUnitsPrice}=>${computeUnitPrice}`);
|
|
86
92
|
finalTxParams.computeUnitsPrice = computeUnitPrice;
|
package/lib/node/tx/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tx/types.ts"],"names":[],"mappings":";;AAAA,OAAO,EACN,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,EACd,MAAM,EACN,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,oBAAY,oBAAoB;IAC/B,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,KAAK,UAAU;CACf;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,oBAAoB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tx/types.ts"],"names":[],"mappings":";;AAAA,OAAO,EACN,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,EACd,MAAM,EACN,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,oBAAY,oBAAoB;IAC/B,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,KAAK,UAAU;CACf;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,KAAK,EAAE,oBAAoB,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,QAAQ;IACxB,MAAM,EAAE,OAAO,CAAC;IAEhB,IAAI,CACH,EAAE,EAAE,WAAW,EACf,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACjC,IAAI,CAAC,EAAE,cAAc,EACrB,SAAS,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzB,wBAAwB,CACvB,EAAE,EAAE,oBAAoB,EACxB,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACjC,IAAI,CAAC,EAAE,cAAc,EACrB,SAAS,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzB,uBAAuB,CACtB,GAAG,EAAE,sBAAsB,EAAE,EAC7B,mBAAmB,EAAE,yBAAyB,EAAE,EAChD,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACjC,IAAI,CAAC,EAAE,cAAc,EACrB,SAAS,CAAC,EAAE,8BAA8B,GACxC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEjC,kBAAkB,CACjB,cAAc,EAAE,MAAM,GAAG,UAAU,EACnC,IAAI,EAAE,cAAc,GAClB,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzB,mBAAmB,CAAC,EAAE,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhE,eAAe,IAAI,MAAM,CAAC;IAC1B,iCAAiC,IAAI,MAAM,CAAC;IAC5C,aAAa,IAAI,MAAM,CAAC;CACxB;AAED,qBAAa,WAAY,SAAQ,KAAK;IAE7B,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,MAAM;gBADZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM;CAOpB"}
|
|
@@ -9,12 +9,7 @@ type ResolveReference = {
|
|
|
9
9
|
resolve?: () => void;
|
|
10
10
|
};
|
|
11
11
|
export declare class WhileValidTxSender extends BaseTxSender {
|
|
12
|
-
connection: Connection;
|
|
13
|
-
wallet: IWallet;
|
|
14
|
-
opts: ConfirmOptions;
|
|
15
|
-
timeout: number;
|
|
16
12
|
retrySleep: number;
|
|
17
|
-
additionalConnections: Connection[];
|
|
18
13
|
timoutCount: number;
|
|
19
14
|
untilValid: Map<string, {
|
|
20
15
|
blockhash: string;
|
|
@@ -27,7 +22,7 @@ export declare class WhileValidTxSender extends BaseTxSender {
|
|
|
27
22
|
wallet: IWallet;
|
|
28
23
|
opts?: ConfirmOptions;
|
|
29
24
|
retrySleep?: number;
|
|
30
|
-
additionalConnections?:
|
|
25
|
+
additionalConnections?: Connection[];
|
|
31
26
|
additionalTxSenderCallbacks?: ((base58EncodedTx: string) => void)[];
|
|
32
27
|
confirmationStrategy?: ConfirmationStrategy;
|
|
33
28
|
txHandler?: TxHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whileValidTxSender.d.ts","sourceRoot":"","sources":["../../../src/tx/whileValidTxSender.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EACN,cAAc,EACd,UAAU,EAEV,MAAM,EACN,WAAW,EACX,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKnC,KAAK,gBAAgB,GAAG;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,YAAY;IACnD,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"whileValidTxSender.d.ts","sourceRoot":"","sources":["../../../src/tx/whileValidTxSender.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EACN,cAAc,EACd,UAAU,EAEV,MAAM,EACN,WAAW,EACX,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB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,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,EAChC,IAAI,EAAE,cAAc,EACpB,SAAS,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,WAAW,CAAC;IAgDjB,wBAAwB,CAC7B,EAAE,EAAE,oBAAoB,EACxB,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACjC,IAAI,CAAC,EAAE,cAAc,EACrB,SAAS,CAAC,EAAE,OAAO,GACjB,OAAO,CAAC,YAAY,CAAC;IA8DlB,kBAAkB,CACvB,cAAc,EAAE,MAAM,GAAG,UAAU,EACnC,IAAI,EAAE,cAAc,GAClB,OAAO,CAAC,YAAY,CAAC;CA+DxB"}
|
|
@@ -60,6 +60,9 @@ class WhileValidTxSender extends baseTxSender_1.BaseTxSender {
|
|
|
60
60
|
async prepareTx(tx, additionalSigners, opts, preSigned) {
|
|
61
61
|
var _a;
|
|
62
62
|
let latestBlockhash = await this.txHandler.getLatestBlockhashForTransaction();
|
|
63
|
+
if (!latestBlockhash) {
|
|
64
|
+
throw new Error('WhileValidTxSender: failed to fetch latest blockhash for transaction');
|
|
65
|
+
}
|
|
63
66
|
// handle tx
|
|
64
67
|
let signedTx = tx;
|
|
65
68
|
if (!preSigned) {
|
|
@@ -72,12 +75,22 @@ class WhileValidTxSender extends baseTxSender_1.BaseTxSender {
|
|
|
72
75
|
latestBlockhash = tx.SIGNATURE_BLOCK_AND_EXPIRY;
|
|
73
76
|
}
|
|
74
77
|
// handle subclass-specific side effects
|
|
75
|
-
const
|
|
78
|
+
const signature = (signedTx === null || signedTx === void 0 ? void 0 : signedTx.signature) || ((_a = signedTx.signatures[0]) === null || _a === void 0 ? void 0 : _a.signature);
|
|
79
|
+
if (!signature) {
|
|
80
|
+
throw new Error('WhileValidTxSender: signed transaction is missing a signature');
|
|
81
|
+
}
|
|
82
|
+
const txSig = bs58_1.default.encode(signature);
|
|
83
|
+
if (!latestBlockhash) {
|
|
84
|
+
throw new Error('WhileValidTxSender: failed to resolve latest blockhash for transaction');
|
|
85
|
+
}
|
|
76
86
|
this.untilValid.set(txSig, latestBlockhash);
|
|
77
87
|
return signedTx;
|
|
78
88
|
}
|
|
79
89
|
async sendVersionedTransaction(tx, additionalSigners, opts, preSigned) {
|
|
80
90
|
let latestBlockhash = await this.txHandler.getLatestBlockhashForTransaction();
|
|
91
|
+
if (!latestBlockhash) {
|
|
92
|
+
throw new Error('WhileValidTxSender: failed to fetch latest blockhash for transaction');
|
|
93
|
+
}
|
|
81
94
|
let signedTx;
|
|
82
95
|
if (preSigned) {
|
|
83
96
|
signedTx = tx;
|
|
@@ -100,17 +113,24 @@ class WhileValidTxSender extends baseTxSender_1.BaseTxSender {
|
|
|
100
113
|
additionalSigners === null || additionalSigners === void 0 ? void 0 : additionalSigners.filter((s) => s !== undefined).forEach((kp) => {
|
|
101
114
|
tx.sign([kp]);
|
|
102
115
|
});
|
|
103
|
-
signedTx = await this.txHandler.signVersionedTx(tx, additionalSigners, latestBlockhash);
|
|
116
|
+
signedTx = await this.txHandler.signVersionedTx(tx, additionalSigners !== null && additionalSigners !== void 0 ? additionalSigners : [], latestBlockhash);
|
|
104
117
|
}
|
|
105
118
|
if (opts === undefined) {
|
|
106
119
|
opts = this.opts;
|
|
107
120
|
}
|
|
108
|
-
const
|
|
121
|
+
const signature = signedTx.signatures[0];
|
|
122
|
+
if (!signature) {
|
|
123
|
+
throw new Error('WhileValidTxSender: signed transaction is missing a signature');
|
|
124
|
+
}
|
|
125
|
+
const txSig = bs58_1.default.encode(signature);
|
|
126
|
+
if (!latestBlockhash) {
|
|
127
|
+
throw new Error('WhileValidTxSender: failed to resolve latest blockhash for transaction');
|
|
128
|
+
}
|
|
109
129
|
this.untilValid.set(txSig, latestBlockhash);
|
|
110
130
|
return this.sendRawTransaction(signedTx.serialize(), opts);
|
|
111
131
|
}
|
|
112
132
|
async sendRawTransaction(rawTransaction, opts) {
|
|
113
|
-
var _a, _b, _c
|
|
133
|
+
var _a, _b, _c;
|
|
114
134
|
const startTime = this.getTimestamp();
|
|
115
135
|
const txid = await this.connection.sendRawTransaction(rawTransaction, opts);
|
|
116
136
|
(_a = this.txSigCache) === null || _a === void 0 ? void 0 : _a.set(txid, false);
|
|
@@ -143,16 +163,18 @@ class WhileValidTxSender extends baseTxSender_1.BaseTxSender {
|
|
|
143
163
|
try {
|
|
144
164
|
const result = await this.confirmTransaction(txid, opts.commitment);
|
|
145
165
|
(_b = this.txSigCache) === null || _b === void 0 ? void 0 : _b.set(txid, true);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
if (result) {
|
|
167
|
+
await this.checkConfirmationResultForError(txid, result.value);
|
|
168
|
+
if (((_c = result.value) === null || _c === void 0 ? void 0 : _c.err) && this.throwOnTransactionError) {
|
|
169
|
+
// Fallback error handling if there's a problem reporting the error in checkConfirmationResultForError
|
|
170
|
+
throw new web3_js_1.SendTransactionError({
|
|
171
|
+
action: 'send',
|
|
172
|
+
signature: txid,
|
|
173
|
+
transactionMessage: `Transaction Failed`,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
slot = result.context.slot;
|
|
154
177
|
}
|
|
155
|
-
slot = (_d = result === null || result === void 0 ? void 0 : result.context) === null || _d === void 0 ? void 0 : _d.slot;
|
|
156
178
|
// eslint-disable-next-line no-useless-catch
|
|
157
179
|
}
|
|
158
180
|
catch (e) {
|