@velocity-exchange/sdk 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -32
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +5 -3
- package/lib/browser/accounts/basicUserAccountSubscriber.js +4 -3
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +4 -3
- package/lib/browser/accounts/bulkAccountLoader.d.ts +5 -5
- package/lib/browser/accounts/bulkAccountLoader.js +12 -1
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcAccountSubscriber.js +8 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +13 -5
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +12 -8
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +8 -2
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +3 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +4 -3
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +16 -5
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +16 -5
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +8 -4
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +17 -11
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +6 -6
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
- package/lib/browser/accounts/types.d.ts +4 -4
- package/lib/browser/accounts/utils.d.ts +1 -0
- package/lib/browser/accounts/utils.js +8 -1
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketAccountSubscriber.js +17 -5
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +17 -6
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +14 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +9 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +0 -3
- package/lib/browser/addresses/marketAddresses.js +3 -2
- package/lib/browser/addresses/pda.d.ts +0 -2
- package/lib/browser/addresses/pda.js +1 -14
- package/lib/browser/adminClient.d.ts +24 -29
- package/lib/browser/adminClient.js +156 -157
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +6 -4
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/browser/bankrun/bankrunConnection.d.ts +8 -5
- package/lib/browser/bankrun/bankrunConnection.js +92 -32
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +3 -2
- package/lib/browser/clock/clockSubscriber.d.ts +6 -6
- package/lib/browser/clock/clockSubscriber.js +4 -3
- package/lib/browser/config.d.ts +1 -1
- package/lib/browser/config.js +8 -4
- package/lib/browser/constants/index.d.ts +1 -2
- package/lib/browser/constants/index.js +1 -2
- package/lib/browser/constants/numericConstants.d.ts +1 -2
- package/lib/browser/constants/numericConstants.js +7 -5
- package/lib/browser/constants/spotMarkets.d.ts +0 -1
- package/lib/browser/constituentMap/constituentMap.js +5 -1
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
- package/lib/browser/core/VelocityCore.d.ts +0 -1
- package/lib/browser/core/instructions/deposit.d.ts +0 -1
- package/lib/browser/core/instructions/perpOrders.d.ts +14 -0
- package/lib/browser/core/instructions/perpOrders.js +14 -0
- package/lib/browser/core/instructions/withdraw.d.ts +0 -1
- package/lib/browser/core/remainingAccounts.d.ts +2 -2
- package/lib/browser/core/remainingAccounts.js +2 -2
- package/lib/browser/decode/user.js +9 -1
- package/lib/browser/dlob/DLOB.d.ts +6 -2
- package/lib/browser/dlob/DLOB.js +201 -138
- package/lib/browser/dlob/DLOBNode.d.ts +5 -3
- package/lib/browser/dlob/DLOBNode.js +7 -0
- package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -1
- package/lib/browser/dlob/DLOBSubscriber.js +37 -32
- package/lib/browser/dlob/NodeList.d.ts +0 -1
- package/lib/browser/dlob/NodeList.js +8 -7
- package/lib/browser/dlob/orderBookLevels.d.ts +0 -1
- package/lib/browser/dlob/orderBookLevels.js +19 -12
- package/lib/browser/events/eventList.d.ts +3 -3
- package/lib/browser/events/eventList.js +4 -1
- package/lib/browser/events/eventSubscriber.d.ts +5 -2
- package/lib/browser/events/eventSubscriber.js +75 -26
- package/lib/browser/events/eventsServerLogProvider.d.ts +2 -2
- package/lib/browser/events/eventsServerLogProvider.js +15 -8
- package/lib/browser/events/fetchLogs.d.ts +1 -1
- package/lib/browser/events/fetchLogs.js +4 -2
- package/lib/browser/events/pollingLogProvider.d.ts +2 -2
- package/lib/browser/events/pollingLogProvider.js +1 -0
- package/lib/browser/events/txEventCache.d.ts +3 -3
- package/lib/browser/events/txEventCache.js +6 -2
- package/lib/browser/events/types.d.ts +2 -4
- package/lib/browser/events/types.js +0 -2
- package/lib/browser/events/webSocketLogProvider.d.ts +2 -2
- package/lib/browser/events/webSocketLogProvider.js +5 -2
- package/lib/browser/factory/bigNum.d.ts +0 -1
- package/lib/browser/factory/bigNum.js +1 -1
- package/lib/browser/idl/velocity.d.ts +1243 -1586
- package/lib/browser/idl/velocity.json +1234 -1577
- package/lib/browser/index.d.ts +0 -2
- package/lib/browser/index.js +0 -2
- package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/browser/jupiter/jupiterClient.d.ts +1 -2
- package/lib/browser/jupiter/jupiterClient.js +18 -8
- package/lib/browser/marginCalculation.d.ts +0 -1
- package/lib/browser/marginCalculation.js +1 -0
- package/lib/browser/marinade/index.d.ts +2 -3
- package/lib/browser/marinade/index.js +5 -0
- package/lib/browser/math/amm.d.ts +31 -14
- package/lib/browser/math/amm.js +77 -22
- package/lib/browser/math/auction.d.ts +0 -1
- package/lib/browser/math/bankruptcy.js +1 -1
- package/lib/browser/math/conversion.d.ts +0 -1
- package/lib/browser/math/funding.d.ts +0 -1
- package/lib/browser/math/funding.js +6 -6
- package/lib/browser/math/insurance.d.ts +1 -2
- package/lib/browser/math/insurance.js +4 -5
- package/lib/browser/math/liquidation.d.ts +0 -1
- package/lib/browser/math/margin.d.ts +1 -10
- package/lib/browser/math/margin.js +3 -62
- package/lib/browser/math/market.d.ts +4 -13
- package/lib/browser/math/market.js +6 -40
- package/lib/browser/math/oracles.d.ts +0 -4
- package/lib/browser/math/oracles.js +1 -14
- package/lib/browser/math/orders.d.ts +0 -6
- package/lib/browser/math/orders.js +2 -74
- package/lib/browser/math/position.d.ts +1 -6
- package/lib/browser/math/position.js +5 -10
- package/lib/browser/math/repeg.d.ts +0 -2
- package/lib/browser/math/repeg.js +1 -23
- package/lib/browser/math/spotBalance.d.ts +4 -5
- package/lib/browser/math/spotBalance.js +6 -6
- package/lib/browser/math/spotMarket.d.ts +0 -7
- package/lib/browser/math/spotMarket.js +1 -16
- package/lib/browser/math/spotPosition.d.ts +4 -5
- package/lib/browser/math/state.d.ts +0 -3
- package/lib/browser/math/state.js +1 -9
- package/lib/browser/math/superStake.d.ts +3 -54
- package/lib/browser/math/superStake.js +16 -13
- package/lib/browser/math/trade.d.ts +2 -3
- package/lib/browser/math/trade.js +6 -6
- package/lib/browser/math/utils.d.ts +0 -1
- package/lib/browser/memcmp.d.ts +0 -1
- package/lib/browser/memcmp.js +1 -10
- package/lib/browser/oracles/oracleClientCache.d.ts +1 -1
- package/lib/browser/oracles/prelaunchOracleClient.js +3 -2
- package/lib/browser/oracles/pythClient.d.ts +0 -1
- package/lib/browser/oracles/pythClient.js +9 -3
- package/lib/browser/oracles/pythLazerClient.d.ts +0 -1
- package/lib/browser/oracles/pythLazerClient.js +3 -2
- package/lib/browser/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/browser/oracles/types.d.ts +0 -1
- package/lib/browser/oracles/utils.d.ts +4 -1
- package/lib/browser/oracles/utils.js +9 -1
- package/lib/browser/orderParams.d.ts +0 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +1 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -2
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +32 -8
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/browser/pyth/types.d.ts +0 -1
- package/lib/browser/slot/SlotSubscriber.d.ts +1 -1
- package/lib/browser/slot/SlotSubscriber.js +2 -1
- package/lib/browser/slot/SlothashSubscriber.d.ts +3 -2
- package/lib/browser/slot/SlothashSubscriber.js +11 -4
- package/lib/browser/swap/UnifiedSwapClient.d.ts +0 -1
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +13 -5
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +1 -1
- package/lib/browser/swift/swiftOrderSubscriber.js +10 -5
- package/lib/browser/testClient.js +3 -2
- package/lib/browser/titan/titanClient.d.ts +0 -1
- package/lib/browser/tokenFaucet.d.ts +0 -1
- package/lib/browser/tokenFaucet.js +16 -2
- package/lib/browser/tx/baseTxSender.d.ts +4 -4
- package/lib/browser/tx/baseTxSender.js +5 -4
- package/lib/browser/tx/fastSingleTxSender.d.ts +3 -3
- package/lib/browser/tx/fastSingleTxSender.js +9 -5
- package/lib/browser/tx/reportTransactionError.d.ts +2 -2
- package/lib/browser/tx/reportTransactionError.js +5 -1
- package/lib/browser/tx/retryTxSender.d.ts +1 -1
- package/lib/browser/tx/retryTxSender.js +4 -2
- package/lib/browser/tx/txHandler.d.ts +9 -3
- package/lib/browser/tx/txHandler.js +54 -40
- package/lib/browser/tx/txParamProcessor.d.ts +4 -1
- package/lib/browser/tx/txParamProcessor.js +6 -0
- package/lib/browser/tx/types.d.ts +1 -1
- package/lib/browser/tx/whileValidTxSender.d.ts +1 -6
- package/lib/browser/tx/whileValidTxSender.js +35 -13
- package/lib/browser/types.d.ts +25 -69
- package/lib/browser/types.js +2 -2
- package/lib/browser/user.d.ts +21 -8
- package/lib/browser/user.js +156 -132
- package/lib/browser/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/browser/userMap/grpcSubscription.d.ts +1 -1
- package/lib/browser/userMap/referrerMap.js +10 -3
- package/lib/browser/userMap/revenueShareEscrowMap.js +4 -0
- package/lib/browser/userMap/userMap.d.ts +1 -1
- package/lib/browser/userMap/userMap.js +36 -23
- package/lib/browser/userMap/userStatsMap.d.ts +1 -1
- package/lib/browser/userMap/userStatsMap.js +18 -13
- package/lib/browser/userStats.d.ts +7 -2
- package/lib/browser/userStats.js +18 -4
- package/lib/browser/util/TransactionConfirmationManager.js +4 -2
- package/lib/browser/util/chainClock.d.ts +1 -1
- package/lib/browser/util/computeUnits.d.ts +1 -1
- package/lib/browser/util/computeUnits.js +6 -1
- package/lib/browser/velocityClient.d.ts +93 -36
- package/lib/browser/velocityClient.js +414 -280
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +5 -3
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserAccountSubscriber.js +4 -3
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +5 -3
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +4 -3
- package/lib/node/accounts/bulkAccountLoader.d.ts +5 -5
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/bulkAccountLoader.js +12 -1
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcAccountSubscriber.js +8 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +3 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +13 -5
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +12 -8
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +8 -2
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +18 -3
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +40 -17
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +3 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +4 -3
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +7 -3
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +3 -3
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +0 -2
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +16 -5
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +0 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +16 -5
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +8 -4
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +17 -11
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +6 -6
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +7 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +64 -28
- package/lib/node/accounts/types.d.ts +4 -4
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/utils.d.ts +1 -0
- package/lib/node/accounts/utils.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +8 -1
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +17 -5
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +4 -2
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +17 -6
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +9 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +14 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +15 -3
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +14 -4
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +4 -2
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +9 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +4 -2
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +9 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +4 -4
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +48 -20
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +7 -3
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +45 -14
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +0 -3
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
- package/lib/node/addresses/marketAddresses.js +3 -2
- package/lib/node/addresses/pda.d.ts +0 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +1 -14
- package/lib/node/adminClient.d.ts +24 -29
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +156 -157
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +6 -4
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/node/bankrun/bankrunConnection.d.ts +8 -5
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.js +92 -32
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +3 -2
- package/lib/node/clock/clockSubscriber.d.ts +6 -6
- package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.js +4 -3
- package/lib/node/config.d.ts +1 -1
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +8 -4
- package/lib/node/constants/index.d.ts +1 -2
- package/lib/node/constants/index.d.ts.map +1 -1
- package/lib/node/constants/index.js +1 -2
- package/lib/node/constants/numericConstants.d.ts +1 -2
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +7 -5
- package/lib/node/constants/spotMarkets.d.ts +0 -1
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +5 -1
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +3 -2
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +2 -3
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +10 -3
- package/lib/node/core/VelocityCore.d.ts +0 -1
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/instructions/deposit.d.ts +0 -1
- package/lib/node/core/instructions/deposit.d.ts.map +1 -1
- package/lib/node/core/instructions/perpOrders.d.ts +14 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
- package/lib/node/core/instructions/perpOrders.js +14 -0
- package/lib/node/core/instructions/withdraw.d.ts +0 -1
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.d.ts +2 -2
- package/lib/node/core/remainingAccounts.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.js +2 -2
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +9 -1
- package/lib/node/dlob/DLOB.d.ts +6 -2
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +201 -138
- package/lib/node/dlob/DLOBNode.d.ts +5 -3
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +7 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts +0 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +37 -32
- package/lib/node/dlob/NodeList.d.ts +0 -1
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.js +8 -7
- package/lib/node/dlob/orderBookLevels.d.ts +0 -1
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +19 -12
- package/lib/node/events/eventList.d.ts +3 -3
- package/lib/node/events/eventList.d.ts.map +1 -1
- package/lib/node/events/eventList.js +4 -1
- package/lib/node/events/eventSubscriber.d.ts +5 -2
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +75 -26
- package/lib/node/events/eventsServerLogProvider.d.ts +2 -2
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
- package/lib/node/events/eventsServerLogProvider.js +15 -8
- package/lib/node/events/fetchLogs.d.ts +1 -1
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.js +4 -2
- package/lib/node/events/pollingLogProvider.d.ts +2 -2
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
- package/lib/node/events/pollingLogProvider.js +1 -0
- package/lib/node/events/txEventCache.d.ts +3 -3
- package/lib/node/events/txEventCache.d.ts.map +1 -1
- package/lib/node/events/txEventCache.js +6 -2
- package/lib/node/events/types.d.ts +2 -4
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +0 -2
- package/lib/node/events/webSocketLogProvider.d.ts +2 -2
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
- package/lib/node/events/webSocketLogProvider.js +5 -2
- package/lib/node/factory/bigNum.d.ts +0 -1
- package/lib/node/factory/bigNum.d.ts.map +1 -1
- package/lib/node/factory/bigNum.js +1 -1
- package/lib/node/idl/velocity.d.ts +1243 -1586
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +1234 -1577
- package/lib/node/index.d.ts +0 -2
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -2
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.d.ts +1 -2
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.js +18 -8
- package/lib/node/marginCalculation.d.ts +0 -1
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marginCalculation.js +1 -0
- package/lib/node/marinade/index.d.ts +2 -3
- package/lib/node/marinade/index.d.ts.map +1 -1
- package/lib/node/marinade/index.js +5 -0
- package/lib/node/math/amm.d.ts +31 -14
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +77 -22
- package/lib/node/math/auction.d.ts +0 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/bankruptcy.js +1 -1
- package/lib/node/math/conversion.d.ts +0 -1
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/funding.d.ts +0 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +6 -6
- package/lib/node/math/insurance.d.ts +1 -2
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +4 -5
- package/lib/node/math/liquidation.d.ts +0 -1
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/margin.d.ts +1 -10
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +3 -62
- package/lib/node/math/market.d.ts +4 -13
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +6 -40
- package/lib/node/math/oracles.d.ts +0 -4
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +1 -14
- package/lib/node/math/orders.d.ts +0 -6
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +2 -74
- package/lib/node/math/position.d.ts +1 -6
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +5 -10
- package/lib/node/math/repeg.d.ts +0 -2
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/repeg.js +1 -23
- package/lib/node/math/spotBalance.d.ts +4 -5
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +6 -6
- package/lib/node/math/spotMarket.d.ts +0 -7
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +1 -16
- package/lib/node/math/spotPosition.d.ts +4 -5
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/state.d.ts +0 -3
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/state.js +1 -9
- package/lib/node/math/superStake.d.ts +3 -54
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +16 -13
- package/lib/node/math/trade.d.ts +2 -3
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +6 -6
- package/lib/node/math/utils.d.ts +0 -1
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/memcmp.d.ts +0 -1
- package/lib/node/memcmp.d.ts.map +1 -1
- package/lib/node/memcmp.js +1 -10
- package/lib/node/oracles/oracleClientCache.d.ts +1 -1
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +3 -2
- package/lib/node/oracles/pythClient.d.ts +0 -1
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.js +9 -3
- package/lib/node/oracles/pythLazerClient.d.ts +0 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +3 -2
- package/lib/node/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/types.d.ts +0 -1
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +4 -1
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/oracles/utils.js +9 -1
- package/lib/node/orderParams.d.ts +0 -1
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +8 -2
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +1 -1
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +32 -8
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +1 -1
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/pyth/types.d.ts +0 -1
- package/lib/node/pyth/types.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.d.ts +1 -1
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.js +2 -1
- package/lib/node/slot/SlothashSubscriber.d.ts +3 -2
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlothashSubscriber.js +11 -4
- package/lib/node/swap/UnifiedSwapClient.d.ts +0 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +0 -3
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +5 -5
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +3 -2
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +13 -5
- package/lib/node/swift/swiftOrderSubscriber.d.ts +1 -1
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +10 -5
- package/lib/node/testClient.js +3 -2
- package/lib/node/titan/titanClient.d.ts +0 -1
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/tokenFaucet.d.ts +0 -1
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +16 -2
- package/lib/node/tx/baseTxSender.d.ts +4 -4
- package/lib/node/tx/baseTxSender.d.ts.map +1 -1
- package/lib/node/tx/baseTxSender.js +5 -4
- package/lib/node/tx/fastSingleTxSender.d.ts +3 -3
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.js +9 -5
- package/lib/node/tx/reportTransactionError.d.ts +2 -2
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
- package/lib/node/tx/reportTransactionError.js +5 -1
- package/lib/node/tx/retryTxSender.d.ts +1 -1
- package/lib/node/tx/retryTxSender.d.ts.map +1 -1
- package/lib/node/tx/retryTxSender.js +4 -2
- package/lib/node/tx/txHandler.d.ts +9 -3
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +54 -40
- package/lib/node/tx/txParamProcessor.d.ts +4 -1
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
- package/lib/node/tx/txParamProcessor.js +6 -0
- package/lib/node/tx/types.d.ts +1 -1
- package/lib/node/tx/types.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.d.ts +1 -6
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.js +35 -13
- package/lib/node/types.d.ts +25 -69
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +2 -2
- package/lib/node/user.d.ts +21 -8
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +156 -132
- package/lib/node/userMap/WebsocketSubscription.d.ts +1 -1
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/userMap/grpcSubscription.d.ts +1 -1
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +10 -3
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +4 -0
- package/lib/node/userMap/userMap.d.ts +1 -1
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +36 -23
- package/lib/node/userMap/userStatsMap.d.ts +1 -1
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +18 -13
- package/lib/node/userStats.d.ts +7 -2
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +18 -4
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
- package/lib/node/util/TransactionConfirmationManager.js +4 -2
- package/lib/node/util/chainClock.d.ts +1 -1
- package/lib/node/util/chainClock.d.ts.map +1 -1
- package/lib/node/util/computeUnits.d.ts +1 -1
- package/lib/node/util/computeUnits.d.ts.map +1 -1
- package/lib/node/util/computeUnits.js +6 -1
- package/lib/node/velocityClient.d.ts +93 -36
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +414 -280
- package/package.json +15 -8
- package/src/accounts/basicUserAccountSubscriber.ts +7 -5
- package/src/accounts/basicUserStatsAccountSubscriber.ts +9 -5
- package/src/accounts/bulkAccountLoader.ts +20 -7
- package/src/accounts/grpcAccountSubscriber.ts +11 -3
- package/src/accounts/grpcMultiAccountSubscriber.ts +24 -9
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +16 -12
- package/src/accounts/grpcProgramAccountSubscriber.ts +11 -3
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +17 -7
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +66 -39
- package/src/accounts/laserProgramAccountSubscriber.ts +3 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +5 -3
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +8 -3
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -5
- package/src/accounts/pollingOracleAccountSubscriber.ts +17 -10
- package/src/accounts/pollingTokenAccountSubscriber.ts +17 -10
- package/src/accounts/pollingUserAccountSubscriber.ts +26 -20
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +12 -10
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +76 -30
- package/src/accounts/types.ts +6 -4
- package/src/accounts/utils.ts +10 -0
- package/src/accounts/webSocketAccountSubscriber.ts +23 -10
- package/src/accounts/webSocketAccountSubscriberV2.ts +23 -8
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +17 -2
- package/src/accounts/webSocketProgramAccountSubscriber.ts +29 -4
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +30 -4
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +29 -4
- package/src/accounts/webSocketUserAccountSubscriber.ts +11 -2
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +15 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +76 -48
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +74 -35
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +1 -6
- package/src/addresses/marketAddresses.ts +3 -2
- package/src/addresses/pda.ts +0 -25
- package/src/adminClient.ts +273 -303
- package/src/auctionSubscriber/auctionSubscriber.ts +7 -5
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -5
- package/src/bankrun/bankrunConnection.ts +110 -40
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +5 -4
- package/src/clock/clockSubscriber.ts +10 -9
- package/src/config.ts +8 -3
- package/src/constants/index.ts +1 -2
- package/src/constants/numericConstants.ts +8 -4
- package/src/constituentMap/constituentMap.ts +8 -1
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +4 -2
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +13 -4
- package/src/core/instructions/perpOrders.ts +14 -0
- package/src/core/remainingAccounts.ts +4 -4
- package/src/decode/user.ts +8 -1
- package/src/dlob/DLOB.ts +296 -172
- package/src/dlob/DLOBNode.ts +23 -3
- package/src/dlob/DLOBSubscriber.ts +51 -34
- package/src/dlob/NodeList.ts +8 -7
- package/src/dlob/orderBookLevels.ts +45 -25
- package/src/events/eventList.ts +4 -1
- package/src/events/eventSubscriber.ts +107 -49
- package/src/events/eventsServerLogProvider.ts +22 -13
- package/src/events/fetchLogs.ts +3 -3
- package/src/events/pollingLogProvider.ts +2 -2
- package/src/events/txEventCache.ts +8 -2
- package/src/events/types.ts +0 -8
- package/src/events/webSocketLogProvider.ts +5 -3
- package/src/factory/bigNum.ts +2 -2
- package/src/idl/velocity.json +1234 -1577
- package/src/idl/velocity.ts +1234 -1577
- package/src/index.ts +0 -2
- package/src/jupiter/jupiterClient.ts +30 -10
- package/src/marginCalculation.ts +1 -0
- package/src/marinade/index.ts +11 -2
- package/src/math/amm.ts +188 -33
- package/src/math/bankruptcy.ts +1 -1
- package/src/math/funding.ts +7 -6
- package/src/math/insurance.ts +6 -8
- package/src/math/margin.ts +5 -112
- package/src/math/market.ts +6 -96
- package/src/math/oracles.ts +0 -17
- package/src/math/orders.ts +1 -110
- package/src/math/position.ts +4 -16
- package/src/math/repeg.ts +0 -29
- package/src/math/spotBalance.ts +14 -10
- package/src/math/spotMarket.ts +2 -28
- package/src/math/spotPosition.ts +4 -4
- package/src/math/state.ts +0 -8
- package/src/math/superStake.ts +19 -65
- package/src/math/trade.ts +2 -6
- package/src/memcmp.ts +0 -9
- package/src/oracles/prelaunchOracleClient.ts +7 -2
- package/src/oracles/pythClient.ts +12 -3
- package/src/oracles/pythLazerClient.ts +7 -2
- package/src/oracles/utils.ts +15 -0
- package/src/orderSubscriber/OrderSubscriber.ts +10 -4
- package/src/priorityFee/heliusPriorityFeeMethod.ts +1 -1
- package/src/priorityFee/priorityFeeSubscriber.ts +45 -9
- package/src/priorityFee/solanaPriorityFeeMethod.ts +1 -1
- package/src/pyth/types.ts +0 -2
- package/src/slot/SlotSubscriber.ts +3 -3
- package/src/slot/SlothashSubscriber.ts +17 -6
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +5 -6
- package/src/swift/signedMsgUserAccountSubscriber.ts +16 -8
- package/src/swift/swiftOrderSubscriber.ts +10 -9
- package/src/testClient.ts +2 -2
- package/src/tokenFaucet.ts +22 -3
- package/src/tx/baseTxSender.ts +10 -10
- package/src/tx/fastSingleTxSender.ts +12 -8
- package/src/tx/reportTransactionError.ts +12 -7
- package/src/tx/retryTxSender.ts +6 -4
- package/src/tx/txHandler.ts +88 -43
- package/src/tx/txParamProcessor.ts +18 -3
- package/src/tx/types.ts +1 -1
- package/src/tx/whileValidTxSender.ts +51 -22
- package/src/types.ts +39 -75
- package/src/user.ts +200 -152
- package/src/userMap/WebsocketSubscription.ts +1 -1
- package/src/userMap/grpcSubscription.ts +1 -1
- package/src/userMap/referrerMap.ts +14 -10
- package/src/userMap/revenueShareEscrowMap.ts +8 -3
- package/src/userMap/userMap.ts +43 -25
- package/src/userMap/userStatsMap.ts +32 -19
- package/src/userStats.ts +21 -8
- package/src/util/TransactionConfirmationManager.ts +10 -2
- package/src/util/chainClock.ts +1 -1
- package/src/util/computeUnits.ts +7 -3
- package/src/velocityClient.ts +536 -383
- package/tests/VelocityCore/remainingAccounts.test.ts +4 -5
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +19 -11
- package/tests/amm/test.ts +300 -95
- package/tests/decode/userAccountBufferStrings.ts +100 -100
- package/tests/dlob/helpers.ts +162 -173
- package/tests/dlob/test.ts +155 -106
- package/tests/tx/TransactionConfirmationManager.test.ts +9 -2
- package/tests/user/getMarginCalculation.ts +1 -1
- package/tests/user/helpers.ts +3 -4
- package/tests/user/marginCalculations.test.ts +2 -2
- package/tests/user/test.ts +3 -3
- package/tsconfig.browser.json +3 -1
- package/tsconfig.json +21 -2
- package/.yarn/install-state.gz +0 -0
- package/VERSION +0 -1
- package/bun.lock +0 -1885
- package/lib/browser/constants/insuranceFund.d.ts +0 -5
- package/lib/browser/constants/insuranceFund.js +0 -9
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +0 -37
- package/lib/browser/tx/forwardOnlyTxSender.js +0 -92
- package/lib/browser/util/tps.d.ts +0 -2
- package/lib/browser/util/tps.js +0 -16
- package/lib/node/constants/insuranceFund.d.ts +0 -6
- package/lib/node/constants/insuranceFund.d.ts.map +0 -1
- package/lib/node/constants/insuranceFund.js +0 -9
- package/lib/node/tx/forwardOnlyTxSender.d.ts +0 -38
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +0 -1
- package/lib/node/tx/forwardOnlyTxSender.js +0 -92
- package/lib/node/util/tps.d.ts +0 -3
- package/lib/node/util/tps.d.ts.map +0 -1
- package/lib/node/util/tps.js +0 -16
- package/scripts/updateVersion.js +0 -28
- package/src/constants/insuranceFund.ts +0 -8
- package/src/tx/forwardOnlyTxSender.ts +0 -145
- package/src/util/tps.ts +0 -27
- package/tests/decode/phoenix.ts +0 -71
package/src/adminClient.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* pause/unpause exchange, and all ~126 admin instruction handlers in `instructions/admin.rs`.
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
|
+
AccountMeta,
|
|
10
11
|
AddressLookupTableAccount,
|
|
11
12
|
Keypair,
|
|
12
13
|
LAMPORTS_PER_SOL,
|
|
@@ -24,7 +25,6 @@ import {
|
|
|
24
25
|
MarketStatus,
|
|
25
26
|
ContractTier,
|
|
26
27
|
AssetTier,
|
|
27
|
-
IfRebalanceConfigParams,
|
|
28
28
|
TxParams,
|
|
29
29
|
AddAmmConstituentMappingDatum,
|
|
30
30
|
SwapReduceOnly,
|
|
@@ -32,6 +32,8 @@ import {
|
|
|
32
32
|
ConstituentStatus,
|
|
33
33
|
LPPoolAccount,
|
|
34
34
|
TransferFeeAndPnlPoolDirection,
|
|
35
|
+
MarketType,
|
|
36
|
+
SpotMarketAccount,
|
|
35
37
|
} from './types';
|
|
36
38
|
import { DEFAULT_MARKET_NAME, encodeName } from './userName';
|
|
37
39
|
import { BN } from './isomorphic/anchor';
|
|
@@ -42,13 +44,10 @@ import {
|
|
|
42
44
|
getSpotMarketVaultPublicKey,
|
|
43
45
|
getPerpMarketPublicKey,
|
|
44
46
|
getInsuranceFundVaultPublicKey,
|
|
45
|
-
getProtocolIfSharesTransferConfigPublicKey,
|
|
46
47
|
getPrelaunchOraclePublicKey,
|
|
47
48
|
getUserStatsAccountPublicKey,
|
|
48
49
|
getPythLazerOraclePublicKey,
|
|
49
50
|
getTokenProgramForSpotMarket,
|
|
50
|
-
getIfRebalanceConfigPublicKey,
|
|
51
|
-
getInsuranceFundStakeAccountPublicKey,
|
|
52
51
|
getLpPoolPublicKey,
|
|
53
52
|
getAmmConstituentMappingPublicKey,
|
|
54
53
|
getConstituentTargetBasePublicKey,
|
|
@@ -61,6 +60,7 @@ import {
|
|
|
61
60
|
} from './addresses/pda';
|
|
62
61
|
import { squareRootBN } from './math/utils';
|
|
63
62
|
import {
|
|
63
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
64
64
|
createInitializeMint2Instruction,
|
|
65
65
|
createMintToInstruction,
|
|
66
66
|
createTransferCheckedInstruction,
|
|
@@ -76,7 +76,6 @@ import {
|
|
|
76
76
|
ONE,
|
|
77
77
|
BASE_PRECISION,
|
|
78
78
|
PRICE_PRECISION,
|
|
79
|
-
GOV_SPOT_MARKET_INDEX,
|
|
80
79
|
} from './constants/numericConstants';
|
|
81
80
|
import { calculateTargetPriceTrade } from './math/trade';
|
|
82
81
|
import { calculateAmmReservesAfterSwap, getSwapDirection } from './math/amm';
|
|
@@ -226,7 +225,11 @@ export class AdminClient extends VelocityClient {
|
|
|
226
225
|
spotMarketIndex
|
|
227
226
|
);
|
|
228
227
|
|
|
229
|
-
const
|
|
228
|
+
const mintAccountInfo = await this.connection.getAccountInfo(mint);
|
|
229
|
+
if (!mintAccountInfo) {
|
|
230
|
+
throw new Error(`Mint account ${mint.toString()} not found`);
|
|
231
|
+
}
|
|
232
|
+
const tokenProgram = mintAccountInfo.owner;
|
|
230
233
|
|
|
231
234
|
const nameBuffer = encodeName(name);
|
|
232
235
|
const initializeIx = await this.program.instruction.initializeSpotMarket(
|
|
@@ -527,13 +530,14 @@ export class AdminClient extends VelocityClient {
|
|
|
527
530
|
public async getAddMarketToAmmCacheIx(
|
|
528
531
|
perpMarketIndex: number
|
|
529
532
|
): Promise<TransactionInstruction> {
|
|
533
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
530
534
|
return await this.program.instruction.addMarketToAmmCache({
|
|
531
535
|
accounts: {
|
|
532
536
|
state: await this.getStatePublicKey(),
|
|
533
537
|
admin: this.useHotWalletAdmin
|
|
534
538
|
? this.wallet.publicKey
|
|
535
539
|
: this.getStateAccount().coldAdmin,
|
|
536
|
-
perpMarket:
|
|
540
|
+
perpMarket: perpMarketAccount.pubkey,
|
|
537
541
|
ammCache: getAmmCachePublicKey(this.program.programId),
|
|
538
542
|
rent: SYSVAR_RENT_PUBKEY,
|
|
539
543
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
@@ -787,6 +791,7 @@ export class AdminClient extends VelocityClient {
|
|
|
787
791
|
perpMarketIndex: number,
|
|
788
792
|
sqrtK: BN
|
|
789
793
|
): Promise<TransactionInstruction> {
|
|
794
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
790
795
|
return await this.program.instruction.updateK(sqrtK, {
|
|
791
796
|
accounts: {
|
|
792
797
|
state: await this.getStatePublicKey(),
|
|
@@ -797,7 +802,7 @@ export class AdminClient extends VelocityClient {
|
|
|
797
802
|
this.program.programId,
|
|
798
803
|
perpMarketIndex
|
|
799
804
|
),
|
|
800
|
-
oracle:
|
|
805
|
+
oracle: perpMarketAccount.oracle,
|
|
801
806
|
},
|
|
802
807
|
});
|
|
803
808
|
}
|
|
@@ -863,8 +868,9 @@ export class AdminClient extends VelocityClient {
|
|
|
863
868
|
|
|
864
869
|
public async getRecenterPerpMarketAmmCrankIx(
|
|
865
870
|
perpMarketIndex: number,
|
|
866
|
-
depth
|
|
871
|
+
depth?: BN
|
|
867
872
|
): Promise<TransactionInstruction> {
|
|
873
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
868
874
|
return await this.program.instruction.recenterPerpMarketAmmCrank(
|
|
869
875
|
depth ?? null,
|
|
870
876
|
{
|
|
@@ -881,7 +887,7 @@ export class AdminClient extends VelocityClient {
|
|
|
881
887
|
this.program.programId,
|
|
882
888
|
QUOTE_SPOT_MARKET_INDEX
|
|
883
889
|
),
|
|
884
|
-
oracle:
|
|
890
|
+
oracle: perpMarketAccount.oracle,
|
|
885
891
|
},
|
|
886
892
|
}
|
|
887
893
|
);
|
|
@@ -1015,7 +1021,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1015
1021
|
perpMarketIndex: number,
|
|
1016
1022
|
targetPrice: BN
|
|
1017
1023
|
): Promise<TransactionInstruction> {
|
|
1018
|
-
const perpMarket = this.
|
|
1024
|
+
const perpMarket = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
1019
1025
|
|
|
1020
1026
|
const [direction, tradeSize, _] = calculateTargetPriceTrade(
|
|
1021
1027
|
perpMarket,
|
|
@@ -1078,7 +1084,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1078
1084
|
this.program.programId,
|
|
1079
1085
|
perpMarketIndex
|
|
1080
1086
|
);
|
|
1081
|
-
const perpMarketAccount = this.
|
|
1087
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
1082
1088
|
|
|
1083
1089
|
return await this.program.instruction.repegAmmCurve(newPeg, {
|
|
1084
1090
|
accounts: {
|
|
@@ -1108,7 +1114,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1108
1114
|
public async getUpdatePerpMarketAmmOracleTwapIx(
|
|
1109
1115
|
perpMarketIndex: number
|
|
1110
1116
|
): Promise<TransactionInstruction> {
|
|
1111
|
-
const perpMarketAccount = this.
|
|
1117
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
1112
1118
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1113
1119
|
this.program.programId,
|
|
1114
1120
|
perpMarketIndex
|
|
@@ -1142,7 +1148,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1142
1148
|
public async getResetPerpMarketAmmOracleTwapIx(
|
|
1143
1149
|
perpMarketIndex: number
|
|
1144
1150
|
): Promise<TransactionInstruction> {
|
|
1145
|
-
const perpMarketAccount = this.
|
|
1151
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
1146
1152
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1147
1153
|
this.program.programId,
|
|
1148
1154
|
perpMarketIndex
|
|
@@ -1273,9 +1279,9 @@ export class AdminClient extends VelocityClient {
|
|
|
1273
1279
|
amount: BN,
|
|
1274
1280
|
sourceVault: PublicKey
|
|
1275
1281
|
): Promise<TransactionInstruction> {
|
|
1276
|
-
const spotMarket = this.
|
|
1282
|
+
const spotMarket = this.getSpotMarketAccountOrThrow(spotMarketIndex);
|
|
1277
1283
|
|
|
1278
|
-
const remainingAccounts = [];
|
|
1284
|
+
const remainingAccounts: AccountMeta[] = [];
|
|
1279
1285
|
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
1280
1286
|
if (this.isTransferHook(spotMarket)) {
|
|
1281
1287
|
await this.addExtraAccountMetasToRemainingAccounts(
|
|
@@ -1425,15 +1431,13 @@ export class AdminClient extends VelocityClient {
|
|
|
1425
1431
|
public async updatePerpMarketAmmSummaryStats(
|
|
1426
1432
|
perpMarketIndex: number,
|
|
1427
1433
|
updateAmmSummaryStats?: boolean,
|
|
1428
|
-
netUnsettledFundingPnl?: BN
|
|
1429
|
-
excludeTotalLiqFee?: boolean
|
|
1434
|
+
netUnsettledFundingPnl?: BN
|
|
1430
1435
|
): Promise<TransactionSignature> {
|
|
1431
1436
|
const updatePerpMarketMarginRatioIx =
|
|
1432
1437
|
await this.getUpdatePerpMarketAmmSummaryStatsIx(
|
|
1433
1438
|
perpMarketIndex,
|
|
1434
1439
|
updateAmmSummaryStats,
|
|
1435
|
-
netUnsettledFundingPnl
|
|
1436
|
-
excludeTotalLiqFee
|
|
1440
|
+
netUnsettledFundingPnl
|
|
1437
1441
|
);
|
|
1438
1442
|
|
|
1439
1443
|
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
@@ -1446,14 +1450,13 @@ export class AdminClient extends VelocityClient {
|
|
|
1446
1450
|
public async getUpdatePerpMarketAmmSummaryStatsIx(
|
|
1447
1451
|
perpMarketIndex: number,
|
|
1448
1452
|
updateAmmSummaryStats?: boolean,
|
|
1449
|
-
netUnsettledFundingPnl?: BN
|
|
1450
|
-
excludeTotalLiqFee?: boolean
|
|
1453
|
+
netUnsettledFundingPnl?: BN
|
|
1451
1454
|
): Promise<TransactionInstruction> {
|
|
1455
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
1452
1456
|
return await this.program.instruction.updatePerpMarketAmmSummaryStats(
|
|
1453
1457
|
{
|
|
1454
1458
|
updateAmmSummaryStats: updateAmmSummaryStats ?? null,
|
|
1455
1459
|
netUnsettledFundingPnl: netUnsettledFundingPnl ?? null,
|
|
1456
|
-
excludeTotalLiqFee: excludeTotalLiqFee ?? null,
|
|
1457
1460
|
},
|
|
1458
1461
|
{
|
|
1459
1462
|
accounts: {
|
|
@@ -1469,7 +1472,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1469
1472
|
this.program.programId,
|
|
1470
1473
|
QUOTE_SPOT_MARKET_INDEX
|
|
1471
1474
|
),
|
|
1472
|
-
oracle:
|
|
1475
|
+
oracle: perpMarketAccount.oracle,
|
|
1473
1476
|
},
|
|
1474
1477
|
}
|
|
1475
1478
|
);
|
|
@@ -2053,12 +2056,14 @@ export class AdminClient extends VelocityClient {
|
|
|
2053
2056
|
|
|
2054
2057
|
public async updateWithdrawGuardThreshold(
|
|
2055
2058
|
spotMarketIndex: number,
|
|
2056
|
-
withdrawGuardThreshold: BN
|
|
2059
|
+
withdrawGuardThreshold: BN,
|
|
2060
|
+
oracle?: PublicKey
|
|
2057
2061
|
): Promise<TransactionSignature> {
|
|
2058
2062
|
const updateWithdrawGuardThresholdIx =
|
|
2059
2063
|
await this.getUpdateWithdrawGuardThresholdIx(
|
|
2060
2064
|
spotMarketIndex,
|
|
2061
|
-
withdrawGuardThreshold
|
|
2065
|
+
withdrawGuardThreshold,
|
|
2066
|
+
oracle
|
|
2062
2067
|
);
|
|
2063
2068
|
|
|
2064
2069
|
const tx = await this.buildTransaction(updateWithdrawGuardThresholdIx);
|
|
@@ -2070,8 +2075,39 @@ export class AdminClient extends VelocityClient {
|
|
|
2070
2075
|
|
|
2071
2076
|
public async getUpdateWithdrawGuardThresholdIx(
|
|
2072
2077
|
spotMarketIndex: number,
|
|
2073
|
-
withdrawGuardThreshold: BN
|
|
2078
|
+
withdrawGuardThreshold: BN,
|
|
2079
|
+
oracle?: PublicKey
|
|
2074
2080
|
): Promise<TransactionInstruction> {
|
|
2081
|
+
const spotMarketPublicKey = await getSpotMarketPublicKey(
|
|
2082
|
+
this.program.programId,
|
|
2083
|
+
spotMarketIndex
|
|
2084
|
+
);
|
|
2085
|
+
|
|
2086
|
+
if (!oracle) {
|
|
2087
|
+
const cachedSpotMarket = this.isSubscribed
|
|
2088
|
+
? this.getSpotMarketAccount(spotMarketIndex)
|
|
2089
|
+
: undefined;
|
|
2090
|
+
if (cachedSpotMarket) {
|
|
2091
|
+
oracle = cachedSpotMarket.oracle;
|
|
2092
|
+
} else {
|
|
2093
|
+
const accountInfo = await this.connection.getAccountInfo(
|
|
2094
|
+
spotMarketPublicKey
|
|
2095
|
+
);
|
|
2096
|
+
if (!accountInfo) {
|
|
2097
|
+
throw new Error(
|
|
2098
|
+
`Spot market account not found: ${spotMarketPublicKey.toString()}`
|
|
2099
|
+
);
|
|
2100
|
+
}
|
|
2101
|
+
const spotMarket = (
|
|
2102
|
+
this.program.account as any
|
|
2103
|
+
).spotMarket.coder.accounts.decodeUnchecked(
|
|
2104
|
+
'spotMarket',
|
|
2105
|
+
accountInfo.data
|
|
2106
|
+
) as SpotMarketAccount;
|
|
2107
|
+
oracle = spotMarket.oracle;
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2075
2111
|
return await this.program.instruction.updateWithdrawGuardThreshold(
|
|
2076
2112
|
withdrawGuardThreshold,
|
|
2077
2113
|
{
|
|
@@ -2080,10 +2116,8 @@ export class AdminClient extends VelocityClient {
|
|
|
2080
2116
|
? this.getStateAccount().coldAdmin
|
|
2081
2117
|
: this.wallet.publicKey,
|
|
2082
2118
|
state: await this.getStatePublicKey(),
|
|
2083
|
-
spotMarket:
|
|
2084
|
-
|
|
2085
|
-
spotMarketIndex
|
|
2086
|
-
),
|
|
2119
|
+
spotMarket: spotMarketPublicKey,
|
|
2120
|
+
oracle,
|
|
2087
2121
|
},
|
|
2088
2122
|
}
|
|
2089
2123
|
);
|
|
@@ -2091,13 +2125,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2091
2125
|
|
|
2092
2126
|
public async updateSpotMarketIfFactor(
|
|
2093
2127
|
spotMarketIndex: number,
|
|
2094
|
-
|
|
2095
|
-
|
|
2128
|
+
ifFeeFactor: number,
|
|
2129
|
+
protocolFeeFactor: number
|
|
2096
2130
|
): Promise<TransactionSignature> {
|
|
2097
2131
|
const updateSpotMarketIfFactorIx = await this.getUpdateSpotMarketIfFactorIx(
|
|
2098
2132
|
spotMarketIndex,
|
|
2099
|
-
|
|
2100
|
-
|
|
2133
|
+
ifFeeFactor,
|
|
2134
|
+
protocolFeeFactor
|
|
2101
2135
|
);
|
|
2102
2136
|
|
|
2103
2137
|
const tx = await this.buildTransaction(updateSpotMarketIfFactorIx);
|
|
@@ -2109,13 +2143,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2109
2143
|
|
|
2110
2144
|
public async getUpdateSpotMarketIfFactorIx(
|
|
2111
2145
|
spotMarketIndex: number,
|
|
2112
|
-
|
|
2113
|
-
|
|
2146
|
+
ifFeeFactor: number,
|
|
2147
|
+
protocolFeeFactor: number
|
|
2114
2148
|
): Promise<TransactionInstruction> {
|
|
2115
2149
|
return await this.program.instruction.updateSpotMarketIfFactor(
|
|
2116
2150
|
spotMarketIndex,
|
|
2117
|
-
|
|
2118
|
-
|
|
2151
|
+
ifFeeFactor,
|
|
2152
|
+
protocolFeeFactor,
|
|
2119
2153
|
{
|
|
2120
2154
|
accounts: {
|
|
2121
2155
|
admin: this.isSubscribed
|
|
@@ -2353,6 +2387,7 @@ export class AdminClient extends VelocityClient {
|
|
|
2353
2387
|
oracleSource: OracleSource,
|
|
2354
2388
|
skipInvaraintCheck = false
|
|
2355
2389
|
): Promise<TransactionInstruction> {
|
|
2390
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
2356
2391
|
return await this.program.instruction.updatePerpMarketOracle(
|
|
2357
2392
|
oracle,
|
|
2358
2393
|
oracleSource,
|
|
@@ -2368,7 +2403,7 @@ export class AdminClient extends VelocityClient {
|
|
|
2368
2403
|
perpMarketIndex
|
|
2369
2404
|
),
|
|
2370
2405
|
oracle: oracle,
|
|
2371
|
-
oldOracle:
|
|
2406
|
+
oldOracle: perpMarketAccount.oracle,
|
|
2372
2407
|
ammCache: getAmmCachePublicKey(this.program.programId),
|
|
2373
2408
|
},
|
|
2374
2409
|
}
|
|
@@ -2603,6 +2638,7 @@ export class AdminClient extends VelocityClient {
|
|
|
2603
2638
|
oracleSource: OracleSource,
|
|
2604
2639
|
skipInvaraintCheck = false
|
|
2605
2640
|
): Promise<TransactionInstruction> {
|
|
2641
|
+
const spotMarketAccount = this.getSpotMarketAccountOrThrow(spotMarketIndex);
|
|
2606
2642
|
return await this.program.instruction.updateSpotMarketOracle(
|
|
2607
2643
|
oracle,
|
|
2608
2644
|
oracleSource,
|
|
@@ -2618,7 +2654,7 @@ export class AdminClient extends VelocityClient {
|
|
|
2618
2654
|
spotMarketIndex
|
|
2619
2655
|
),
|
|
2620
2656
|
oracle: oracle,
|
|
2621
|
-
oldOracle:
|
|
2657
|
+
oldOracle: spotMarketAccount.oracle,
|
|
2622
2658
|
},
|
|
2623
2659
|
}
|
|
2624
2660
|
);
|
|
@@ -3255,6 +3291,7 @@ export class AdminClient extends VelocityClient {
|
|
|
3255
3291
|
perpMarketIndex: number,
|
|
3256
3292
|
maxSlippageRatio: number
|
|
3257
3293
|
): Promise<TransactionInstruction> {
|
|
3294
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
3258
3295
|
return await (this.program.instruction as any).updateMaxSlippageRatio(
|
|
3259
3296
|
maxSlippageRatio,
|
|
3260
3297
|
{
|
|
@@ -3263,7 +3300,7 @@ export class AdminClient extends VelocityClient {
|
|
|
3263
3300
|
? this.getStateAccount().coldAdmin
|
|
3264
3301
|
: this.wallet.publicKey,
|
|
3265
3302
|
state: await this.getStatePublicKey(),
|
|
3266
|
-
perpMarket:
|
|
3303
|
+
perpMarket: perpMarketAccount.pubkey,
|
|
3267
3304
|
},
|
|
3268
3305
|
}
|
|
3269
3306
|
);
|
|
@@ -3477,6 +3514,46 @@ export class AdminClient extends VelocityClient {
|
|
|
3477
3514
|
);
|
|
3478
3515
|
}
|
|
3479
3516
|
|
|
3517
|
+
public async updatePerpMarketFeePoolBufferTarget(
|
|
3518
|
+
perpMarketIndex: number,
|
|
3519
|
+
feePoolBufferTarget: BN
|
|
3520
|
+
): Promise<TransactionSignature> {
|
|
3521
|
+
const updatePerpMarketFeePoolBufferTargetIx =
|
|
3522
|
+
await this.getUpdatePerpMarketFeePoolBufferTargetIx(
|
|
3523
|
+
perpMarketIndex,
|
|
3524
|
+
feePoolBufferTarget
|
|
3525
|
+
);
|
|
3526
|
+
|
|
3527
|
+
const tx = await this.buildTransaction(
|
|
3528
|
+
updatePerpMarketFeePoolBufferTargetIx
|
|
3529
|
+
);
|
|
3530
|
+
|
|
3531
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3532
|
+
|
|
3533
|
+
return txSig;
|
|
3534
|
+
}
|
|
3535
|
+
|
|
3536
|
+
public async getUpdatePerpMarketFeePoolBufferTargetIx(
|
|
3537
|
+
perpMarketIndex: number,
|
|
3538
|
+
feePoolBufferTarget: BN
|
|
3539
|
+
): Promise<TransactionInstruction> {
|
|
3540
|
+
return await this.program.instruction.updatePerpMarketFeePoolBufferTarget(
|
|
3541
|
+
feePoolBufferTarget,
|
|
3542
|
+
{
|
|
3543
|
+
accounts: {
|
|
3544
|
+
admin: this.isSubscribed
|
|
3545
|
+
? this.getStateAccount().coldAdmin
|
|
3546
|
+
: this.wallet.publicKey,
|
|
3547
|
+
state: await this.getStatePublicKey(),
|
|
3548
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3549
|
+
this.program.programId,
|
|
3550
|
+
perpMarketIndex
|
|
3551
|
+
),
|
|
3552
|
+
},
|
|
3553
|
+
}
|
|
3554
|
+
);
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3480
3557
|
public async updateSpotMarketFeeAdjustment(
|
|
3481
3558
|
perpMarketIndex: number,
|
|
3482
3559
|
feeAdjustment: number
|
|
@@ -3518,13 +3595,15 @@ export class AdminClient extends VelocityClient {
|
|
|
3518
3595
|
public async updatePerpMarketLiquidationFee(
|
|
3519
3596
|
perpMarketIndex: number,
|
|
3520
3597
|
liquidatorFee: number,
|
|
3521
|
-
ifLiquidationFee: number
|
|
3598
|
+
ifLiquidationFee: number,
|
|
3599
|
+
protocolLiquidationFee = 0
|
|
3522
3600
|
): Promise<TransactionSignature> {
|
|
3523
3601
|
const updatePerpMarketLiquidationFeeIx =
|
|
3524
3602
|
await this.getUpdatePerpMarketLiquidationFeeIx(
|
|
3525
3603
|
perpMarketIndex,
|
|
3526
3604
|
liquidatorFee,
|
|
3527
|
-
ifLiquidationFee
|
|
3605
|
+
ifLiquidationFee,
|
|
3606
|
+
protocolLiquidationFee
|
|
3528
3607
|
);
|
|
3529
3608
|
|
|
3530
3609
|
const tx = await this.buildTransaction(updatePerpMarketLiquidationFeeIx);
|
|
@@ -3537,11 +3616,13 @@ export class AdminClient extends VelocityClient {
|
|
|
3537
3616
|
public async getUpdatePerpMarketLiquidationFeeIx(
|
|
3538
3617
|
perpMarketIndex: number,
|
|
3539
3618
|
liquidatorFee: number,
|
|
3540
|
-
ifLiquidationFee: number
|
|
3619
|
+
ifLiquidationFee: number,
|
|
3620
|
+
protocolLiquidationFee = 0
|
|
3541
3621
|
): Promise<TransactionInstruction> {
|
|
3542
3622
|
return await this.program.instruction.updatePerpMarketLiquidationFee(
|
|
3543
3623
|
liquidatorFee,
|
|
3544
3624
|
ifLiquidationFee,
|
|
3625
|
+
protocolLiquidationFee,
|
|
3545
3626
|
{
|
|
3546
3627
|
accounts: {
|
|
3547
3628
|
admin: this.isSubscribed
|
|
@@ -3560,13 +3641,15 @@ export class AdminClient extends VelocityClient {
|
|
|
3560
3641
|
public async updateSpotMarketLiquidationFee(
|
|
3561
3642
|
spotMarketIndex: number,
|
|
3562
3643
|
liquidatorFee: number,
|
|
3563
|
-
ifLiquidationFee: number
|
|
3644
|
+
ifLiquidationFee: number,
|
|
3645
|
+
protocolLiquidationFee = 0
|
|
3564
3646
|
): Promise<TransactionSignature> {
|
|
3565
3647
|
const updateSpotMarketLiquidationFeeIx =
|
|
3566
3648
|
await this.getUpdateSpotMarketLiquidationFeeIx(
|
|
3567
3649
|
spotMarketIndex,
|
|
3568
3650
|
liquidatorFee,
|
|
3569
|
-
ifLiquidationFee
|
|
3651
|
+
ifLiquidationFee,
|
|
3652
|
+
protocolLiquidationFee
|
|
3570
3653
|
);
|
|
3571
3654
|
|
|
3572
3655
|
const tx = await this.buildTransaction(updateSpotMarketLiquidationFeeIx);
|
|
@@ -3579,11 +3662,13 @@ export class AdminClient extends VelocityClient {
|
|
|
3579
3662
|
public async getUpdateSpotMarketLiquidationFeeIx(
|
|
3580
3663
|
spotMarketIndex: number,
|
|
3581
3664
|
liquidatorFee: number,
|
|
3582
|
-
ifLiquidationFee: number
|
|
3665
|
+
ifLiquidationFee: number,
|
|
3666
|
+
protocolLiquidationFee = 0
|
|
3583
3667
|
): Promise<TransactionInstruction> {
|
|
3584
3668
|
return await this.program.instruction.updateSpotMarketLiquidationFee(
|
|
3585
3669
|
liquidatorFee,
|
|
3586
3670
|
ifLiquidationFee,
|
|
3671
|
+
protocolLiquidationFee,
|
|
3587
3672
|
{
|
|
3588
3673
|
accounts: {
|
|
3589
3674
|
admin: this.isSubscribed
|
|
@@ -3599,187 +3684,155 @@ export class AdminClient extends VelocityClient {
|
|
|
3599
3684
|
);
|
|
3600
3685
|
}
|
|
3601
3686
|
|
|
3602
|
-
public async
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
const tx = await this.buildTransaction(
|
|
3607
|
-
initializeProtocolIfSharesTransferConfigIx
|
|
3608
|
-
);
|
|
3609
|
-
|
|
3610
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3611
|
-
|
|
3612
|
-
return txSig;
|
|
3613
|
-
}
|
|
3614
|
-
|
|
3615
|
-
public async getInitializeProtocolIfSharesTransferConfigIx(): Promise<TransactionInstruction> {
|
|
3616
|
-
return await (
|
|
3617
|
-
this.program.instruction as any
|
|
3618
|
-
).initializeProtocolIfSharesTransferConfig({
|
|
3619
|
-
accounts: {
|
|
3620
|
-
admin: this.isSubscribed
|
|
3621
|
-
? this.getStateAccount().coldAdmin
|
|
3622
|
-
: this.wallet.publicKey,
|
|
3623
|
-
state: await this.getStatePublicKey(),
|
|
3624
|
-
rent: SYSVAR_RENT_PUBKEY,
|
|
3625
|
-
systemProgram: anchor.web3.SystemProgram.programId,
|
|
3626
|
-
protocolIfSharesTransferConfig:
|
|
3627
|
-
getProtocolIfSharesTransferConfigPublicKey(this.program.programId),
|
|
3628
|
-
},
|
|
3629
|
-
});
|
|
3630
|
-
}
|
|
3631
|
-
|
|
3632
|
-
public async updateProtocolIfSharesTransferConfig(
|
|
3633
|
-
whitelistedSigners?: PublicKey[],
|
|
3634
|
-
maxTransferPerEpoch?: BN
|
|
3687
|
+
public async updateProtocolFeeRecipient(
|
|
3688
|
+
protocolFeeRecipient: PublicKey,
|
|
3689
|
+
marketType: MarketType
|
|
3635
3690
|
): Promise<TransactionSignature> {
|
|
3636
|
-
const
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
maxTransferPerEpoch
|
|
3640
|
-
);
|
|
3641
|
-
|
|
3642
|
-
const tx = await this.buildTransaction(
|
|
3643
|
-
updateProtocolIfSharesTransferConfigIx
|
|
3691
|
+
const ix = await this.getUpdateProtocolFeeRecipientIx(
|
|
3692
|
+
protocolFeeRecipient,
|
|
3693
|
+
marketType
|
|
3644
3694
|
);
|
|
3645
|
-
|
|
3695
|
+
const tx = await this.buildTransaction(ix);
|
|
3646
3696
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3647
|
-
|
|
3648
3697
|
return txSig;
|
|
3649
3698
|
}
|
|
3650
3699
|
|
|
3651
|
-
public async
|
|
3652
|
-
|
|
3653
|
-
|
|
3700
|
+
public async getUpdateProtocolFeeRecipientIx(
|
|
3701
|
+
protocolFeeRecipient: PublicKey,
|
|
3702
|
+
marketType: MarketType
|
|
3654
3703
|
): Promise<TransactionInstruction> {
|
|
3655
|
-
return await (
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
whitelistedSigners || null,
|
|
3659
|
-
maxTransferPerEpoch,
|
|
3704
|
+
return await this.program.instruction.updateProtocolFeeRecipient(
|
|
3705
|
+
protocolFeeRecipient,
|
|
3706
|
+
marketType,
|
|
3660
3707
|
{
|
|
3661
3708
|
accounts: {
|
|
3662
3709
|
admin: this.isSubscribed
|
|
3663
3710
|
? this.getStateAccount().coldAdmin
|
|
3664
3711
|
: this.wallet.publicKey,
|
|
3665
3712
|
state: await this.getStatePublicKey(),
|
|
3666
|
-
protocolIfSharesTransferConfig:
|
|
3667
|
-
getProtocolIfSharesTransferConfigPublicKey(this.program.programId),
|
|
3668
3713
|
},
|
|
3669
3714
|
}
|
|
3670
3715
|
);
|
|
3671
3716
|
}
|
|
3672
3717
|
|
|
3673
|
-
public async
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3718
|
+
public async withdrawProtocolFeesSpot(
|
|
3719
|
+
marketIndex: number,
|
|
3720
|
+
amount: BN,
|
|
3721
|
+
txParams?: TxParams
|
|
3677
3722
|
): Promise<TransactionSignature> {
|
|
3678
|
-
const
|
|
3679
|
-
|
|
3680
|
-
outMarketIndex,
|
|
3681
|
-
inMarketIndex,
|
|
3682
|
-
amount
|
|
3683
|
-
);
|
|
3684
|
-
|
|
3685
|
-
const tx = await this.buildTransaction(
|
|
3686
|
-
transferProtocolIfSharesToRevenuePoolIx
|
|
3687
|
-
);
|
|
3688
|
-
|
|
3723
|
+
const ix = await this.getWithdrawProtocolFeesSpotIx(marketIndex, amount);
|
|
3724
|
+
const tx = await this.buildTransaction(ix, txParams);
|
|
3689
3725
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3690
|
-
|
|
3691
3726
|
return txSig;
|
|
3692
3727
|
}
|
|
3693
3728
|
|
|
3694
|
-
public async
|
|
3695
|
-
|
|
3696
|
-
inMarketIndex: number,
|
|
3729
|
+
public async getWithdrawProtocolFeesSpotIx(
|
|
3730
|
+
marketIndex: number,
|
|
3697
3731
|
amount: BN
|
|
3698
3732
|
): Promise<TransactionInstruction> {
|
|
3699
|
-
const
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3733
|
+
const spotMarket = this.getSpotMarketAccountOrThrow(marketIndex);
|
|
3734
|
+
const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarket);
|
|
3735
|
+
const recipient = this.getStateAccount().protocolFeeRecipientSpot;
|
|
3736
|
+
const recipientTokenAccount = getAssociatedTokenAddressSync(
|
|
3737
|
+
spotMarket.mint,
|
|
3738
|
+
recipient,
|
|
3739
|
+
true,
|
|
3740
|
+
tokenProgramId
|
|
3741
|
+
);
|
|
3703
3742
|
|
|
3704
|
-
|
|
3705
|
-
|
|
3743
|
+
const remainingAccounts: {
|
|
3744
|
+
pubkey: PublicKey;
|
|
3745
|
+
isSigner: boolean;
|
|
3746
|
+
isWritable: boolean;
|
|
3747
|
+
}[] = [];
|
|
3748
|
+
if (this.isTransferHook(spotMarket)) {
|
|
3749
|
+
await this.addExtraAccountMetasToRemainingAccounts(
|
|
3750
|
+
spotMarket.mint,
|
|
3751
|
+
remainingAccounts
|
|
3752
|
+
);
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3755
|
+
return await this.program.instruction.withdrawProtocolFeesSpot(
|
|
3756
|
+
marketIndex,
|
|
3706
3757
|
amount,
|
|
3707
3758
|
{
|
|
3708
3759
|
accounts: {
|
|
3709
|
-
authority: this.wallet.publicKey,
|
|
3710
3760
|
state: await this.getStatePublicKey(),
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
outMarketIndex
|
|
3723
|
-
),
|
|
3724
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
3725
|
-
velocitySigner: this.getStateAccount().signer,
|
|
3761
|
+
payer: this.wallet.publicKey,
|
|
3762
|
+
authority: this.wallet.publicKey,
|
|
3763
|
+
spotMarket: spotMarket.pubkey,
|
|
3764
|
+
spotMarketVault: spotMarket.vault,
|
|
3765
|
+
mint: spotMarket.mint,
|
|
3766
|
+
recipient,
|
|
3767
|
+
recipientTokenAccount,
|
|
3768
|
+
tokenProgram: tokenProgramId,
|
|
3769
|
+
velocitySigner: this.getSignerPublicKey(),
|
|
3770
|
+
systemProgram: SystemProgram.programId,
|
|
3771
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
3726
3772
|
},
|
|
3727
3773
|
remainingAccounts,
|
|
3728
3774
|
}
|
|
3729
3775
|
);
|
|
3730
3776
|
}
|
|
3731
3777
|
|
|
3732
|
-
public async
|
|
3778
|
+
public async withdrawProtocolFeesPerp(
|
|
3733
3779
|
marketIndex: number,
|
|
3734
3780
|
amount: BN,
|
|
3735
|
-
recipientTokenAccount: PublicKey,
|
|
3736
3781
|
txParams?: TxParams
|
|
3737
3782
|
): Promise<TransactionSignature> {
|
|
3738
|
-
const ix = await this.
|
|
3739
|
-
marketIndex,
|
|
3740
|
-
amount,
|
|
3741
|
-
recipientTokenAccount
|
|
3742
|
-
);
|
|
3783
|
+
const ix = await this.getWithdrawProtocolFeesPerpIx(marketIndex, amount);
|
|
3743
3784
|
const tx = await this.buildTransaction(ix, txParams);
|
|
3744
3785
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3745
3786
|
return txSig;
|
|
3746
3787
|
}
|
|
3747
3788
|
|
|
3748
|
-
public async
|
|
3789
|
+
public async getWithdrawProtocolFeesPerpIx(
|
|
3749
3790
|
marketIndex: number,
|
|
3750
|
-
amount: BN
|
|
3751
|
-
recipientTokenAccount: PublicKey
|
|
3791
|
+
amount: BN
|
|
3752
3792
|
): Promise<TransactionInstruction> {
|
|
3753
|
-
const
|
|
3754
|
-
const
|
|
3793
|
+
const perpMarket = this.getPerpMarketAccountOrThrow(marketIndex);
|
|
3794
|
+
const quoteSpotMarket = this.getSpotMarketAccountOrThrow(
|
|
3795
|
+
perpMarket.quoteSpotMarketIndex
|
|
3796
|
+
);
|
|
3797
|
+
const tokenProgramId = this.getTokenProgramForSpotMarket(quoteSpotMarket);
|
|
3798
|
+
const recipient = this.getStateAccount().protocolFeeRecipientPerp;
|
|
3799
|
+
const recipientTokenAccount = getAssociatedTokenAddressSync(
|
|
3800
|
+
quoteSpotMarket.mint,
|
|
3801
|
+
recipient,
|
|
3802
|
+
true,
|
|
3803
|
+
tokenProgramId
|
|
3804
|
+
);
|
|
3755
3805
|
|
|
3756
3806
|
const remainingAccounts: {
|
|
3757
3807
|
pubkey: PublicKey;
|
|
3758
3808
|
isSigner: boolean;
|
|
3759
3809
|
isWritable: boolean;
|
|
3760
3810
|
}[] = [];
|
|
3761
|
-
this.
|
|
3762
|
-
if (this.isTransferHook(spotMarket)) {
|
|
3811
|
+
if (this.isTransferHook(quoteSpotMarket)) {
|
|
3763
3812
|
await this.addExtraAccountMetasToRemainingAccounts(
|
|
3764
|
-
|
|
3813
|
+
quoteSpotMarket.mint,
|
|
3765
3814
|
remainingAccounts
|
|
3766
3815
|
);
|
|
3767
3816
|
}
|
|
3768
3817
|
|
|
3769
|
-
return await this.program.instruction.
|
|
3818
|
+
return await this.program.instruction.withdrawProtocolFeesPerp(
|
|
3770
3819
|
marketIndex,
|
|
3771
3820
|
amount,
|
|
3772
3821
|
{
|
|
3773
3822
|
accounts: {
|
|
3774
3823
|
state: await this.getStatePublicKey(),
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3824
|
+
payer: this.wallet.publicKey,
|
|
3825
|
+
authority: this.wallet.publicKey,
|
|
3826
|
+
perpMarket: perpMarket.pubkey,
|
|
3827
|
+
quoteSpotMarket: quoteSpotMarket.pubkey,
|
|
3828
|
+
spotMarketVault: quoteSpotMarket.vault,
|
|
3829
|
+
mint: quoteSpotMarket.mint,
|
|
3830
|
+
recipient,
|
|
3780
3831
|
recipientTokenAccount,
|
|
3781
3832
|
tokenProgram: tokenProgramId,
|
|
3782
3833
|
velocitySigner: this.getSignerPublicKey(),
|
|
3834
|
+
systemProgram: SystemProgram.programId,
|
|
3835
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
3783
3836
|
},
|
|
3784
3837
|
remainingAccounts,
|
|
3785
3838
|
}
|
|
@@ -4055,36 +4108,44 @@ export class AdminClient extends VelocityClient {
|
|
|
4055
4108
|
);
|
|
4056
4109
|
}
|
|
4057
4110
|
|
|
4058
|
-
public async
|
|
4059
|
-
|
|
4111
|
+
public async updatePerpMarketFundingBiasSensitivity(
|
|
4112
|
+
perpMarketIndex: number,
|
|
4113
|
+
fundingBiasSensitivity: number
|
|
4060
4114
|
): Promise<TransactionSignature> {
|
|
4061
|
-
const
|
|
4062
|
-
await this.
|
|
4063
|
-
|
|
4064
|
-
|
|
4115
|
+
const updatePerpMarketFundingBiasSensitivityIx =
|
|
4116
|
+
await this.getUpdatePerpMarketFundingBiasSensitivityIx(
|
|
4117
|
+
perpMarketIndex,
|
|
4118
|
+
fundingBiasSensitivity
|
|
4119
|
+
);
|
|
4120
|
+
const tx = await this.buildTransaction(
|
|
4121
|
+
updatePerpMarketFundingBiasSensitivityIx
|
|
4122
|
+
);
|
|
4065
4123
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4066
4124
|
|
|
4067
4125
|
return txSig;
|
|
4068
4126
|
}
|
|
4069
4127
|
|
|
4070
|
-
public async
|
|
4071
|
-
|
|
4128
|
+
public async getUpdatePerpMarketFundingBiasSensitivityIx(
|
|
4129
|
+
perpMarketIndex: number,
|
|
4130
|
+
fundingBiasSensitivity: number
|
|
4072
4131
|
): Promise<TransactionInstruction> {
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4132
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
4133
|
+
this.program.programId,
|
|
4134
|
+
perpMarketIndex
|
|
4135
|
+
);
|
|
4136
|
+
|
|
4137
|
+
return await this.program.instruction.updatePerpMarketFundingBiasSensitivity(
|
|
4138
|
+
fundingBiasSensitivity,
|
|
4139
|
+
{
|
|
4140
|
+
accounts: {
|
|
4141
|
+
admin: this.useHotWalletAdmin
|
|
4142
|
+
? this.wallet.publicKey
|
|
4143
|
+
: this.getStateAccount().coldAdmin,
|
|
4144
|
+
state: await this.getStatePublicKey(),
|
|
4145
|
+
perpMarket: perpMarketPublicKey,
|
|
4146
|
+
},
|
|
4147
|
+
}
|
|
4148
|
+
);
|
|
4088
4149
|
}
|
|
4089
4150
|
|
|
4090
4151
|
public async initializePythLazerOracle(
|
|
@@ -4141,7 +4202,7 @@ export class AdminClient extends VelocityClient {
|
|
|
4141
4202
|
adminTokenAccount?: PublicKey
|
|
4142
4203
|
): Promise<TransactionInstruction> {
|
|
4143
4204
|
const state = await this.getStatePublicKey();
|
|
4144
|
-
const spotMarket = this.
|
|
4205
|
+
const spotMarket = this.getSpotMarketAccountOrThrow(marketIndex);
|
|
4145
4206
|
|
|
4146
4207
|
const remainingAccounts = this.getRemainingAccounts({
|
|
4147
4208
|
userAccounts: [],
|
|
@@ -4311,106 +4372,6 @@ export class AdminClient extends VelocityClient {
|
|
|
4311
4372
|
);
|
|
4312
4373
|
}
|
|
4313
4374
|
|
|
4314
|
-
public async updateDelegateUserGovTokenInsuranceStake(
|
|
4315
|
-
authority: PublicKey,
|
|
4316
|
-
delegate: PublicKey
|
|
4317
|
-
): Promise<TransactionSignature> {
|
|
4318
|
-
const updateDelegateUserGovTokenInsuranceStakeIx =
|
|
4319
|
-
await this.getUpdateDelegateUserGovTokenInsuranceStakeIx(
|
|
4320
|
-
authority,
|
|
4321
|
-
delegate
|
|
4322
|
-
);
|
|
4323
|
-
|
|
4324
|
-
const tx = await this.buildTransaction(
|
|
4325
|
-
updateDelegateUserGovTokenInsuranceStakeIx
|
|
4326
|
-
);
|
|
4327
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4328
|
-
|
|
4329
|
-
return txSig;
|
|
4330
|
-
}
|
|
4331
|
-
|
|
4332
|
-
public async getUpdateDelegateUserGovTokenInsuranceStakeIx(
|
|
4333
|
-
authority: PublicKey,
|
|
4334
|
-
delegate: PublicKey
|
|
4335
|
-
): Promise<TransactionInstruction> {
|
|
4336
|
-
const marketIndex = GOV_SPOT_MARKET_INDEX;
|
|
4337
|
-
const spotMarket = this.getSpotMarketAccount(marketIndex);
|
|
4338
|
-
const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
|
|
4339
|
-
this.program.programId,
|
|
4340
|
-
delegate,
|
|
4341
|
-
marketIndex
|
|
4342
|
-
);
|
|
4343
|
-
const userStatsPublicKey = getUserStatsAccountPublicKey(
|
|
4344
|
-
this.program.programId,
|
|
4345
|
-
authority
|
|
4346
|
-
);
|
|
4347
|
-
|
|
4348
|
-
const ix = (
|
|
4349
|
-
this.program.instruction as any
|
|
4350
|
-
).getUpdateDelegateUserGovTokenInsuranceStakeIx({
|
|
4351
|
-
accounts: {
|
|
4352
|
-
state: await this.getStatePublicKey(),
|
|
4353
|
-
spotMarket: spotMarket.pubkey,
|
|
4354
|
-
insuranceFundStake: ifStakeAccountPublicKey,
|
|
4355
|
-
userStats: userStatsPublicKey,
|
|
4356
|
-
signer: this.wallet.publicKey,
|
|
4357
|
-
insuranceFundVault: spotMarket.insuranceFund.vault,
|
|
4358
|
-
},
|
|
4359
|
-
});
|
|
4360
|
-
|
|
4361
|
-
return ix;
|
|
4362
|
-
}
|
|
4363
|
-
|
|
4364
|
-
public async depositIntoInsuranceFundStake(
|
|
4365
|
-
marketIndex: number,
|
|
4366
|
-
amount: BN,
|
|
4367
|
-
userStatsPublicKey: PublicKey,
|
|
4368
|
-
insuranceFundStakePublicKey: PublicKey,
|
|
4369
|
-
userTokenAccountPublicKey: PublicKey,
|
|
4370
|
-
txParams?: TxParams
|
|
4371
|
-
): Promise<TransactionSignature> {
|
|
4372
|
-
const tx = await this.buildTransaction(
|
|
4373
|
-
await this.getDepositIntoInsuranceFundStakeIx(
|
|
4374
|
-
marketIndex,
|
|
4375
|
-
amount,
|
|
4376
|
-
userStatsPublicKey,
|
|
4377
|
-
insuranceFundStakePublicKey,
|
|
4378
|
-
userTokenAccountPublicKey
|
|
4379
|
-
),
|
|
4380
|
-
txParams
|
|
4381
|
-
);
|
|
4382
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4383
|
-
return txSig;
|
|
4384
|
-
}
|
|
4385
|
-
|
|
4386
|
-
public async getDepositIntoInsuranceFundStakeIx(
|
|
4387
|
-
marketIndex: number,
|
|
4388
|
-
amount: BN,
|
|
4389
|
-
userStatsPublicKey: PublicKey,
|
|
4390
|
-
insuranceFundStakePublicKey: PublicKey,
|
|
4391
|
-
userTokenAccountPublicKey: PublicKey
|
|
4392
|
-
): Promise<TransactionInstruction> {
|
|
4393
|
-
const spotMarket = this.getSpotMarketAccount(marketIndex);
|
|
4394
|
-
return await this.program.instruction.depositIntoInsuranceFundStake(
|
|
4395
|
-
marketIndex,
|
|
4396
|
-
amount,
|
|
4397
|
-
{
|
|
4398
|
-
accounts: {
|
|
4399
|
-
signer: this.wallet.publicKey,
|
|
4400
|
-
state: await this.getStatePublicKey(),
|
|
4401
|
-
spotMarket: spotMarket.pubkey,
|
|
4402
|
-
insuranceFundStake: insuranceFundStakePublicKey,
|
|
4403
|
-
userStats: userStatsPublicKey,
|
|
4404
|
-
spotMarketVault: spotMarket.vault,
|
|
4405
|
-
insuranceFundVault: spotMarket.insuranceFund.vault,
|
|
4406
|
-
userTokenAccount: userTokenAccountPublicKey,
|
|
4407
|
-
tokenProgram: this.getTokenProgramForSpotMarket(spotMarket),
|
|
4408
|
-
velocitySigner: this.getSignerPublicKey(),
|
|
4409
|
-
},
|
|
4410
|
-
}
|
|
4411
|
-
);
|
|
4412
|
-
}
|
|
4413
|
-
|
|
4414
4375
|
public async updateFeatureBitFlagsSettleLpPool(
|
|
4415
4376
|
enable: boolean
|
|
4416
4377
|
): Promise<TransactionSignature> {
|
|
@@ -4653,7 +4614,7 @@ export class AdminClient extends VelocityClient {
|
|
|
4653
4614
|
lpPool,
|
|
4654
4615
|
spotMarketIndex
|
|
4655
4616
|
);
|
|
4656
|
-
const spotMarketAccount = this.
|
|
4617
|
+
const spotMarketAccount = this.getSpotMarketAccountOrThrow(spotMarketIndex);
|
|
4657
4618
|
|
|
4658
4619
|
return [
|
|
4659
4620
|
this.program.instruction.initializeConstituent(
|
|
@@ -5144,8 +5105,8 @@ export class AdminClient extends VelocityClient {
|
|
|
5144
5105
|
userAccountPublicKey,
|
|
5145
5106
|
});
|
|
5146
5107
|
}
|
|
5147
|
-
const outSpotMarket = this.
|
|
5148
|
-
const inSpotMarket = this.
|
|
5108
|
+
const outSpotMarket = this.getSpotMarketAccountOrThrow(outMarketIndex);
|
|
5109
|
+
const inSpotMarket = this.getSpotMarketAccountOrThrow(inMarketIndex);
|
|
5149
5110
|
|
|
5150
5111
|
const outTokenProgram = this.getTokenProgramForSpotMarket(outSpotMarket);
|
|
5151
5112
|
const inTokenProgram = this.getTokenProgramForSpotMarket(inSpotMarket);
|
|
@@ -5194,7 +5155,7 @@ export class AdminClient extends VelocityClient {
|
|
|
5194
5155
|
}
|
|
5195
5156
|
);
|
|
5196
5157
|
|
|
5197
|
-
const remainingAccounts = [];
|
|
5158
|
+
const remainingAccounts: AccountMeta[] = [];
|
|
5198
5159
|
remainingAccounts.push({
|
|
5199
5160
|
pubkey: outTokenProgram,
|
|
5200
5161
|
isWritable: false,
|
|
@@ -5251,8 +5212,8 @@ export class AdminClient extends VelocityClient {
|
|
|
5251
5212
|
ixs: TransactionInstruction[];
|
|
5252
5213
|
lookupTables: AddressLookupTableAccount[];
|
|
5253
5214
|
}> {
|
|
5254
|
-
const outMarket = this.
|
|
5255
|
-
const inMarket = this.
|
|
5215
|
+
const outMarket = this.getSpotMarketAccountOrThrow(outMarketIndex);
|
|
5216
|
+
const inMarket = this.getSpotMarketAccountOrThrow(inMarketIndex);
|
|
5256
5217
|
|
|
5257
5218
|
if (!quote) {
|
|
5258
5219
|
const fetchedQuote = await jupiterClient.getQuote({
|
|
@@ -5368,8 +5329,10 @@ export class AdminClient extends VelocityClient {
|
|
|
5368
5329
|
inSpotMarketIndex: number,
|
|
5369
5330
|
outSpotMarketIndex: number
|
|
5370
5331
|
): Promise<TransactionInstruction[]> {
|
|
5371
|
-
const inSpotMarketAccount =
|
|
5372
|
-
|
|
5332
|
+
const inSpotMarketAccount =
|
|
5333
|
+
this.getSpotMarketAccountOrThrow(inSpotMarketIndex);
|
|
5334
|
+
const outSpotMarketAccount =
|
|
5335
|
+
this.getSpotMarketAccountOrThrow(outSpotMarketIndex);
|
|
5373
5336
|
|
|
5374
5337
|
const outTokenAccount = await this.getAssociatedTokenAccount(
|
|
5375
5338
|
outSpotMarketAccount.marketIndex,
|
|
@@ -5437,6 +5400,8 @@ export class AdminClient extends VelocityClient {
|
|
|
5437
5400
|
minOutAmount: BN,
|
|
5438
5401
|
externalUserAuthority: PublicKey
|
|
5439
5402
|
) {
|
|
5403
|
+
const inMarket = this.getSpotMarketAccountOrThrow(inMarketIndex);
|
|
5404
|
+
const outMarket = this.getSpotMarketAccountOrThrow(outMarketIndex);
|
|
5440
5405
|
const { beginSwapIx, endSwapIx } = await this.getSwapIx(
|
|
5441
5406
|
{
|
|
5442
5407
|
lpPoolId,
|
|
@@ -5462,13 +5427,13 @@ export class AdminClient extends VelocityClient {
|
|
|
5462
5427
|
await this.getAssociatedTokenAccount(
|
|
5463
5428
|
inMarketIndex,
|
|
5464
5429
|
false,
|
|
5465
|
-
getTokenProgramForSpotMarket(
|
|
5430
|
+
getTokenProgramForSpotMarket(inMarket),
|
|
5466
5431
|
externalUserAuthority
|
|
5467
5432
|
),
|
|
5468
5433
|
await this.getAssociatedTokenAccount(
|
|
5469
5434
|
outMarketIndex,
|
|
5470
5435
|
false,
|
|
5471
|
-
getTokenProgramForSpotMarket(
|
|
5436
|
+
getTokenProgramForSpotMarket(outMarket),
|
|
5472
5437
|
externalUserAuthority
|
|
5473
5438
|
),
|
|
5474
5439
|
inMarketIndex,
|
|
@@ -5514,8 +5479,10 @@ export class AdminClient extends VelocityClient {
|
|
|
5514
5479
|
withdrawIx: TransactionInstruction;
|
|
5515
5480
|
}> {
|
|
5516
5481
|
const lpPool = getLpPoolPublicKey(this.program.programId, lpPoolId);
|
|
5517
|
-
const depositSpotMarket =
|
|
5518
|
-
|
|
5482
|
+
const depositSpotMarket =
|
|
5483
|
+
this.getSpotMarketAccountOrThrow(depositMarketIndex);
|
|
5484
|
+
const withdrawSpotMarket =
|
|
5485
|
+
this.getSpotMarketAccountOrThrow(borrowMarketIndex);
|
|
5519
5486
|
|
|
5520
5487
|
const depositTokenProgram =
|
|
5521
5488
|
this.getTokenProgramForSpotMarket(depositSpotMarket);
|
|
@@ -5663,6 +5630,7 @@ export class AdminClient extends VelocityClient {
|
|
|
5663
5630
|
lpFeeTransferScalar?: number,
|
|
5664
5631
|
lpExchangeFeeExcluscionScalar?: number
|
|
5665
5632
|
): Promise<TransactionInstruction> {
|
|
5633
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(marketIndex);
|
|
5666
5634
|
return this.program.instruction.updatePerpMarketLpPoolFeeTransferScalar(
|
|
5667
5635
|
lpFeeTransferScalar ?? null,
|
|
5668
5636
|
lpExchangeFeeExcluscionScalar ?? null,
|
|
@@ -5672,7 +5640,7 @@ export class AdminClient extends VelocityClient {
|
|
|
5672
5640
|
? this.wallet.publicKey
|
|
5673
5641
|
: this.getStateAccount().coldAdmin,
|
|
5674
5642
|
state: await this.getStatePublicKey(),
|
|
5675
|
-
perpMarket:
|
|
5643
|
+
perpMarket: perpMarketAccount.pubkey,
|
|
5676
5644
|
},
|
|
5677
5645
|
}
|
|
5678
5646
|
);
|
|
@@ -5695,6 +5663,7 @@ export class AdminClient extends VelocityClient {
|
|
|
5695
5663
|
marketIndex: number,
|
|
5696
5664
|
pausedOperations: number
|
|
5697
5665
|
): Promise<TransactionInstruction> {
|
|
5666
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(marketIndex);
|
|
5698
5667
|
return this.program.instruction.updatePerpMarketLpPoolPausedOperations(
|
|
5699
5668
|
pausedOperations,
|
|
5700
5669
|
{
|
|
@@ -5703,7 +5672,7 @@ export class AdminClient extends VelocityClient {
|
|
|
5703
5672
|
? this.wallet.publicKey
|
|
5704
5673
|
: this.getStateAccount().coldAdmin,
|
|
5705
5674
|
state: await this.getStatePublicKey(),
|
|
5706
|
-
perpMarket:
|
|
5675
|
+
perpMarket: perpMarketAccount.pubkey,
|
|
5707
5676
|
},
|
|
5708
5677
|
}
|
|
5709
5678
|
);
|
|
@@ -5768,13 +5737,14 @@ export class AdminClient extends VelocityClient {
|
|
|
5768
5737
|
marketIndex: number,
|
|
5769
5738
|
marketConfig: number
|
|
5770
5739
|
): Promise<TransactionInstruction> {
|
|
5740
|
+
const perpMarketAccount = this.getPerpMarketAccountOrThrow(marketIndex);
|
|
5771
5741
|
return this.program.instruction.updatePerpMarketConfig(marketConfig, {
|
|
5772
5742
|
accounts: {
|
|
5773
5743
|
admin: this.useHotWalletAdmin
|
|
5774
5744
|
? this.wallet.publicKey
|
|
5775
5745
|
: this.getStateAccount().coldAdmin,
|
|
5776
5746
|
state: await this.getStatePublicKey(),
|
|
5777
|
-
perpMarket:
|
|
5747
|
+
perpMarket: perpMarketAccount.pubkey,
|
|
5778
5748
|
},
|
|
5779
5749
|
});
|
|
5780
5750
|
}
|
|
@@ -5921,13 +5891,13 @@ export enum HotRole {
|
|
|
5921
5891
|
LpCache = 'lpCache',
|
|
5922
5892
|
LpSwap = 'lpSwap',
|
|
5923
5893
|
LpSettle = 'lpSettle',
|
|
5924
|
-
IfRebalance = 'ifRebalance',
|
|
5925
5894
|
FeatureFlag = 'featureFlag',
|
|
5926
5895
|
Fuel = 'fuel',
|
|
5927
5896
|
UserFlag = 'userFlag',
|
|
5928
5897
|
VaultDeposit = 'vaultDeposit',
|
|
5929
5898
|
MmOracleCrank = 'mmOracleCrank',
|
|
5930
5899
|
AmmSpreadAdjust = 'ammSpreadAdjust',
|
|
5900
|
+
FeeWithdraw = 'feeWithdraw',
|
|
5931
5901
|
}
|
|
5932
5902
|
|
|
5933
5903
|
/** Anchor encodes Rust enums as `{ <variant>: {} }`. */
|