@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
|
@@ -4,13 +4,11 @@ import StrictEventEmitter from 'strict-event-emitter-types';
|
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
export declare class AuctionSubscriber {
|
|
6
6
|
private velocityClient;
|
|
7
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
8
|
-
private get driftClient();
|
|
9
7
|
private opts;
|
|
10
8
|
private resubOpts?;
|
|
11
9
|
eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
|
|
12
|
-
private subscriber
|
|
13
|
-
constructor({ velocityClient,
|
|
10
|
+
private subscriber?;
|
|
11
|
+
constructor({ velocityClient, opts, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
|
|
14
12
|
subscribe(): Promise<void>;
|
|
15
13
|
unsubscribe(): Promise<void>;
|
|
16
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auctionSubscriber.d.ts","sourceRoot":"","sources":["../../../src/auctionSubscriber/auctionSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAG3E,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAMtC,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,cAAc,CAAiB;IACvC,
|
|
1
|
+
{"version":3,"file":"auctionSubscriber.d.ts","sourceRoot":"","sources":["../../../src/auctionSubscriber/auctionSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAG3E,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAMtC,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,SAAS,CAAC,CAAY;IAE9B,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAC;IACxE,OAAO,CAAC,UAAU,CAAC,CAAiD;gBAExD,EACX,cAAc,EACd,IAAI,EACJ,cAAc,EACd,gBAAgB,GAChB,EAAE,uBAAuB;IAQb,SAAS;IAiCT,WAAW;CAMxB"}
|
|
@@ -5,25 +5,23 @@ const memcmp_1 = require("../memcmp");
|
|
|
5
5
|
const events_1 = require("events");
|
|
6
6
|
const webSocketProgramAccountSubscriber_1 = require("../accounts/webSocketProgramAccountSubscriber");
|
|
7
7
|
class AuctionSubscriber {
|
|
8
|
-
|
|
9
|
-
get driftClient() {
|
|
10
|
-
return this.velocityClient;
|
|
11
|
-
}
|
|
12
|
-
constructor({ velocityClient, driftClient, opts, resubTimeoutMs, logResubMessages, }) {
|
|
8
|
+
constructor({ velocityClient, opts, resubTimeoutMs, logResubMessages, }) {
|
|
13
9
|
// Type-system guarantees at least one of the two is supplied.
|
|
14
|
-
this.velocityClient =
|
|
15
|
-
this.opts = opts || this.velocityClient.opts;
|
|
10
|
+
this.velocityClient = velocityClient;
|
|
11
|
+
this.opts = opts || this.velocityClient.opts || {};
|
|
16
12
|
this.eventEmitter = new events_1.EventEmitter();
|
|
17
13
|
this.resubOpts = { resubTimeoutMs, logResubMessages };
|
|
18
14
|
}
|
|
19
15
|
async subscribe() {
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
let subscriber = this.subscriber;
|
|
17
|
+
if (!subscriber) {
|
|
18
|
+
subscriber = new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('AuctionSubscriber', 'user', this.velocityClient.program, this.velocityClient.program.account.user.coder.accounts.decode.bind(this.velocityClient.program.account.user.coder.accounts), {
|
|
22
19
|
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getUserWithAuctionFilter)()],
|
|
23
20
|
commitment: this.opts.commitment,
|
|
24
21
|
}, this.resubOpts);
|
|
22
|
+
this.subscriber = subscriber;
|
|
25
23
|
}
|
|
26
|
-
await
|
|
24
|
+
await subscriber.subscribe((accountId, data, context) => {
|
|
27
25
|
this.eventEmitter.emit('onAccountUpdate', data, accountId, context.slot);
|
|
28
26
|
});
|
|
29
27
|
}
|
|
@@ -4,14 +4,12 @@ import StrictEventEmitter from 'strict-event-emitter-types';
|
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
export declare class AuctionSubscriberGrpc {
|
|
6
6
|
private velocityClient;
|
|
7
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
8
|
-
private get driftClient();
|
|
9
7
|
private opts;
|
|
10
8
|
private resubOpts?;
|
|
11
9
|
private grpcConfigs?;
|
|
12
10
|
eventEmitter: StrictEventEmitter<EventEmitter, AuctionSubscriberEvents>;
|
|
13
|
-
private subscriber
|
|
14
|
-
constructor({ velocityClient,
|
|
11
|
+
private subscriber?;
|
|
12
|
+
constructor({ velocityClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }: AuctionSubscriberConfig);
|
|
15
13
|
subscribe(): Promise<void>;
|
|
16
14
|
unsubscribe(): Promise<void>;
|
|
17
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auctionSubscriberGrpc.d.ts","sourceRoot":"","sources":["../../../src/auctionSubscriber/auctionSubscriberGrpc.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAG3E,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAOtC,qBAAa,qBAAqB;IACjC,OAAO,CAAC,cAAc,CAAiB;IACvC,
|
|
1
|
+
{"version":3,"file":"auctionSubscriberGrpc.d.ts","sourceRoot":"","sources":["../../../src/auctionSubscriber/auctionSubscriberGrpc.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAG3E,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAOtC,qBAAa,qBAAqB;IACjC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,WAAW,CAAC,CAAc;IAElC,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAC;IACxE,OAAO,CAAC,UAAU,CAAC,CAAiD;gBAExD,EACX,cAAc,EACd,IAAI,EACJ,WAAW,EACX,cAAc,EACd,gBAAgB,GAChB,EAAE,uBAAuB;IASb,SAAS;IAsCT,WAAW;CAMxB"}
|
|
@@ -5,25 +5,26 @@ const memcmp_1 = require("../memcmp");
|
|
|
5
5
|
const events_1 = require("events");
|
|
6
6
|
const grpcProgramAccountSubscriber_1 = require("../accounts/grpcProgramAccountSubscriber");
|
|
7
7
|
class AuctionSubscriberGrpc {
|
|
8
|
-
|
|
9
|
-
get driftClient() {
|
|
10
|
-
return this.velocityClient;
|
|
11
|
-
}
|
|
12
|
-
constructor({ velocityClient, driftClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }) {
|
|
8
|
+
constructor({ velocityClient, opts, grpcConfigs, resubTimeoutMs, logResubMessages, }) {
|
|
13
9
|
// Type-system guarantees at least one of the two is supplied.
|
|
14
|
-
this.velocityClient =
|
|
15
|
-
this.opts = opts || this.velocityClient.opts;
|
|
10
|
+
this.velocityClient = velocityClient;
|
|
11
|
+
this.opts = opts || this.velocityClient.opts || {};
|
|
16
12
|
this.eventEmitter = new events_1.EventEmitter();
|
|
17
13
|
this.resubOpts = { resubTimeoutMs, logResubMessages };
|
|
18
14
|
this.grpcConfigs = grpcConfigs;
|
|
19
15
|
}
|
|
20
16
|
async subscribe() {
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
let subscriber = this.subscriber;
|
|
18
|
+
if (!subscriber) {
|
|
19
|
+
if (!this.grpcConfigs) {
|
|
20
|
+
throw new Error('grpcConfigs must be provided to use AuctionSubscriberGrpc');
|
|
21
|
+
}
|
|
22
|
+
subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'AuctionSubscriber', 'user', this.velocityClient.program, this.velocityClient.program.account.user.coder.accounts.decode.bind(this.velocityClient.program.account.user.coder.accounts), {
|
|
23
23
|
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getUserWithAuctionFilter)()],
|
|
24
24
|
}, this.resubOpts);
|
|
25
|
+
this.subscriber = subscriber;
|
|
25
26
|
}
|
|
26
|
-
await
|
|
27
|
+
await subscriber.subscribe((accountId, data, context) => {
|
|
27
28
|
this.eventEmitter.emit('onAccountUpdate', data, accountId, context.slot);
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -2,14 +2,15 @@ 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
|
type AuctionSubscriberConfigBase = {
|
|
7
6
|
opts?: ConfirmOptions;
|
|
8
7
|
resubTimeoutMs?: number;
|
|
9
8
|
logResubMessages?: boolean;
|
|
10
9
|
grpcConfigs?: GrpcConfigs;
|
|
11
10
|
};
|
|
12
|
-
export type AuctionSubscriberConfig = AuctionSubscriberConfigBase &
|
|
11
|
+
export type AuctionSubscriberConfig = AuctionSubscriberConfigBase & {
|
|
12
|
+
velocityClient: VelocityClient;
|
|
13
|
+
};
|
|
13
14
|
export interface AuctionSubscriberEvents {
|
|
14
15
|
onAccountUpdate: (account: UserAccount, pubkey: PublicKey, slot: number) => void;
|
|
15
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auctionSubscriber/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auctionSubscriber/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5D,KAAK,2BAA2B,GAAG;IAClC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,GAAG;IACnE,cAAc,EAAE,cAAc,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACvC,eAAe,EAAE,CAChB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,KACR,IAAI,CAAC;CACV"}
|
|
@@ -10,7 +10,7 @@ export type ClientSubscriptionId = number;
|
|
|
10
10
|
export type Connection = SolanaConnection | BankrunConnection;
|
|
11
11
|
type BankrunTransactionMetaNormalized = {
|
|
12
12
|
logMessages: string[];
|
|
13
|
-
err: TransactionError;
|
|
13
|
+
err: TransactionError | null;
|
|
14
14
|
};
|
|
15
15
|
type BankrunTransactionRespose = {
|
|
16
16
|
slot: number;
|
|
@@ -34,7 +34,8 @@ export declare class BankrunConnection {
|
|
|
34
34
|
private readonly _banksClient;
|
|
35
35
|
private readonly context;
|
|
36
36
|
private transactionToMeta;
|
|
37
|
-
private
|
|
37
|
+
private _clock?;
|
|
38
|
+
private get clock();
|
|
38
39
|
private nextClientSubscriptionId;
|
|
39
40
|
private onLogCallbacks;
|
|
40
41
|
private onAccountChangeCallbacks;
|
|
@@ -43,14 +44,14 @@ export declare class BankrunConnection {
|
|
|
43
44
|
getSlot(): Promise<bigint>;
|
|
44
45
|
toConnection(): SolanaConnection;
|
|
45
46
|
getTokenAccount(publicKey: PublicKey): Promise<Account>;
|
|
46
|
-
getMultipleAccountsInfo(publicKeys: PublicKey[], _commitmentOrConfig?: Commitment): Promise<AccountInfo<Buffer>[]>;
|
|
47
|
+
getMultipleAccountsInfo(publicKeys: PublicKey[], _commitmentOrConfig?: Commitment): Promise<(AccountInfo<Buffer> | null)[]>;
|
|
47
48
|
getAccountInfo(publicKey: PublicKey): Promise<null | AccountInfo<Buffer>>;
|
|
48
49
|
getAccountInfoAndContext(publicKey: PublicKey, _commitment?: Commitment): Promise<RpcResponseAndContext<null | AccountInfo<Buffer>>>;
|
|
49
50
|
sendRawTransaction(rawTransaction: Buffer | Uint8Array | Array<number>, _options?: any): Promise<TransactionSignature>;
|
|
50
51
|
sendTransaction(tx: Transaction | VersionedTransaction): Promise<TransactionSignature>;
|
|
51
52
|
updateSlotAndClock(): Promise<void>;
|
|
52
53
|
getTime(): number;
|
|
53
|
-
getParsedAccountInfo(publicKey: PublicKey): Promise<RpcResponseAndContext<AccountInfo<Buffer>>>;
|
|
54
|
+
getParsedAccountInfo(publicKey: PublicKey): Promise<RpcResponseAndContext<null | AccountInfo<Buffer>>>;
|
|
54
55
|
getLatestBlockhash(commitment?: Commitment): Promise<Readonly<{
|
|
55
56
|
blockhash: string;
|
|
56
57
|
lastValidBlockHeight: number;
|
|
@@ -61,6 +62,7 @@ export declare class BankrunConnection {
|
|
|
61
62
|
* There's really no direct equivalent to getTransaction exposed by SolanaProgramTest, so we do the best that we can here - it's a little hacky.
|
|
62
63
|
*/
|
|
63
64
|
getTransaction(signature: string, _rawConfig?: GetTransactionConfig | GetVersionedTransactionConfig): Promise<BankrunTransactionRespose | null>;
|
|
65
|
+
private getTransactionMetaOrThrow;
|
|
64
66
|
findComputeUnitConsumption(signature: string): bigint;
|
|
65
67
|
printTxLogs(signature: string): void;
|
|
66
68
|
simulateTransaction(transaction: Transaction | VersionedTransaction, _config?: SimulateTransactionConfig): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bankrunConnection.d.ts","sourceRoot":"","sources":["../../../src/bankrun/bankrunConnection.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAEN,WAAW,EACX,OAAO,EACP,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,6BAA6B,EAC7B,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,EAE5B,gBAAgB,EAChB,uBAAuB,EACvB,UAAU,IAAI,gBAAgB,EAE9B,SAAS,EACT,UAAU,EACV,YAAY,EACZ,qBAAqB,EAErB,yBAAyB,EACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,kBAAkB,EAClB,WAAW,EAGX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAiB,MAAM,mBAAmB,CAAC;AAG3D,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAC1C,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAE9D,KAAK,gCAAgC,GAAG;IACvC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,EAAE,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"bankrunConnection.d.ts","sourceRoot":"","sources":["../../../src/bankrun/bankrunConnection.ts"],"names":[],"mappings":"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"}
|
|
@@ -78,6 +78,12 @@ class BankrunContextWrapper {
|
|
|
78
78
|
}
|
|
79
79
|
exports.BankrunContextWrapper = BankrunContextWrapper;
|
|
80
80
|
class BankrunConnection {
|
|
81
|
+
get clock() {
|
|
82
|
+
if (!this._clock) {
|
|
83
|
+
throw new Error('BankrunConnection: clock accessed before updateSlotAndClock()');
|
|
84
|
+
}
|
|
85
|
+
return this._clock;
|
|
86
|
+
}
|
|
81
87
|
constructor(banksClient, context, verifySignatures = true) {
|
|
82
88
|
this.transactionToMeta = new Map();
|
|
83
89
|
this.nextClientSubscriptionId = 0;
|
|
@@ -95,6 +101,9 @@ class BankrunConnection {
|
|
|
95
101
|
}
|
|
96
102
|
async getTokenAccount(publicKey) {
|
|
97
103
|
const info = await this.getAccountInfo(publicKey);
|
|
104
|
+
if (info === null) {
|
|
105
|
+
throw new Error(`Account not found: ${publicKey.toBase58()}`);
|
|
106
|
+
}
|
|
98
107
|
return (0, spl_token_1.unpackAccount)(publicKey, info, info.owner);
|
|
99
108
|
}
|
|
100
109
|
async getMultipleAccountsInfo(publicKeys, _commitmentOrConfig) {
|
|
@@ -132,9 +141,17 @@ class BankrunConnection {
|
|
|
132
141
|
? await internal.tryProcessVersionedTransaction(serialized)
|
|
133
142
|
: await internal.tryProcessLegacyTransaction(serialized);
|
|
134
143
|
const banksTransactionMeta = new solana_bankrun_1.BanksTransactionResultWithMeta(inner);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
let signature;
|
|
145
|
+
if (isVersioned) {
|
|
146
|
+
signature = bs58_1.default.encode(tx.signatures[0]);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const legacySignature = tx.signatures[0].signature;
|
|
150
|
+
if (legacySignature === null) {
|
|
151
|
+
throw new Error('BankrunConnection: transaction is missing its first signature');
|
|
152
|
+
}
|
|
153
|
+
signature = bs58_1.default.encode(legacySignature);
|
|
154
|
+
}
|
|
138
155
|
if (banksTransactionMeta.result) {
|
|
139
156
|
if (!banksTransactionMeta.result
|
|
140
157
|
.toString()
|
|
@@ -151,9 +168,12 @@ class BankrunConnection {
|
|
|
151
168
|
}
|
|
152
169
|
let finalizedCount = 0;
|
|
153
170
|
while (finalizedCount < 10) {
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
171
|
+
const statusValue = (await this.getSignatureStatus(signature)).value;
|
|
172
|
+
if (statusValue === null) {
|
|
173
|
+
throw new Error(`BankrunConnection: no signature status for ${signature}`);
|
|
174
|
+
}
|
|
175
|
+
const signatureStatus = statusValue.confirmationStatus;
|
|
176
|
+
if ((signatureStatus === null || signatureStatus === void 0 ? void 0 : signatureStatus.toString()) == '"finalized"') {
|
|
157
177
|
finalizedCount += 1;
|
|
158
178
|
}
|
|
159
179
|
}
|
|
@@ -167,18 +187,23 @@ class BankrunConnection {
|
|
|
167
187
|
}
|
|
168
188
|
if (this.onLogCallbacks.size > 0) {
|
|
169
189
|
const transaction = await this.getTransaction(signature);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
logs
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
logCallback(
|
|
190
|
+
if (transaction !== null) {
|
|
191
|
+
const context = { slot: transaction.slot };
|
|
192
|
+
const logs = {
|
|
193
|
+
logs: transaction.meta.logMessages,
|
|
194
|
+
err: transaction.meta.err,
|
|
195
|
+
signature,
|
|
196
|
+
};
|
|
197
|
+
for (const logCallback of this.onLogCallbacks.values()) {
|
|
198
|
+
logCallback(logs, context);
|
|
199
|
+
}
|
|
178
200
|
}
|
|
179
201
|
}
|
|
180
202
|
for (const [publicKey, callback,] of this.onAccountChangeCallbacks.values()) {
|
|
181
203
|
const accountInfo = await this.getParsedAccountInfo(publicKey);
|
|
204
|
+
if (accountInfo.value === null) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
182
207
|
callback(accountInfo.value, accountInfo.context);
|
|
183
208
|
}
|
|
184
209
|
return signature;
|
|
@@ -190,7 +215,7 @@ class BankrunConnection {
|
|
|
190
215
|
const currentClock = await this._banksClient.getClock();
|
|
191
216
|
const newClock = new solana_bankrun_1.Clock(nextSlot, currentClock.epochStartTimestamp, currentClock.epoch, currentClock.leaderScheduleEpoch, currentClock.unixTimestamp + BigInt(1));
|
|
192
217
|
this.context.setClock(newClock);
|
|
193
|
-
this.
|
|
218
|
+
this._clock = newClock;
|
|
194
219
|
}
|
|
195
220
|
getTime() {
|
|
196
221
|
return Number(this.clock.unixTimestamp);
|
|
@@ -212,6 +237,9 @@ class BankrunConnection {
|
|
|
212
237
|
}
|
|
213
238
|
async getLatestBlockhash(commitment) {
|
|
214
239
|
const blockhashAndBlockheight = await this._banksClient.getLatestBlockhash(commitment);
|
|
240
|
+
if (blockhashAndBlockheight === null) {
|
|
241
|
+
throw new Error('Failed to get latest blockhash');
|
|
242
|
+
}
|
|
215
243
|
return {
|
|
216
244
|
blockhash: blockhashAndBlockheight[0],
|
|
217
245
|
lastValidBlockHeight: Number(blockhashAndBlockheight[1]),
|
|
@@ -258,6 +286,9 @@ class BankrunConnection {
|
|
|
258
286
|
return null;
|
|
259
287
|
}
|
|
260
288
|
const transactionStatus = await this._banksClient.getTransactionStatus(signature);
|
|
289
|
+
if (transactionStatus === null) {
|
|
290
|
+
throw new Error(`tx has no status: ${signature}`);
|
|
291
|
+
}
|
|
261
292
|
if (txMeta.meta === null) {
|
|
262
293
|
throw new Error(`tx has no meta: ${JSON.stringify(txMeta)}`);
|
|
263
294
|
}
|
|
@@ -270,36 +301,43 @@ class BankrunConnection {
|
|
|
270
301
|
meta,
|
|
271
302
|
};
|
|
272
303
|
}
|
|
273
|
-
|
|
304
|
+
getTransactionMetaOrThrow(signature) {
|
|
274
305
|
const txMeta = this.transactionToMeta.get(signature);
|
|
275
306
|
if (txMeta === undefined) {
|
|
276
307
|
throw new Error('Transaction not found');
|
|
277
308
|
}
|
|
278
|
-
|
|
309
|
+
if (txMeta.meta === null) {
|
|
310
|
+
throw new Error(`tx has no meta: ${JSON.stringify(txMeta)}`);
|
|
311
|
+
}
|
|
312
|
+
return txMeta.meta;
|
|
313
|
+
}
|
|
314
|
+
findComputeUnitConsumption(signature) {
|
|
315
|
+
return this.getTransactionMetaOrThrow(signature).computeUnitsConsumed;
|
|
279
316
|
}
|
|
280
317
|
printTxLogs(signature) {
|
|
281
|
-
|
|
282
|
-
if (txMeta === undefined) {
|
|
283
|
-
throw new Error('Transaction not found');
|
|
284
|
-
}
|
|
285
|
-
console.log(txMeta.meta.logMessages);
|
|
318
|
+
console.log(this.getTransactionMetaOrThrow(signature).logMessages);
|
|
286
319
|
}
|
|
287
320
|
async simulateTransaction(transaction, _config) {
|
|
288
|
-
var _a, _b, _c, _d;
|
|
289
321
|
const simulationResult = await this._banksClient.simulateTransaction(transaction);
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
322
|
+
const meta = simulationResult.meta;
|
|
323
|
+
if (meta === null) {
|
|
324
|
+
throw new Error('BankrunConnection: simulation returned no meta');
|
|
325
|
+
}
|
|
326
|
+
let returnData;
|
|
327
|
+
if (meta.returnData !== null) {
|
|
328
|
+
const returnDataNormalized = Buffer.from(meta.returnData.data).toString('base64');
|
|
329
|
+
returnData = {
|
|
330
|
+
programId: meta.returnData.programId.toBase58(),
|
|
331
|
+
data: [returnDataNormalized, 'base64'],
|
|
332
|
+
};
|
|
333
|
+
}
|
|
296
334
|
return {
|
|
297
335
|
context: { slot: Number(await this._banksClient.getSlot()) },
|
|
298
336
|
value: {
|
|
299
337
|
err: simulationResult.result,
|
|
300
|
-
logs:
|
|
338
|
+
logs: meta.logMessages,
|
|
301
339
|
accounts: undefined,
|
|
302
|
-
unitsConsumed: Number(
|
|
340
|
+
unitsConsumed: Number(meta.computeUnitsConsumed),
|
|
303
341
|
returnData,
|
|
304
342
|
},
|
|
305
343
|
};
|
|
@@ -11,7 +11,7 @@ export declare class BlockhashSubscriber {
|
|
|
11
11
|
private updateIntervalMs;
|
|
12
12
|
constructor(config: BlockhashSubscriberConfig);
|
|
13
13
|
getBlockhashCacheSize(): number;
|
|
14
|
-
getLatestBlockHeight(): number;
|
|
14
|
+
getLatestBlockHeight(): number | undefined;
|
|
15
15
|
getLatestBlockHeightContext(): Context | undefined;
|
|
16
16
|
/**
|
|
17
17
|
* Returns the latest cached blockhash, based on an offset from the latest obtained
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockhashSubscriber.d.ts","sourceRoot":"","sources":["../../../src/blockhashSubscriber/BlockhashSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,8BAA8B,EAG9B,OAAO,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"BlockhashSubscriber.d.ts","sourceRoot":"","sources":["../../../src/blockhashSubscriber/BlockhashSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,8BAA8B,EAG9B,OAAO,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,wBAAwB,CAAsB;IACtD,OAAO,CAAC,WAAW,CAA6C;IAChE,OAAO,CAAC,yBAAyB,CAA4C;IAC7E,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,gBAAgB,CAAS;gBAErB,MAAM,EAAE,yBAAyB;IAW7C,qBAAqB,IAAI,MAAM;IAI/B,oBAAoB,IAAI,MAAM,GAAG,SAAS;IAI1C,2BAA2B,IAAI,OAAO,GAAG,SAAS;IAIlD;;;;;OAKG;IACH,kBAAkB,CACjB,MAAM,SAAI,EACV,UAAU,GAAE,OAAO,GAAG,SAAmB,GACvC,8BAA8B,GAAG,SAAS;IAkB7C,gBAAgB;IASV,eAAe;IA6Bf,SAAS;IAaf,WAAW;CAOX"}
|
|
@@ -40,8 +40,9 @@ class BlockhashSubscriber {
|
|
|
40
40
|
return this.blockhashes[this.blockhashes.length - 1 - clampedOffset];
|
|
41
41
|
}
|
|
42
42
|
pruneBlockhashes() {
|
|
43
|
-
if (this.latestBlockHeight) {
|
|
44
|
-
|
|
43
|
+
if (this.latestBlockHeight !== undefined) {
|
|
44
|
+
const latestBlockHeight = this.latestBlockHeight;
|
|
45
|
+
this.blockhashes = this.blockhashes.filter((blockhash) => blockhash.lastValidBlockHeight > latestBlockHeight);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
async updateBlockhash() {
|
|
@@ -11,13 +11,13 @@ export interface ClockSubscriberEvent {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class ClockSubscriber {
|
|
13
13
|
private connection;
|
|
14
|
-
private _latestSlot
|
|
15
|
-
private _currentTs
|
|
16
|
-
private subscriptionId
|
|
14
|
+
private _latestSlot?;
|
|
15
|
+
private _currentTs?;
|
|
16
|
+
private subscriptionId?;
|
|
17
17
|
commitment: Commitment;
|
|
18
18
|
eventEmitter: StrictEventEmitter<EventEmitter, ClockSubscriberEvent>;
|
|
19
|
-
get latestSlot(): number;
|
|
20
|
-
get currentTs(): number;
|
|
19
|
+
get latestSlot(): number | undefined;
|
|
20
|
+
get currentTs(): number | undefined;
|
|
21
21
|
private timeoutId?;
|
|
22
22
|
private resubTimeoutMs?;
|
|
23
23
|
private isUnsubscribing;
|
|
@@ -25,7 +25,7 @@ export declare class ClockSubscriber {
|
|
|
25
25
|
constructor(connection: Connection, config?: ClockSubscriberConfig);
|
|
26
26
|
subscribe(): Promise<void>;
|
|
27
27
|
private setTimeout;
|
|
28
|
-
getUnixTs(): number;
|
|
28
|
+
getUnixTs(): number | undefined;
|
|
29
29
|
unsubscribe(onResub?: boolean): Promise<void>;
|
|
30
30
|
}
|
|
31
31
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clockSubscriber.d.ts","sourceRoot":"","sources":["../../../src/clock/clockSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAuB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,kBAAkB,MAAM,sCAAsC,CAAC;AAItE,KAAK,qBAAqB,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACpC,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,qBAAa,eAAe;IAsB1B,OAAO,CAAC,UAAU;IArBnB,OAAO,CAAC,WAAW,CAAS;
|
|
1
|
+
{"version":3,"file":"clockSubscriber.d.ts","sourceRoot":"","sources":["../../../src/clock/clockSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAuB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,kBAAkB,MAAM,sCAAsC,CAAC;AAItE,KAAK,qBAAqB,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACpC,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,qBAAa,eAAe;IAsB1B,OAAO,CAAC,UAAU;IArBnB,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IAErE,IAAW,UAAU,IAAI,MAAM,GAAG,SAAS,CAE1C;IAED,IAAW,SAAS,IAAI,MAAM,GAAG,SAAS,CAEzC;IAGD,OAAO,CAAC,SAAS,CAAC,CAAgC;IAClD,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,aAAa,CAAS;gBAGrB,UAAU,EAAE,UAAU,EAC9B,MAAM,CAAC,EAAE,qBAAqB;IAYlB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAiCvC,OAAO,CAAC,UAAU;IAkBX,SAAS,IAAI,MAAM,GAAG,SAAS;IAIzB,WAAW,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBxD"}
|
|
@@ -18,7 +18,7 @@ class ClockSubscriber {
|
|
|
18
18
|
this.eventEmitter = new events_1.EventEmitter();
|
|
19
19
|
this.resubTimeoutMs = config === null || config === void 0 ? void 0 : config.resubTimeoutMs;
|
|
20
20
|
this.commitment = (config === null || config === void 0 ? void 0 : config.commitment) || 'confirmed';
|
|
21
|
-
if (this.resubTimeoutMs < 1000) {
|
|
21
|
+
if (this.resubTimeoutMs !== undefined && this.resubTimeoutMs < 1000) {
|
|
22
22
|
console.log('resubTimeoutMs should be at least 1000ms to avoid spamming resub');
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -34,8 +34,9 @@ class ClockSubscriber {
|
|
|
34
34
|
this.setTimeout();
|
|
35
35
|
}
|
|
36
36
|
this._latestSlot = context.slot;
|
|
37
|
-
|
|
38
|
-
this.
|
|
37
|
+
const currentTs = new anchor_1.BN(acctInfo.data.subarray(32, 39), undefined, 'le').toNumber();
|
|
38
|
+
this._currentTs = currentTs;
|
|
39
|
+
this.eventEmitter.emit('clockUpdate', currentTs);
|
|
39
40
|
}
|
|
40
41
|
}, this.commitment);
|
|
41
42
|
if (this.resubTimeoutMs) {
|
package/lib/node/config.d.ts
CHANGED
|
@@ -4,25 +4,17 @@ import { PerpMarketConfig } from './constants/perpMarkets';
|
|
|
4
4
|
import { SpotMarketConfig } from './constants/spotMarkets';
|
|
5
5
|
import { OracleInfo } from './oracles/types';
|
|
6
6
|
import { Program } from './isomorphic/anchor';
|
|
7
|
-
import {
|
|
8
|
-
export type VelocityProgram = Program<
|
|
9
|
-
/** @deprecated Use `VelocityProgram` instead. `DriftProgram` will be removed in a future major. */
|
|
10
|
-
export type DriftProgram = VelocityProgram;
|
|
7
|
+
import { Velocity } from './idl/velocity';
|
|
8
|
+
export type VelocityProgram = Program<Velocity>;
|
|
11
9
|
export type VelocityEnv = 'devnet' | 'mainnet-beta';
|
|
12
|
-
/** @deprecated Use `VelocityEnv` instead. `DriftEnv` will be removed in a future major. */
|
|
13
|
-
export type DriftEnv = VelocityEnv;
|
|
14
10
|
/** Widened env type accepted by `initialize()`; `'master'` is a legacy alias for `'devnet'`. */
|
|
15
11
|
export type LegacyVelocityEnv = VelocityEnv | 'master';
|
|
16
12
|
export interface VelocityConfig {
|
|
17
13
|
ENV: VelocityEnv;
|
|
18
14
|
PYTH_ORACLE_MAPPING_ADDRESS: string;
|
|
19
15
|
VELOCITY_PROGRAM_ID: string;
|
|
20
|
-
/** @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. */
|
|
21
|
-
DRIFT_PROGRAM_ID: string;
|
|
22
16
|
JIT_PROXY_PROGRAM_ID?: string;
|
|
23
17
|
VELOCITY_ORACLE_RECEIVER_ID: string;
|
|
24
|
-
/** @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. */
|
|
25
|
-
DRIFT_ORACLE_RECEIVER_ID: string;
|
|
26
18
|
QUOTE_MINT_ADDRESS: string;
|
|
27
19
|
V2_ALPHA_TICKET_MINT_ADDRESS: string;
|
|
28
20
|
PERP_MARKETS: PerpMarketConfig[];
|
|
@@ -32,18 +24,10 @@ export interface VelocityConfig {
|
|
|
32
24
|
MARKET_LOOKUP_TABLES: string[];
|
|
33
25
|
SB_ON_DEMAND_PID: PublicKey;
|
|
34
26
|
}
|
|
35
|
-
|
|
36
|
-
export type DriftConfig = VelocityConfig;
|
|
37
|
-
export declare const VELOCITY_PROGRAM_ID = "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH";
|
|
38
|
-
/** @deprecated Use `VELOCITY_PROGRAM_ID` instead. `DRIFT_PROGRAM_ID` will be removed in a future major. */
|
|
39
|
-
export declare const DRIFT_PROGRAM_ID = "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH";
|
|
27
|
+
export declare const VELOCITY_PROGRAM_ID = "vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P";
|
|
40
28
|
export declare const VELOCITY_DEVNET_PROGRAM_ID = "vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P";
|
|
41
|
-
/** @deprecated Use `VELOCITY_DEVNET_PROGRAM_ID` instead. `DRIFT_DEVNET_PROGRAM_ID` will be removed in a future major. */
|
|
42
|
-
export declare const DRIFT_DEVNET_PROGRAM_ID = "vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P";
|
|
43
29
|
export declare const VELOCITY_ORACLE_RECEIVER_ID = "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha";
|
|
44
|
-
|
|
45
|
-
export declare const DRIFT_ORACLE_RECEIVER_ID = "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha";
|
|
46
|
-
export declare const PTYH_LAZER_PROGRAM_ID = "pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
|
|
30
|
+
export declare const PYTH_LAZER_PROGRAM_ID = "pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
|
|
47
31
|
export declare const SB_ON_DEMAND_DEVNET_PID: PublicKey;
|
|
48
32
|
export declare const SB_ON_DEMAND_MAINNET_PID: PublicKey;
|
|
49
33
|
export declare const PYTH_LAZER_STORAGE_ACCOUNT_KEY: PublicKey;
|
|
@@ -52,6 +36,13 @@ export declare const configs: {
|
|
|
52
36
|
[key in VelocityEnv]: VelocityConfig;
|
|
53
37
|
};
|
|
54
38
|
export declare const getConfig: () => VelocityConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Allows customization of the SDK's environment and endpoints. You can pass individual settings to override the settings with your own presets.
|
|
41
|
+
*
|
|
42
|
+
* Defaults to master environment if you don't use this function.
|
|
43
|
+
* @param props
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
55
46
|
export declare const initialize: (props: {
|
|
56
47
|
env: LegacyVelocityEnv;
|
|
57
48
|
overrideEnv?: Partial<VelocityConfig>;
|
package/lib/node/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAGN,gBAAgB,EAEhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,gBAAgB,EAIhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAkB,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAGN,gBAAgB,EAEhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,gBAAgB,EAIhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAkB,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,cAAc,CAAC;AAEpD,gGAAgG;AAChG,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEvD,MAAM,WAAW,cAAc;IAC9B,GAAG,EAAE,WAAW,CAAC;IACjB,2BAA2B,EAAE,MAAM,CAAC;IACpC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,2BAA2B,EAAE,MAAM,CAAC;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4BAA4B,EAAE,MAAM,CAAC;IACrC,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,2CAA2C;IAC3C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,gBAAgB,EAAE,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,gDACc,CAAC;AAE/C,eAAO,MAAM,0BAA0B,gDACO,CAAC;AAE/C,eAAO,MAAM,2BAA2B,iDACO,CAAC;AAEhD,eAAO,MAAM,qBAAqB,gDACY,CAAC;AAE/C,eAAO,MAAM,uBAAuB,WAEnC,CAAC;AACF,eAAO,MAAM,wBAAwB,WAEpC,CAAC;AACF,eAAO,MAAM,8BAA8B,WAE1C,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,cAGvC,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE;KAAG,GAAG,IAAI,WAAW,GAAG,cAAc;CAoC3D,CAAC;AAIF,eAAO,MAAM,SAAS,QAAO,cAA+B,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,UAAW;IACjC,GAAG,EAAE,iBAAiB,CAAC;IACvB,WAAW,CAAC,EAAE,QAAQ,cAAc,CAAC,CAAC;CACtC,KAAG,cAOH,CAAC;AAEF,wBAAgB,mCAAmC,CAClD,GAAG,EAAE,WAAW,EAChB,WAAW,CAAC,EAAE,gBAAgB,EAAE,EAChC,WAAW,CAAC,EAAE,gBAAgB,EAAE,GAC9B;IACF,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,UAAU,EAAE,CAAC;CAC1B,CAmCA;AAED,wBAAsB,uBAAuB,CAC5C,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC;IACV,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;CACxC,CAAC,CAyCD"}
|