@velocity-exchange/sdk 0.1.0 → 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/CHANGELOG.md +15 -0
- package/bun.lock +23 -1
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +5 -3
- package/lib/browser/accounts/basicUserAccountSubscriber.js +4 -3
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +4 -3
- package/lib/browser/accounts/bulkAccountLoader.d.ts +5 -5
- package/lib/browser/accounts/bulkAccountLoader.js +12 -1
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcAccountSubscriber.js +8 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +13 -5
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +12 -8
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +8 -2
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +3 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +4 -3
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +16 -5
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +16 -5
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +8 -4
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +17 -11
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +6 -6
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
- package/lib/browser/accounts/types.d.ts +4 -4
- package/lib/browser/accounts/utils.d.ts +1 -0
- package/lib/browser/accounts/utils.js +8 -1
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketAccountSubscriber.js +17 -5
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +17 -6
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +14 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +9 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +0 -3
- package/lib/browser/addresses/marketAddresses.js +3 -2
- package/lib/browser/addresses/pda.d.ts +0 -2
- package/lib/browser/addresses/pda.js +1 -14
- package/lib/browser/adminClient.d.ts +24 -28
- package/lib/browser/adminClient.js +156 -157
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +6 -4
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/browser/bankrun/bankrunConnection.d.ts +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 +1 -1
- package/lib/browser/config.js +8 -4
- package/lib/browser/constants/index.d.ts +1 -2
- package/lib/browser/constants/index.js +1 -2
- package/lib/browser/constants/numericConstants.d.ts +1 -3
- package/lib/browser/constants/numericConstants.js +3 -5
- package/lib/browser/constituentMap/constituentMap.js +5 -1
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
- package/lib/browser/core/instructions/perpOrders.d.ts +14 -0
- package/lib/browser/core/instructions/perpOrders.js +14 -0
- package/lib/browser/core/remainingAccounts.d.ts +2 -2
- package/lib/browser/core/remainingAccounts.js +2 -2
- package/lib/browser/decode/user.js +9 -1
- package/lib/browser/dlob/DLOB.d.ts +6 -1
- package/lib/browser/dlob/DLOB.js +201 -138
- package/lib/browser/dlob/DLOBNode.d.ts +5 -2
- package/lib/browser/dlob/DLOBNode.js +7 -0
- package/lib/browser/dlob/DLOBSubscriber.js +37 -32
- package/lib/browser/dlob/NodeList.js +8 -7
- package/lib/browser/dlob/orderBookLevels.js +19 -12
- package/lib/browser/events/eventList.js +4 -1
- package/lib/browser/events/eventSubscriber.d.ts +5 -2
- package/lib/browser/events/eventSubscriber.js +75 -26
- package/lib/browser/events/eventsServerLogProvider.d.ts +1 -1
- package/lib/browser/events/eventsServerLogProvider.js +15 -8
- package/lib/browser/events/fetchLogs.d.ts +1 -1
- package/lib/browser/events/fetchLogs.js +4 -2
- package/lib/browser/events/pollingLogProvider.d.ts +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 +2 -4
- package/lib/browser/events/types.js +0 -2
- 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/browser/idl/velocity.d.ts +1243 -1586
- package/lib/browser/idl/velocity.json +1234 -1577
- package/lib/browser/index.d.ts +0 -2
- package/lib/browser/index.js +0 -2
- package/lib/browser/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 +77 -22
- package/lib/browser/math/bankruptcy.js +1 -1
- package/lib/browser/math/funding.js +6 -6
- package/lib/browser/math/insurance.d.ts +1 -1
- package/lib/browser/math/insurance.js +4 -5
- package/lib/browser/math/margin.d.ts +1 -9
- package/lib/browser/math/margin.js +3 -62
- package/lib/browser/math/market.d.ts +4 -12
- package/lib/browser/math/market.js +6 -40
- package/lib/browser/math/oracles.d.ts +0 -3
- package/lib/browser/math/oracles.js +1 -14
- package/lib/browser/math/orders.d.ts +0 -5
- package/lib/browser/math/orders.js +2 -74
- package/lib/browser/math/position.d.ts +0 -4
- package/lib/browser/math/position.js +5 -10
- 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 +3 -53
- package/lib/browser/math/superStake.js +16 -13
- package/lib/browser/math/trade.js +6 -6
- 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 +3 -2
- 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 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -2
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +32 -8
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/pyth/types.d.ts +0 -1
- package/lib/browser/slot/SlotSubscriber.d.ts +1 -1
- package/lib/browser/slot/SlotSubscriber.js +2 -1
- package/lib/browser/slot/SlothashSubscriber.d.ts +3 -2
- package/lib/browser/slot/SlothashSubscriber.js +11 -4
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +13 -5
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +1 -1
- package/lib/browser/swift/swiftOrderSubscriber.js +10 -5
- package/lib/browser/testClient.js +3 -2
- package/lib/browser/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 +27 -70
- package/lib/browser/types.js +2 -2
- package/lib/browser/user.d.ts +21 -7
- package/lib/browser/user.js +156 -132
- package/lib/browser/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/browser/userMap/grpcSubscription.d.ts +1 -1
- package/lib/browser/userMap/referrerMap.js +10 -3
- package/lib/browser/userMap/revenueShareEscrowMap.js +4 -0
- package/lib/browser/userMap/userMap.d.ts +1 -1
- package/lib/browser/userMap/userMap.js +36 -23
- package/lib/browser/userMap/userStatsMap.d.ts +1 -1
- package/lib/browser/userMap/userStatsMap.js +18 -13
- package/lib/browser/userStats.d.ts +7 -2
- package/lib/browser/userStats.js +18 -4
- package/lib/browser/util/TransactionConfirmationManager.js +4 -2
- package/lib/browser/util/chainClock.d.ts +1 -1
- package/lib/browser/util/computeUnits.d.ts +1 -1
- package/lib/browser/util/computeUnits.js +6 -1
- package/lib/browser/velocityClient.d.ts +92 -34
- package/lib/browser/velocityClient.js +414 -280
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +5 -3
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserAccountSubscriber.js +4 -3
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +4 -3
- package/lib/node/accounts/bulkAccountLoader.d.ts +5 -5
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/bulkAccountLoader.js +12 -1
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcAccountSubscriber.js +8 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +13 -5
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +12 -8
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +8 -2
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +3 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +4 -3
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +16 -5
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +16 -5
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +8 -4
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +17 -11
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +6 -6
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
- package/lib/node/accounts/types.d.ts +4 -4
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/utils.d.ts +1 -0
- package/lib/node/accounts/utils.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +8 -1
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +17 -5
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +17 -6
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +14 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +9 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +0 -3
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
- package/lib/node/addresses/marketAddresses.js +3 -2
- package/lib/node/addresses/pda.d.ts +0 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +1 -14
- package/lib/node/adminClient.d.ts +24 -28
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +156 -157
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +6 -4
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/node/bankrun/bankrunConnection.d.ts +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 +1 -1
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +8 -4
- package/lib/node/constants/index.d.ts +1 -2
- package/lib/node/constants/index.d.ts.map +1 -1
- package/lib/node/constants/index.js +1 -2
- package/lib/node/constants/numericConstants.d.ts +1 -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.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +5 -1
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
- package/lib/node/core/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/remainingAccounts.d.ts +2 -2
- package/lib/node/core/remainingAccounts.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.js +2 -2
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +9 -1
- package/lib/node/dlob/DLOB.d.ts +6 -1
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +201 -138
- package/lib/node/dlob/DLOBNode.d.ts +5 -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.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +37 -32
- 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 +19 -12
- package/lib/node/events/eventList.d.ts +3 -3
- package/lib/node/events/eventList.d.ts.map +1 -1
- package/lib/node/events/eventList.js +4 -1
- package/lib/node/events/eventSubscriber.d.ts +5 -2
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +75 -26
- package/lib/node/events/eventsServerLogProvider.d.ts +2 -2
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
- package/lib/node/events/eventsServerLogProvider.js +15 -8
- package/lib/node/events/fetchLogs.d.ts +1 -1
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.js +4 -2
- package/lib/node/events/pollingLogProvider.d.ts +2 -2
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
- package/lib/node/events/pollingLogProvider.js +1 -0
- package/lib/node/events/txEventCache.d.ts +3 -3
- package/lib/node/events/txEventCache.d.ts.map +1 -1
- package/lib/node/events/txEventCache.js +6 -2
- package/lib/node/events/types.d.ts +2 -4
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +0 -2
- package/lib/node/events/webSocketLogProvider.d.ts +2 -2
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
- package/lib/node/events/webSocketLogProvider.js +5 -2
- package/lib/node/factory/bigNum.js +1 -1
- package/lib/node/idl/velocity.d.ts +1243 -1586
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +1234 -1577
- package/lib/node/index.d.ts +0 -2
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -2
- package/lib/node/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 +77 -22
- package/lib/node/math/bankruptcy.js +1 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +6 -6
- package/lib/node/math/insurance.d.ts +1 -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 +1 -9
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +3 -62
- package/lib/node/math/market.d.ts +4 -12
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +6 -40
- package/lib/node/math/oracles.d.ts +0 -3
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +1 -14
- package/lib/node/math/orders.d.ts +0 -5
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +2 -74
- package/lib/node/math/position.d.ts +1 -5
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +5 -10
- package/lib/node/math/repeg.d.ts +0 -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 +3 -53
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +16 -13
- package/lib/node/math/trade.d.ts +2 -2
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +6 -6
- 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 +3 -2
- 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 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +8 -2
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +32 -8
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/pyth/types.d.ts +0 -1
- package/lib/node/pyth/types.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.d.ts +1 -1
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.js +2 -1
- package/lib/node/slot/SlothashSubscriber.d.ts +3 -2
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlothashSubscriber.js +11 -4
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +13 -5
- package/lib/node/swift/swiftOrderSubscriber.d.ts +1 -1
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +10 -5
- package/lib/node/testClient.js +3 -2
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +16 -2
- package/lib/node/tx/baseTxSender.d.ts +4 -4
- package/lib/node/tx/baseTxSender.d.ts.map +1 -1
- package/lib/node/tx/baseTxSender.js +5 -4
- package/lib/node/tx/fastSingleTxSender.d.ts +3 -3
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.js +9 -5
- package/lib/node/tx/reportTransactionError.d.ts +2 -2
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
- package/lib/node/tx/reportTransactionError.js +5 -1
- package/lib/node/tx/retryTxSender.d.ts +1 -1
- package/lib/node/tx/retryTxSender.d.ts.map +1 -1
- package/lib/node/tx/retryTxSender.js +4 -2
- package/lib/node/tx/txHandler.d.ts +9 -3
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +54 -40
- package/lib/node/tx/txParamProcessor.d.ts +4 -1
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
- package/lib/node/tx/txParamProcessor.js +6 -0
- package/lib/node/tx/types.d.ts +1 -1
- package/lib/node/tx/types.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.d.ts +1 -6
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.js +35 -13
- package/lib/node/types.d.ts +25 -68
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +2 -2
- package/lib/node/user.d.ts +21 -7
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +156 -132
- package/lib/node/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/userMap/grpcSubscription.d.ts +1 -1
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +10 -3
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +4 -0
- package/lib/node/userMap/userMap.d.ts +1 -1
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +36 -23
- package/lib/node/userMap/userStatsMap.d.ts +1 -1
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +18 -13
- package/lib/node/userStats.d.ts +7 -2
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +18 -4
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
- package/lib/node/util/TransactionConfirmationManager.js +4 -2
- package/lib/node/util/chainClock.d.ts +1 -1
- package/lib/node/util/chainClock.d.ts.map +1 -1
- package/lib/node/util/computeUnits.d.ts +1 -1
- package/lib/node/util/computeUnits.d.ts.map +1 -1
- package/lib/node/util/computeUnits.js +6 -1
- package/lib/node/velocityClient.d.ts +93 -35
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +414 -280
- package/package.json +5 -3
- package/src/accounts/basicUserAccountSubscriber.ts +7 -5
- package/src/accounts/basicUserStatsAccountSubscriber.ts +9 -5
- package/src/accounts/bulkAccountLoader.ts +20 -7
- package/src/accounts/grpcAccountSubscriber.ts +11 -3
- package/src/accounts/grpcMultiAccountSubscriber.ts +24 -9
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +16 -12
- package/src/accounts/grpcProgramAccountSubscriber.ts +11 -3
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +17 -7
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +66 -39
- package/src/accounts/laserProgramAccountSubscriber.ts +3 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +5 -3
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +8 -3
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -5
- package/src/accounts/pollingOracleAccountSubscriber.ts +17 -10
- package/src/accounts/pollingTokenAccountSubscriber.ts +17 -10
- package/src/accounts/pollingUserAccountSubscriber.ts +26 -20
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +12 -10
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +76 -30
- package/src/accounts/types.ts +6 -4
- package/src/accounts/utils.ts +10 -0
- package/src/accounts/webSocketAccountSubscriber.ts +23 -10
- package/src/accounts/webSocketAccountSubscriberV2.ts +23 -8
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +17 -2
- package/src/accounts/webSocketProgramAccountSubscriber.ts +29 -4
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +30 -4
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +29 -4
- package/src/accounts/webSocketUserAccountSubscriber.ts +11 -2
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +15 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +76 -48
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +74 -35
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +1 -6
- package/src/addresses/marketAddresses.ts +3 -2
- package/src/addresses/pda.ts +0 -25
- package/src/adminClient.ts +273 -303
- package/src/auctionSubscriber/auctionSubscriber.ts +7 -5
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -5
- package/src/bankrun/bankrunConnection.ts +83 -39
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +5 -4
- package/src/clock/clockSubscriber.ts +10 -9
- package/src/config.ts +8 -3
- package/src/constants/index.ts +1 -2
- package/src/constants/numericConstants.ts +3 -3
- package/src/constituentMap/constituentMap.ts +8 -1
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +4 -2
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +13 -4
- package/src/core/instructions/perpOrders.ts +14 -0
- package/src/core/remainingAccounts.ts +4 -4
- package/src/decode/user.ts +8 -1
- package/src/dlob/DLOB.ts +296 -172
- package/src/dlob/DLOBNode.ts +23 -3
- package/src/dlob/DLOBSubscriber.ts +51 -34
- package/src/dlob/NodeList.ts +8 -7
- package/src/dlob/orderBookLevels.ts +45 -25
- package/src/events/eventList.ts +4 -1
- package/src/events/eventSubscriber.ts +107 -49
- package/src/events/eventsServerLogProvider.ts +22 -13
- package/src/events/fetchLogs.ts +3 -3
- package/src/events/pollingLogProvider.ts +2 -2
- package/src/events/txEventCache.ts +8 -2
- package/src/events/types.ts +0 -8
- package/src/events/webSocketLogProvider.ts +5 -3
- package/src/factory/bigNum.ts +2 -2
- package/src/idl/velocity.json +1234 -1577
- package/src/idl/velocity.ts +1234 -1577
- package/src/index.ts +0 -2
- package/src/jupiter/jupiterClient.ts +30 -10
- package/src/marginCalculation.ts +1 -0
- package/src/math/amm.ts +188 -33
- package/src/math/bankruptcy.ts +1 -1
- package/src/math/funding.ts +7 -6
- package/src/math/insurance.ts +6 -8
- package/src/math/margin.ts +5 -112
- package/src/math/market.ts +6 -96
- package/src/math/oracles.ts +0 -17
- package/src/math/orders.ts +1 -110
- package/src/math/position.ts +4 -16
- package/src/math/repeg.ts +0 -29
- package/src/math/spotBalance.ts +14 -10
- package/src/math/spotMarket.ts +2 -28
- package/src/math/spotPosition.ts +4 -4
- package/src/math/state.ts +0 -8
- package/src/math/superStake.ts +19 -65
- package/src/math/trade.ts +2 -6
- package/src/memcmp.ts +0 -9
- package/src/oracles/prelaunchOracleClient.ts +7 -2
- package/src/oracles/pythClient.ts +12 -3
- package/src/oracles/pythLazerClient.ts +7 -2
- package/src/oracles/utils.ts +15 -0
- package/src/orderSubscriber/OrderSubscriber.ts +10 -4
- package/src/priorityFee/heliusPriorityFeeMethod.ts +1 -1
- package/src/priorityFee/priorityFeeSubscriber.ts +45 -9
- package/src/priorityFee/solanaPriorityFeeMethod.ts +1 -1
- package/src/pyth/types.ts +0 -2
- package/src/slot/SlotSubscriber.ts +3 -3
- package/src/slot/SlothashSubscriber.ts +17 -6
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +5 -6
- package/src/swift/signedMsgUserAccountSubscriber.ts +16 -8
- package/src/swift/swiftOrderSubscriber.ts +10 -9
- package/src/testClient.ts +2 -2
- package/src/tokenFaucet.ts +22 -3
- package/src/tx/baseTxSender.ts +10 -10
- package/src/tx/fastSingleTxSender.ts +12 -8
- package/src/tx/reportTransactionError.ts +12 -7
- package/src/tx/retryTxSender.ts +6 -4
- package/src/tx/txHandler.ts +88 -43
- package/src/tx/txParamProcessor.ts +18 -3
- package/src/tx/types.ts +1 -1
- package/src/tx/whileValidTxSender.ts +51 -22
- package/src/types.ts +39 -75
- package/src/user.ts +200 -152
- package/src/userMap/WebsocketSubscription.ts +1 -1
- package/src/userMap/grpcSubscription.ts +1 -1
- package/src/userMap/referrerMap.ts +13 -9
- package/src/userMap/revenueShareEscrowMap.ts +6 -1
- package/src/userMap/userMap.ts +43 -25
- package/src/userMap/userStatsMap.ts +32 -19
- package/src/userStats.ts +21 -8
- package/src/util/TransactionConfirmationManager.ts +10 -2
- package/src/util/chainClock.ts +1 -1
- package/src/util/computeUnits.ts +7 -3
- package/src/velocityClient.ts +536 -383
- package/tests/amm/test.ts +138 -0
- package/tests/dlob/helpers.ts +6 -1
- 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/tps.d.ts +0 -2
- package/lib/browser/util/tps.js +0 -16
- package/lib/node/constants/insuranceFund.d.ts +0 -6
- package/lib/node/constants/insuranceFund.d.ts.map +0 -1
- package/lib/node/constants/insuranceFund.js +0 -9
- package/lib/node/tx/forwardOnlyTxSender.d.ts +0 -38
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +0 -1
- package/lib/node/tx/forwardOnlyTxSender.js +0 -92
- package/lib/node/util/tps.d.ts +0 -3
- package/lib/node/util/tps.d.ts.map +0 -1
- package/lib/node/util/tps.js +0 -16
- package/src/constants/insuranceFund.ts +0 -8
- package/src/tx/forwardOnlyTxSender.ts +0 -145
- package/src/util/tps.ts +0 -27
|
@@ -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");
|
|
@@ -45,7 +45,7 @@ async function findBestSuperStakeIxs({ marketIndex, amount, jupiterClient, veloc
|
|
|
45
45
|
else if (marketIndex === 8) {
|
|
46
46
|
return findBestLstSuperStakeIxs({
|
|
47
47
|
amount,
|
|
48
|
-
lstMint: velocityClient.
|
|
48
|
+
lstMint: velocityClient.getSpotMarketAccountOrThrow(8).mint,
|
|
49
49
|
lstMarketIndex: 8,
|
|
50
50
|
jupiterClient,
|
|
51
51
|
velocityClient,
|
|
@@ -64,8 +64,8 @@ async function findBestMSolSuperStakeIxs({ amount, jupiterClient, velocityClient
|
|
|
64
64
|
const marinadeProgram = (0, marinade_1.getMarinadeFinanceProgram)(velocityClient.provider);
|
|
65
65
|
price = await (0, marinade_1.getMarinadeMSolPrice)(marinadeProgram);
|
|
66
66
|
}
|
|
67
|
-
const solSpotMarketAccount = velocityClient.
|
|
68
|
-
const mSolSpotMarketAccount = velocityClient.
|
|
67
|
+
const solSpotMarketAccount = velocityClient.getSpotMarketAccountOrThrow(1);
|
|
68
|
+
const mSolSpotMarketAccount = velocityClient.getSpotMarketAccountOrThrow(2);
|
|
69
69
|
let jupiterPrice;
|
|
70
70
|
let quote = jupiterQuote;
|
|
71
71
|
if (!jupiterQuote) {
|
|
@@ -77,7 +77,7 @@ async function findBestMSolSuperStakeIxs({ amount, jupiterClient, velocityClient
|
|
|
77
77
|
slippageBps: 1000,
|
|
78
78
|
onlyDirectRoutes,
|
|
79
79
|
});
|
|
80
|
-
jupiterPrice = +
|
|
80
|
+
jupiterPrice = +fetchedQuote.outAmount / +fetchedQuote.inAmount;
|
|
81
81
|
quote = fetchedQuote;
|
|
82
82
|
}
|
|
83
83
|
catch (e) {
|
|
@@ -122,7 +122,7 @@ async function findBestJitoSolSuperStakeIxs({ amount, jupiterClient, velocityCli
|
|
|
122
122
|
velocityClient,
|
|
123
123
|
userAccountPublicKey,
|
|
124
124
|
onlyDirectRoutes,
|
|
125
|
-
lstMint: velocityClient.
|
|
125
|
+
lstMint: velocityClient.getSpotMarketAccountOrThrow(6).mint,
|
|
126
126
|
lstMarketIndex: 6,
|
|
127
127
|
jupiterQuote,
|
|
128
128
|
});
|
|
@@ -187,12 +187,6 @@ async function fetchJitoSolMetrics() {
|
|
|
187
187
|
return data;
|
|
188
188
|
}
|
|
189
189
|
exports.fetchJitoSolMetrics = fetchJitoSolMetrics;
|
|
190
|
-
const fetchMSolMetrics = async () => {
|
|
191
|
-
const res = await (0, node_fetch_1.default)('https://api2.marinade.finance/metrics_json');
|
|
192
|
-
const data = await res.json();
|
|
193
|
-
return data;
|
|
194
|
-
};
|
|
195
|
-
exports.fetchMSolMetrics = fetchMSolMetrics;
|
|
196
190
|
const getJitoSolHistoricalPriceMap = async (timestamps) => {
|
|
197
191
|
try {
|
|
198
192
|
const data = await fetchJitoSolMetrics();
|
|
@@ -258,7 +252,10 @@ async function calculateSolEarned({ marketIndex, user, depositRecords, }) {
|
|
|
258
252
|
await Promise.all(timestamps.map(getMsolPrice));
|
|
259
253
|
}
|
|
260
254
|
else if (marketIndex === 6) {
|
|
261
|
-
|
|
255
|
+
const jitoSolRatios = await getJitoSolHistoricalPriceMap(timestamps);
|
|
256
|
+
if (jitoSolRatios) {
|
|
257
|
+
lstRatios = jitoSolRatios;
|
|
258
|
+
}
|
|
262
259
|
}
|
|
263
260
|
else if (marketIndex === 8) {
|
|
264
261
|
await getBSolPrice(timestamps);
|
|
@@ -277,6 +274,9 @@ async function calculateSolEarned({ marketIndex, user, depositRecords, }) {
|
|
|
277
274
|
record.marketIndex === 6 ||
|
|
278
275
|
record.marketIndex === 8) {
|
|
279
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
|
+
}
|
|
280
280
|
const lstRatioBN = new anchor_1.BN(lstRatio * web3_js_1.LAMPORTS_PER_SOL);
|
|
281
281
|
const solAmount = record.amount.mul(lstRatioBN).div(numericConstants_1.LAMPORTS_PRECISION);
|
|
282
282
|
if ((0, types_1.isVariant)(record.direction, 'deposit')) {
|
|
@@ -289,6 +289,9 @@ async function calculateSolEarned({ marketIndex, user, depositRecords, }) {
|
|
|
289
289
|
}
|
|
290
290
|
const currentLstTokenAmount = await user.getTokenAmount(marketIndex);
|
|
291
291
|
const currentLstRatio = lstRatios.get(now);
|
|
292
|
+
if (currentLstRatio === undefined) {
|
|
293
|
+
throw new Error(`Missing current LST/SOL ratio for timestamp ${now}`);
|
|
294
|
+
}
|
|
292
295
|
const currentLstRatioBN = new anchor_1.BN(currentLstRatio * web3_js_1.LAMPORTS_PER_SOL);
|
|
293
296
|
solEarned = solEarned.add(currentLstTokenAmount.mul(currentLstRatioBN).div(numericConstants_1.LAMPORTS_PRECISION));
|
|
294
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, market.marketStats,
|
|
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, market.marketStats,
|
|
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, market.marketStats,
|
|
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,7 +280,7 @@ 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, market.marketStats,
|
|
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,
|
|
@@ -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);
|
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) {
|
|
@@ -9,6 +9,7 @@ const anchor_1 = require("../isomorphic/anchor");
|
|
|
9
9
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
10
10
|
const wallet_1 = require("../wallet");
|
|
11
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;
|
|
@@ -23,8 +24,8 @@ class PythLazerClient {
|
|
|
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);
|
|
@@ -22,7 +22,7 @@ export declare class OrderSubscriber {
|
|
|
22
22
|
commitment: Commitment;
|
|
23
23
|
eventEmitter: StrictEventEmitter<EventEmitter, OrderSubscriberEvents>;
|
|
24
24
|
fetchPromise?: Promise<void>;
|
|
25
|
-
fetchPromiseResolver
|
|
25
|
+
private fetchPromiseResolver;
|
|
26
26
|
mostRecentSlot: number;
|
|
27
27
|
decodeFn: (name: string, data: Buffer) => UserAccount;
|
|
28
28
|
decodeData?: boolean;
|
|
@@ -17,6 +17,8 @@ class OrderSubscriber {
|
|
|
17
17
|
constructor(config) {
|
|
18
18
|
var _a, _b, _c, _d, _e;
|
|
19
19
|
this.usersAccounts = new Map();
|
|
20
|
+
this.fetchPromiseResolver = () => { };
|
|
21
|
+
this.mostRecentSlot = 0;
|
|
20
22
|
const velocityClient = config.velocityClient;
|
|
21
23
|
if (!velocityClient) {
|
|
22
24
|
throw new Error('OrderSubscriber: velocityClient must be provided');
|
|
@@ -179,7 +181,7 @@ class OrderSubscriber {
|
|
|
179
181
|
}
|
|
180
182
|
async addPubkey(userAccountPublicKey) {
|
|
181
183
|
const accountInfo = await this.velocityClient.connection.getAccountInfoAndContext(userAccountPublicKey, this.commitment);
|
|
182
|
-
if (accountInfo) {
|
|
184
|
+
if (accountInfo.value) {
|
|
183
185
|
this.tryUpdateUserAccount(userAccountPublicKey.toString(), 'buffer', accountInfo.value.data, accountInfo.context.slot);
|
|
184
186
|
}
|
|
185
187
|
}
|
|
@@ -187,7 +189,11 @@ class OrderSubscriber {
|
|
|
187
189
|
if (!this.usersAccounts.has(key)) {
|
|
188
190
|
await this.addPubkey(new web3_js_1.PublicKey(key));
|
|
189
191
|
}
|
|
190
|
-
|
|
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;
|
|
191
197
|
}
|
|
192
198
|
async unsubscribe() {
|
|
193
199
|
this.usersAccounts.clear();
|
|
@@ -17,4 +17,4 @@ export type HeliusPriorityFeeResponse = {
|
|
|
17
17
|
};
|
|
18
18
|
id: string;
|
|
19
19
|
};
|
|
20
|
-
export declare function fetchHeliusPriorityFee(heliusRpcUrl: string, lookbackDistance: number, addresses: string[]): Promise<HeliusPriorityFeeResponse>;
|
|
20
|
+
export declare function fetchHeliusPriorityFee(heliusRpcUrl: string, lookbackDistance: number, addresses: string[]): Promise<HeliusPriorityFeeResponse | undefined>;
|
|
@@ -5,7 +5,7 @@ import { MaxOverSlotsStrategy } from './maxOverSlotsStrategy';
|
|
|
5
5
|
import { HeliusPriorityFeeLevels, HeliusPriorityLevel } from './heliusPriorityFeeMethod';
|
|
6
6
|
import { VelocityMarketInfo } from './velocityPriorityFeeMethod';
|
|
7
7
|
export declare class PriorityFeeSubscriber {
|
|
8
|
-
connection
|
|
8
|
+
connection?: Connection;
|
|
9
9
|
frequencyMs: number;
|
|
10
10
|
addresses: string[];
|
|
11
11
|
velocityMarkets?: VelocityMarketInfo[];
|
|
@@ -9,7 +9,7 @@ const heliusPriorityFeeMethod_1 = require("./heliusPriorityFeeMethod");
|
|
|
9
9
|
const velocityPriorityFeeMethod_1 = require("./velocityPriorityFeeMethod");
|
|
10
10
|
class PriorityFeeSubscriber {
|
|
11
11
|
constructor(config) {
|
|
12
|
-
var _a, _b, _c, _d;
|
|
12
|
+
var _a, _b, _c, _d, _e;
|
|
13
13
|
this.averageStrategy = new averageOverSlotsStrategy_1.AverageOverSlotsStrategy();
|
|
14
14
|
this.maxStrategy = new maxOverSlotsStrategy_1.MaxOverSlotsStrategy();
|
|
15
15
|
this.priorityFeeMethod = types_1.PriorityFeeMethod.SOLANA;
|
|
@@ -36,7 +36,7 @@ class PriorityFeeSubscriber {
|
|
|
36
36
|
this.priorityFeeMethod = config.priorityFeeMethod;
|
|
37
37
|
if (this.priorityFeeMethod === types_1.PriorityFeeMethod.HELIUS) {
|
|
38
38
|
if (config.heliusRpcUrl === undefined) {
|
|
39
|
-
if (this.connection.rpcEndpoint.includes('helius')) {
|
|
39
|
+
if ((_c = this.connection) === null || _c === void 0 ? void 0 : _c.rpcEndpoint.includes('helius')) {
|
|
40
40
|
this.heliusRpcUrl = this.connection.rpcEndpoint;
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
@@ -49,7 +49,7 @@ class PriorityFeeSubscriber {
|
|
|
49
49
|
}
|
|
50
50
|
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.VELOCITY) {
|
|
51
51
|
this.velocityPriorityFeeEndpoint =
|
|
52
|
-
(
|
|
52
|
+
(_d = config.velocityPriorityFeeEndpoint) !== null && _d !== void 0 ? _d : config.velocityPriorityFeeEndpoint;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
if (this.priorityFeeMethod === types_1.PriorityFeeMethod.SOLANA) {
|
|
@@ -58,7 +58,7 @@ class PriorityFeeSubscriber {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
this.maxFeeMicroLamports = config.maxFeeMicroLamports;
|
|
61
|
-
this.priorityFeeMultiplier = (
|
|
61
|
+
this.priorityFeeMultiplier = (_e = config.priorityFeeMultiplier) !== null && _e !== void 0 ? _e : 1.0;
|
|
62
62
|
}
|
|
63
63
|
async subscribe() {
|
|
64
64
|
if (this.intervalId) {
|
|
@@ -68,7 +68,13 @@ class PriorityFeeSubscriber {
|
|
|
68
68
|
await this.load();
|
|
69
69
|
}
|
|
70
70
|
async loadForSolana() {
|
|
71
|
+
if (this.connection === undefined) {
|
|
72
|
+
throw new Error('connection must be provided to use SOLANA priority fee API');
|
|
73
|
+
}
|
|
71
74
|
const samples = await (0, solanaPriorityFeeMethod_1.fetchSolanaPriorityFee)(this.connection, this.lookbackDistance, this.addresses);
|
|
75
|
+
if (samples === undefined) {
|
|
76
|
+
throw new Error('fetchSolanaPriorityFee returned no samples');
|
|
77
|
+
}
|
|
72
78
|
if (samples.length > 0) {
|
|
73
79
|
this.latestPriorityFee = samples[0].prioritizationFee;
|
|
74
80
|
this.lastSlotSeen = samples[0].slot;
|
|
@@ -81,9 +87,12 @@ class PriorityFeeSubscriber {
|
|
|
81
87
|
}
|
|
82
88
|
async loadForHelius() {
|
|
83
89
|
var _a, _b;
|
|
90
|
+
if (this.heliusRpcUrl === undefined) {
|
|
91
|
+
throw new Error('heliusRpcUrl must be provided to use PriorityFeeMethod.HELIUS');
|
|
92
|
+
}
|
|
84
93
|
const sample = await (0, heliusPriorityFeeMethod_1.fetchHeliusPriorityFee)(this.heliusRpcUrl, this.lookbackDistance, this.addresses);
|
|
85
94
|
this.lastHeliusSample = (_b = (_a = sample === null || sample === void 0 ? void 0 : sample.result) === null || _a === void 0 ? void 0 : _a.priorityFeeLevels) !== null && _b !== void 0 ? _b : undefined;
|
|
86
|
-
if (this.lastHeliusSample) {
|
|
95
|
+
if (sample !== undefined && this.lastHeliusSample) {
|
|
87
96
|
this.lastAvgStrategyResult =
|
|
88
97
|
this.lastHeliusSample[heliusPriorityFeeMethod_1.HeliusPriorityLevel.MEDIUM];
|
|
89
98
|
this.lastMaxStrategyResult =
|
|
@@ -97,12 +106,27 @@ class PriorityFeeSubscriber {
|
|
|
97
106
|
if (!this.velocityMarkets) {
|
|
98
107
|
return;
|
|
99
108
|
}
|
|
109
|
+
if (this.velocityPriorityFeeEndpoint === undefined) {
|
|
110
|
+
throw new Error('velocityPriorityFeeEndpoint must be provided to use PriorityFeeMethod.VELOCITY');
|
|
111
|
+
}
|
|
100
112
|
const sample = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.velocityMarkets.map((m) => m.marketType), this.velocityMarkets.map((m) => m.marketIndex));
|
|
101
113
|
if (sample.length > 0) {
|
|
102
|
-
|
|
103
|
-
|
|
114
|
+
// The endpoint returns one fee-level set per requested market. Take the
|
|
115
|
+
// max level across markets so a transaction touching several markets is
|
|
116
|
+
// covered by the most expensive one. (Base indexed the array itself with
|
|
117
|
+
// a string enum key — `sample['medium']` — which yielded `undefined` and
|
|
118
|
+
// produced NaN strategy results; the missing per-element index is fixed
|
|
119
|
+
// here.)
|
|
120
|
+
this.lastAvgStrategyResult = Math.max(...sample.map((s) => s[heliusPriorityFeeMethod_1.HeliusPriorityLevel.MEDIUM]));
|
|
121
|
+
this.lastMaxStrategyResult = Math.max(...sample.map((s) => s[heliusPriorityFeeMethod_1.HeliusPriorityLevel.UNSAFE_MAX]));
|
|
104
122
|
if (this.customStrategy) {
|
|
105
|
-
|
|
123
|
+
// Custom strategies expect `{ slot, prioritizationFee }[]`; map each
|
|
124
|
+
// market's medium level into that shape so they aggregate real values
|
|
125
|
+
// instead of summing the absent `prioritizationFee` field (NaN).
|
|
126
|
+
this.lastCustomStrategyResult = this.customStrategy.calculate(sample.map((s) => ({
|
|
127
|
+
slot: 0,
|
|
128
|
+
prioritizationFee: s[heliusPriorityFeeMethod_1.HeliusPriorityLevel.MEDIUM],
|
|
129
|
+
})));
|
|
106
130
|
}
|
|
107
131
|
}
|
|
108
132
|
}
|
|
@@ -3,4 +3,4 @@ export type SolanaPriorityFeeResponse = {
|
|
|
3
3
|
slot: number;
|
|
4
4
|
prioritizationFee: number;
|
|
5
5
|
};
|
|
6
|
-
export declare function fetchSolanaPriorityFee(connection: Connection, lookbackDistance: number, addresses: string[]): Promise<SolanaPriorityFeeResponse[]>;
|
|
6
|
+
export declare function fetchSolanaPriorityFee(connection: Connection, lookbackDistance: number, addresses: string[]): Promise<SolanaPriorityFeeResponse[] | undefined>;
|
|
@@ -2222,5 +2222,4 @@ export type PythSolanaReceiver = {
|
|
|
2222
2222
|
];
|
|
2223
2223
|
};
|
|
2224
2224
|
export declare const IDL: PythSolanaReceiver;
|
|
2225
|
-
export declare const PYTH_SOLANA_RECEIVER_IDL: PythSolanaReceiver;
|
|
2226
2225
|
export type PriceUpdateAccount = IdlAccounts<PythSolanaReceiver>['priceUpdateV2'];
|
|
@@ -11,7 +11,7 @@ export interface SlotSubscriberEvents {
|
|
|
11
11
|
export declare class SlotSubscriber {
|
|
12
12
|
private connection;
|
|
13
13
|
currentSlot: number;
|
|
14
|
-
subscriptionId
|
|
14
|
+
subscriptionId?: number;
|
|
15
15
|
eventEmitter: StrictEventEmitter<EventEmitter, SlotSubscriberEvents>;
|
|
16
16
|
timeoutId?: ReturnType<typeof setTimeout>;
|
|
17
17
|
resubTimeoutMs?: number;
|
|
@@ -5,11 +5,12 @@ const events_1 = require("events");
|
|
|
5
5
|
class SlotSubscriber {
|
|
6
6
|
constructor(connection, config) {
|
|
7
7
|
this.connection = connection;
|
|
8
|
+
this.currentSlot = 0;
|
|
8
9
|
this.isUnsubscribing = false;
|
|
9
10
|
this.receivingData = false;
|
|
10
11
|
this.eventEmitter = new events_1.EventEmitter();
|
|
11
12
|
this.resubTimeoutMs = config === null || config === void 0 ? void 0 : config.resubTimeoutMs;
|
|
12
|
-
if (this.resubTimeoutMs < 1000) {
|
|
13
|
+
if (this.resubTimeoutMs !== undefined && this.resubTimeoutMs < 1000) {
|
|
13
14
|
console.log('resubTimeoutMs should be at least 1000ms to avoid spamming resub');
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -9,8 +9,9 @@ export type Slothash = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare class SlothashSubscriber {
|
|
11
11
|
private connection;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
private _currentSlothash?;
|
|
13
|
+
private get currentSlothash();
|
|
14
|
+
subscriptionId?: number;
|
|
14
15
|
commitment: Commitment;
|
|
15
16
|
timeoutId?: ReturnType<typeof setTimeout>;
|
|
16
17
|
resubTimeoutMs?: number;
|
|
@@ -8,6 +8,12 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
8
8
|
const bs58_1 = __importDefault(require("bs58"));
|
|
9
9
|
const anchor_1 = require("../isomorphic/anchor");
|
|
10
10
|
class SlothashSubscriber {
|
|
11
|
+
get currentSlothash() {
|
|
12
|
+
if (!this._currentSlothash) {
|
|
13
|
+
throw new Error('SlothashSubscriber: slothash accessed before subscribe()');
|
|
14
|
+
}
|
|
15
|
+
return this._currentSlothash;
|
|
16
|
+
}
|
|
11
17
|
constructor(connection, config) {
|
|
12
18
|
var _a;
|
|
13
19
|
this.connection = connection;
|
|
@@ -15,7 +21,7 @@ class SlothashSubscriber {
|
|
|
15
21
|
this.receivingData = false;
|
|
16
22
|
this.resubTimeoutMs = config === null || config === void 0 ? void 0 : config.resubTimeoutMs;
|
|
17
23
|
this.commitment = (_a = config === null || config === void 0 ? void 0 : config.commitment) !== null && _a !== void 0 ? _a : 'processed';
|
|
18
|
-
if (this.resubTimeoutMs < 1000) {
|
|
24
|
+
if (this.resubTimeoutMs != null && this.resubTimeoutMs < 1000) {
|
|
19
25
|
console.log('resubTimeoutMs should be at least 1000ms to avoid spamming resub');
|
|
20
26
|
}
|
|
21
27
|
}
|
|
@@ -27,15 +33,16 @@ class SlothashSubscriber {
|
|
|
27
33
|
if (currentAccountData == null) {
|
|
28
34
|
throw new Error('Failed to retrieve current slot hash');
|
|
29
35
|
}
|
|
30
|
-
this.
|
|
36
|
+
this._currentSlothash = deserializeSlothash(currentAccountData.data);
|
|
31
37
|
this.subscriptionId = this.connection.onAccountChange(web3_js_1.SYSVAR_SLOT_HASHES_PUBKEY, (slothashInfo, context) => {
|
|
32
|
-
if (!this.
|
|
38
|
+
if (!this._currentSlothash ||
|
|
39
|
+
this._currentSlothash.slot < context.slot) {
|
|
33
40
|
if (this.resubTimeoutMs && !this.isUnsubscribing) {
|
|
34
41
|
this.receivingData = true;
|
|
35
42
|
clearTimeout(this.timeoutId);
|
|
36
43
|
this.setTimeout();
|
|
37
44
|
}
|
|
38
|
-
this.
|
|
45
|
+
this._currentSlothash = deserializeSlothash(slothashInfo.data);
|
|
39
46
|
}
|
|
40
47
|
}, this.commitment);
|
|
41
48
|
if (this.resubTimeoutMs) {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { grpcProgramAccountSubscriber } from '../accounts/grpcProgramAccountSubscriber';
|
|
2
1
|
import { GrpcConfigs } from '../accounts/types';
|
|
3
|
-
import { SignedMsgUserOrdersAccount } from '../types';
|
|
4
2
|
import { SignedMsgUserOrdersAccountSubscriber, SignedMsgUserOrdersAccountSubscriberConfig } from './signedMsgUserAccountSubscriber';
|
|
5
3
|
export declare class grpcSignedMsgUserOrdersAccountSubscriber extends SignedMsgUserOrdersAccountSubscriber {
|
|
6
4
|
private grpcConfigs;
|
|
7
|
-
subscriber: grpcProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
|
|
8
5
|
constructor({ grpcConfigs, ...rest }: SignedMsgUserOrdersAccountSubscriberConfig & {
|
|
9
6
|
grpcConfigs: GrpcConfigs;
|
|
10
7
|
});
|
|
@@ -10,8 +10,8 @@ class grpcSignedMsgUserOrdersAccountSubscriber extends signedMsgUserAccountSubsc
|
|
|
10
10
|
this.grpcConfigs = grpcConfigs;
|
|
11
11
|
}
|
|
12
12
|
async subscribe() {
|
|
13
|
-
if (!this.
|
|
14
|
-
this.
|
|
13
|
+
if (!this._subscriber) {
|
|
14
|
+
this._subscriber =
|
|
15
15
|
await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.velocityClient.program, this.decodeFn, {
|
|
16
16
|
filters: [(0, memcmp_1.getSignedMsgUserOrdersFilter)()],
|
|
17
17
|
}, this.resubOpts);
|
|
@@ -38,10 +38,10 @@ class grpcSignedMsgUserOrdersAccountSubscriber extends signedMsgUserAccountSubsc
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async unsubscribe() {
|
|
41
|
-
if (!this.
|
|
41
|
+
if (!this._subscriber)
|
|
42
42
|
return;
|
|
43
|
-
await this.
|
|
44
|
-
this.
|
|
43
|
+
await this._subscriber.unsubscribe();
|
|
44
|
+
this._subscriber = undefined;
|
|
45
45
|
if (this.resyncTimeoutId !== undefined) {
|
|
46
46
|
clearTimeout(this.resyncTimeoutId);
|
|
47
47
|
this.resyncTimeoutId = undefined;
|
|
@@ -33,8 +33,9 @@ export declare class SignedMsgUserOrdersAccountSubscriber {
|
|
|
33
33
|
}>;
|
|
34
34
|
mostRecentSlot: number;
|
|
35
35
|
fetchPromise?: Promise<void>;
|
|
36
|
-
fetchPromiseResolver
|
|
37
|
-
protected
|
|
36
|
+
private fetchPromiseResolver;
|
|
37
|
+
protected _subscriber?: WebSocketProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
|
|
38
|
+
protected get subscriber(): WebSocketProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
|
|
38
39
|
eventEmitter: StrictEventEmitter<EventEmitter, SignedMsgUserOrdersAccountSubscriberEvents>;
|
|
39
40
|
constructor({ velocityClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }: SignedMsgUserOrdersAccountSubscriberConfig);
|
|
40
41
|
subscribe(): Promise<void>;
|
|
@@ -5,8 +5,16 @@ const memcmp_1 = require("../memcmp");
|
|
|
5
5
|
const webSocketProgramAccountSubscriber_1 = require("../accounts/webSocketProgramAccountSubscriber");
|
|
6
6
|
const events_1 = require("events");
|
|
7
7
|
class SignedMsgUserOrdersAccountSubscriber {
|
|
8
|
+
get subscriber() {
|
|
9
|
+
if (!this._subscriber) {
|
|
10
|
+
throw new Error('SignedMsgUserOrdersAccountSubscriber: subscriber accessed before subscribe()');
|
|
11
|
+
}
|
|
12
|
+
return this._subscriber;
|
|
13
|
+
}
|
|
8
14
|
constructor({ velocityClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }) {
|
|
9
15
|
this.signedMsgUserOrderAccounts = new Map();
|
|
16
|
+
this.mostRecentSlot = 0;
|
|
17
|
+
this.fetchPromiseResolver = () => { };
|
|
10
18
|
this.commitment = commitment !== null && commitment !== void 0 ? commitment : 'confirmed';
|
|
11
19
|
this.resubOpts = resubOpts;
|
|
12
20
|
// Type-system guarantees at least one of the two is supplied.
|
|
@@ -19,9 +27,9 @@ class SignedMsgUserOrdersAccountSubscriber {
|
|
|
19
27
|
this.resubOpts = resubOpts;
|
|
20
28
|
}
|
|
21
29
|
async subscribe() {
|
|
22
|
-
if (!this.
|
|
30
|
+
if (!this._subscriber) {
|
|
23
31
|
const filters = [(0, memcmp_1.getSignedMsgUserOrdersFilter)()];
|
|
24
|
-
this.
|
|
32
|
+
this._subscriber =
|
|
25
33
|
new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.velocityClient.program, this.decodeFn, {
|
|
26
34
|
filters,
|
|
27
35
|
commitment: this.commitment,
|
|
@@ -106,10 +114,10 @@ class SignedMsgUserOrdersAccountSubscriber {
|
|
|
106
114
|
}
|
|
107
115
|
}
|
|
108
116
|
async unsubscribe() {
|
|
109
|
-
if (!this.
|
|
117
|
+
if (!this._subscriber)
|
|
110
118
|
return;
|
|
111
|
-
await this.
|
|
112
|
-
this.
|
|
119
|
+
await this._subscriber.unsubscribe();
|
|
120
|
+
this._subscriber = undefined;
|
|
113
121
|
if (this.resyncTimeoutId !== undefined) {
|
|
114
122
|
clearTimeout(this.resyncTimeoutId);
|
|
115
123
|
this.resyncTimeoutId = undefined;
|
|
@@ -52,7 +52,7 @@ export declare class SwiftOrderSubscriber {
|
|
|
52
52
|
private ws;
|
|
53
53
|
private velocityClient;
|
|
54
54
|
userAccountGetter?: AccountGetter;
|
|
55
|
-
onOrder
|
|
55
|
+
onOrder?: (orderMessageRaw: SwiftOrderMessage, signedMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, isDelegateSigner?: boolean) => Promise<void>;
|
|
56
56
|
subscribed: boolean;
|
|
57
57
|
constructor(config: SwiftOrderSubscriberConfig);
|
|
58
58
|
unsubscribe(): void;
|