@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
|
@@ -14,7 +14,7 @@ export class AuctionSubscriber {
|
|
|
14
14
|
private resubOpts?: ResubOpts;
|
|
15
15
|
|
|
16
16
|
eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
|
|
17
|
-
private subscriber
|
|
17
|
+
private subscriber?: WebSocketProgramAccountSubscriber<UserAccount>;
|
|
18
18
|
|
|
19
19
|
constructor({
|
|
20
20
|
velocityClient,
|
|
@@ -24,14 +24,15 @@ export class AuctionSubscriber {
|
|
|
24
24
|
}: AuctionSubscriberConfig) {
|
|
25
25
|
// Type-system guarantees at least one of the two is supplied.
|
|
26
26
|
this.velocityClient = velocityClient!;
|
|
27
|
-
this.opts = opts || this.velocityClient.opts;
|
|
27
|
+
this.opts = opts || this.velocityClient.opts || {};
|
|
28
28
|
this.eventEmitter = new EventEmitter();
|
|
29
29
|
this.resubOpts = { resubTimeoutMs, logResubMessages };
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
public async subscribe() {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
let subscriber = this.subscriber;
|
|
34
|
+
if (!subscriber) {
|
|
35
|
+
subscriber = new WebSocketProgramAccountSubscriber<UserAccount>(
|
|
35
36
|
'AuctionSubscriber',
|
|
36
37
|
'user',
|
|
37
38
|
this.velocityClient.program,
|
|
@@ -46,9 +47,10 @@ export class AuctionSubscriber {
|
|
|
46
47
|
},
|
|
47
48
|
this.resubOpts
|
|
48
49
|
);
|
|
50
|
+
this.subscriber = subscriber;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
await
|
|
53
|
+
await subscriber.subscribe(
|
|
52
54
|
(accountId: PublicKey, data: UserAccount, context: Context) => {
|
|
53
55
|
this.eventEmitter.emit(
|
|
54
56
|
'onAccountUpdate',
|
|
@@ -16,7 +16,7 @@ export class AuctionSubscriberGrpc {
|
|
|
16
16
|
private grpcConfigs?: GrpcConfigs;
|
|
17
17
|
|
|
18
18
|
eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
|
|
19
|
-
private subscriber
|
|
19
|
+
private subscriber?: WebSocketProgramAccountSubscriber<UserAccount>;
|
|
20
20
|
|
|
21
21
|
constructor({
|
|
22
22
|
velocityClient,
|
|
@@ -27,15 +27,21 @@ export class AuctionSubscriberGrpc {
|
|
|
27
27
|
}: AuctionSubscriberConfig) {
|
|
28
28
|
// Type-system guarantees at least one of the two is supplied.
|
|
29
29
|
this.velocityClient = velocityClient!;
|
|
30
|
-
this.opts = opts || this.velocityClient.opts;
|
|
30
|
+
this.opts = opts || this.velocityClient.opts || {};
|
|
31
31
|
this.eventEmitter = new EventEmitter();
|
|
32
32
|
this.resubOpts = { resubTimeoutMs, logResubMessages };
|
|
33
33
|
this.grpcConfigs = grpcConfigs;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
public async subscribe() {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
let subscriber = this.subscriber;
|
|
38
|
+
if (!subscriber) {
|
|
39
|
+
if (!this.grpcConfigs) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
'grpcConfigs must be provided to use AuctionSubscriberGrpc'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
subscriber = await grpcProgramAccountSubscriber.create<UserAccount>(
|
|
39
45
|
this.grpcConfigs,
|
|
40
46
|
'AuctionSubscriber',
|
|
41
47
|
'user',
|
|
@@ -50,9 +56,10 @@ export class AuctionSubscriberGrpc {
|
|
|
50
56
|
},
|
|
51
57
|
this.resubOpts
|
|
52
58
|
);
|
|
59
|
+
this.subscriber = subscriber;
|
|
53
60
|
}
|
|
54
61
|
|
|
55
|
-
await
|
|
62
|
+
await subscriber.subscribe(
|
|
56
63
|
(accountId: PublicKey, data: UserAccount, context: Context) => {
|
|
57
64
|
this.eventEmitter.emit(
|
|
58
65
|
'onAccountUpdate',
|
|
@@ -43,7 +43,7 @@ export type Connection = SolanaConnection | BankrunConnection;
|
|
|
43
43
|
|
|
44
44
|
type BankrunTransactionMetaNormalized = {
|
|
45
45
|
logMessages: string[];
|
|
46
|
-
err: TransactionError;
|
|
46
|
+
err: TransactionError | null;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
type BankrunTransactionRespose = {
|
|
@@ -159,7 +159,15 @@ export class BankrunConnection {
|
|
|
159
159
|
TransactionSignature,
|
|
160
160
|
BanksTransactionResultWithMeta
|
|
161
161
|
> = new Map();
|
|
162
|
-
private
|
|
162
|
+
private _clock?: Clock;
|
|
163
|
+
private get clock(): Clock {
|
|
164
|
+
if (!this._clock) {
|
|
165
|
+
throw new Error(
|
|
166
|
+
'BankrunConnection: clock accessed before updateSlotAndClock()'
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
return this._clock;
|
|
170
|
+
}
|
|
163
171
|
|
|
164
172
|
private nextClientSubscriptionId = 0;
|
|
165
173
|
private onLogCallbacks = new Map<number, LogsCallback>();
|
|
@@ -190,13 +198,32 @@ export class BankrunConnection {
|
|
|
190
198
|
|
|
191
199
|
async getTokenAccount(publicKey: PublicKey): Promise<Account> {
|
|
192
200
|
const info = await this.getAccountInfo(publicKey);
|
|
201
|
+
if (info === null) {
|
|
202
|
+
throw new Error(`Account not found: ${publicKey.toBase58()}`);
|
|
203
|
+
}
|
|
193
204
|
return unpackAccount(publicKey, info, info.owner);
|
|
194
205
|
}
|
|
195
206
|
|
|
207
|
+
// Mirrors the drift-vaults bankrun helper: returns the decoded SPL token
|
|
208
|
+
// Account (with .amount), not web3.js's { value: { amount } } shape. The
|
|
209
|
+
// vaults tests read `.amount` off the result directly.
|
|
210
|
+
async getTokenAccountBalance(
|
|
211
|
+
publicKey: PublicKey,
|
|
212
|
+
_commitment?: Commitment
|
|
213
|
+
): Promise<Account> {
|
|
214
|
+
return this.getTokenAccount(publicKey);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// SOL lamport balance, straight off the BanksClient. Returns a bigint like
|
|
218
|
+
// the drift-vaults bankrun helper (callers wrap with Number()).
|
|
219
|
+
async getBalance(publicKey: PublicKey): Promise<bigint> {
|
|
220
|
+
return this._banksClient.getBalance(publicKey);
|
|
221
|
+
}
|
|
222
|
+
|
|
196
223
|
async getMultipleAccountsInfo(
|
|
197
224
|
publicKeys: PublicKey[],
|
|
198
225
|
_commitmentOrConfig?: Commitment
|
|
199
|
-
): Promise<AccountInfo<Buffer>[]> {
|
|
226
|
+
): Promise<(AccountInfo<Buffer> | null)[]> {
|
|
200
227
|
const accountInfos = [];
|
|
201
228
|
|
|
202
229
|
for (const publicKey of publicKeys) {
|
|
@@ -225,7 +252,17 @@ export class BankrunConnection {
|
|
|
225
252
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
226
253
|
_options?: any
|
|
227
254
|
): Promise<TransactionSignature> {
|
|
228
|
-
|
|
255
|
+
// Raw bytes may encode either a legacy or a versioned (v0) transaction.
|
|
256
|
+
// sendTransaction handles both, but they must be deserialized with the
|
|
257
|
+
// matching type: legacy parses with Transaction.from, versioned needs
|
|
258
|
+
// VersionedTransaction.deserialize. Versioned-tx clients (e.g. the vaults
|
|
259
|
+
// VaultClient) always send v0, so fall back when the legacy parse throws.
|
|
260
|
+
let tx: Transaction | VersionedTransaction;
|
|
261
|
+
try {
|
|
262
|
+
tx = Transaction.from(rawTransaction);
|
|
263
|
+
} catch (e) {
|
|
264
|
+
tx = VersionedTransaction.deserialize(rawTransaction as Uint8Array);
|
|
265
|
+
}
|
|
229
266
|
const signature = await this.sendTransaction(tx);
|
|
230
267
|
return signature;
|
|
231
268
|
}
|
|
@@ -246,9 +283,18 @@ export class BankrunConnection {
|
|
|
246
283
|
: await internal.tryProcessLegacyTransaction(serialized);
|
|
247
284
|
const banksTransactionMeta = new BanksTransactionResultWithMeta(inner);
|
|
248
285
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
286
|
+
let signature: string;
|
|
287
|
+
if (isVersioned) {
|
|
288
|
+
signature = bs58.encode((tx as VersionedTransaction).signatures[0]);
|
|
289
|
+
} else {
|
|
290
|
+
const legacySignature = (tx as Transaction).signatures[0].signature;
|
|
291
|
+
if (legacySignature === null) {
|
|
292
|
+
throw new Error(
|
|
293
|
+
'BankrunConnection: transaction is missing its first signature'
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
signature = bs58.encode(legacySignature);
|
|
297
|
+
}
|
|
252
298
|
|
|
253
299
|
if (banksTransactionMeta.result) {
|
|
254
300
|
if (
|
|
@@ -273,9 +319,14 @@ export class BankrunConnection {
|
|
|
273
319
|
}
|
|
274
320
|
let finalizedCount = 0;
|
|
275
321
|
while (finalizedCount < 10) {
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
322
|
+
const statusValue = (await this.getSignatureStatus(signature)).value;
|
|
323
|
+
if (statusValue === null) {
|
|
324
|
+
throw new Error(
|
|
325
|
+
`BankrunConnection: no signature status for ${signature}`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
const signatureStatus = statusValue.confirmationStatus;
|
|
329
|
+
if (signatureStatus?.toString() == '"finalized"') {
|
|
279
330
|
finalizedCount += 1;
|
|
280
331
|
}
|
|
281
332
|
}
|
|
@@ -291,14 +342,16 @@ export class BankrunConnection {
|
|
|
291
342
|
if (this.onLogCallbacks.size > 0) {
|
|
292
343
|
const transaction = await this.getTransaction(signature);
|
|
293
344
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
logs
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
logCallback(
|
|
345
|
+
if (transaction !== null) {
|
|
346
|
+
const context = { slot: transaction.slot };
|
|
347
|
+
const logs = {
|
|
348
|
+
logs: transaction.meta.logMessages,
|
|
349
|
+
err: transaction.meta.err,
|
|
350
|
+
signature,
|
|
351
|
+
};
|
|
352
|
+
for (const logCallback of this.onLogCallbacks.values()) {
|
|
353
|
+
logCallback(logs, context);
|
|
354
|
+
}
|
|
302
355
|
}
|
|
303
356
|
}
|
|
304
357
|
|
|
@@ -307,6 +360,9 @@ export class BankrunConnection {
|
|
|
307
360
|
callback,
|
|
308
361
|
] of this.onAccountChangeCallbacks.values()) {
|
|
309
362
|
const accountInfo = await this.getParsedAccountInfo(publicKey);
|
|
363
|
+
if (accountInfo.value === null) {
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
310
366
|
callback(accountInfo.value, accountInfo.context);
|
|
311
367
|
}
|
|
312
368
|
|
|
@@ -326,7 +382,7 @@ export class BankrunConnection {
|
|
|
326
382
|
currentClock.unixTimestamp + BigInt(1)
|
|
327
383
|
);
|
|
328
384
|
this.context.setClock(newClock);
|
|
329
|
-
this.
|
|
385
|
+
this._clock = newClock;
|
|
330
386
|
}
|
|
331
387
|
|
|
332
388
|
getTime(): number {
|
|
@@ -335,7 +391,7 @@ export class BankrunConnection {
|
|
|
335
391
|
|
|
336
392
|
async getParsedAccountInfo(
|
|
337
393
|
publicKey: PublicKey
|
|
338
|
-
): Promise<RpcResponseAndContext<AccountInfo<Buffer>>> {
|
|
394
|
+
): Promise<RpcResponseAndContext<null | AccountInfo<Buffer>>> {
|
|
339
395
|
const accountInfoBytes = await this._banksClient.getAccount(publicKey);
|
|
340
396
|
if (accountInfoBytes === null) {
|
|
341
397
|
return {
|
|
@@ -360,6 +416,9 @@ export class BankrunConnection {
|
|
|
360
416
|
const blockhashAndBlockheight = await this._banksClient.getLatestBlockhash(
|
|
361
417
|
commitment
|
|
362
418
|
);
|
|
419
|
+
if (blockhashAndBlockheight === null) {
|
|
420
|
+
throw new Error('Failed to get latest blockhash');
|
|
421
|
+
}
|
|
363
422
|
return {
|
|
364
423
|
blockhash: blockhashAndBlockheight[0],
|
|
365
424
|
lastValidBlockHeight: Number(blockhashAndBlockheight[1]),
|
|
@@ -427,6 +486,9 @@ export class BankrunConnection {
|
|
|
427
486
|
const transactionStatus = await this._banksClient.getTransactionStatus(
|
|
428
487
|
signature
|
|
429
488
|
);
|
|
489
|
+
if (transactionStatus === null) {
|
|
490
|
+
throw new Error(`tx has no status: ${signature}`);
|
|
491
|
+
}
|
|
430
492
|
if (txMeta.meta === null) {
|
|
431
493
|
throw new Error(`tx has no meta: ${JSON.stringify(txMeta)}`);
|
|
432
494
|
}
|
|
@@ -440,24 +502,27 @@ export class BankrunConnection {
|
|
|
440
502
|
};
|
|
441
503
|
}
|
|
442
504
|
|
|
443
|
-
|
|
505
|
+
private getTransactionMetaOrThrow(
|
|
506
|
+
signature: string
|
|
507
|
+
): NonNullable<BanksTransactionResultWithMeta['meta']> {
|
|
444
508
|
const txMeta = this.transactionToMeta.get(
|
|
445
509
|
signature as TransactionSignature
|
|
446
510
|
);
|
|
447
511
|
if (txMeta === undefined) {
|
|
448
512
|
throw new Error('Transaction not found');
|
|
449
513
|
}
|
|
450
|
-
|
|
514
|
+
if (txMeta.meta === null) {
|
|
515
|
+
throw new Error(`tx has no meta: ${JSON.stringify(txMeta)}`);
|
|
516
|
+
}
|
|
517
|
+
return txMeta.meta;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
findComputeUnitConsumption(signature: string): bigint {
|
|
521
|
+
return this.getTransactionMetaOrThrow(signature).computeUnitsConsumed;
|
|
451
522
|
}
|
|
452
523
|
|
|
453
524
|
printTxLogs(signature: string): void {
|
|
454
|
-
|
|
455
|
-
signature as TransactionSignature
|
|
456
|
-
);
|
|
457
|
-
if (txMeta === undefined) {
|
|
458
|
-
throw new Error('Transaction not found');
|
|
459
|
-
}
|
|
460
|
-
console.log(txMeta.meta.logMessages);
|
|
525
|
+
console.log(this.getTransactionMetaOrThrow(signature).logMessages);
|
|
461
526
|
}
|
|
462
527
|
|
|
463
528
|
async simulateTransaction(
|
|
@@ -467,22 +532,27 @@ export class BankrunConnection {
|
|
|
467
532
|
const simulationResult = await this._banksClient.simulateTransaction(
|
|
468
533
|
transaction
|
|
469
534
|
);
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
535
|
+
const meta = simulationResult.meta;
|
|
536
|
+
if (meta === null) {
|
|
537
|
+
throw new Error('BankrunConnection: simulation returned no meta');
|
|
538
|
+
}
|
|
539
|
+
let returnData: TransactionReturnData | undefined;
|
|
540
|
+
if (meta.returnData !== null) {
|
|
541
|
+
const returnDataNormalized = Buffer.from(meta.returnData.data).toString(
|
|
542
|
+
'base64'
|
|
543
|
+
);
|
|
544
|
+
returnData = {
|
|
545
|
+
programId: meta.returnData.programId.toBase58(),
|
|
546
|
+
data: [returnDataNormalized, 'base64'],
|
|
547
|
+
};
|
|
548
|
+
}
|
|
479
549
|
return {
|
|
480
550
|
context: { slot: Number(await this._banksClient.getSlot()) },
|
|
481
551
|
value: {
|
|
482
552
|
err: simulationResult.result,
|
|
483
|
-
logs:
|
|
553
|
+
logs: meta.logMessages,
|
|
484
554
|
accounts: undefined,
|
|
485
|
-
unitsConsumed: Number(
|
|
555
|
+
unitsConsumed: Number(meta.computeUnitsConsumed),
|
|
486
556
|
returnData,
|
|
487
557
|
},
|
|
488
558
|
};
|
|
@@ -9,7 +9,7 @@ import { BlockhashSubscriberConfig } from './types';
|
|
|
9
9
|
export class BlockhashSubscriber {
|
|
10
10
|
private connection: Connection;
|
|
11
11
|
private isSubscribed = false;
|
|
12
|
-
private latestBlockHeight: number;
|
|
12
|
+
private latestBlockHeight: number | undefined;
|
|
13
13
|
private latestBlockHeightContext: Context | undefined;
|
|
14
14
|
private blockhashes: Array<BlockhashWithExpiryBlockHeight> = [];
|
|
15
15
|
private updateBlockhashIntervalId: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -31,7 +31,7 @@ export class BlockhashSubscriber {
|
|
|
31
31
|
return this.blockhashes.length;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
getLatestBlockHeight(): number {
|
|
34
|
+
getLatestBlockHeight(): number | undefined {
|
|
35
35
|
return this.latestBlockHeight;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -67,9 +67,10 @@ export class BlockhashSubscriber {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
pruneBlockhashes() {
|
|
70
|
-
if (this.latestBlockHeight) {
|
|
70
|
+
if (this.latestBlockHeight !== undefined) {
|
|
71
|
+
const latestBlockHeight = this.latestBlockHeight;
|
|
71
72
|
this.blockhashes = this.blockhashes.filter(
|
|
72
|
-
(blockhash) => blockhash.lastValidBlockHeight >
|
|
73
|
+
(blockhash) => blockhash.lastValidBlockHeight > latestBlockHeight
|
|
73
74
|
);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -14,17 +14,17 @@ export interface ClockSubscriberEvent {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export class ClockSubscriber {
|
|
17
|
-
private _latestSlot
|
|
18
|
-
private _currentTs
|
|
19
|
-
private subscriptionId
|
|
17
|
+
private _latestSlot?: number;
|
|
18
|
+
private _currentTs?: number;
|
|
19
|
+
private subscriptionId?: number;
|
|
20
20
|
commitment: Commitment;
|
|
21
21
|
eventEmitter: StrictEventEmitter<EventEmitter, ClockSubscriberEvent>;
|
|
22
22
|
|
|
23
|
-
public get latestSlot(): number {
|
|
23
|
+
public get latestSlot(): number | undefined {
|
|
24
24
|
return this._latestSlot;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
public get currentTs(): number {
|
|
27
|
+
public get currentTs(): number | undefined {
|
|
28
28
|
return this._currentTs;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ export class ClockSubscriber {
|
|
|
41
41
|
this.eventEmitter = new EventEmitter();
|
|
42
42
|
this.resubTimeoutMs = config?.resubTimeoutMs;
|
|
43
43
|
this.commitment = config?.commitment || 'confirmed';
|
|
44
|
-
if (this.resubTimeoutMs < 1000) {
|
|
44
|
+
if (this.resubTimeoutMs !== undefined && this.resubTimeoutMs < 1000) {
|
|
45
45
|
console.log(
|
|
46
46
|
'resubTimeoutMs should be at least 1000ms to avoid spamming resub'
|
|
47
47
|
);
|
|
@@ -63,12 +63,13 @@ export class ClockSubscriber {
|
|
|
63
63
|
this.setTimeout();
|
|
64
64
|
}
|
|
65
65
|
this._latestSlot = context.slot;
|
|
66
|
-
|
|
66
|
+
const currentTs = new BN(
|
|
67
67
|
acctInfo.data.subarray(32, 39),
|
|
68
68
|
undefined,
|
|
69
69
|
'le'
|
|
70
70
|
).toNumber();
|
|
71
|
-
this.
|
|
71
|
+
this._currentTs = currentTs;
|
|
72
|
+
this.eventEmitter.emit('clockUpdate', currentTs);
|
|
72
73
|
}
|
|
73
74
|
},
|
|
74
75
|
this.commitment
|
|
@@ -98,7 +99,7 @@ export class ClockSubscriber {
|
|
|
98
99
|
}, this.resubTimeoutMs);
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
public getUnixTs(): number {
|
|
102
|
+
public getUnixTs(): number | undefined {
|
|
102
103
|
return this.currentTs;
|
|
103
104
|
}
|
|
104
105
|
|
package/src/config.ts
CHANGED
|
@@ -49,8 +49,9 @@ export const VELOCITY_DEVNET_PROGRAM_ID =
|
|
|
49
49
|
export const VELOCITY_ORACLE_RECEIVER_ID =
|
|
50
50
|
'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha';
|
|
51
51
|
|
|
52
|
-
export const
|
|
52
|
+
export const PYTH_LAZER_PROGRAM_ID =
|
|
53
53
|
'pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt';
|
|
54
|
+
|
|
54
55
|
export const SB_ON_DEMAND_DEVNET_PID = new PublicKey(
|
|
55
56
|
'Aio4gaXjXzJNVLtzwtNVmSqGKpANtXhybbkhtAC94ji2'
|
|
56
57
|
);
|
|
@@ -137,9 +138,13 @@ export function getMarketsAndOraclesForSubscription(
|
|
|
137
138
|
oracleInfos: OracleInfo[];
|
|
138
139
|
} {
|
|
139
140
|
const perpMarketsToUse =
|
|
140
|
-
perpMarkets
|
|
141
|
+
perpMarkets !== undefined && perpMarkets.length > 0
|
|
142
|
+
? perpMarkets
|
|
143
|
+
: PerpMarkets[env];
|
|
141
144
|
const spotMarketsToUse =
|
|
142
|
-
spotMarkets
|
|
145
|
+
spotMarkets !== undefined && spotMarkets.length > 0
|
|
146
|
+
? spotMarkets
|
|
147
|
+
: SpotMarkets[env];
|
|
143
148
|
|
|
144
149
|
const perpMarketIndexes = [];
|
|
145
150
|
const spotMarketIndexes = [];
|
package/src/constants/index.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Protocol constants: numeric precision bases, market indices, transaction size limits,
|
|
3
|
-
*
|
|
3
|
+
* and perp/spot market config arrays.
|
|
4
4
|
* Import specific submodules to avoid pulling in unused market lists.
|
|
5
5
|
*/
|
|
6
|
-
export * from './insuranceFund';
|
|
7
6
|
export * from './numericConstants';
|
|
8
7
|
export * from './perpMarkets';
|
|
9
8
|
export * from './spotMarkets';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LAMPORTS_PER_SOL } from '@solana/web3.js';
|
|
2
2
|
import { BN } from '../isomorphic/anchor';
|
|
3
|
-
import { BigNum } from '../factory/bigNum';
|
|
4
3
|
|
|
5
4
|
export const ZERO = new BN(0);
|
|
6
5
|
export const ONE = new BN(1);
|
|
@@ -85,6 +84,9 @@ export const MARGIN_PRECISION = TEN_THOUSAND;
|
|
|
85
84
|
export const BID_ASK_SPREAD_PRECISION = new BN(1000000); // 10^6
|
|
86
85
|
export const LIQUIDATION_PCT_PRECISION = TEN_THOUSAND;
|
|
87
86
|
export const FUNDING_RATE_OFFSET_DENOMINATOR = new BN(3333);
|
|
87
|
+
export const FUNDING_RATE_OFFSET_PERCENTAGE = FUNDING_RATE_PRECISION.div(
|
|
88
|
+
FUNDING_RATE_OFFSET_DENOMINATOR
|
|
89
|
+
);
|
|
88
90
|
export const FUNDING_RATE_CLAMP_DENOMINATOR = new BN(2000);
|
|
89
91
|
export const PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO = PRICE_PRECISION.mul(
|
|
90
92
|
AMM_TO_QUOTE_PRECISION_RATIO
|
|
@@ -95,7 +97,6 @@ export const ONE_HOUR = new BN(60 * 60);
|
|
|
95
97
|
export const ONE_YEAR = new BN(31536000);
|
|
96
98
|
|
|
97
99
|
export const QUOTE_SPOT_MARKET_INDEX = 0;
|
|
98
|
-
export const GOV_SPOT_MARKET_INDEX = 15;
|
|
99
100
|
|
|
100
101
|
export const LAMPORTS_PRECISION = new BN(LAMPORTS_PER_SOL);
|
|
101
102
|
export const LAMPORTS_EXP = new BN(Math.log10(LAMPORTS_PER_SOL));
|
|
@@ -115,5 +116,8 @@ export const DUST_POSITION_SIZE = QUOTE_PRECISION.divn(100); // Dust position is
|
|
|
115
116
|
export const GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = 99;
|
|
116
117
|
|
|
117
118
|
// integer constants
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
// Built with `BN` directly (not `BigNum.fromPrint`) to avoid a module-load
|
|
120
|
+
// circular dependency: `bigNum.ts` imports `ZERO` from this file, so importing
|
|
121
|
+
// `bigNum.ts` first leaves `BigNum` undefined while this module body evaluates.
|
|
122
|
+
export const MAX_I64 = new BN('9223372036854775807');
|
|
123
|
+
export const MIN_I64 = new BN('-9223372036854775808');
|
|
@@ -98,6 +98,12 @@ export class ConstituentMap implements ConstituentMapInterface {
|
|
|
98
98
|
config.subscriptionConfig.commitment,
|
|
99
99
|
this.getFilters()
|
|
100
100
|
);
|
|
101
|
+
} else {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`ConstituentMap: unsupported subscriptionConfig type: ${
|
|
104
|
+
(config.subscriptionConfig as { type: string }).type
|
|
105
|
+
}`
|
|
106
|
+
);
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
// Listen for account updates from the subscriber
|
|
@@ -184,7 +190,8 @@ export class ConstituentMap implements ConstituentMapInterface {
|
|
|
184
190
|
);
|
|
185
191
|
await Promise.all(promises);
|
|
186
192
|
} catch (error) {
|
|
187
|
-
|
|
193
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
194
|
+
console.log(`ConstituentMap.sync() error: ${message}`);
|
|
188
195
|
}
|
|
189
196
|
}
|
|
190
197
|
|
|
@@ -63,10 +63,12 @@ export class PollingConstituentAccountSubscriber
|
|
|
63
63
|
await this.constituentMap.sync();
|
|
64
64
|
this.eventEmitter.emit('update');
|
|
65
65
|
} catch (error) {
|
|
66
|
+
const normalizedError =
|
|
67
|
+
error instanceof Error ? error : new Error(String(error));
|
|
66
68
|
console.log(
|
|
67
|
-
`PollingConstituentAccountSubscriber.sync() error: ${
|
|
69
|
+
`PollingConstituentAccountSubscriber.sync() error: ${normalizedError.message}`
|
|
68
70
|
);
|
|
69
|
-
this.eventEmitter.emit('error',
|
|
71
|
+
this.eventEmitter.emit('error', normalizedError);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -21,7 +21,15 @@ export class WebSocketConstituentAccountSubscriber
|
|
|
21
21
|
program: VelocityProgram;
|
|
22
22
|
eventEmitter: StrictEventEmitter<EventEmitter, ConstituentAccountEvents>;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
private _constituentDataAccountSubscriber?: WebSocketProgramAccountSubscriber<ConstituentAccount>;
|
|
25
|
+
private get constituentDataAccountSubscriber(): WebSocketProgramAccountSubscriber<ConstituentAccount> {
|
|
26
|
+
if (!this._constituentDataAccountSubscriber) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
'WebSocketConstituentAccountSubscriber: constituentDataAccountSubscriber accessed before subscribe()'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return this._constituentDataAccountSubscriber;
|
|
32
|
+
}
|
|
25
33
|
constituentMap: ConstituentMap;
|
|
26
34
|
private additionalFilters?: MemcmpFilter[];
|
|
27
35
|
|
|
@@ -45,7 +53,7 @@ export class WebSocketConstituentAccountSubscriber
|
|
|
45
53
|
if (this.isSubscribed) {
|
|
46
54
|
return true;
|
|
47
55
|
}
|
|
48
|
-
this.
|
|
56
|
+
this._constituentDataAccountSubscriber =
|
|
49
57
|
new WebSocketProgramAccountSubscriber<ConstituentAccount>(
|
|
50
58
|
'LpPoolConstituent',
|
|
51
59
|
'constituent',
|
|
@@ -85,10 +93,11 @@ export class WebSocketConstituentAccountSubscriber
|
|
|
85
93
|
await this.constituentMap.sync();
|
|
86
94
|
this.eventEmitter.emit('update');
|
|
87
95
|
} catch (error) {
|
|
96
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
88
97
|
console.log(
|
|
89
|
-
`WebSocketConstituentAccountSubscriber.sync() error: ${
|
|
98
|
+
`WebSocketConstituentAccountSubscriber.sync() error: ${err.message}`
|
|
90
99
|
);
|
|
91
|
-
this.eventEmitter.emit('error',
|
|
100
|
+
this.eventEmitter.emit('error', err);
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
103
|
|
|
@@ -82,6 +82,20 @@ export async function buildPlaceAndMakePerpOrderInstruction(args: {
|
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Build a raw `cancelOrder` instruction.
|
|
87
|
+
*
|
|
88
|
+
* Pass `orderId: null` to cancel the user's most recently placed order. The program
|
|
89
|
+
* resolves a `null` ID on-chain via `get_last_order_id`, which makes this safe to use
|
|
90
|
+
* in a multi-instruction transaction where a place instruction precedes the cancel and
|
|
91
|
+
* the program-assigned order ID is not yet known at build time — e.g.:
|
|
92
|
+
*
|
|
93
|
+
* [placePerpOrder] → [cancelOrder(orderId: null)]
|
|
94
|
+
*
|
|
95
|
+
* The on-chain `order_id` counter is a monotonically incrementing u32 on the user
|
|
96
|
+
* account, so `get_last_order_id` reliably points to the order placed in the preceding
|
|
97
|
+
* instruction of the same transaction.
|
|
98
|
+
*/
|
|
85
99
|
export async function buildCancelOrderInstruction(args: {
|
|
86
100
|
program: VelocityProgram;
|
|
87
101
|
orderId: number | null;
|
|
@@ -25,11 +25,11 @@ export type RemainingAccountsContext = {
|
|
|
25
25
|
|
|
26
26
|
/** Used to resolve user's last slot for cache invalidation. */
|
|
27
27
|
getUserAccountAndSlot: (
|
|
28
|
-
subAccountId: number,
|
|
28
|
+
subAccountId: number | undefined,
|
|
29
29
|
authority: PublicKey
|
|
30
30
|
) => { slot: number } | undefined;
|
|
31
31
|
|
|
32
|
-
activeSubAccountId: number;
|
|
32
|
+
activeSubAccountId: number | undefined;
|
|
33
33
|
authority: PublicKey;
|
|
34
34
|
|
|
35
35
|
/** Mutable caches + forced-market sets (owned by caller). */
|
|
@@ -57,7 +57,7 @@ export function getRemainingAccounts(
|
|
|
57
57
|
)?.slot;
|
|
58
58
|
|
|
59
59
|
for (const [marketIndex, slot] of ctx.perpMarketLastSlotCache.entries()) {
|
|
60
|
-
if (slot > lastUserSlot) {
|
|
60
|
+
if (lastUserSlot !== undefined && slot > lastUserSlot) {
|
|
61
61
|
addPerpMarketToRemainingAccountMaps(
|
|
62
62
|
ctx,
|
|
63
63
|
marketIndex,
|
|
@@ -72,7 +72,7 @@ export function getRemainingAccounts(
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
for (const [marketIndex, slot] of ctx.spotMarketLastSlotCache.entries()) {
|
|
75
|
-
if (slot > lastUserSlot) {
|
|
75
|
+
if (lastUserSlot !== undefined && slot > lastUserSlot) {
|
|
76
76
|
addSpotMarketToRemainingAccountMaps(
|
|
77
77
|
ctx,
|
|
78
78
|
marketIndex,
|