@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
package/src/math/spotPosition.ts
CHANGED
|
@@ -25,14 +25,14 @@ export type OrderFillSimulation = {
|
|
|
25
25
|
tokenValue: BN;
|
|
26
26
|
weight: BN;
|
|
27
27
|
weightedTokenValue: BN;
|
|
28
|
-
freeCollateralContribution;
|
|
28
|
+
freeCollateralContribution: BN;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export function getWorstCaseTokenAmounts(
|
|
32
32
|
spotPosition: SpotPosition,
|
|
33
33
|
spotMarketAccount: SpotMarketAccount,
|
|
34
34
|
strictOraclePrice: StrictOraclePrice,
|
|
35
|
-
marginCategory: MarginCategory,
|
|
35
|
+
marginCategory: MarginCategory | undefined,
|
|
36
36
|
customMarginRatio?: number,
|
|
37
37
|
includeOpenOrders: boolean = true
|
|
38
38
|
): OrderFillSimulation {
|
|
@@ -108,7 +108,7 @@ export function calculateWeightedTokenValue(
|
|
|
108
108
|
tokenValue: BN,
|
|
109
109
|
oraclePrice: BN,
|
|
110
110
|
spotMarket: SpotMarketAccount,
|
|
111
|
-
marginCategory: MarginCategory,
|
|
111
|
+
marginCategory: MarginCategory | undefined,
|
|
112
112
|
customMarginRatio?: number
|
|
113
113
|
): { weight: BN; weightedTokenValue: BN } {
|
|
114
114
|
let weight: BN;
|
|
@@ -158,7 +158,7 @@ export function simulateOrderFill(
|
|
|
158
158
|
openOrders: BN,
|
|
159
159
|
strictOraclePrice: StrictOraclePrice,
|
|
160
160
|
spotMarket: SpotMarketAccount,
|
|
161
|
-
marginCategory: MarginCategory,
|
|
161
|
+
marginCategory: MarginCategory | undefined,
|
|
162
162
|
customMarginRatio?: number
|
|
163
163
|
): OrderFillSimulation {
|
|
164
164
|
const ordersValue = getTokenValue(openOrders.neg(), spotMarket.decimals, {
|
package/src/math/state.ts
CHANGED
|
@@ -38,11 +38,3 @@ export function useMedianTriggerPrice(stateAccount: StateAccount): boolean {
|
|
|
38
38
|
(stateAccount.featureBitFlags & FeatureBitFlags.MEDIAN_TRIGGER_PRICE) > 0
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
export function builderCodesEnabled(stateAccount: StateAccount): boolean {
|
|
43
|
-
return (stateAccount.featureBitFlags & FeatureBitFlags.BUILDER_CODES) > 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function builderReferralEnabled(stateAccount: StateAccount): boolean {
|
|
47
|
-
return (stateAccount.featureBitFlags & FeatureBitFlags.BUILDER_REFERRAL) > 0;
|
|
48
|
-
}
|
package/src/math/superStake.ts
CHANGED
|
@@ -95,7 +95,7 @@ export async function findBestSuperStakeIxs({
|
|
|
95
95
|
} else if (marketIndex === 8) {
|
|
96
96
|
return findBestLstSuperStakeIxs({
|
|
97
97
|
amount,
|
|
98
|
-
lstMint: velocityClient.
|
|
98
|
+
lstMint: velocityClient.getSpotMarketAccountOrThrow(8).mint,
|
|
99
99
|
lstMarketIndex: 8,
|
|
100
100
|
jupiterClient,
|
|
101
101
|
velocityClient,
|
|
@@ -137,10 +137,10 @@ export async function findBestMSolSuperStakeIxs({
|
|
|
137
137
|
price = await getMarinadeMSolPrice(marinadeProgram);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
const solSpotMarketAccount = velocityClient.
|
|
141
|
-
const mSolSpotMarketAccount = velocityClient.
|
|
140
|
+
const solSpotMarketAccount = velocityClient.getSpotMarketAccountOrThrow(1);
|
|
141
|
+
const mSolSpotMarketAccount = velocityClient.getSpotMarketAccountOrThrow(2);
|
|
142
142
|
|
|
143
|
-
let jupiterPrice: number;
|
|
143
|
+
let jupiterPrice: number | undefined;
|
|
144
144
|
let quote = jupiterQuote;
|
|
145
145
|
if (!jupiterQuote) {
|
|
146
146
|
try {
|
|
@@ -152,7 +152,7 @@ export async function findBestMSolSuperStakeIxs({
|
|
|
152
152
|
onlyDirectRoutes,
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
jupiterPrice = +
|
|
155
|
+
jupiterPrice = +fetchedQuote.outAmount / +fetchedQuote.inAmount;
|
|
156
156
|
|
|
157
157
|
quote = fetchedQuote;
|
|
158
158
|
} catch (e) {
|
|
@@ -216,7 +216,7 @@ export async function findBestJitoSolSuperStakeIxs({
|
|
|
216
216
|
velocityClient,
|
|
217
217
|
userAccountPublicKey,
|
|
218
218
|
onlyDirectRoutes,
|
|
219
|
-
lstMint: velocityClient.
|
|
219
|
+
lstMint: velocityClient.getSpotMarketAccountOrThrow(6).mint,
|
|
220
220
|
lstMarketIndex: 6,
|
|
221
221
|
jupiterQuote,
|
|
222
222
|
});
|
|
@@ -326,63 +326,6 @@ export async function fetchJitoSolMetrics() {
|
|
|
326
326
|
return data;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
export type MSOL_METRICS_ENDPOINT_RESPONSE = {
|
|
330
|
-
total_active_balance: number;
|
|
331
|
-
available_reserve_balance: number;
|
|
332
|
-
emergency_cooling_down: number;
|
|
333
|
-
tvl_sol: number;
|
|
334
|
-
msol_directed_stake_sol: number;
|
|
335
|
-
msol_directed_stake_msol: number;
|
|
336
|
-
mnde_total_supply: number;
|
|
337
|
-
mnde_circulating_supply: number;
|
|
338
|
-
validators_count: number;
|
|
339
|
-
stake_accounts: number;
|
|
340
|
-
staking_sol_cap: number;
|
|
341
|
-
m_sol_price: number;
|
|
342
|
-
avg_staking_apy: number;
|
|
343
|
-
msol_price_apy_14d: number;
|
|
344
|
-
msol_price_apy_30d: number;
|
|
345
|
-
msol_price_apy_90d: number;
|
|
346
|
-
msol_price_apy_365d: number;
|
|
347
|
-
reserve_pda: number;
|
|
348
|
-
treasury_m_sol_amount: number;
|
|
349
|
-
m_sol_mint_supply: number;
|
|
350
|
-
m_sol_supply_state: number;
|
|
351
|
-
liq_pool_sol: number;
|
|
352
|
-
liq_pool_m_sol: number;
|
|
353
|
-
liq_pool_value: number;
|
|
354
|
-
liq_pool_token_supply: number;
|
|
355
|
-
liq_pool_token_price: number;
|
|
356
|
-
liq_pool_target: number;
|
|
357
|
-
liq_pool_min_fee: number;
|
|
358
|
-
liq_pool_max_fee: number;
|
|
359
|
-
liq_pool_current_fee: number;
|
|
360
|
-
liq_pool_treasury_cut: number;
|
|
361
|
-
liq_pool_cap: number;
|
|
362
|
-
total_cooling_down: number;
|
|
363
|
-
last_stake_delta_epoch: number;
|
|
364
|
-
circulating_ticket_count: number;
|
|
365
|
-
circulating_ticket_balance: number;
|
|
366
|
-
reward_fee_bp: number;
|
|
367
|
-
lido_staking: number;
|
|
368
|
-
lido_st_sol_price: number;
|
|
369
|
-
lido_stsol_price_apy_14d: number;
|
|
370
|
-
lido_stsol_price_apy_30d: number;
|
|
371
|
-
lido_stsol_price_apy_90d: number;
|
|
372
|
-
lido_stsol_price_apy_365d: number;
|
|
373
|
-
stake_delta: number;
|
|
374
|
-
bot_balance: number;
|
|
375
|
-
treasury_farm_claim_mnde_balance: number;
|
|
376
|
-
last_3_epochs_avg_duration_hs: number;
|
|
377
|
-
mnde_votes_validators: number;
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
export const fetchMSolMetrics = async () => {
|
|
381
|
-
const res = await fetch('https://api2.marinade.finance/metrics_json');
|
|
382
|
-
const data: MSOL_METRICS_ENDPOINT_RESPONSE = await res.json();
|
|
383
|
-
return data;
|
|
384
|
-
};
|
|
385
|
-
|
|
386
329
|
const getJitoSolHistoricalPriceMap = async (timestamps: number[]) => {
|
|
387
330
|
try {
|
|
388
331
|
const data = await fetchJitoSolMetrics();
|
|
@@ -436,7 +379,7 @@ export async function calculateSolEarned({
|
|
|
436
379
|
|
|
437
380
|
let lstRatios = new Map<number, number>();
|
|
438
381
|
|
|
439
|
-
const getMsolPrice = async (timestamp) => {
|
|
382
|
+
const getMsolPrice = async (timestamp: number) => {
|
|
440
383
|
const date = new Date(timestamp * 1000); // Convert Unix timestamp to milliseconds
|
|
441
384
|
const swaggerApiDateTime = date.toISOString(); // Format date as swagger API date-time
|
|
442
385
|
const url = `https://api.marinade.finance/msol/price_sol?time=${swaggerApiDateTime}`;
|
|
@@ -465,7 +408,10 @@ export async function calculateSolEarned({
|
|
|
465
408
|
if (marketIndex === 2) {
|
|
466
409
|
await Promise.all(timestamps.map(getMsolPrice));
|
|
467
410
|
} else if (marketIndex === 6) {
|
|
468
|
-
|
|
411
|
+
const jitoSolRatios = await getJitoSolHistoricalPriceMap(timestamps);
|
|
412
|
+
if (jitoSolRatios) {
|
|
413
|
+
lstRatios = jitoSolRatios;
|
|
414
|
+
}
|
|
469
415
|
} else if (marketIndex === 8) {
|
|
470
416
|
await getBSolPrice(timestamps);
|
|
471
417
|
}
|
|
@@ -484,6 +430,11 @@ export async function calculateSolEarned({
|
|
|
484
430
|
record.marketIndex === 8
|
|
485
431
|
) {
|
|
486
432
|
const lstRatio = lstRatios.get(record.ts.toNumber());
|
|
433
|
+
if (lstRatio === undefined) {
|
|
434
|
+
throw new Error(
|
|
435
|
+
`Missing LST/SOL ratio for deposit record at timestamp ${record.ts.toNumber()}`
|
|
436
|
+
);
|
|
437
|
+
}
|
|
487
438
|
const lstRatioBN = new BN(lstRatio * LAMPORTS_PER_SOL);
|
|
488
439
|
|
|
489
440
|
const solAmount = record.amount.mul(lstRatioBN).div(LAMPORTS_PRECISION);
|
|
@@ -497,6 +448,9 @@ export async function calculateSolEarned({
|
|
|
497
448
|
|
|
498
449
|
const currentLstTokenAmount = await user.getTokenAmount(marketIndex);
|
|
499
450
|
const currentLstRatio = lstRatios.get(now);
|
|
451
|
+
if (currentLstRatio === undefined) {
|
|
452
|
+
throw new Error(`Missing current LST/SOL ratio for timestamp ${now}`);
|
|
453
|
+
}
|
|
500
454
|
const currentLstRatioBN = new BN(currentLstRatio * LAMPORTS_PER_SOL);
|
|
501
455
|
|
|
502
456
|
solEarned = solEarned.add(
|
package/src/math/trade.ts
CHANGED
|
@@ -114,7 +114,6 @@ export function calculateTradeSlippage(
|
|
|
114
114
|
calculateUpdatedAMMSpreadReserves(
|
|
115
115
|
market.amm,
|
|
116
116
|
market.marketStats,
|
|
117
|
-
market.totalExchangeFee,
|
|
118
117
|
direction,
|
|
119
118
|
mmOraclePriceData,
|
|
120
119
|
latestSlot
|
|
@@ -187,7 +186,6 @@ export function calculateTradeAcquiredAmounts(
|
|
|
187
186
|
calculateUpdatedAMMSpreadReserves(
|
|
188
187
|
market.amm,
|
|
189
188
|
market.marketStats,
|
|
190
|
-
market.totalExchangeFee,
|
|
191
189
|
direction,
|
|
192
190
|
mmOraclePriceData,
|
|
193
191
|
latestSlot
|
|
@@ -279,7 +277,6 @@ export function calculateTargetPriceTrade(
|
|
|
279
277
|
calculateUpdatedAMMSpreadReserves(
|
|
280
278
|
market.amm,
|
|
281
279
|
market.marketStats,
|
|
282
|
-
market.totalExchangeFee,
|
|
283
280
|
direction,
|
|
284
281
|
mmOraclePriceData,
|
|
285
282
|
latestSlot
|
|
@@ -376,7 +373,7 @@ export function calculateTargetPriceTrade(
|
|
|
376
373
|
|
|
377
374
|
assert(tp1.sub(tp2).lte(originalDiff), 'Target Price Calculation incorrect');
|
|
378
375
|
assert(
|
|
379
|
-
tp2.lte(tp1) || tp2.sub(tp1).abs()
|
|
376
|
+
tp2.lte(tp1) || tp2.sub(tp1).abs().ltn(100000),
|
|
380
377
|
'Target Price Calculation incorrect' +
|
|
381
378
|
tp2.toString() +
|
|
382
379
|
'>=' +
|
|
@@ -443,7 +440,6 @@ export function calculateEstimatedPerpEntryPrice(
|
|
|
443
440
|
calculateUpdatedAMMSpreadReserves(
|
|
444
441
|
market.amm,
|
|
445
442
|
market.marketStats,
|
|
446
|
-
market.totalExchangeFee,
|
|
447
443
|
direction,
|
|
448
444
|
mmOraclePriceData,
|
|
449
445
|
new BN(slot)
|
|
@@ -493,7 +489,7 @@ export function calculateEstimatedPerpEntryPrice(
|
|
|
493
489
|
|
|
494
490
|
let limitOrder = limitOrders.next().value;
|
|
495
491
|
if (limitOrder) {
|
|
496
|
-
const limitOrderPrice = limitOrder.
|
|
492
|
+
const limitOrderPrice = limitOrder.getPriceOrThrow(mmOraclePriceData, slot);
|
|
497
493
|
bestPrice = takerIsLong
|
|
498
494
|
? BN.min(limitOrderPrice, bestPrice)
|
|
499
495
|
: BN.max(limitOrderPrice, bestPrice);
|
package/src/memcmp.ts
CHANGED
|
@@ -48,15 +48,6 @@ export function getUserWithAuctionFilter(): MemcmpFilter {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export function getUserThatHasBeenLP(): MemcmpFilter {
|
|
52
|
-
return {
|
|
53
|
-
memcmp: {
|
|
54
|
-
offset: 4267,
|
|
55
|
-
bytes: bs58.encode(Uint8Array.from([99])),
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
51
|
export function getUserWithName(name: string): MemcmpFilter {
|
|
61
52
|
return {
|
|
62
53
|
memcmp: {
|
|
@@ -2,6 +2,7 @@ import { Connection, PublicKey } from '@solana/web3.js';
|
|
|
2
2
|
import { OracleClient, OraclePriceData } from './types';
|
|
3
3
|
import { VelocityProgram } from '../config';
|
|
4
4
|
import { PrelaunchOracle } from '../types';
|
|
5
|
+
import { getOracleAccountDataOrThrow } from './utils';
|
|
5
6
|
|
|
6
7
|
export class PrelaunchOracleClient implements OracleClient {
|
|
7
8
|
private connection: Connection;
|
|
@@ -15,8 +16,12 @@ export class PrelaunchOracleClient implements OracleClient {
|
|
|
15
16
|
public async getOraclePriceData(
|
|
16
17
|
pricePublicKey: PublicKey
|
|
17
18
|
): Promise<OraclePriceData> {
|
|
18
|
-
const
|
|
19
|
-
|
|
19
|
+
const data = await getOracleAccountDataOrThrow(
|
|
20
|
+
this.connection,
|
|
21
|
+
pricePublicKey,
|
|
22
|
+
'Prelaunch oracle'
|
|
23
|
+
);
|
|
24
|
+
return this.getOraclePriceDataFromBuffer(data);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
public getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData {
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
QUOTE_PRECISION,
|
|
9
9
|
TEN,
|
|
10
10
|
} from '../constants/numericConstants';
|
|
11
|
+
import { getOracleAccountDataOrThrow } from './utils';
|
|
11
12
|
|
|
12
13
|
export class PythClient implements OracleClient {
|
|
13
14
|
private connection: Connection;
|
|
@@ -27,14 +28,22 @@ export class PythClient implements OracleClient {
|
|
|
27
28
|
public async getOraclePriceData(
|
|
28
29
|
pricePublicKey: PublicKey
|
|
29
30
|
): Promise<OraclePriceData> {
|
|
30
|
-
const
|
|
31
|
-
|
|
31
|
+
const data = await getOracleAccountDataOrThrow(
|
|
32
|
+
this.connection,
|
|
33
|
+
pricePublicKey,
|
|
34
|
+
'Pyth oracle'
|
|
35
|
+
);
|
|
36
|
+
return this.getOraclePriceDataFromBuffer(data);
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
public getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData {
|
|
35
40
|
const priceData = parsePriceData(buffer);
|
|
41
|
+
// `confidence` is absent on uninitialized/invalid price accounts. Base passed it
|
|
42
|
+
// straight into convertPythPrice, where `undefined * 10**exponent` is `NaN` and
|
|
43
|
+
// `new BN(NaN)` coerces to 0 — so base already yielded a zero-confidence price.
|
|
44
|
+
// `?? 0` makes that explicit and type-checks, preserving the same result.
|
|
36
45
|
const confidence = convertPythPrice(
|
|
37
|
-
priceData.confidence,
|
|
46
|
+
priceData.confidence ?? 0,
|
|
38
47
|
priceData.exponent,
|
|
39
48
|
this.multiple
|
|
40
49
|
);
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from '../constants/numericConstants';
|
|
12
12
|
import { Wallet } from '../wallet';
|
|
13
13
|
import velocityIDL from '../idl/velocity.json';
|
|
14
|
+
import { getOracleAccountDataOrThrow } from './utils';
|
|
14
15
|
|
|
15
16
|
export class PythLazerClient implements OracleClient {
|
|
16
17
|
private connection: Connection;
|
|
@@ -46,8 +47,12 @@ export class PythLazerClient implements OracleClient {
|
|
|
46
47
|
public async getOraclePriceData(
|
|
47
48
|
pricePublicKey: PublicKey
|
|
48
49
|
): Promise<OraclePriceData> {
|
|
49
|
-
const
|
|
50
|
-
|
|
50
|
+
const data = await getOracleAccountDataOrThrow(
|
|
51
|
+
this.connection,
|
|
52
|
+
pricePublicKey,
|
|
53
|
+
'Pyth lazer oracle'
|
|
54
|
+
);
|
|
55
|
+
return this.getOraclePriceDataFromBuffer(data);
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
public getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData {
|
package/src/oracles/utils.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
1
2
|
import { BN } from '../isomorphic/anchor';
|
|
2
3
|
import { OraclePriceData } from './types';
|
|
3
4
|
|
|
5
|
+
export async function getOracleAccountDataOrThrow(
|
|
6
|
+
connection: Connection,
|
|
7
|
+
pricePublicKey: PublicKey,
|
|
8
|
+
oracleName: string
|
|
9
|
+
): Promise<Buffer> {
|
|
10
|
+
const accountInfo = await connection.getAccountInfo(pricePublicKey);
|
|
11
|
+
if (!accountInfo) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`${oracleName} account not found: ${pricePublicKey.toBase58()}`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return accountInfo.data;
|
|
17
|
+
}
|
|
18
|
+
|
|
4
19
|
export function getOracleConfidenceFromMMOracleData(
|
|
5
20
|
mmOraclePrice: BN,
|
|
6
21
|
oraclePriceData: OraclePriceData
|
|
@@ -27,9 +27,9 @@ export class OrderSubscriber {
|
|
|
27
27
|
eventEmitter: StrictEventEmitter<EventEmitter, OrderSubscriberEvents>;
|
|
28
28
|
|
|
29
29
|
fetchPromise?: Promise<void>;
|
|
30
|
-
fetchPromiseResolver: () => void;
|
|
30
|
+
private fetchPromiseResolver: () => void = () => {};
|
|
31
31
|
|
|
32
|
-
mostRecentSlot
|
|
32
|
+
mostRecentSlot = 0;
|
|
33
33
|
decodeFn: (name: string, data: Buffer) => UserAccount;
|
|
34
34
|
decodeData?: boolean;
|
|
35
35
|
|
|
@@ -276,7 +276,7 @@ export class OrderSubscriber {
|
|
|
276
276
|
userAccountPublicKey,
|
|
277
277
|
this.commitment
|
|
278
278
|
);
|
|
279
|
-
if (accountInfo) {
|
|
279
|
+
if (accountInfo.value) {
|
|
280
280
|
this.tryUpdateUserAccount(
|
|
281
281
|
userAccountPublicKey.toString(),
|
|
282
282
|
'buffer',
|
|
@@ -290,7 +290,13 @@ export class OrderSubscriber {
|
|
|
290
290
|
if (!this.usersAccounts.has(key)) {
|
|
291
291
|
await this.addPubkey(new PublicKey(key));
|
|
292
292
|
}
|
|
293
|
-
|
|
293
|
+
const slotAndUserAccount = this.usersAccounts.get(key);
|
|
294
|
+
if (!slotAndUserAccount) {
|
|
295
|
+
throw new Error(
|
|
296
|
+
`OrderSubscriber: user account ${key} not found after addPubkey`
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
return slotAndUserAccount.userAccount;
|
|
294
300
|
}
|
|
295
301
|
|
|
296
302
|
public async unsubscribe(): Promise<void> {
|
|
@@ -28,7 +28,7 @@ export async function fetchHeliusPriorityFee(
|
|
|
28
28
|
heliusRpcUrl: string,
|
|
29
29
|
lookbackDistance: number,
|
|
30
30
|
addresses: string[]
|
|
31
|
-
): Promise<HeliusPriorityFeeResponse> {
|
|
31
|
+
): Promise<HeliusPriorityFeeResponse | undefined> {
|
|
32
32
|
try {
|
|
33
33
|
const response = await fetch(heliusRpcUrl, {
|
|
34
34
|
method: 'POST',
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from './velocityPriorityFeeMethod';
|
|
20
20
|
|
|
21
21
|
export class PriorityFeeSubscriber {
|
|
22
|
-
connection
|
|
22
|
+
connection?: Connection;
|
|
23
23
|
frequencyMs: number;
|
|
24
24
|
addresses: string[];
|
|
25
25
|
velocityMarkets?: VelocityMarketInfo[];
|
|
@@ -64,7 +64,7 @@ export class PriorityFeeSubscriber {
|
|
|
64
64
|
|
|
65
65
|
if (this.priorityFeeMethod === PriorityFeeMethod.HELIUS) {
|
|
66
66
|
if (config.heliusRpcUrl === undefined) {
|
|
67
|
-
if (this.connection
|
|
67
|
+
if (this.connection?.rpcEndpoint.includes('helius')) {
|
|
68
68
|
this.heliusRpcUrl = this.connection.rpcEndpoint;
|
|
69
69
|
} else {
|
|
70
70
|
throw new Error(
|
|
@@ -103,11 +103,19 @@ export class PriorityFeeSubscriber {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
private async loadForSolana(): Promise<void> {
|
|
106
|
+
if (this.connection === undefined) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
'connection must be provided to use SOLANA priority fee API'
|
|
109
|
+
);
|
|
110
|
+
}
|
|
106
111
|
const samples = await fetchSolanaPriorityFee(
|
|
107
|
-
this.connection
|
|
112
|
+
this.connection,
|
|
108
113
|
this.lookbackDistance,
|
|
109
114
|
this.addresses
|
|
110
115
|
);
|
|
116
|
+
if (samples === undefined) {
|
|
117
|
+
throw new Error('fetchSolanaPriorityFee returned no samples');
|
|
118
|
+
}
|
|
111
119
|
if (samples.length > 0) {
|
|
112
120
|
this.latestPriorityFee = samples[0].prioritizationFee;
|
|
113
121
|
this.lastSlotSeen = samples[0].slot;
|
|
@@ -121,6 +129,11 @@ export class PriorityFeeSubscriber {
|
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
private async loadForHelius(): Promise<void> {
|
|
132
|
+
if (this.heliusRpcUrl === undefined) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
'heliusRpcUrl must be provided to use PriorityFeeMethod.HELIUS'
|
|
135
|
+
);
|
|
136
|
+
}
|
|
124
137
|
const sample = await fetchHeliusPriorityFee(
|
|
125
138
|
this.heliusRpcUrl,
|
|
126
139
|
this.lookbackDistance,
|
|
@@ -128,13 +141,13 @@ export class PriorityFeeSubscriber {
|
|
|
128
141
|
);
|
|
129
142
|
this.lastHeliusSample = sample?.result?.priorityFeeLevels ?? undefined;
|
|
130
143
|
|
|
131
|
-
if (this.lastHeliusSample) {
|
|
144
|
+
if (sample !== undefined && this.lastHeliusSample) {
|
|
132
145
|
this.lastAvgStrategyResult =
|
|
133
146
|
this.lastHeliusSample[HeliusPriorityLevel.MEDIUM];
|
|
134
147
|
this.lastMaxStrategyResult =
|
|
135
148
|
this.lastHeliusSample[HeliusPriorityLevel.UNSAFE_MAX];
|
|
136
149
|
if (this.customStrategy) {
|
|
137
|
-
this.lastCustomStrategyResult = this.customStrategy.calculate(sample
|
|
150
|
+
this.lastCustomStrategyResult = this.customStrategy.calculate(sample);
|
|
138
151
|
}
|
|
139
152
|
}
|
|
140
153
|
}
|
|
@@ -143,16 +156,39 @@ export class PriorityFeeSubscriber {
|
|
|
143
156
|
if (!this.velocityMarkets) {
|
|
144
157
|
return;
|
|
145
158
|
}
|
|
159
|
+
if (this.velocityPriorityFeeEndpoint === undefined) {
|
|
160
|
+
throw new Error(
|
|
161
|
+
'velocityPriorityFeeEndpoint must be provided to use PriorityFeeMethod.VELOCITY'
|
|
162
|
+
);
|
|
163
|
+
}
|
|
146
164
|
const sample = await fetchVelocityPriorityFee(
|
|
147
|
-
this.velocityPriorityFeeEndpoint
|
|
165
|
+
this.velocityPriorityFeeEndpoint,
|
|
148
166
|
this.velocityMarkets.map((m) => m.marketType),
|
|
149
167
|
this.velocityMarkets.map((m) => m.marketIndex)
|
|
150
168
|
);
|
|
151
169
|
if (sample.length > 0) {
|
|
152
|
-
|
|
153
|
-
|
|
170
|
+
// The endpoint returns one fee-level set per requested market. Take the
|
|
171
|
+
// max level across markets so a transaction touching several markets is
|
|
172
|
+
// covered by the most expensive one. (Base indexed the array itself with
|
|
173
|
+
// a string enum key — `sample['medium']` — which yielded `undefined` and
|
|
174
|
+
// produced NaN strategy results; the missing per-element index is fixed
|
|
175
|
+
// here.)
|
|
176
|
+
this.lastAvgStrategyResult = Math.max(
|
|
177
|
+
...sample.map((s) => s[HeliusPriorityLevel.MEDIUM])
|
|
178
|
+
);
|
|
179
|
+
this.lastMaxStrategyResult = Math.max(
|
|
180
|
+
...sample.map((s) => s[HeliusPriorityLevel.UNSAFE_MAX])
|
|
181
|
+
);
|
|
154
182
|
if (this.customStrategy) {
|
|
155
|
-
|
|
183
|
+
// Custom strategies expect `{ slot, prioritizationFee }[]`; map each
|
|
184
|
+
// market's medium level into that shape so they aggregate real values
|
|
185
|
+
// instead of summing the absent `prioritizationFee` field (NaN).
|
|
186
|
+
this.lastCustomStrategyResult = this.customStrategy.calculate(
|
|
187
|
+
sample.map((s) => ({
|
|
188
|
+
slot: 0,
|
|
189
|
+
prioritizationFee: s[HeliusPriorityLevel.MEDIUM],
|
|
190
|
+
}))
|
|
191
|
+
);
|
|
156
192
|
}
|
|
157
193
|
}
|
|
158
194
|
}
|
|
@@ -9,7 +9,7 @@ export async function fetchSolanaPriorityFee(
|
|
|
9
9
|
connection: Connection,
|
|
10
10
|
lookbackDistance: number,
|
|
11
11
|
addresses: string[]
|
|
12
|
-
): Promise<SolanaPriorityFeeResponse[]> {
|
|
12
|
+
): Promise<SolanaPriorityFeeResponse[] | undefined> {
|
|
13
13
|
try {
|
|
14
14
|
// @ts-ignore
|
|
15
15
|
const rpcJSONResponse: any = await connection._rpcRequest(
|
package/src/pyth/types.ts
CHANGED
|
@@ -12,8 +12,8 @@ export interface SlotSubscriberEvents {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export class SlotSubscriber {
|
|
15
|
-
currentSlot
|
|
16
|
-
subscriptionId
|
|
15
|
+
currentSlot = 0;
|
|
16
|
+
subscriptionId?: number;
|
|
17
17
|
eventEmitter: StrictEventEmitter<EventEmitter, SlotSubscriberEvents>;
|
|
18
18
|
|
|
19
19
|
// Reconnection
|
|
@@ -28,7 +28,7 @@ export class SlotSubscriber {
|
|
|
28
28
|
) {
|
|
29
29
|
this.eventEmitter = new EventEmitter();
|
|
30
30
|
this.resubTimeoutMs = config?.resubTimeoutMs;
|
|
31
|
-
if (this.resubTimeoutMs < 1000) {
|
|
31
|
+
if (this.resubTimeoutMs !== undefined && this.resubTimeoutMs < 1000) {
|
|
32
32
|
console.log(
|
|
33
33
|
'resubTimeoutMs should be at least 1000ms to avoid spamming resub'
|
|
34
34
|
);
|
|
@@ -18,8 +18,16 @@ export type Slothash = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export class SlothashSubscriber {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
private _currentSlothash?: Slothash;
|
|
22
|
+
private get currentSlothash(): Slothash {
|
|
23
|
+
if (!this._currentSlothash) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
'SlothashSubscriber: slothash accessed before subscribe()'
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return this._currentSlothash;
|
|
29
|
+
}
|
|
30
|
+
subscriptionId?: number;
|
|
23
31
|
commitment: Commitment;
|
|
24
32
|
|
|
25
33
|
// Reconnection
|
|
@@ -34,7 +42,7 @@ export class SlothashSubscriber {
|
|
|
34
42
|
) {
|
|
35
43
|
this.resubTimeoutMs = config?.resubTimeoutMs;
|
|
36
44
|
this.commitment = config?.commitment ?? 'processed';
|
|
37
|
-
if (this.resubTimeoutMs < 1000) {
|
|
45
|
+
if (this.resubTimeoutMs != null && this.resubTimeoutMs < 1000) {
|
|
38
46
|
console.log(
|
|
39
47
|
'resubTimeoutMs should be at least 1000ms to avoid spamming resub'
|
|
40
48
|
);
|
|
@@ -53,18 +61,21 @@ export class SlothashSubscriber {
|
|
|
53
61
|
if (currentAccountData == null) {
|
|
54
62
|
throw new Error('Failed to retrieve current slot hash');
|
|
55
63
|
}
|
|
56
|
-
this.
|
|
64
|
+
this._currentSlothash = deserializeSlothash(currentAccountData.data);
|
|
57
65
|
|
|
58
66
|
this.subscriptionId = this.connection.onAccountChange(
|
|
59
67
|
SYSVAR_SLOT_HASHES_PUBKEY,
|
|
60
68
|
(slothashInfo, context) => {
|
|
61
|
-
if (
|
|
69
|
+
if (
|
|
70
|
+
!this._currentSlothash ||
|
|
71
|
+
this._currentSlothash.slot < context.slot
|
|
72
|
+
) {
|
|
62
73
|
if (this.resubTimeoutMs && !this.isUnsubscribing) {
|
|
63
74
|
this.receivingData = true;
|
|
64
75
|
clearTimeout(this.timeoutId);
|
|
65
76
|
this.setTimeout();
|
|
66
77
|
}
|
|
67
|
-
this.
|
|
78
|
+
this._currentSlothash = deserializeSlothash(slothashInfo.data);
|
|
68
79
|
}
|
|
69
80
|
},
|
|
70
81
|
this.commitment
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
|
|
11
11
|
export class grpcSignedMsgUserOrdersAccountSubscriber extends SignedMsgUserOrdersAccountSubscriber {
|
|
12
12
|
private grpcConfigs: GrpcConfigs;
|
|
13
|
-
override subscriber: grpcProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
|
|
14
13
|
|
|
15
14
|
constructor({
|
|
16
15
|
grpcConfigs,
|
|
@@ -23,8 +22,8 @@ export class grpcSignedMsgUserOrdersAccountSubscriber extends SignedMsgUserOrder
|
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
public async subscribe(): Promise<void> {
|
|
26
|
-
if (!this.
|
|
27
|
-
this.
|
|
25
|
+
if (!this._subscriber) {
|
|
26
|
+
this._subscriber =
|
|
28
27
|
await grpcProgramAccountSubscriber.create<SignedMsgUserOrdersAccount>(
|
|
29
28
|
this.grpcConfigs,
|
|
30
29
|
'SingedMsgUserOrdersAccountMap',
|
|
@@ -71,9 +70,9 @@ export class grpcSignedMsgUserOrdersAccountSubscriber extends SignedMsgUserOrder
|
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
public async unsubscribe(): Promise<void> {
|
|
74
|
-
if (!this.
|
|
75
|
-
await this.
|
|
76
|
-
this.
|
|
73
|
+
if (!this._subscriber) return;
|
|
74
|
+
await this._subscriber.unsubscribe();
|
|
75
|
+
this._subscriber = undefined;
|
|
77
76
|
if (this.resyncTimeoutId !== undefined) {
|
|
78
77
|
clearTimeout(this.resyncTimeoutId);
|
|
79
78
|
this.resyncTimeoutId = undefined;
|