@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
|
@@ -5,6 +5,7 @@ import { VelocityClient } from '../velocityClient';
|
|
|
5
5
|
import { BN } from '../isomorphic/anchor';
|
|
6
6
|
import { User } from '../user';
|
|
7
7
|
import { DepositRecord } from '../types';
|
|
8
|
+
import fetch from 'node-fetch';
|
|
8
9
|
export type BSOL_STATS_API_RESPONSE = {
|
|
9
10
|
success: boolean;
|
|
10
11
|
stats?: {
|
|
@@ -27,15 +28,13 @@ export type BSOL_EMISSIONS_API_RESPONSE = {
|
|
|
27
28
|
lend: number;
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
|
-
export declare function fetchBSolMetrics(): Promise<
|
|
31
|
-
export declare function fetchBSolVelocityEmissions(): Promise<
|
|
32
|
-
|
|
33
|
-
export declare const fetchBSolDriftEmissions: typeof fetchBSolVelocityEmissions;
|
|
34
|
-
export declare function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, driftClient, userAccountPublicKey, price, forceMarinade, onlyDirectRoutes, jupiterQuote, }: {
|
|
31
|
+
export declare function fetchBSolMetrics(): Promise<fetch.Response>;
|
|
32
|
+
export declare function fetchBSolVelocityEmissions(): Promise<fetch.Response>;
|
|
33
|
+
export declare function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, velocityClient, userAccountPublicKey, price, forceMarinade, onlyDirectRoutes, jupiterQuote, }: {
|
|
35
34
|
marketIndex: number;
|
|
36
35
|
amount: BN;
|
|
37
36
|
jupiterClient: JupiterClient;
|
|
38
|
-
|
|
37
|
+
velocityClient: VelocityClient;
|
|
39
38
|
price?: number;
|
|
40
39
|
userAccountPublicKey?: PublicKey;
|
|
41
40
|
forceMarinade?: boolean;
|
|
@@ -47,10 +46,10 @@ export declare function findBestSuperStakeIxs({ marketIndex, amount, jupiterClie
|
|
|
47
46
|
method: 'jupiter' | 'marinade';
|
|
48
47
|
price?: number;
|
|
49
48
|
}>;
|
|
50
|
-
export declare function findBestMSolSuperStakeIxs({ amount, jupiterClient,
|
|
49
|
+
export declare function findBestMSolSuperStakeIxs({ amount, jupiterClient, velocityClient, userAccountPublicKey, price, forceMarinade, onlyDirectRoutes, jupiterQuote, }: {
|
|
51
50
|
amount: BN;
|
|
52
51
|
jupiterClient: JupiterClient;
|
|
53
|
-
|
|
52
|
+
velocityClient: VelocityClient;
|
|
54
53
|
price?: number;
|
|
55
54
|
userAccountPublicKey?: PublicKey;
|
|
56
55
|
forceMarinade?: boolean;
|
|
@@ -62,10 +61,10 @@ export declare function findBestMSolSuperStakeIxs({ amount, jupiterClient, drift
|
|
|
62
61
|
method: 'jupiter' | 'marinade';
|
|
63
62
|
price: number;
|
|
64
63
|
}>;
|
|
65
|
-
export declare function findBestJitoSolSuperStakeIxs({ amount, jupiterClient,
|
|
64
|
+
export declare function findBestJitoSolSuperStakeIxs({ amount, jupiterClient, velocityClient, userAccountPublicKey, onlyDirectRoutes, jupiterQuote, }: {
|
|
66
65
|
amount: BN;
|
|
67
66
|
jupiterClient: JupiterClient;
|
|
68
|
-
|
|
67
|
+
velocityClient: VelocityClient;
|
|
69
68
|
userAccountPublicKey?: PublicKey;
|
|
70
69
|
onlyDirectRoutes?: boolean;
|
|
71
70
|
jupiterQuote?: QuoteResponse;
|
|
@@ -80,12 +79,12 @@ export declare function findBestJitoSolSuperStakeIxs({ amount, jupiterClient, dr
|
|
|
80
79
|
*
|
|
81
80
|
* Without doing any extra steps like checking if you can get a better rate by staking directly with that LST platform
|
|
82
81
|
*/
|
|
83
|
-
export declare function findBestLstSuperStakeIxs({ amount, jupiterClient,
|
|
82
|
+
export declare function findBestLstSuperStakeIxs({ amount, jupiterClient, velocityClient, userAccountPublicKey, onlyDirectRoutes, lstMarketIndex, jupiterQuote, }: {
|
|
84
83
|
amount: BN;
|
|
85
84
|
lstMint: PublicKey;
|
|
86
85
|
lstMarketIndex: number;
|
|
87
86
|
jupiterClient: JupiterClient;
|
|
88
|
-
|
|
87
|
+
velocityClient: VelocityClient;
|
|
89
88
|
userAccountPublicKey?: PublicKey;
|
|
90
89
|
onlyDirectRoutes?: boolean;
|
|
91
90
|
jupiterQuote?: QuoteResponse;
|
|
@@ -109,57 +108,6 @@ export type JITO_SOL_METRICS_ENDPOINT_RESPONSE = {
|
|
|
109
108
|
}[];
|
|
110
109
|
};
|
|
111
110
|
export declare function fetchJitoSolMetrics(): Promise<JITO_SOL_METRICS_ENDPOINT_RESPONSE>;
|
|
112
|
-
export type MSOL_METRICS_ENDPOINT_RESPONSE = {
|
|
113
|
-
total_active_balance: number;
|
|
114
|
-
available_reserve_balance: number;
|
|
115
|
-
emergency_cooling_down: number;
|
|
116
|
-
tvl_sol: number;
|
|
117
|
-
msol_directed_stake_sol: number;
|
|
118
|
-
msol_directed_stake_msol: number;
|
|
119
|
-
mnde_total_supply: number;
|
|
120
|
-
mnde_circulating_supply: number;
|
|
121
|
-
validators_count: number;
|
|
122
|
-
stake_accounts: number;
|
|
123
|
-
staking_sol_cap: number;
|
|
124
|
-
m_sol_price: number;
|
|
125
|
-
avg_staking_apy: number;
|
|
126
|
-
msol_price_apy_14d: number;
|
|
127
|
-
msol_price_apy_30d: number;
|
|
128
|
-
msol_price_apy_90d: number;
|
|
129
|
-
msol_price_apy_365d: number;
|
|
130
|
-
reserve_pda: number;
|
|
131
|
-
treasury_m_sol_amount: number;
|
|
132
|
-
m_sol_mint_supply: number;
|
|
133
|
-
m_sol_supply_state: number;
|
|
134
|
-
liq_pool_sol: number;
|
|
135
|
-
liq_pool_m_sol: number;
|
|
136
|
-
liq_pool_value: number;
|
|
137
|
-
liq_pool_token_supply: number;
|
|
138
|
-
liq_pool_token_price: number;
|
|
139
|
-
liq_pool_target: number;
|
|
140
|
-
liq_pool_min_fee: number;
|
|
141
|
-
liq_pool_max_fee: number;
|
|
142
|
-
liq_pool_current_fee: number;
|
|
143
|
-
liq_pool_treasury_cut: number;
|
|
144
|
-
liq_pool_cap: number;
|
|
145
|
-
total_cooling_down: number;
|
|
146
|
-
last_stake_delta_epoch: number;
|
|
147
|
-
circulating_ticket_count: number;
|
|
148
|
-
circulating_ticket_balance: number;
|
|
149
|
-
reward_fee_bp: number;
|
|
150
|
-
lido_staking: number;
|
|
151
|
-
lido_st_sol_price: number;
|
|
152
|
-
lido_stsol_price_apy_14d: number;
|
|
153
|
-
lido_stsol_price_apy_30d: number;
|
|
154
|
-
lido_stsol_price_apy_90d: number;
|
|
155
|
-
lido_stsol_price_apy_365d: number;
|
|
156
|
-
stake_delta: number;
|
|
157
|
-
bot_balance: number;
|
|
158
|
-
treasury_farm_claim_mnde_balance: number;
|
|
159
|
-
last_3_epochs_avg_duration_hs: number;
|
|
160
|
-
mnde_votes_validators: number;
|
|
161
|
-
};
|
|
162
|
-
export declare const fetchMSolMetrics: () => Promise<MSOL_METRICS_ENDPOINT_RESPONSE>;
|
|
163
111
|
export declare function calculateSolEarned({ marketIndex, user, depositRecords, }: {
|
|
164
112
|
marketIndex: number;
|
|
165
113
|
user: User;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.calculateEstimatedSuperStakeLiquidationPrice = exports.calculateSolEarned = exports.
|
|
6
|
+
exports.calculateEstimatedSuperStakeLiquidationPrice = exports.calculateSolEarned = exports.fetchJitoSolMetrics = exports.findBestLstSuperStakeIxs = exports.findBestJitoSolSuperStakeIxs = exports.findBestMSolSuperStakeIxs = exports.findBestSuperStakeIxs = exports.fetchBSolVelocityEmissions = exports.fetchBSolMetrics = void 0;
|
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
8
|
const marinade_1 = require("../marinade");
|
|
9
9
|
const anchor_1 = require("../isomorphic/anchor");
|
|
@@ -16,17 +16,15 @@ async function fetchBSolMetrics() {
|
|
|
16
16
|
}
|
|
17
17
|
exports.fetchBSolMetrics = fetchBSolMetrics;
|
|
18
18
|
async function fetchBSolVelocityEmissions() {
|
|
19
|
-
return await (0, node_fetch_1.default)('https://stake.solblaze.org/api/v1/
|
|
19
|
+
return await (0, node_fetch_1.default)('https://stake.solblaze.org/api/v1/velocity_emissions');
|
|
20
20
|
}
|
|
21
21
|
exports.fetchBSolVelocityEmissions = fetchBSolVelocityEmissions;
|
|
22
|
-
|
|
23
|
-
exports.fetchBSolDriftEmissions = fetchBSolVelocityEmissions;
|
|
24
|
-
async function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, driftClient, userAccountPublicKey, price, forceMarinade, onlyDirectRoutes, jupiterQuote, }) {
|
|
22
|
+
async function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, velocityClient, userAccountPublicKey, price, forceMarinade, onlyDirectRoutes, jupiterQuote, }) {
|
|
25
23
|
if (marketIndex === 2) {
|
|
26
24
|
return findBestMSolSuperStakeIxs({
|
|
27
25
|
amount,
|
|
28
26
|
jupiterClient,
|
|
29
|
-
|
|
27
|
+
velocityClient,
|
|
30
28
|
userAccountPublicKey,
|
|
31
29
|
price,
|
|
32
30
|
forceMarinade,
|
|
@@ -38,7 +36,7 @@ async function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, drift
|
|
|
38
36
|
return findBestJitoSolSuperStakeIxs({
|
|
39
37
|
amount,
|
|
40
38
|
jupiterClient,
|
|
41
|
-
|
|
39
|
+
velocityClient,
|
|
42
40
|
userAccountPublicKey,
|
|
43
41
|
onlyDirectRoutes,
|
|
44
42
|
jupiterQuote,
|
|
@@ -47,10 +45,10 @@ async function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, drift
|
|
|
47
45
|
else if (marketIndex === 8) {
|
|
48
46
|
return findBestLstSuperStakeIxs({
|
|
49
47
|
amount,
|
|
50
|
-
lstMint:
|
|
48
|
+
lstMint: velocityClient.getSpotMarketAccountOrThrow(8).mint,
|
|
51
49
|
lstMarketIndex: 8,
|
|
52
50
|
jupiterClient,
|
|
53
|
-
|
|
51
|
+
velocityClient,
|
|
54
52
|
userAccountPublicKey,
|
|
55
53
|
onlyDirectRoutes,
|
|
56
54
|
jupiterQuote,
|
|
@@ -61,13 +59,13 @@ async function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, drift
|
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
exports.findBestSuperStakeIxs = findBestSuperStakeIxs;
|
|
64
|
-
async function findBestMSolSuperStakeIxs({ amount, jupiterClient,
|
|
62
|
+
async function findBestMSolSuperStakeIxs({ amount, jupiterClient, velocityClient, userAccountPublicKey, price, forceMarinade, onlyDirectRoutes, jupiterQuote, }) {
|
|
65
63
|
if (!price) {
|
|
66
|
-
const marinadeProgram = (0, marinade_1.getMarinadeFinanceProgram)(
|
|
64
|
+
const marinadeProgram = (0, marinade_1.getMarinadeFinanceProgram)(velocityClient.provider);
|
|
67
65
|
price = await (0, marinade_1.getMarinadeMSolPrice)(marinadeProgram);
|
|
68
66
|
}
|
|
69
|
-
const solSpotMarketAccount =
|
|
70
|
-
const mSolSpotMarketAccount =
|
|
67
|
+
const solSpotMarketAccount = velocityClient.getSpotMarketAccountOrThrow(1);
|
|
68
|
+
const mSolSpotMarketAccount = velocityClient.getSpotMarketAccountOrThrow(2);
|
|
71
69
|
let jupiterPrice;
|
|
72
70
|
let quote = jupiterQuote;
|
|
73
71
|
if (!jupiterQuote) {
|
|
@@ -79,7 +77,7 @@ async function findBestMSolSuperStakeIxs({ amount, jupiterClient, driftClient, u
|
|
|
79
77
|
slippageBps: 1000,
|
|
80
78
|
onlyDirectRoutes,
|
|
81
79
|
});
|
|
82
|
-
jupiterPrice = +
|
|
80
|
+
jupiterPrice = +fetchedQuote.outAmount / +fetchedQuote.inAmount;
|
|
83
81
|
quote = fetchedQuote;
|
|
84
82
|
}
|
|
85
83
|
catch (e) {
|
|
@@ -87,7 +85,7 @@ async function findBestMSolSuperStakeIxs({ amount, jupiterClient, driftClient, u
|
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
if (!jupiterPrice || price <= jupiterPrice || forceMarinade) {
|
|
90
|
-
const ixs = await
|
|
88
|
+
const ixs = await velocityClient.getStakeForMSOLIx({
|
|
91
89
|
amount,
|
|
92
90
|
userAccountPublicKey,
|
|
93
91
|
});
|
|
@@ -99,7 +97,7 @@ async function findBestMSolSuperStakeIxs({ amount, jupiterClient, driftClient, u
|
|
|
99
97
|
};
|
|
100
98
|
}
|
|
101
99
|
else {
|
|
102
|
-
const { ixs, lookupTables } = await
|
|
100
|
+
const { ixs, lookupTables } = await velocityClient.getJupiterSwapIxV6({
|
|
103
101
|
inMarketIndex: 1,
|
|
104
102
|
outMarketIndex: 2,
|
|
105
103
|
jupiterClient,
|
|
@@ -117,14 +115,14 @@ async function findBestMSolSuperStakeIxs({ amount, jupiterClient, driftClient, u
|
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
exports.findBestMSolSuperStakeIxs = findBestMSolSuperStakeIxs;
|
|
120
|
-
async function findBestJitoSolSuperStakeIxs({ amount, jupiterClient,
|
|
118
|
+
async function findBestJitoSolSuperStakeIxs({ amount, jupiterClient, velocityClient, userAccountPublicKey, onlyDirectRoutes, jupiterQuote, }) {
|
|
121
119
|
return await findBestLstSuperStakeIxs({
|
|
122
120
|
amount,
|
|
123
121
|
jupiterClient,
|
|
124
|
-
|
|
122
|
+
velocityClient,
|
|
125
123
|
userAccountPublicKey,
|
|
126
124
|
onlyDirectRoutes,
|
|
127
|
-
lstMint:
|
|
125
|
+
lstMint: velocityClient.getSpotMarketAccountOrThrow(6).mint,
|
|
128
126
|
lstMarketIndex: 6,
|
|
129
127
|
jupiterQuote,
|
|
130
128
|
});
|
|
@@ -135,8 +133,8 @@ exports.findBestJitoSolSuperStakeIxs = findBestJitoSolSuperStakeIxs;
|
|
|
135
133
|
*
|
|
136
134
|
* Without doing any extra steps like checking if you can get a better rate by staking directly with that LST platform
|
|
137
135
|
*/
|
|
138
|
-
async function findBestLstSuperStakeIxs({ amount, jupiterClient,
|
|
139
|
-
const { ixs, lookupTables } = await
|
|
136
|
+
async function findBestLstSuperStakeIxs({ amount, jupiterClient, velocityClient, userAccountPublicKey, onlyDirectRoutes, lstMarketIndex, jupiterQuote, }) {
|
|
137
|
+
const { ixs, lookupTables } = await velocityClient.getJupiterSwapIxV6({
|
|
140
138
|
inMarketIndex: 1,
|
|
141
139
|
outMarketIndex: lstMarketIndex,
|
|
142
140
|
jupiterClient,
|
|
@@ -189,12 +187,6 @@ async function fetchJitoSolMetrics() {
|
|
|
189
187
|
return data;
|
|
190
188
|
}
|
|
191
189
|
exports.fetchJitoSolMetrics = fetchJitoSolMetrics;
|
|
192
|
-
const fetchMSolMetrics = async () => {
|
|
193
|
-
const res = await (0, node_fetch_1.default)('https://api2.marinade.finance/metrics_json');
|
|
194
|
-
const data = await res.json();
|
|
195
|
-
return data;
|
|
196
|
-
};
|
|
197
|
-
exports.fetchMSolMetrics = fetchMSolMetrics;
|
|
198
190
|
const getJitoSolHistoricalPriceMap = async (timestamps) => {
|
|
199
191
|
try {
|
|
200
192
|
const data = await fetchJitoSolMetrics();
|
|
@@ -260,7 +252,10 @@ async function calculateSolEarned({ marketIndex, user, depositRecords, }) {
|
|
|
260
252
|
await Promise.all(timestamps.map(getMsolPrice));
|
|
261
253
|
}
|
|
262
254
|
else if (marketIndex === 6) {
|
|
263
|
-
|
|
255
|
+
const jitoSolRatios = await getJitoSolHistoricalPriceMap(timestamps);
|
|
256
|
+
if (jitoSolRatios) {
|
|
257
|
+
lstRatios = jitoSolRatios;
|
|
258
|
+
}
|
|
264
259
|
}
|
|
265
260
|
else if (marketIndex === 8) {
|
|
266
261
|
await getBSolPrice(timestamps);
|
|
@@ -279,6 +274,9 @@ async function calculateSolEarned({ marketIndex, user, depositRecords, }) {
|
|
|
279
274
|
record.marketIndex === 6 ||
|
|
280
275
|
record.marketIndex === 8) {
|
|
281
276
|
const lstRatio = lstRatios.get(record.ts.toNumber());
|
|
277
|
+
if (lstRatio === undefined) {
|
|
278
|
+
throw new Error(`Missing LST/SOL ratio for deposit record at timestamp ${record.ts.toNumber()}`);
|
|
279
|
+
}
|
|
282
280
|
const lstRatioBN = new anchor_1.BN(lstRatio * web3_js_1.LAMPORTS_PER_SOL);
|
|
283
281
|
const solAmount = record.amount.mul(lstRatioBN).div(numericConstants_1.LAMPORTS_PRECISION);
|
|
284
282
|
if ((0, types_1.isVariant)(record.direction, 'deposit')) {
|
|
@@ -291,6 +289,9 @@ async function calculateSolEarned({ marketIndex, user, depositRecords, }) {
|
|
|
291
289
|
}
|
|
292
290
|
const currentLstTokenAmount = await user.getTokenAmount(marketIndex);
|
|
293
291
|
const currentLstRatio = lstRatios.get(now);
|
|
292
|
+
if (currentLstRatio === undefined) {
|
|
293
|
+
throw new Error(`Missing current LST/SOL ratio for timestamp ${now}`);
|
|
294
|
+
}
|
|
294
295
|
const currentLstRatioBN = new anchor_1.BN(currentLstRatio * web3_js_1.LAMPORTS_PER_SOL);
|
|
295
296
|
solEarned = solEarned.add(currentLstTokenAmount.mul(currentLstRatioBN).div(numericConstants_1.LAMPORTS_PRECISION));
|
|
296
297
|
const currentSOLTokenAmount = await user.getTokenAmount(1);
|
|
@@ -53,7 +53,7 @@ function calculateTradeSlippage(direction, amount, market, inputAssetType = 'quo
|
|
|
53
53
|
.div(acquiredBaseReserve.abs());
|
|
54
54
|
let amm;
|
|
55
55
|
if (useSpread && market.amm.baseSpread > 0) {
|
|
56
|
-
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, direction, mmOraclePriceData, latestSlot);
|
|
56
|
+
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, direction, mmOraclePriceData, latestSlot);
|
|
57
57
|
amm = {
|
|
58
58
|
baseAssetReserve,
|
|
59
59
|
quoteAssetReserve,
|
|
@@ -102,7 +102,7 @@ function calculateTradeAcquiredAmounts(direction, amount, market, inputAssetType
|
|
|
102
102
|
const swapDirection = (0, amm_1.getSwapDirection)(inputAssetType, direction);
|
|
103
103
|
let amm;
|
|
104
104
|
if (useSpread && market.amm.baseSpread > 0) {
|
|
105
|
-
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, direction, mmOraclePriceData, latestSlot);
|
|
105
|
+
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, direction, mmOraclePriceData, latestSlot);
|
|
106
106
|
amm = {
|
|
107
107
|
baseAssetReserve,
|
|
108
108
|
quoteAssetReserve,
|
|
@@ -166,7 +166,7 @@ function calculateTargetPriceTrade(market, targetPrice, pct = MAXPCT, outputAsse
|
|
|
166
166
|
let quoteAssetReserveBefore;
|
|
167
167
|
let peg = market.amm.pegMultiplier;
|
|
168
168
|
if (useSpread && market.amm.baseSpread > 0) {
|
|
169
|
-
const { baseAssetReserve, quoteAssetReserve, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, direction, mmOraclePriceData, latestSlot);
|
|
169
|
+
const { baseAssetReserve, quoteAssetReserve, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, direction, mmOraclePriceData, latestSlot);
|
|
170
170
|
baseAssetReserveBefore = baseAssetReserve;
|
|
171
171
|
quoteAssetReserveBefore = quoteAssetReserve;
|
|
172
172
|
peg = newPeg;
|
|
@@ -239,7 +239,7 @@ function calculateTargetPriceTrade(market, targetPrice, pct = MAXPCT, outputAsse
|
|
|
239
239
|
.mul(numericConstants_1.PRICE_PRECISION)
|
|
240
240
|
.div(baseSize.abs());
|
|
241
241
|
(0, assert_1.assert)(tp1.sub(tp2).lte(originalDiff), 'Target Price Calculation incorrect');
|
|
242
|
-
(0, assert_1.assert)(tp2.lte(tp1) || tp2.sub(tp1).abs()
|
|
242
|
+
(0, assert_1.assert)(tp2.lte(tp1) || tp2.sub(tp1).abs().ltn(100000), 'Target Price Calculation incorrect' +
|
|
243
243
|
tp2.toString() +
|
|
244
244
|
'>=' +
|
|
245
245
|
tp1.toString() +
|
|
@@ -280,14 +280,14 @@ function calculateEstimatedPerpEntryPrice(assetType, amount, direction, market,
|
|
|
280
280
|
const takerIsLong = (0, types_2.isVariant)(direction, 'long');
|
|
281
281
|
const limitOrders = dlob[takerIsLong ? 'getRestingLimitAsks' : 'getRestingLimitBids'](market.marketIndex, slot, types_1.MarketType.PERP, mmOraclePriceData);
|
|
282
282
|
const swapDirection = (0, amm_1.getSwapDirection)(assetType, direction);
|
|
283
|
-
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, direction, mmOraclePriceData, new anchor_1.BN(slot));
|
|
283
|
+
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } = (0, amm_1.calculateUpdatedAMMSpreadReserves)(market.amm, market.marketStats, direction, mmOraclePriceData, new anchor_1.BN(slot));
|
|
284
284
|
const amm = {
|
|
285
285
|
baseAssetReserve,
|
|
286
286
|
quoteAssetReserve,
|
|
287
287
|
sqrtK: sqrtK,
|
|
288
288
|
pegMultiplier: newPeg,
|
|
289
289
|
};
|
|
290
|
-
const [ammBids, ammAsks] = (0, amm_1.calculateMarketOpenBidAsk)(market.amm.baseAssetReserve, market.amm.minBaseAssetReserve, market.amm.maxBaseAssetReserve, market.
|
|
290
|
+
const [ammBids, ammAsks] = (0, amm_1.calculateMarketOpenBidAsk)(market.amm.baseAssetReserve, market.amm.minBaseAssetReserve, market.amm.maxBaseAssetReserve, market.orderStepSize);
|
|
291
291
|
let ammLiquidity;
|
|
292
292
|
if (assetType === 'base') {
|
|
293
293
|
ammLiquidity = takerIsLong ? ammAsks.abs() : ammBids;
|
|
@@ -302,7 +302,7 @@ function calculateEstimatedPerpEntryPrice(assetType, amount, direction, market,
|
|
|
302
302
|
let cumulativeQuoteFilled = numericConstants_1.ZERO;
|
|
303
303
|
let limitOrder = limitOrders.next().value;
|
|
304
304
|
if (limitOrder) {
|
|
305
|
-
const limitOrderPrice = limitOrder.
|
|
305
|
+
const limitOrderPrice = limitOrder.getPriceOrThrow(mmOraclePriceData, slot);
|
|
306
306
|
bestPrice = takerIsLong
|
|
307
307
|
? anchor_1.BN.min(limitOrderPrice, bestPrice)
|
|
308
308
|
: anchor_1.BN.max(limitOrderPrice, bestPrice);
|
|
@@ -18,6 +18,6 @@ export declare function isBNSafe(number: number): boolean;
|
|
|
18
18
|
/**
|
|
19
19
|
* Converts a number to BN makes sure the number is safe to convert to BN (that it does not overflow number after multiplying by precision)
|
|
20
20
|
* @param number the number to convert to BN
|
|
21
|
-
* @param precision the BN precision to use (i.e. QUOTE_PRECISION and BASE_PRECISION from
|
|
21
|
+
* @param precision the BN precision to use (i.e. QUOTE_PRECISION and BASE_PRECISION from velocity sdk)
|
|
22
22
|
*/
|
|
23
23
|
export declare function numberToSafeBN(number: number, precision: BN): BN;
|
|
@@ -93,7 +93,7 @@ exports.isBNSafe = isBNSafe;
|
|
|
93
93
|
/**
|
|
94
94
|
* Converts a number to BN makes sure the number is safe to convert to BN (that it does not overflow number after multiplying by precision)
|
|
95
95
|
* @param number the number to convert to BN
|
|
96
|
-
* @param precision the BN precision to use (i.e. QUOTE_PRECISION and BASE_PRECISION from
|
|
96
|
+
* @param precision the BN precision to use (i.e. QUOTE_PRECISION and BASE_PRECISION from velocity sdk)
|
|
97
97
|
*/
|
|
98
98
|
function numberToSafeBN(number, precision) {
|
|
99
99
|
// check if number has decimals
|
package/lib/browser/memcmp.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare function getNonIdleUserFilter(): MemcmpFilter;
|
|
|
4
4
|
export declare function getUserWithOrderFilter(): MemcmpFilter;
|
|
5
5
|
export declare function getUserWithoutOrderFilter(): MemcmpFilter;
|
|
6
6
|
export declare function getUserWithAuctionFilter(): MemcmpFilter;
|
|
7
|
-
export declare function getUserThatHasBeenLP(): MemcmpFilter;
|
|
8
7
|
export declare function getUserWithName(name: string): MemcmpFilter;
|
|
9
8
|
export declare function getUsersWithPoolId(poolId: number): MemcmpFilter;
|
|
10
9
|
export declare function getUserStatsFilter(): MemcmpFilter;
|
package/lib/browser/memcmp.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getConstituentLpPoolFilter = exports.getConstituentFilter = exports.getRevenueShareEscrowFilter = exports.getSpotMarketAccountsFilter = exports.getPerpMarketAccountsFilter = exports.getSignedMsgUserOrdersFilter = exports.getUserStatsIsReferredOrReferrerFilter = exports.getUserStatsIsReferredFilter = exports.getUserStatsFilter = exports.getUsersWithPoolId = exports.getUserWithName = exports.
|
|
6
|
+
exports.getConstituentLpPoolFilter = exports.getConstituentFilter = exports.getRevenueShareEscrowFilter = exports.getSpotMarketAccountsFilter = exports.getPerpMarketAccountsFilter = exports.getSignedMsgUserOrdersFilter = exports.getUserStatsIsReferredOrReferrerFilter = exports.getUserStatsIsReferredFilter = exports.getUserStatsFilter = exports.getUsersWithPoolId = exports.getUserWithName = exports.getUserWithAuctionFilter = exports.getUserWithoutOrderFilter = exports.getUserWithOrderFilter = exports.getNonIdleUserFilter = exports.getUserFilter = void 0;
|
|
7
7
|
const bs58_1 = __importDefault(require("bs58"));
|
|
8
8
|
const anchor29_1 = require("./isomorphic/anchor29");
|
|
9
9
|
const userName_1 = require("./userName");
|
|
@@ -52,15 +52,6 @@ function getUserWithAuctionFilter() {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
exports.getUserWithAuctionFilter = getUserWithAuctionFilter;
|
|
55
|
-
function getUserThatHasBeenLP() {
|
|
56
|
-
return {
|
|
57
|
-
memcmp: {
|
|
58
|
-
offset: 4267,
|
|
59
|
-
bytes: bs58_1.default.encode(Uint8Array.from([99])),
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
exports.getUserThatHasBeenLP = getUserThatHasBeenLP;
|
|
64
55
|
function getUserWithName(name) {
|
|
65
56
|
return {
|
|
66
57
|
memcmp: {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PrelaunchOracleClient = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
4
5
|
class PrelaunchOracleClient {
|
|
5
6
|
constructor(connection, program) {
|
|
6
7
|
this.connection = connection;
|
|
7
8
|
this.program = program;
|
|
8
9
|
}
|
|
9
10
|
async getOraclePriceData(pricePublicKey) {
|
|
10
|
-
const
|
|
11
|
-
return this.getOraclePriceDataFromBuffer(
|
|
11
|
+
const data = await (0, utils_1.getOracleAccountDataOrThrow)(this.connection, pricePublicKey, 'Prelaunch oracle');
|
|
12
|
+
return this.getOraclePriceDataFromBuffer(data);
|
|
12
13
|
}
|
|
13
14
|
getOraclePriceDataFromBuffer(buffer) {
|
|
14
15
|
const prelaunchOracle = this.program.account.prelaunchOracle.coder.accounts.decodeUnchecked('prelaunchOracle', buffer);
|
|
@@ -4,6 +4,7 @@ exports.PythClient = void 0;
|
|
|
4
4
|
const client_1 = require("@pythnetwork/client");
|
|
5
5
|
const anchor_1 = require("../isomorphic/anchor");
|
|
6
6
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
7
8
|
class PythClient {
|
|
8
9
|
constructor(connection, multiple = numericConstants_1.ONE, stableCoin = false) {
|
|
9
10
|
this.connection = connection;
|
|
@@ -11,12 +12,17 @@ class PythClient {
|
|
|
11
12
|
this.stableCoin = stableCoin;
|
|
12
13
|
}
|
|
13
14
|
async getOraclePriceData(pricePublicKey) {
|
|
14
|
-
const
|
|
15
|
-
return this.getOraclePriceDataFromBuffer(
|
|
15
|
+
const data = await (0, utils_1.getOracleAccountDataOrThrow)(this.connection, pricePublicKey, 'Pyth oracle');
|
|
16
|
+
return this.getOraclePriceDataFromBuffer(data);
|
|
16
17
|
}
|
|
17
18
|
getOraclePriceDataFromBuffer(buffer) {
|
|
19
|
+
var _a;
|
|
18
20
|
const priceData = (0, client_1.parsePriceData)(buffer);
|
|
19
|
-
|
|
21
|
+
// `confidence` is absent on uninitialized/invalid price accounts. Base passed it
|
|
22
|
+
// straight into convertPythPrice, where `undefined * 10**exponent` is `NaN` and
|
|
23
|
+
// `new BN(NaN)` coerces to 0 — so base already yielded a zero-confidence price.
|
|
24
|
+
// `?? 0` makes that explicit and type-checks, preserving the same result.
|
|
25
|
+
const confidence = convertPythPrice((_a = priceData.confidence) !== null && _a !== void 0 ? _a : 0, priceData.exponent, this.multiple);
|
|
20
26
|
const minPublishers = Math.min(priceData.numComponentPrices, 3);
|
|
21
27
|
let price = convertPythPrice(priceData.aggregate.price, priceData.exponent, this.multiple);
|
|
22
28
|
if (this.stableCoin) {
|
|
@@ -8,7 +8,8 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
8
8
|
const anchor_1 = require("../isomorphic/anchor");
|
|
9
9
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
10
10
|
const wallet_1 = require("../wallet");
|
|
11
|
-
const
|
|
11
|
+
const velocity_json_1 = __importDefault(require("../idl/velocity.json"));
|
|
12
|
+
const utils_1 = require("./utils");
|
|
12
13
|
class PythLazerClient {
|
|
13
14
|
constructor(connection, multiple = numericConstants_1.ONE, stableCoin = false) {
|
|
14
15
|
this.connection = connection;
|
|
@@ -19,12 +20,12 @@ class PythLazerClient {
|
|
|
19
20
|
new wallet_1.Wallet(new web3_js_1.Keypair()), {
|
|
20
21
|
commitment: connection.commitment,
|
|
21
22
|
});
|
|
22
|
-
this.program = new anchor_1.Program(
|
|
23
|
+
this.program = new anchor_1.Program(velocity_json_1.default, provider);
|
|
23
24
|
this.decodeFunc = this.program.account.pythLazerOracle.coder.accounts.decodeUnchecked.bind(this.program.account.pythLazerOracle.coder.accounts);
|
|
24
25
|
}
|
|
25
26
|
async getOraclePriceData(pricePublicKey) {
|
|
26
|
-
const
|
|
27
|
-
return this.getOraclePriceDataFromBuffer(
|
|
27
|
+
const data = await (0, utils_1.getOracleAccountDataOrThrow)(this.connection, pricePublicKey, 'Pyth lazer oracle');
|
|
28
|
+
return this.getOraclePriceDataFromBuffer(data);
|
|
28
29
|
}
|
|
29
30
|
getOraclePriceDataFromBuffer(buffer) {
|
|
30
31
|
const priceData = this.decodeFunc('pythLazerOracle', buffer);
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
/// <reference types="bn.js" />
|
|
4
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
2
5
|
import { BN } from '../isomorphic/anchor';
|
|
3
6
|
import { OraclePriceData } from './types';
|
|
7
|
+
export declare function getOracleAccountDataOrThrow(connection: Connection, pricePublicKey: PublicKey, oracleName: string): Promise<Buffer>;
|
|
4
8
|
export declare function getOracleConfidenceFromMMOracleData(mmOraclePrice: BN, oraclePriceData: OraclePriceData): BN;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOracleConfidenceFromMMOracleData = void 0;
|
|
3
|
+
exports.getOracleConfidenceFromMMOracleData = exports.getOracleAccountDataOrThrow = void 0;
|
|
4
|
+
async function getOracleAccountDataOrThrow(connection, pricePublicKey, oracleName) {
|
|
5
|
+
const accountInfo = await connection.getAccountInfo(pricePublicKey);
|
|
6
|
+
if (!accountInfo) {
|
|
7
|
+
throw new Error(`${oracleName} account not found: ${pricePublicKey.toBase58()}`);
|
|
8
|
+
}
|
|
9
|
+
return accountInfo.data;
|
|
10
|
+
}
|
|
11
|
+
exports.getOracleAccountDataOrThrow = getOracleAccountDataOrThrow;
|
|
4
12
|
function getOracleConfidenceFromMMOracleData(mmOraclePrice, oraclePriceData) {
|
|
5
13
|
const mmOracleDiffPremium = mmOraclePrice.sub(oraclePriceData.price).abs();
|
|
6
14
|
return oraclePriceData.confidence.add(mmOracleDiffPremium);
|
|
@@ -14,8 +14,6 @@ import { EventEmitter } from 'events';
|
|
|
14
14
|
import { grpcSubscription } from './grpcSubscription';
|
|
15
15
|
export declare class OrderSubscriber {
|
|
16
16
|
velocityClient: VelocityClient;
|
|
17
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
18
|
-
get driftClient(): VelocityClient;
|
|
19
17
|
usersAccounts: Map<string, {
|
|
20
18
|
slot: number;
|
|
21
19
|
userAccount: UserAccount;
|
|
@@ -24,7 +22,7 @@ export declare class OrderSubscriber {
|
|
|
24
22
|
commitment: Commitment;
|
|
25
23
|
eventEmitter: StrictEventEmitter<EventEmitter, OrderSubscriberEvents>;
|
|
26
24
|
fetchPromise?: Promise<void>;
|
|
27
|
-
fetchPromiseResolver
|
|
25
|
+
private fetchPromiseResolver;
|
|
28
26
|
mostRecentSlot: number;
|
|
29
27
|
decodeFn: (name: string, data: Buffer) => UserAccount;
|
|
30
28
|
decodeData?: boolean;
|
|
@@ -14,16 +14,14 @@ const grpcSubscription_1 = require("./grpcSubscription");
|
|
|
14
14
|
const orders_1 = require("../math/orders");
|
|
15
15
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
16
16
|
class OrderSubscriber {
|
|
17
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
18
|
-
get driftClient() {
|
|
19
|
-
return this.velocityClient;
|
|
20
|
-
}
|
|
21
17
|
constructor(config) {
|
|
22
|
-
var _a, _b, _c, _d, _e
|
|
18
|
+
var _a, _b, _c, _d, _e;
|
|
23
19
|
this.usersAccounts = new Map();
|
|
24
|
-
|
|
20
|
+
this.fetchPromiseResolver = () => { };
|
|
21
|
+
this.mostRecentSlot = 0;
|
|
22
|
+
const velocityClient = config.velocityClient;
|
|
25
23
|
if (!velocityClient) {
|
|
26
|
-
throw new Error('OrderSubscriber: velocityClient
|
|
24
|
+
throw new Error('OrderSubscriber: velocityClient must be provided');
|
|
27
25
|
}
|
|
28
26
|
this.velocityClient = velocityClient;
|
|
29
27
|
this.commitment = config.subscriptionConfig.commitment || 'processed';
|
|
@@ -39,8 +37,8 @@ class OrderSubscriber {
|
|
|
39
37
|
grpcConfigs: config.subscriptionConfig.grpcConfigs,
|
|
40
38
|
skipInitialLoad: config.subscriptionConfig.skipInitialLoad,
|
|
41
39
|
resubOpts: {
|
|
42
|
-
resubTimeoutMs: (
|
|
43
|
-
logResubMessages: (
|
|
40
|
+
resubTimeoutMs: (_a = config.subscriptionConfig) === null || _a === void 0 ? void 0 : _a.resubTimeoutMs,
|
|
41
|
+
logResubMessages: (_b = config.subscriptionConfig) === null || _b === void 0 ? void 0 : _b.logResubMessages,
|
|
44
42
|
},
|
|
45
43
|
resyncIntervalMs: config.subscriptionConfig.resyncIntervalMs,
|
|
46
44
|
decoded: config.decodeData,
|
|
@@ -52,14 +50,14 @@ class OrderSubscriber {
|
|
|
52
50
|
commitment: this.commitment,
|
|
53
51
|
skipInitialLoad: config.subscriptionConfig.skipInitialLoad,
|
|
54
52
|
resubOpts: {
|
|
55
|
-
resubTimeoutMs: (
|
|
56
|
-
logResubMessages: (
|
|
53
|
+
resubTimeoutMs: (_c = config.subscriptionConfig) === null || _c === void 0 ? void 0 : _c.resubTimeoutMs,
|
|
54
|
+
logResubMessages: (_d = config.subscriptionConfig) === null || _d === void 0 ? void 0 : _d.logResubMessages,
|
|
57
55
|
},
|
|
58
56
|
resyncIntervalMs: config.subscriptionConfig.resyncIntervalMs,
|
|
59
57
|
decoded: config.decodeData,
|
|
60
58
|
});
|
|
61
59
|
}
|
|
62
|
-
if ((
|
|
60
|
+
if ((_e = config.fastDecode) !== null && _e !== void 0 ? _e : true) {
|
|
63
61
|
this.decodeFn = (name, data) => (0, user_1.decodeUser)(data);
|
|
64
62
|
}
|
|
65
63
|
else {
|
|
@@ -183,7 +181,7 @@ class OrderSubscriber {
|
|
|
183
181
|
}
|
|
184
182
|
async addPubkey(userAccountPublicKey) {
|
|
185
183
|
const accountInfo = await this.velocityClient.connection.getAccountInfoAndContext(userAccountPublicKey, this.commitment);
|
|
186
|
-
if (accountInfo) {
|
|
184
|
+
if (accountInfo.value) {
|
|
187
185
|
this.tryUpdateUserAccount(userAccountPublicKey.toString(), 'buffer', accountInfo.value.data, accountInfo.context.slot);
|
|
188
186
|
}
|
|
189
187
|
}
|
|
@@ -191,7 +189,11 @@ class OrderSubscriber {
|
|
|
191
189
|
if (!this.usersAccounts.has(key)) {
|
|
192
190
|
await this.addPubkey(new web3_js_1.PublicKey(key));
|
|
193
191
|
}
|
|
194
|
-
|
|
192
|
+
const slotAndUserAccount = this.usersAccounts.get(key);
|
|
193
|
+
if (!slotAndUserAccount) {
|
|
194
|
+
throw new Error(`OrderSubscriber: user account ${key} not found after addPubkey`);
|
|
195
|
+
}
|
|
196
|
+
return slotAndUserAccount.userAccount;
|
|
195
197
|
}
|
|
196
198
|
async unsubscribe() {
|
|
197
199
|
this.usersAccounts.clear();
|
|
@@ -16,7 +16,7 @@ class WebsocketSubscription {
|
|
|
16
16
|
if (this.subscriber) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
this.subscriber = new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('OrderSubscriber', 'user', this.orderSubscriber.
|
|
19
|
+
this.subscriber = new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('OrderSubscriber', 'user', this.orderSubscriber.velocityClient.program, this.orderSubscriber.decodeFn, {
|
|
20
20
|
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getNonIdleUserFilter)()],
|
|
21
21
|
commitment: this.commitment,
|
|
22
22
|
}, this.resubOpts);
|
|
@@ -19,12 +19,12 @@ class grpcSubscription {
|
|
|
19
19
|
}
|
|
20
20
|
if (this.grpcConfigs.client === 'laser') {
|
|
21
21
|
this.subscriber =
|
|
22
|
-
await laserProgramAccountSubscriber_1.LaserstreamProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'user', this.orderSubscriber.
|
|
22
|
+
await laserProgramAccountSubscriber_1.LaserstreamProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'user', this.orderSubscriber.velocityClient.program, this.orderSubscriber.decodeFn, {
|
|
23
23
|
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getNonIdleUserFilter)()],
|
|
24
24
|
}, this.resubOpts);
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'user', this.orderSubscriber.
|
|
27
|
+
this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'user', this.orderSubscriber.velocityClient.program, this.orderSubscriber.decodeFn, {
|
|
28
28
|
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getNonIdleUserFilter)()],
|
|
29
29
|
}, this.resubOpts);
|
|
30
30
|
}
|
|
@@ -4,8 +4,6 @@ import { VelocityClient } from '../velocityClient';
|
|
|
4
4
|
import { GrpcConfigs } from '../accounts/types';
|
|
5
5
|
export type OrderSubscriberConfig = {
|
|
6
6
|
velocityClient?: VelocityClient;
|
|
7
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
8
|
-
driftClient?: VelocityClient;
|
|
9
7
|
subscriptionConfig: {
|
|
10
8
|
type: 'polling';
|
|
11
9
|
frequency: number;
|