@velocity-exchange/sdk 0.0.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +1 -1
- package/CHANGELOG.md +35 -0
- package/README.md +30 -30
- package/bun.lock +24 -2
- 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 +9 -3
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +19 -6
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -5
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +44 -23
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +4 -1
- 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 -5
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +69 -35
- package/lib/browser/accounts/types.d.ts +6 -12
- package/lib/browser/accounts/utils.d.ts +1 -0
- package/lib/browser/accounts/utils.js +10 -3
- 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 -8
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +52 -26
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -7
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +49 -20
- 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 +1 -9
- package/lib/browser/addresses/pda.js +4 -23
- package/lib/browser/adminClient.d.ts +25 -29
- package/lib/browser/adminClient.js +168 -169
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +2 -4
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +8 -10
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +2 -4
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +11 -10
- package/lib/browser/auctionSubscriber/types.d.ts +3 -2
- package/lib/browser/bankrun/bankrunConnection.d.ts +6 -4
- package/lib/browser/bankrun/bankrunConnection.js +69 -31
- 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 +11 -20
- package/lib/browser/config.js +13 -36
- 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 -3
- package/lib/browser/constants/numericConstants.js +3 -5
- package/lib/browser/constituentMap/constituentMap.d.ts +0 -2
- package/lib/browser/constituentMap/constituentMap.js +10 -6
- 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 +9 -15
- package/lib/browser/core/VelocityCore.js +5 -7
- 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 +1 -1
- package/lib/browser/core/instructions/withdraw.js +1 -1
- package/lib/browser/core/remainingAccounts.d.ts +2 -2
- package/lib/browser/core/remainingAccounts.js +5 -5
- package/lib/browser/decode/user.js +9 -1
- package/lib/browser/dlob/DLOB.d.ts +7 -2
- package/lib/browser/dlob/DLOB.js +205 -142
- package/lib/browser/dlob/DLOBNode.d.ts +5 -2
- package/lib/browser/dlob/DLOBNode.js +7 -0
- package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -2
- package/lib/browser/dlob/DLOBSubscriber.js +39 -39
- package/lib/browser/dlob/NodeList.js +8 -7
- package/lib/browser/dlob/orderBookLevels.js +24 -17
- package/lib/browser/dlob/types.d.ts +0 -2
- package/lib/browser/events/eventList.js +4 -1
- package/lib/browser/events/eventSubscriber.d.ts +6 -3
- package/lib/browser/events/eventSubscriber.js +75 -26
- package/lib/browser/events/eventsServerLogProvider.d.ts +1 -1
- package/lib/browser/events/eventsServerLogProvider.js +17 -10
- package/lib/browser/events/fetchLogs.d.ts +1 -1
- package/lib/browser/events/fetchLogs.js +4 -2
- package/lib/browser/events/parse.js +14 -14
- package/lib/browser/events/pollingLogProvider.d.ts +1 -1
- package/lib/browser/events/pollingLogProvider.js +1 -0
- package/lib/browser/events/txEventCache.js +6 -2
- package/lib/browser/events/types.d.ts +3 -7
- package/lib/browser/events/types.js +1 -3
- package/lib/browser/events/webSocketLogProvider.d.ts +1 -1
- package/lib/browser/events/webSocketLogProvider.js +5 -2
- package/lib/browser/factory/bigNum.js +1 -1
- package/lib/{node/idl/drift.d.ts → browser/idl/velocity.d.ts} +2412 -2481
- package/lib/browser/idl/{drift.json → velocity.json} +2265 -2333
- package/lib/browser/index.d.ts +1 -3
- package/lib/browser/index.js +1 -4
- package/lib/browser/jupiter/jupiterClient.d.ts +1 -1
- package/lib/browser/jupiter/jupiterClient.js +18 -8
- package/lib/browser/marginCalculation.js +1 -0
- package/lib/browser/math/amm.d.ts +31 -13
- package/lib/browser/math/amm.js +87 -31
- package/lib/browser/math/auction.js +16 -12
- package/lib/browser/math/bankruptcy.js +1 -1
- package/lib/browser/math/builder.d.ts +18 -1
- package/lib/browser/math/builder.js +32 -1
- package/lib/browser/math/funding.js +30 -30
- package/lib/browser/math/insurance.d.ts +1 -1
- package/lib/browser/math/insurance.js +4 -5
- package/lib/browser/math/margin.d.ts +3 -11
- package/lib/browser/math/margin.js +10 -69
- package/lib/browser/math/market.d.ts +4 -12
- package/lib/browser/math/market.js +12 -46
- package/lib/browser/math/oracles.d.ts +4 -7
- package/lib/browser/math/oracles.js +24 -37
- package/lib/browser/math/orders.d.ts +2 -7
- package/lib/browser/math/orders.js +9 -81
- package/lib/browser/math/position.d.ts +0 -4
- package/lib/browser/math/position.js +6 -11
- package/lib/browser/math/repeg.d.ts +0 -1
- package/lib/browser/math/repeg.js +1 -23
- package/lib/browser/math/spotBalance.d.ts +4 -4
- package/lib/browser/math/spotBalance.js +6 -6
- package/lib/browser/math/spotMarket.d.ts +0 -6
- package/lib/browser/math/spotMarket.js +1 -16
- package/lib/browser/math/spotPosition.d.ts +4 -4
- package/lib/browser/math/state.d.ts +0 -2
- package/lib/browser/math/state.js +1 -9
- package/lib/browser/math/superStake.d.ts +11 -63
- package/lib/browser/math/superStake.js +29 -28
- package/lib/browser/math/trade.js +7 -7
- package/lib/browser/math/utils.d.ts +1 -1
- package/lib/browser/math/utils.js +1 -1
- package/lib/browser/memcmp.d.ts +0 -1
- package/lib/browser/memcmp.js +1 -10
- package/lib/browser/oracles/prelaunchOracleClient.js +3 -2
- package/lib/browser/oracles/pythClient.js +9 -3
- package/lib/browser/oracles/pythLazerClient.js +5 -4
- package/lib/browser/oracles/utils.d.ts +4 -0
- package/lib/browser/oracles/utils.js +9 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +1 -3
- package/lib/browser/orderSubscriber/OrderSubscriber.js +16 -14
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/browser/orderSubscriber/types.d.ts +0 -2
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +2 -6
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +34 -18
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +3 -11
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/priorityFee/types.d.ts +3 -8
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +1 -3
- package/lib/browser/pyth/pythLazerSubscriber.d.ts +1 -1
- package/lib/browser/pyth/pythLazerSubscriber.js +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.js +1 -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 +7 -7
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +14 -10
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +7 -6
- package/lib/browser/swift/swiftOrderSubscriber.js +15 -16
- package/lib/browser/testClient.js +3 -2
- 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 +7 -1
- 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 +102 -157
- package/lib/browser/types.js +6 -2
- package/lib/browser/user.d.ts +22 -10
- package/lib/browser/user.js +174 -154
- package/lib/browser/userConfig.d.ts +3 -2
- package/lib/browser/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/browser/userMap/WebsocketSubscription.js +1 -1
- package/lib/browser/userMap/grpcSubscription.d.ts +1 -1
- package/lib/browser/userMap/grpcSubscription.js +1 -1
- package/lib/browser/userMap/referrerMap.d.ts +0 -2
- package/lib/browser/userMap/referrerMap.js +10 -7
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +0 -2
- package/lib/browser/userMap/revenueShareEscrowMap.js +4 -4
- package/lib/browser/userMap/userMap.d.ts +3 -5
- package/lib/browser/userMap/userMap.js +39 -30
- package/lib/browser/userMap/userMapConfig.d.ts +3 -2
- package/lib/browser/userMap/userStatsMap.d.ts +1 -3
- package/lib/browser/userMap/userStatsMap.js +18 -17
- package/lib/browser/userStats.d.ts +7 -4
- package/lib/browser/userStats.js +28 -18
- package/lib/browser/userStatsConfig.d.ts +3 -2
- 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/util/ed25519Utils.d.ts +1 -1
- package/lib/browser/util/ed25519Utils.js +1 -1
- package/lib/browser/velocityClient.d.ts +144 -71
- package/lib/browser/velocityClient.js +653 -457
- package/lib/browser/velocityClientConfig.d.ts +0 -8
- 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 +9 -3
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +19 -6
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -5
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +44 -23
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +4 -1
- 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 -5
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +69 -35
- package/lib/node/accounts/types.d.ts +6 -12
- 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 +10 -3
- 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 -8
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +52 -26
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -7
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +49 -20
- 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 +1 -9
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +4 -23
- package/lib/node/adminClient.d.ts +25 -29
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +168 -169
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +2 -4
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +8 -10
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +2 -4
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +11 -10
- package/lib/node/auctionSubscriber/types.d.ts +3 -2
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.d.ts +6 -4
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.js +69 -31
- 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 +11 -20
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +13 -36
- 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 -3
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +3 -5
- package/lib/node/constituentMap/constituentMap.d.ts +0 -2
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +10 -6
- 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 +9 -15
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +5 -7
- 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 +1 -1
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/core/instructions/withdraw.js +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 +5 -5
- 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 +7 -2
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +205 -142
- package/lib/node/dlob/DLOBNode.d.ts +5 -2
- 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 -2
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +39 -39
- 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.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +24 -17
- package/lib/node/dlob/types.d.ts +0 -2
- package/lib/node/dlob/types.d.ts.map +1 -1
- 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 +6 -3
- 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 +17 -10
- 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/parse.d.ts.map +1 -1
- package/lib/node/events/parse.js +14 -14
- 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 +3 -7
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +1 -3
- 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.js +1 -1
- package/lib/{browser/idl/drift.d.ts → node/idl/velocity.d.ts} +2413 -2480
- package/lib/node/idl/velocity.d.ts.map +1 -0
- package/lib/node/idl/{drift.json → velocity.json} +2265 -2333
- package/lib/node/index.d.ts +1 -3
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -4
- package/lib/node/jupiter/jupiterClient.d.ts +1 -1
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.js +18 -8
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marginCalculation.js +1 -0
- package/lib/node/math/amm.d.ts +31 -13
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +87 -31
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +16 -12
- package/lib/node/math/bankruptcy.js +1 -1
- package/lib/node/math/builder.d.ts +18 -1
- package/lib/node/math/builder.d.ts.map +1 -1
- package/lib/node/math/builder.js +32 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +30 -30
- package/lib/node/math/insurance.d.ts +1 -1
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +4 -5
- package/lib/node/math/margin.d.ts +3 -11
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +10 -69
- package/lib/node/math/market.d.ts +4 -12
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +12 -46
- package/lib/node/math/oracles.d.ts +4 -7
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +24 -37
- package/lib/node/math/orders.d.ts +2 -7
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +9 -81
- package/lib/node/math/position.d.ts +1 -5
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +6 -11
- package/lib/node/math/repeg.d.ts +0 -1
- 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 -4
- 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 -6
- 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 -4
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/state.d.ts +0 -2
- 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 +11 -63
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +29 -28
- package/lib/node/math/trade.d.ts +2 -2
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +7 -7
- package/lib/node/math/utils.d.ts +1 -1
- package/lib/node/math/utils.js +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.map +1 -1
- package/lib/node/oracles/pythClient.js +9 -3
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +5 -4
- package/lib/node/oracles/utils.d.ts +4 -0
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/oracles/utils.js +9 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +1 -3
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +16 -14
- package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/node/orderSubscriber/types.d.ts +0 -2
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- 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 +2 -6
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +34 -18
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +3 -11
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/types.d.ts +3 -8
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.js +1 -3
- package/lib/node/pyth/pythLazerSubscriber.d.ts +1 -1
- package/lib/node/pyth/pythLazerSubscriber.js +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.js +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 +7 -7
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +14 -10
- package/lib/node/swift/swiftOrderSubscriber.d.ts +7 -6
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +15 -16
- package/lib/node/testClient.js +3 -2
- 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 +100 -155
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +6 -2
- package/lib/node/user.d.ts +22 -10
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +174 -154
- package/lib/node/userConfig.d.ts +3 -2
- package/lib/node/userConfig.d.ts.map +1 -1
- package/lib/node/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/userMap/WebsocketSubscription.js +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/grpcSubscription.js +1 -1
- package/lib/node/userMap/referrerMap.d.ts +0 -2
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +10 -7
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +0 -2
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +4 -4
- package/lib/node/userMap/userMap.d.ts +3 -5
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +39 -30
- package/lib/node/userMap/userMapConfig.d.ts +3 -2
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +1 -3
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +18 -17
- package/lib/node/userStats.d.ts +7 -4
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +28 -18
- package/lib/node/userStatsConfig.d.ts +3 -2
- package/lib/node/userStatsConfig.d.ts.map +1 -1
- 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/util/ed25519Utils.d.ts +1 -1
- package/lib/node/util/ed25519Utils.js +1 -1
- package/lib/node/velocityClient.d.ts +145 -72
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +653 -457
- package/lib/node/velocityClientConfig.d.ts +0 -8
- package/lib/node/velocityClientConfig.d.ts.map +1 -1
- package/package.json +10 -9
- package/scripts/deposit-isolated-positions.ts +2 -2
- package/scripts/find-flagged-users.ts +1 -1
- package/scripts/grpc-client-test-comparison.ts +4 -4
- package/scripts/grpc-multiuser-client-test-comparison.ts +2 -2
- package/scripts/single-grpc-client-test.ts +3 -3
- package/scripts/updateVersion.js +4 -4
- package/scripts/withdraw-isolated-positions.ts +2 -2
- 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 +12 -4
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +17 -14
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +69 -49
- package/src/accounts/laserProgramAccountSubscriber.ts +4 -1
- 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 +80 -41
- package/src/accounts/types.ts +8 -13
- package/src/accounts/utils.ts +12 -2
- 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 +79 -58
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +77 -45
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +1 -6
- package/src/addresses/marketAddresses.ts +3 -2
- package/src/addresses/pda.ts +3 -38
- package/src/adminClient.ts +285 -315
- package/src/auctionSubscriber/auctionSubscriber.ts +8 -11
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +13 -11
- package/src/auctionSubscriber/types.ts +3 -3
- package/src/bankrun/bankrunConnection.ts +83 -39
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +5 -4
- package/src/clock/clockSubscriber.ts +10 -9
- package/src/config.ts +16 -70
- package/src/constants/index.ts +1 -2
- package/src/constants/numericConstants.ts +3 -3
- package/src/constituentMap/constituentMap.ts +10 -7
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +4 -2
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +13 -4
- package/src/core/VelocityCore.ts +11 -20
- package/src/core/instructions/perpOrders.ts +14 -0
- package/src/core/instructions/withdraw.ts +2 -2
- package/src/core/remainingAccounts.ts +7 -7
- package/src/decode/user.ts +8 -1
- package/src/dlob/DLOB.ts +300 -176
- package/src/dlob/DLOBNode.ts +23 -3
- package/src/dlob/DLOBSubscriber.ts +53 -42
- package/src/dlob/NodeList.ts +8 -7
- package/src/dlob/orderBookLevels.ts +51 -25
- package/src/dlob/types.ts +0 -2
- package/src/events/eventList.ts +4 -1
- package/src/events/eventSubscriber.ts +108 -50
- package/src/events/eventsServerLogProvider.ts +24 -15
- package/src/events/fetchLogs.ts +3 -3
- package/src/events/parse.ts +14 -14
- package/src/events/pollingLogProvider.ts +2 -2
- package/src/events/txEventCache.ts +8 -2
- package/src/events/types.ts +4 -15
- package/src/events/webSocketLogProvider.ts +5 -3
- package/src/factory/bigNum.ts +2 -2
- package/src/idl/{drift.json → velocity.json} +2265 -2333
- package/src/idl/{drift.ts → velocity.ts} +2267 -2335
- package/src/index.ts +1 -6
- package/src/jupiter/jupiterClient.ts +30 -10
- package/src/margin/README.md +2 -2
- package/src/marginCalculation.ts +1 -0
- package/src/math/amm.ts +217 -40
- package/src/math/auction.ts +16 -12
- package/src/math/bankruptcy.ts +1 -1
- package/src/math/builder.ts +45 -1
- package/src/math/funding.ts +51 -47
- package/src/math/insurance.ts +6 -8
- package/src/math/margin.ts +12 -119
- package/src/math/market.ts +16 -98
- package/src/math/oracles.ts +29 -43
- package/src/math/orders.ts +13 -109
- package/src/math/position.ts +6 -12
- 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 +36 -85
- package/src/math/trade.ts +7 -3
- package/src/math/utils.ts +1 -1
- 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 +10 -5
- package/src/oracles/utils.ts +15 -0
- package/src/orderSubscriber/OrderSubscriber.ts +12 -12
- package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
- package/src/orderSubscriber/grpcSubscription.ts +2 -2
- package/src/orderSubscriber/types.ts +0 -2
- package/src/priorityFee/heliusPriorityFeeMethod.ts +1 -1
- package/src/priorityFee/priorityFeeSubscriber.ts +50 -21
- package/src/priorityFee/priorityFeeSubscriberMap.ts +2 -10
- package/src/priorityFee/solanaPriorityFeeMethod.ts +1 -1
- package/src/priorityFee/types.ts +3 -13
- package/src/priorityFee/velocityPriorityFeeMethod.ts +0 -12
- package/src/pyth/pythLazerSubscriber.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/swap/UnifiedSwapClient.ts +1 -1
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +5 -6
- package/src/swift/signedMsgUserAccountSubscriber.ts +18 -16
- package/src/swift/swiftOrderSubscriber.ts +17 -21
- 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 +119 -173
- package/src/user.ts +208 -165
- package/src/userConfig.ts +1 -3
- package/src/userMap/WebsocketSubscription.ts +2 -2
- package/src/userMap/grpcSubscription.ts +2 -2
- package/src/userMap/referrerMap.ts +13 -13
- package/src/userMap/revenueShareEscrowMap.ts +6 -5
- package/src/userMap/userMap.ts +46 -32
- package/src/userMap/userMapConfig.ts +3 -3
- package/src/userMap/userStatsMap.ts +32 -23
- package/src/userStats.ts +22 -13
- package/src/userStatsConfig.ts +3 -3
- package/src/util/TransactionConfirmationManager.ts +10 -2
- package/src/util/chainClock.ts +1 -1
- package/src/util/computeUnits.ts +7 -3
- package/src/util/ed25519Utils.ts +1 -1
- package/src/velocityClient.ts +867 -600
- package/src/velocityClientConfig.ts +0 -10
- package/tests/{DriftCore → VelocityCore}/decode.test.ts +1 -1
- package/tests/{DriftCore → VelocityCore}/fill_trigger.test.ts +1 -1
- package/tests/{DriftCore → VelocityCore}/instructions.test.ts +1 -1
- package/tests/{DriftCore → VelocityCore}/pdas.test.ts +4 -2
- package/tests/amm/test.ts +138 -0
- package/tests/ci/verifyConstants.ts +24 -27
- package/tests/decode/test.ts +2 -2
- package/tests/dlob/helpers.ts +11 -10
- package/tests/events/parseLogsForCuUsage.ts +15 -15
- package/tests/user/helpers.ts +9 -9
- package/tests/user/test.ts +13 -10
- package/tsconfig.json +1 -0
- 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/deprecatedAlias.d.ts +0 -26
- package/lib/browser/util/deprecatedAlias.js +0 -10
- 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/idl/drift.d.ts.map +0 -1
- 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/deprecatedAlias.d.ts +0 -27
- package/lib/node/util/deprecatedAlias.d.ts.map +0 -1
- package/lib/node/util/deprecatedAlias.js +0 -10
- 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/src/constants/insuranceFund.ts +0 -8
- package/src/tx/forwardOnlyTxSender.ts +0 -145
- package/src/util/deprecatedAlias.ts +0 -21
- package/src/util/tps.ts +0 -27
- /package/lib/browser/idl/{drift.js → velocity.js} +0 -0
- /package/lib/node/idl/{drift.js → velocity.js} +0 -0
- /package/tests/{DriftCore → VelocityCore}/perp_orders.test.ts +0 -0
- /package/tests/{DriftCore → VelocityCore}/remainingAccounts.test.ts +0 -0
- /package/tests/{DriftCore → VelocityCore}/settlement_liquidation.test.ts +0 -0
|
@@ -10,33 +10,29 @@ import { ResubOpts } from '../accounts/types';
|
|
|
10
10
|
|
|
11
11
|
export class AuctionSubscriber {
|
|
12
12
|
private velocityClient: VelocityClient;
|
|
13
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
14
|
-
private get driftClient(): VelocityClient {
|
|
15
|
-
return this.velocityClient;
|
|
16
|
-
}
|
|
17
13
|
private opts: ConfirmOptions;
|
|
18
14
|
private resubOpts?: ResubOpts;
|
|
19
15
|
|
|
20
16
|
eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
|
|
21
|
-
private subscriber
|
|
17
|
+
private subscriber?: WebSocketProgramAccountSubscriber<UserAccount>;
|
|
22
18
|
|
|
23
19
|
constructor({
|
|
24
20
|
velocityClient,
|
|
25
|
-
driftClient,
|
|
26
21
|
opts,
|
|
27
22
|
resubTimeoutMs,
|
|
28
23
|
logResubMessages,
|
|
29
24
|
}: AuctionSubscriberConfig) {
|
|
30
25
|
// Type-system guarantees at least one of the two is supplied.
|
|
31
|
-
this.velocityClient =
|
|
32
|
-
this.opts = opts || this.velocityClient.opts;
|
|
26
|
+
this.velocityClient = velocityClient!;
|
|
27
|
+
this.opts = opts || this.velocityClient.opts || {};
|
|
33
28
|
this.eventEmitter = new EventEmitter();
|
|
34
29
|
this.resubOpts = { resubTimeoutMs, logResubMessages };
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
public async subscribe() {
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
let subscriber = this.subscriber;
|
|
34
|
+
if (!subscriber) {
|
|
35
|
+
subscriber = new WebSocketProgramAccountSubscriber<UserAccount>(
|
|
40
36
|
'AuctionSubscriber',
|
|
41
37
|
'user',
|
|
42
38
|
this.velocityClient.program,
|
|
@@ -51,9 +47,10 @@ export class AuctionSubscriber {
|
|
|
51
47
|
},
|
|
52
48
|
this.resubOpts
|
|
53
49
|
);
|
|
50
|
+
this.subscriber = subscriber;
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
await
|
|
53
|
+
await subscriber.subscribe(
|
|
57
54
|
(accountId: PublicKey, data: UserAccount, context: Context) => {
|
|
58
55
|
this.eventEmitter.emit(
|
|
59
56
|
'onAccountUpdate',
|
|
@@ -11,36 +11,37 @@ import { grpcProgramAccountSubscriber } from '../accounts/grpcProgramAccountSubs
|
|
|
11
11
|
|
|
12
12
|
export class AuctionSubscriberGrpc {
|
|
13
13
|
private velocityClient: VelocityClient;
|
|
14
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
15
|
-
private get driftClient(): VelocityClient {
|
|
16
|
-
return this.velocityClient;
|
|
17
|
-
}
|
|
18
14
|
private opts: ConfirmOptions;
|
|
19
15
|
private resubOpts?: ResubOpts;
|
|
20
16
|
private grpcConfigs?: GrpcConfigs;
|
|
21
17
|
|
|
22
18
|
eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
|
|
23
|
-
private subscriber
|
|
19
|
+
private subscriber?: WebSocketProgramAccountSubscriber<UserAccount>;
|
|
24
20
|
|
|
25
21
|
constructor({
|
|
26
22
|
velocityClient,
|
|
27
|
-
driftClient,
|
|
28
23
|
opts,
|
|
29
24
|
grpcConfigs,
|
|
30
25
|
resubTimeoutMs,
|
|
31
26
|
logResubMessages,
|
|
32
27
|
}: AuctionSubscriberConfig) {
|
|
33
28
|
// Type-system guarantees at least one of the two is supplied.
|
|
34
|
-
this.velocityClient =
|
|
35
|
-
this.opts = opts || this.velocityClient.opts;
|
|
29
|
+
this.velocityClient = velocityClient!;
|
|
30
|
+
this.opts = opts || this.velocityClient.opts || {};
|
|
36
31
|
this.eventEmitter = new EventEmitter();
|
|
37
32
|
this.resubOpts = { resubTimeoutMs, logResubMessages };
|
|
38
33
|
this.grpcConfigs = grpcConfigs;
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
public async subscribe() {
|
|
42
|
-
|
|
43
|
-
|
|
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>(
|
|
44
45
|
this.grpcConfigs,
|
|
45
46
|
'AuctionSubscriber',
|
|
46
47
|
'user',
|
|
@@ -55,9 +56,10 @@ export class AuctionSubscriberGrpc {
|
|
|
55
56
|
},
|
|
56
57
|
this.resubOpts
|
|
57
58
|
);
|
|
59
|
+
this.subscriber = subscriber;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
await
|
|
62
|
+
await subscriber.subscribe(
|
|
61
63
|
(accountId: PublicKey, data: UserAccount, context: Context) => {
|
|
62
64
|
this.eventEmitter.emit(
|
|
63
65
|
'onAccountUpdate',
|
|
@@ -2,7 +2,6 @@ import { GrpcConfigs } from '../accounts/types';
|
|
|
2
2
|
import { VelocityClient } from '../velocityClient';
|
|
3
3
|
import { UserAccount } from '../types';
|
|
4
4
|
import { ConfirmOptions, PublicKey } from '@solana/web3.js';
|
|
5
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
6
5
|
|
|
7
6
|
type AuctionSubscriberConfigBase = {
|
|
8
7
|
opts?: ConfirmOptions;
|
|
@@ -11,8 +10,9 @@ type AuctionSubscriberConfigBase = {
|
|
|
11
10
|
grpcConfigs?: GrpcConfigs;
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
export type AuctionSubscriberConfig = AuctionSubscriberConfigBase &
|
|
15
|
-
|
|
13
|
+
export type AuctionSubscriberConfig = AuctionSubscriberConfigBase & {
|
|
14
|
+
velocityClient: VelocityClient;
|
|
15
|
+
};
|
|
16
16
|
|
|
17
17
|
export interface AuctionSubscriberEvents {
|
|
18
18
|
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,16 @@ 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
|
|
|
196
207
|
async getMultipleAccountsInfo(
|
|
197
208
|
publicKeys: PublicKey[],
|
|
198
209
|
_commitmentOrConfig?: Commitment
|
|
199
|
-
): Promise<AccountInfo<Buffer>[]> {
|
|
210
|
+
): Promise<(AccountInfo<Buffer> | null)[]> {
|
|
200
211
|
const accountInfos = [];
|
|
201
212
|
|
|
202
213
|
for (const publicKey of publicKeys) {
|
|
@@ -246,9 +257,18 @@ export class BankrunConnection {
|
|
|
246
257
|
: await internal.tryProcessLegacyTransaction(serialized);
|
|
247
258
|
const banksTransactionMeta = new BanksTransactionResultWithMeta(inner);
|
|
248
259
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
260
|
+
let signature: string;
|
|
261
|
+
if (isVersioned) {
|
|
262
|
+
signature = bs58.encode((tx as VersionedTransaction).signatures[0]);
|
|
263
|
+
} else {
|
|
264
|
+
const legacySignature = (tx as Transaction).signatures[0].signature;
|
|
265
|
+
if (legacySignature === null) {
|
|
266
|
+
throw new Error(
|
|
267
|
+
'BankrunConnection: transaction is missing its first signature'
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
signature = bs58.encode(legacySignature);
|
|
271
|
+
}
|
|
252
272
|
|
|
253
273
|
if (banksTransactionMeta.result) {
|
|
254
274
|
if (
|
|
@@ -273,9 +293,14 @@ export class BankrunConnection {
|
|
|
273
293
|
}
|
|
274
294
|
let finalizedCount = 0;
|
|
275
295
|
while (finalizedCount < 10) {
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
296
|
+
const statusValue = (await this.getSignatureStatus(signature)).value;
|
|
297
|
+
if (statusValue === null) {
|
|
298
|
+
throw new Error(
|
|
299
|
+
`BankrunConnection: no signature status for ${signature}`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
const signatureStatus = statusValue.confirmationStatus;
|
|
303
|
+
if (signatureStatus?.toString() == '"finalized"') {
|
|
279
304
|
finalizedCount += 1;
|
|
280
305
|
}
|
|
281
306
|
}
|
|
@@ -291,14 +316,16 @@ export class BankrunConnection {
|
|
|
291
316
|
if (this.onLogCallbacks.size > 0) {
|
|
292
317
|
const transaction = await this.getTransaction(signature);
|
|
293
318
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
logs
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
logCallback(
|
|
319
|
+
if (transaction !== null) {
|
|
320
|
+
const context = { slot: transaction.slot };
|
|
321
|
+
const logs = {
|
|
322
|
+
logs: transaction.meta.logMessages,
|
|
323
|
+
err: transaction.meta.err,
|
|
324
|
+
signature,
|
|
325
|
+
};
|
|
326
|
+
for (const logCallback of this.onLogCallbacks.values()) {
|
|
327
|
+
logCallback(logs, context);
|
|
328
|
+
}
|
|
302
329
|
}
|
|
303
330
|
}
|
|
304
331
|
|
|
@@ -307,6 +334,9 @@ export class BankrunConnection {
|
|
|
307
334
|
callback,
|
|
308
335
|
] of this.onAccountChangeCallbacks.values()) {
|
|
309
336
|
const accountInfo = await this.getParsedAccountInfo(publicKey);
|
|
337
|
+
if (accountInfo.value === null) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
310
340
|
callback(accountInfo.value, accountInfo.context);
|
|
311
341
|
}
|
|
312
342
|
|
|
@@ -326,7 +356,7 @@ export class BankrunConnection {
|
|
|
326
356
|
currentClock.unixTimestamp + BigInt(1)
|
|
327
357
|
);
|
|
328
358
|
this.context.setClock(newClock);
|
|
329
|
-
this.
|
|
359
|
+
this._clock = newClock;
|
|
330
360
|
}
|
|
331
361
|
|
|
332
362
|
getTime(): number {
|
|
@@ -335,7 +365,7 @@ export class BankrunConnection {
|
|
|
335
365
|
|
|
336
366
|
async getParsedAccountInfo(
|
|
337
367
|
publicKey: PublicKey
|
|
338
|
-
): Promise<RpcResponseAndContext<AccountInfo<Buffer>>> {
|
|
368
|
+
): Promise<RpcResponseAndContext<null | AccountInfo<Buffer>>> {
|
|
339
369
|
const accountInfoBytes = await this._banksClient.getAccount(publicKey);
|
|
340
370
|
if (accountInfoBytes === null) {
|
|
341
371
|
return {
|
|
@@ -360,6 +390,9 @@ export class BankrunConnection {
|
|
|
360
390
|
const blockhashAndBlockheight = await this._banksClient.getLatestBlockhash(
|
|
361
391
|
commitment
|
|
362
392
|
);
|
|
393
|
+
if (blockhashAndBlockheight === null) {
|
|
394
|
+
throw new Error('Failed to get latest blockhash');
|
|
395
|
+
}
|
|
363
396
|
return {
|
|
364
397
|
blockhash: blockhashAndBlockheight[0],
|
|
365
398
|
lastValidBlockHeight: Number(blockhashAndBlockheight[1]),
|
|
@@ -427,6 +460,9 @@ export class BankrunConnection {
|
|
|
427
460
|
const transactionStatus = await this._banksClient.getTransactionStatus(
|
|
428
461
|
signature
|
|
429
462
|
);
|
|
463
|
+
if (transactionStatus === null) {
|
|
464
|
+
throw new Error(`tx has no status: ${signature}`);
|
|
465
|
+
}
|
|
430
466
|
if (txMeta.meta === null) {
|
|
431
467
|
throw new Error(`tx has no meta: ${JSON.stringify(txMeta)}`);
|
|
432
468
|
}
|
|
@@ -440,24 +476,27 @@ export class BankrunConnection {
|
|
|
440
476
|
};
|
|
441
477
|
}
|
|
442
478
|
|
|
443
|
-
|
|
479
|
+
private getTransactionMetaOrThrow(
|
|
480
|
+
signature: string
|
|
481
|
+
): NonNullable<BanksTransactionResultWithMeta['meta']> {
|
|
444
482
|
const txMeta = this.transactionToMeta.get(
|
|
445
483
|
signature as TransactionSignature
|
|
446
484
|
);
|
|
447
485
|
if (txMeta === undefined) {
|
|
448
486
|
throw new Error('Transaction not found');
|
|
449
487
|
}
|
|
450
|
-
|
|
488
|
+
if (txMeta.meta === null) {
|
|
489
|
+
throw new Error(`tx has no meta: ${JSON.stringify(txMeta)}`);
|
|
490
|
+
}
|
|
491
|
+
return txMeta.meta;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
findComputeUnitConsumption(signature: string): bigint {
|
|
495
|
+
return this.getTransactionMetaOrThrow(signature).computeUnitsConsumed;
|
|
451
496
|
}
|
|
452
497
|
|
|
453
498
|
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);
|
|
499
|
+
console.log(this.getTransactionMetaOrThrow(signature).logMessages);
|
|
461
500
|
}
|
|
462
501
|
|
|
463
502
|
async simulateTransaction(
|
|
@@ -467,22 +506,27 @@ export class BankrunConnection {
|
|
|
467
506
|
const simulationResult = await this._banksClient.simulateTransaction(
|
|
468
507
|
transaction
|
|
469
508
|
);
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
509
|
+
const meta = simulationResult.meta;
|
|
510
|
+
if (meta === null) {
|
|
511
|
+
throw new Error('BankrunConnection: simulation returned no meta');
|
|
512
|
+
}
|
|
513
|
+
let returnData: TransactionReturnData | undefined;
|
|
514
|
+
if (meta.returnData !== null) {
|
|
515
|
+
const returnDataNormalized = Buffer.from(meta.returnData.data).toString(
|
|
516
|
+
'base64'
|
|
517
|
+
);
|
|
518
|
+
returnData = {
|
|
519
|
+
programId: meta.returnData.programId.toBase58(),
|
|
520
|
+
data: [returnDataNormalized, 'base64'],
|
|
521
|
+
};
|
|
522
|
+
}
|
|
479
523
|
return {
|
|
480
524
|
context: { slot: Number(await this._banksClient.getSlot()) },
|
|
481
525
|
value: {
|
|
482
526
|
err: simulationResult.result,
|
|
483
|
-
logs:
|
|
527
|
+
logs: meta.logMessages,
|
|
484
528
|
accounts: undefined,
|
|
485
|
-
unitsConsumed: Number(
|
|
529
|
+
unitsConsumed: Number(meta.computeUnitsConsumed),
|
|
486
530
|
returnData,
|
|
487
531
|
},
|
|
488
532
|
};
|
|
@@ -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
|
@@ -15,18 +15,12 @@ import {
|
|
|
15
15
|
import { OracleInfo } from './oracles/types';
|
|
16
16
|
import { Program, ProgramAccount } from './isomorphic/anchor';
|
|
17
17
|
import { getOracleId } from './oracles/oracleId';
|
|
18
|
-
import {
|
|
18
|
+
import { Velocity } from './idl/velocity';
|
|
19
19
|
|
|
20
|
-
export type VelocityProgram = Program<
|
|
21
|
-
|
|
22
|
-
/** @deprecated Use `VelocityProgram` instead. `DriftProgram` will be removed in a future major. */
|
|
23
|
-
export type DriftProgram = VelocityProgram;
|
|
20
|
+
export type VelocityProgram = Program<Velocity>;
|
|
24
21
|
|
|
25
22
|
export type VelocityEnv = 'devnet' | 'mainnet-beta';
|
|
26
23
|
|
|
27
|
-
/** @deprecated Use `VelocityEnv` instead. `DriftEnv` will be removed in a future major. */
|
|
28
|
-
export type DriftEnv = VelocityEnv;
|
|
29
|
-
|
|
30
24
|
/** Widened env type accepted by `initialize()`; `'master'` is a legacy alias for `'devnet'`. */
|
|
31
25
|
export type LegacyVelocityEnv = VelocityEnv | 'master';
|
|
32
26
|
|
|
@@ -34,12 +28,8 @@ export interface VelocityConfig {
|
|
|
34
28
|
ENV: VelocityEnv;
|
|
35
29
|
PYTH_ORACLE_MAPPING_ADDRESS: string;
|
|
36
30
|
VELOCITY_PROGRAM_ID: string;
|
|
37
|
-
/** @deprecated Use `VELOCITY_PROGRAM_ID` instead. Kept on the config shape so existing callers reading this field continue to work; will be removed in a future major. */
|
|
38
|
-
DRIFT_PROGRAM_ID: string;
|
|
39
31
|
JIT_PROXY_PROGRAM_ID?: string;
|
|
40
32
|
VELOCITY_ORACLE_RECEIVER_ID: string;
|
|
41
|
-
/** @deprecated Use `VELOCITY_ORACLE_RECEIVER_ID` instead. Kept on the config shape so existing callers reading this field continue to work; will be removed in a future major. */
|
|
42
|
-
DRIFT_ORACLE_RECEIVER_ID: string;
|
|
43
33
|
QUOTE_MINT_ADDRESS: string;
|
|
44
34
|
V2_ALPHA_TICKET_MINT_ADDRESS: string;
|
|
45
35
|
PERP_MARKETS: PerpMarketConfig[];
|
|
@@ -50,28 +40,18 @@ export interface VelocityConfig {
|
|
|
50
40
|
SB_ON_DEMAND_PID: PublicKey;
|
|
51
41
|
}
|
|
52
42
|
|
|
53
|
-
/** @deprecated Use `VelocityConfig` instead. `DriftConfig` will be removed in a future major. */
|
|
54
|
-
export type DriftConfig = VelocityConfig;
|
|
55
|
-
|
|
56
43
|
export const VELOCITY_PROGRAM_ID =
|
|
57
|
-
'
|
|
58
|
-
|
|
59
|
-
/** @deprecated Use `VELOCITY_PROGRAM_ID` instead. `DRIFT_PROGRAM_ID` will be removed in a future major. */
|
|
60
|
-
export const DRIFT_PROGRAM_ID = VELOCITY_PROGRAM_ID;
|
|
44
|
+
'vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P';
|
|
61
45
|
|
|
62
46
|
export const VELOCITY_DEVNET_PROGRAM_ID =
|
|
63
47
|
'vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P';
|
|
64
48
|
|
|
65
|
-
/** @deprecated Use `VELOCITY_DEVNET_PROGRAM_ID` instead. `DRIFT_DEVNET_PROGRAM_ID` will be removed in a future major. */
|
|
66
|
-
export const DRIFT_DEVNET_PROGRAM_ID = VELOCITY_DEVNET_PROGRAM_ID;
|
|
67
|
-
|
|
68
49
|
export const VELOCITY_ORACLE_RECEIVER_ID =
|
|
69
50
|
'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha';
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
export const DRIFT_ORACLE_RECEIVER_ID = VELOCITY_ORACLE_RECEIVER_ID;
|
|
73
|
-
export const PTYH_LAZER_PROGRAM_ID =
|
|
52
|
+
export const PYTH_LAZER_PROGRAM_ID =
|
|
74
53
|
'pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt';
|
|
54
|
+
|
|
75
55
|
export const SB_ON_DEMAND_DEVNET_PID = new PublicKey(
|
|
76
56
|
'Aio4gaXjXzJNVLtzwtNVmSqGKpANtXhybbkhtAC94ji2'
|
|
77
57
|
);
|
|
@@ -92,8 +72,6 @@ export const configs: { [key in VelocityEnv]: VelocityConfig } = {
|
|
|
92
72
|
ENV: 'devnet',
|
|
93
73
|
PYTH_ORACLE_MAPPING_ADDRESS: 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2',
|
|
94
74
|
VELOCITY_PROGRAM_ID: VELOCITY_DEVNET_PROGRAM_ID,
|
|
95
|
-
/** @deprecated Read `VELOCITY_PROGRAM_ID` instead. */
|
|
96
|
-
DRIFT_PROGRAM_ID: VELOCITY_DEVNET_PROGRAM_ID,
|
|
97
75
|
JIT_PROXY_PROGRAM_ID: 'J1TnP8zvVxbtF5KFp5xRmWuvG9McnhzmBd9XGfCyuxFP',
|
|
98
76
|
QUOTE_MINT_ADDRESS: '8FfvSRKMZRDHrCBy142XMUXrKEkXnxDQ4YmJv7xbAw8Q',
|
|
99
77
|
V2_ALPHA_TICKET_MINT_ADDRESS:
|
|
@@ -104,16 +82,12 @@ export const configs: { [key in VelocityEnv]: VelocityConfig } = {
|
|
|
104
82
|
MARKET_LOOKUP_TABLE: 'FaMS3U4uBojvGn5FSDEPimddcXsCfwkKsFgMVVnDdxGb',
|
|
105
83
|
MARKET_LOOKUP_TABLES: ['FaMS3U4uBojvGn5FSDEPimddcXsCfwkKsFgMVVnDdxGb'],
|
|
106
84
|
VELOCITY_ORACLE_RECEIVER_ID,
|
|
107
|
-
/** @deprecated Read `VELOCITY_ORACLE_RECEIVER_ID` instead. */
|
|
108
|
-
DRIFT_ORACLE_RECEIVER_ID: VELOCITY_ORACLE_RECEIVER_ID,
|
|
109
85
|
SB_ON_DEMAND_PID: SB_ON_DEMAND_DEVNET_PID,
|
|
110
86
|
},
|
|
111
87
|
'mainnet-beta': {
|
|
112
88
|
ENV: 'mainnet-beta',
|
|
113
89
|
PYTH_ORACLE_MAPPING_ADDRESS: 'AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J',
|
|
114
90
|
VELOCITY_PROGRAM_ID,
|
|
115
|
-
/** @deprecated Read `VELOCITY_PROGRAM_ID` instead. */
|
|
116
|
-
DRIFT_PROGRAM_ID: VELOCITY_PROGRAM_ID,
|
|
117
91
|
JIT_PROXY_PROGRAM_ID: 'J1TnP8zvVxbtF5KFp5xRmWuvG9McnhzmBd9XGfCyuxFP',
|
|
118
92
|
QUOTE_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
119
93
|
V2_ALPHA_TICKET_MINT_ADDRESS:
|
|
@@ -127,8 +101,6 @@ export const configs: { [key in VelocityEnv]: VelocityConfig } = {
|
|
|
127
101
|
'EiWSskK5HXnBTptiS5DH6gpAJRVNQ3cAhTKBGaiaysAb',
|
|
128
102
|
],
|
|
129
103
|
VELOCITY_ORACLE_RECEIVER_ID,
|
|
130
|
-
/** @deprecated Read `VELOCITY_ORACLE_RECEIVER_ID` instead. */
|
|
131
|
-
DRIFT_ORACLE_RECEIVER_ID: VELOCITY_ORACLE_RECEIVER_ID,
|
|
132
104
|
SB_ON_DEMAND_PID: SB_ON_DEMAND_MAINNET_PID,
|
|
133
105
|
},
|
|
134
106
|
};
|
|
@@ -144,24 +116,6 @@ export const getConfig = (): VelocityConfig => currentConfig;
|
|
|
144
116
|
* @param props
|
|
145
117
|
* @returns
|
|
146
118
|
*/
|
|
147
|
-
/**
|
|
148
|
-
* Mirror a canonical/deprecated alias pair so the resolved config carries the
|
|
149
|
-
* same value under both keys regardless of which one the caller overrode.
|
|
150
|
-
*/
|
|
151
|
-
const mirrorAlias = <
|
|
152
|
-
K1 extends keyof VelocityConfig,
|
|
153
|
-
K2 extends keyof VelocityConfig,
|
|
154
|
-
>(
|
|
155
|
-
merged: VelocityConfig,
|
|
156
|
-
override: Partial<VelocityConfig>,
|
|
157
|
-
canon: K1,
|
|
158
|
-
deprecated: K2
|
|
159
|
-
): void => {
|
|
160
|
-
const value = override[canon] ?? override[deprecated] ?? merged[canon];
|
|
161
|
-
(merged[canon] as VelocityConfig[K1]) = value as VelocityConfig[K1];
|
|
162
|
-
(merged[deprecated] as VelocityConfig[K2]) = value as VelocityConfig[K2];
|
|
163
|
-
};
|
|
164
|
-
|
|
165
119
|
export const initialize = (props: {
|
|
166
120
|
env: LegacyVelocityEnv;
|
|
167
121
|
overrideEnv?: Partial<VelocityConfig>;
|
|
@@ -169,17 +123,8 @@ export const initialize = (props: {
|
|
|
169
123
|
const override = props.overrideEnv ?? {};
|
|
170
124
|
const normalizedEnv: VelocityEnv =
|
|
171
125
|
props.env === 'master' ? 'devnet' : props.env;
|
|
172
|
-
const merged: VelocityConfig = { ...configs[normalizedEnv], ...override };
|
|
173
|
-
|
|
174
|
-
mirrorAlias(merged, override, 'VELOCITY_PROGRAM_ID', 'DRIFT_PROGRAM_ID');
|
|
175
|
-
mirrorAlias(
|
|
176
|
-
merged,
|
|
177
|
-
override,
|
|
178
|
-
'VELOCITY_ORACLE_RECEIVER_ID',
|
|
179
|
-
'DRIFT_ORACLE_RECEIVER_ID'
|
|
180
|
-
);
|
|
181
126
|
|
|
182
|
-
currentConfig =
|
|
127
|
+
currentConfig = { ...configs[normalizedEnv], ...override };
|
|
183
128
|
return currentConfig;
|
|
184
129
|
};
|
|
185
130
|
|
|
@@ -193,9 +138,13 @@ export function getMarketsAndOraclesForSubscription(
|
|
|
193
138
|
oracleInfos: OracleInfo[];
|
|
194
139
|
} {
|
|
195
140
|
const perpMarketsToUse =
|
|
196
|
-
perpMarkets
|
|
141
|
+
perpMarkets !== undefined && perpMarkets.length > 0
|
|
142
|
+
? perpMarkets
|
|
143
|
+
: PerpMarkets[env];
|
|
197
144
|
const spotMarketsToUse =
|
|
198
|
-
spotMarkets
|
|
145
|
+
spotMarkets !== undefined && spotMarkets.length > 0
|
|
146
|
+
? spotMarkets
|
|
147
|
+
: SpotMarkets[env];
|
|
199
148
|
|
|
200
149
|
const perpMarketIndexes = [];
|
|
201
150
|
const spotMarketIndexes = [];
|
|
@@ -247,13 +196,10 @@ export async function findAllMarketAndOracles(
|
|
|
247
196
|
for (const perpMarketProgramAccount of perpMarketProgramAccounts) {
|
|
248
197
|
const perpMarket = perpMarketProgramAccount.account as PerpMarketAccount;
|
|
249
198
|
perpMarketIndexes.push(perpMarket.marketIndex);
|
|
250
|
-
oracleInfos.set(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
source: perpMarket.amm.oracleSource,
|
|
255
|
-
}
|
|
256
|
-
);
|
|
199
|
+
oracleInfos.set(getOracleId(perpMarket.oracle, perpMarket.oracleSource), {
|
|
200
|
+
publicKey: perpMarket.oracle,
|
|
201
|
+
source: perpMarket.oracleSource,
|
|
202
|
+
});
|
|
257
203
|
}
|
|
258
204
|
|
|
259
205
|
for (const spotMarketProgramAccount of spotMarketProgramAccounts) {
|
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';
|
|
@@ -15,7 +15,6 @@ export const NINE = new BN(9);
|
|
|
15
15
|
export const TEN = new BN(10);
|
|
16
16
|
export const TEN_THOUSAND = new BN(10000);
|
|
17
17
|
export const BN_MAX = new BN(Number.MAX_SAFE_INTEGER);
|
|
18
|
-
export const TEN_MILLION = TEN_THOUSAND.mul(TEN_THOUSAND);
|
|
19
18
|
|
|
20
19
|
export const MAX_LEVERAGE = new BN(5);
|
|
21
20
|
export const MAX_LEVERAGE_ORDER_SIZE = new BN('18446744073709551615');
|
|
@@ -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,4 @@ 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
|
-
export const MAX_I64 = BigNum.fromPrint('9223372036854775807').val;
|
|
119
119
|
export const MIN_I64 = BigNum.fromPrint('-9223372036854775808').val;
|