@velocity-exchange/sdk 0.3.0 → 0.4.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 +51 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.js +18 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +18 -0
- package/lib/browser/accounts/bulkAccountLoader.d.ts +52 -0
- package/lib/browser/accounts/bulkAccountLoader.js +51 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +9 -2
- package/lib/browser/accounts/bulkUserStatsSubscription.js +9 -2
- package/lib/browser/accounts/bulkUserSubscription.d.ts +8 -2
- package/lib/browser/accounts/bulkUserSubscription.js +8 -2
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.js +37 -0
- package/lib/browser/accounts/fetch.d.ts +59 -2
- package/lib/browser/accounts/fetch.js +57 -2
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +30 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +30 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +118 -37
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +40 -12
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +33 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +15 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.js +15 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +15 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +34 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +34 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +19 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +21 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +22 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +32 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +22 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
- package/lib/browser/accounts/testBulkAccountLoader.d.ts +8 -0
- package/lib/browser/accounts/testBulkAccountLoader.js +8 -0
- package/lib/browser/accounts/types.d.ts +149 -0
- package/lib/browser/accounts/types.js +13 -0
- package/lib/browser/accounts/utils.d.ts +18 -0
- package/lib/browser/accounts/utils.js +32 -16
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +41 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.js +41 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +31 -23
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +36 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +26 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +33 -0
- package/lib/browser/addresses/marketAddresses.d.ts +10 -0
- package/lib/browser/addresses/marketAddresses.js +10 -0
- package/lib/browser/addresses/pda.d.ts +214 -2
- package/lib/browser/addresses/pda.js +217 -5
- package/lib/browser/adminClient.d.ts +2136 -4
- package/lib/browser/adminClient.js +2150 -4
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
- package/lib/browser/auctionSubscriber/index.d.ts +6 -0
- package/lib/browser/auctionSubscriber/index.js +6 -0
- package/lib/browser/auctionSubscriber/types.d.ts +7 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +33 -0
- package/lib/browser/blockhashSubscriber/index.d.ts +5 -0
- package/lib/browser/blockhashSubscriber/index.js +5 -0
- package/lib/browser/blockhashSubscriber/types.d.ts +5 -0
- package/lib/browser/clock/clockSubscriber.d.ts +24 -0
- package/lib/browser/clock/clockSubscriber.js +22 -0
- package/lib/browser/config.d.ts +58 -4
- package/lib/browser/config.js +88 -21
- package/lib/browser/constants/numericConstants.d.ts +67 -0
- package/lib/browser/constants/numericConstants.js +68 -1
- package/lib/browser/constants/perpMarkets.d.ts +10 -0
- package/lib/browser/constants/perpMarkets.js +40 -908
- package/lib/browser/constants/spotMarkets.d.ts +13 -0
- package/lib/browser/constants/spotMarkets.js +16 -742
- package/lib/browser/constants/txConstants.d.ts +1 -0
- package/lib/browser/constants/txConstants.js +1 -0
- package/lib/browser/core/VelocityCore.d.ts +285 -8
- package/lib/browser/core/VelocityCore.js +281 -8
- package/lib/browser/core/instructions/deposit.d.ts +22 -0
- package/lib/browser/core/instructions/deposit.js +22 -0
- package/lib/browser/core/instructions/fill.d.ts +17 -0
- package/lib/browser/core/instructions/fill.js +17 -0
- package/lib/browser/core/instructions/funding.d.ts +12 -0
- package/lib/browser/core/instructions/funding.js +12 -0
- package/lib/browser/core/instructions/liquidation.d.ts +18 -0
- package/lib/browser/core/instructions/liquidation.js +18 -0
- package/lib/browser/core/instructions/orders.d.ts +28 -0
- package/lib/browser/core/instructions/orders.js +28 -0
- package/lib/browser/core/instructions/perpOrders.d.ts +106 -0
- package/lib/browser/core/instructions/perpOrders.js +106 -0
- package/lib/browser/core/instructions/settlement.d.ts +14 -0
- package/lib/browser/core/instructions/settlement.js +14 -0
- package/lib/browser/core/instructions/trigger.d.ts +15 -0
- package/lib/browser/core/instructions/trigger.js +15 -0
- package/lib/browser/core/instructions/withdraw.d.ts +21 -0
- package/lib/browser/core/instructions/withdraw.js +21 -0
- package/lib/browser/core/remainingAccounts.d.ts +47 -3
- package/lib/browser/core/remainingAccounts.js +20 -0
- package/lib/browser/core/signedMsg.d.ts +38 -0
- package/lib/browser/core/signedMsg.js +33 -0
- package/lib/browser/decode/customCoder.d.ts +39 -3
- package/lib/browser/decode/customCoder.js +45 -3
- package/lib/browser/decode/user.d.ts +22 -0
- package/lib/browser/decode/user.js +22 -0
- package/lib/browser/dlob/DLOB.d.ts +502 -53
- package/lib/browser/dlob/DLOB.js +540 -98
- package/lib/browser/dlob/DLOBNode.d.ts +86 -4
- package/lib/browser/dlob/DLOBNode.js +37 -4
- package/lib/browser/dlob/DLOBSubscriber.d.ts +39 -12
- package/lib/browser/dlob/DLOBSubscriber.js +42 -12
- package/lib/browser/dlob/NodeList.d.ts +69 -0
- package/lib/browser/dlob/NodeList.js +66 -0
- package/lib/browser/dlob/orderBookLevels.d.ts +106 -13
- package/lib/browser/dlob/orderBookLevels.js +84 -14
- package/lib/browser/dlob/types.d.ts +15 -0
- package/lib/browser/events/eventList.d.ts +14 -0
- package/lib/browser/events/eventList.js +14 -0
- package/lib/browser/events/eventSubscriber.d.ts +87 -10
- package/lib/browser/events/eventSubscriber.js +93 -8
- package/lib/browser/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/browser/events/eventsServerLogProvider.js +27 -0
- package/lib/browser/events/fetchLogs.d.ts +31 -0
- package/lib/browser/events/fetchLogs.js +46 -1
- package/lib/browser/events/parse.d.ts +23 -0
- package/lib/browser/events/parse.js +23 -0
- package/lib/browser/events/pollingLogProvider.d.ts +24 -0
- package/lib/browser/events/pollingLogProvider.js +24 -0
- package/lib/browser/events/sort.d.ts +11 -0
- package/lib/browser/events/sort.js +12 -0
- package/lib/browser/events/txEventCache.d.ts +13 -3
- package/lib/browser/events/txEventCache.js +19 -7
- package/lib/browser/events/types.d.ts +118 -2
- package/lib/browser/events/types.js +11 -0
- package/lib/browser/events/webSocketLogProvider.d.ts +23 -0
- package/lib/browser/events/webSocketLogProvider.js +28 -0
- package/lib/browser/factory/oracleClient.js +2 -2
- package/lib/browser/idl/velocity.d.ts +4 -4
- package/lib/browser/idl/velocity.json +4 -4
- package/lib/browser/keypair.d.ts +8 -0
- package/lib/browser/keypair.js +8 -0
- package/lib/browser/marginCalculation.d.ts +134 -2
- package/lib/browser/marginCalculation.js +121 -0
- package/lib/browser/math/amm.d.ts +348 -29
- package/lib/browser/math/amm.js +310 -32
- package/lib/browser/math/auction.d.ts +95 -19
- package/lib/browser/math/auction.js +118 -28
- package/lib/browser/math/bankruptcy.d.ts +46 -0
- package/lib/browser/math/bankruptcy.js +89 -1
- package/lib/browser/math/builder.d.ts +64 -8
- package/lib/browser/math/builder.js +71 -9
- package/lib/browser/math/conversion.d.ts +21 -0
- package/lib/browser/math/conversion.js +21 -0
- package/lib/browser/math/exchangeStatus.d.ts +91 -0
- package/lib/browser/math/exchangeStatus.js +106 -3
- package/lib/browser/math/funding.d.ts +57 -20
- package/lib/browser/math/funding.js +63 -23
- package/lib/browser/math/insurance.d.ts +62 -0
- package/lib/browser/math/insurance.js +62 -0
- package/lib/browser/math/liquidation.d.ts +127 -11
- package/lib/browser/math/liquidation.js +182 -19
- package/lib/browser/math/margin.d.ts +79 -13
- package/lib/browser/math/margin.js +80 -14
- package/lib/browser/math/market.d.ts +135 -15
- package/lib/browser/math/market.js +145 -17
- package/lib/browser/math/oracles.d.ts +113 -0
- package/lib/browser/math/oracles.js +118 -1
- package/lib/browser/math/orders.d.ts +115 -10
- package/lib/browser/math/orders.js +130 -19
- package/lib/browser/math/position.d.ts +80 -33
- package/lib/browser/math/position.js +80 -33
- package/lib/browser/math/repeg.d.ts +48 -10
- package/lib/browser/math/repeg.js +48 -10
- package/lib/browser/math/spotBalance.d.ts +200 -5
- package/lib/browser/math/spotBalance.js +239 -10
- package/lib/browser/math/spotMarket.d.ts +36 -3
- package/lib/browser/math/spotMarket.js +36 -3
- package/lib/browser/math/spotPosition.d.ts +72 -0
- package/lib/browser/math/spotPosition.js +62 -0
- package/lib/browser/math/state.d.ts +31 -0
- package/lib/browser/math/state.js +31 -0
- package/lib/browser/math/superStake.d.ts +126 -2
- package/lib/browser/math/superStake.js +123 -3
- package/lib/browser/math/tiers.d.ts +29 -0
- package/lib/browser/math/tiers.js +29 -0
- package/lib/browser/math/trade.d.ts +102 -51
- package/lib/browser/math/trade.js +101 -55
- package/lib/browser/math/utils.d.ts +71 -9
- package/lib/browser/math/utils.js +71 -9
- package/lib/browser/memcmp.d.ts +94 -0
- package/lib/browser/memcmp.js +103 -2
- package/lib/browser/oracles/oracleClientCache.d.ts +16 -0
- package/lib/browser/oracles/oracleClientCache.js +16 -0
- package/lib/browser/oracles/oracleId.d.ts +31 -0
- package/lib/browser/oracles/oracleId.js +39 -8
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +20 -0
- package/lib/browser/oracles/prelaunchOracleClient.js +20 -0
- package/lib/browser/oracles/pythClient.d.ts +31 -0
- package/lib/browser/oracles/pythClient.js +32 -1
- package/lib/browser/oracles/pythLazerClient.d.ts +34 -0
- package/lib/browser/oracles/pythLazerClient.js +35 -1
- package/lib/browser/oracles/quoteAssetOracleClient.d.ts +18 -0
- package/lib/browser/oracles/quoteAssetOracleClient.js +18 -0
- package/lib/browser/oracles/strictOraclePrice.d.ts +21 -0
- package/lib/browser/oracles/strictOraclePrice.js +21 -0
- package/lib/browser/oracles/types.d.ts +45 -0
- package/lib/browser/oracles/utils.d.ts +20 -0
- package/lib/browser/oracles/utils.js +20 -0
- package/lib/browser/orderParams.d.ts +42 -4
- package/lib/browser/orderParams.js +42 -4
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +56 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.js +56 -0
- package/lib/browser/orderSubscriber/PollingSubscription.d.ts +11 -0
- package/lib/browser/orderSubscriber/PollingSubscription.js +11 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +18 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +18 -0
- package/lib/browser/orderSubscriber/grpcSubscription.d.ts +16 -0
- package/lib/browser/orderSubscriber/grpcSubscription.js +16 -0
- package/lib/browser/orderSubscriber/types.d.ts +9 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.js +1 -0
- package/lib/browser/priorityFee/averageStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/averageStrategy.js +1 -0
- package/lib/browser/priorityFee/ewmaStrategy.d.ts +10 -0
- package/lib/browser/priorityFee/ewmaStrategy.js +10 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +9 -2
- package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.js +1 -0
- package/lib/browser/priorityFee/maxStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/maxStrategy.js +1 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +39 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +39 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +21 -2
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +10 -0
- package/lib/browser/priorityFee/types.d.ts +32 -0
- package/lib/browser/priorityFee/types.js +5 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +8 -0
- package/lib/browser/slot/SlotSubscriber.d.ts +18 -0
- package/lib/browser/slot/SlotSubscriber.js +16 -0
- package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/browser/slot/SlothashSubscriber.js +25 -1
- package/lib/browser/tx/baseTxSender.d.ts +163 -0
- package/lib/browser/tx/baseTxSender.js +174 -6
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
- package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/browser/tx/fastSingleTxSender.d.ts +47 -0
- package/lib/browser/tx/fastSingleTxSender.js +48 -1
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +48 -0
- package/lib/browser/tx/forwardOnlyTxSender.js +48 -0
- package/lib/browser/tx/reportTransactionError.d.ts +18 -6
- package/lib/browser/tx/reportTransactionError.js +18 -6
- package/lib/browser/tx/retryTxSender.d.ts +40 -0
- package/lib/browser/tx/retryTxSender.js +39 -0
- package/lib/browser/tx/txHandler.d.ts +146 -35
- package/lib/browser/tx/txHandler.js +132 -32
- package/lib/browser/tx/txParamProcessor.d.ts +47 -0
- package/lib/browser/tx/txParamProcessor.js +47 -0
- package/lib/browser/tx/types.d.ts +46 -0
- package/lib/browser/tx/types.js +5 -0
- package/lib/browser/tx/utils.d.ts +26 -0
- package/lib/browser/tx/utils.js +26 -0
- package/lib/browser/tx/whileValidTxSender.d.ts +82 -0
- package/lib/browser/tx/whileValidTxSender.js +81 -0
- package/lib/browser/types.d.ts +781 -13
- package/lib/browser/types.js +126 -9
- package/lib/browser/user.d.ts +645 -84
- package/lib/browser/user.js +779 -96
- package/lib/browser/userMap/PollingSubscription.d.ts +10 -0
- package/lib/browser/userMap/PollingSubscription.js +14 -2
- package/lib/browser/userMap/WebsocketSubscription.d.ts +9 -0
- package/lib/browser/userMap/WebsocketSubscription.js +9 -0
- package/lib/browser/userMap/grpcSubscription.d.ts +8 -0
- package/lib/browser/userMap/grpcSubscription.js +8 -0
- package/lib/browser/userMap/referrerMap.d.ts +72 -2
- package/lib/browser/userMap/referrerMap.js +84 -2
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +37 -10
- package/lib/browser/userMap/revenueShareEscrowMap.js +38 -11
- package/lib/browser/userMap/userMap.d.ts +81 -3
- package/lib/browser/userMap/userMap.js +81 -4
- package/lib/browser/userMap/userMapConfig.d.ts +23 -0
- package/lib/browser/userMap/userStatsMap.d.ts +22 -0
- package/lib/browser/userMap/userStatsMap.js +22 -0
- package/lib/browser/userName.d.ts +16 -0
- package/lib/browser/userName.js +16 -0
- package/lib/browser/userStats.d.ts +28 -1
- package/lib/browser/userStats.js +28 -1
- package/lib/browser/util/TransactionConfirmationManager.d.ts +33 -0
- package/lib/browser/util/TransactionConfirmationManager.js +33 -0
- package/lib/browser/util/chainClock.d.ts +24 -0
- package/lib/browser/util/chainClock.js +20 -0
- package/lib/browser/util/computeUnits.d.ts +32 -0
- package/lib/browser/util/computeUnits.js +32 -0
- package/lib/browser/util/digest.d.ts +17 -0
- package/lib/browser/util/digest.js +17 -0
- package/lib/browser/util/ed25519Utils.d.ts +12 -2
- package/lib/browser/util/ed25519Utils.js +12 -2
- package/lib/browser/util/promiseTimeout.d.ts +9 -0
- package/lib/browser/util/promiseTimeout.js +9 -0
- package/lib/browser/velocityClient.d.ts +3322 -215
- package/lib/browser/velocityClient.js +3412 -245
- package/lib/browser/wallet.d.ts +37 -0
- package/lib/browser/wallet.js +37 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserAccountSubscriber.js +18 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +18 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts +52 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/bulkAccountLoader.js +51 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts +9 -2
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts.map +1 -1
- package/lib/node/accounts/bulkUserStatsSubscription.js +9 -2
- package/lib/node/accounts/bulkUserSubscription.d.ts +8 -2
- package/lib/node/accounts/bulkUserSubscription.d.ts.map +1 -1
- package/lib/node/accounts/bulkUserSubscription.js +8 -2
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.js +37 -0
- package/lib/node/accounts/fetch.d.ts +59 -2
- package/lib/node/accounts/fetch.d.ts.map +1 -1
- package/lib/node/accounts/fetch.js +57 -2
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcAccountSubscriber.js +30 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +118 -37
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +40 -12
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +33 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +15 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserAccountSubscriber.js +15 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +15 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +34 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +34 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +21 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +22 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +32 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +22 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
- package/lib/node/accounts/testBulkAccountLoader.d.ts +8 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/testBulkAccountLoader.js +8 -0
- package/lib/node/accounts/types.d.ts +149 -0
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/types.js +13 -0
- package/lib/node/accounts/utils.d.ts +18 -0
- package/lib/node/accounts/utils.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +32 -16
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +41 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +41 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +31 -23
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +36 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +26 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +33 -0
- package/lib/node/addresses/marketAddresses.d.ts +10 -0
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
- package/lib/node/addresses/marketAddresses.js +10 -0
- package/lib/node/addresses/pda.d.ts +214 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +217 -5
- package/lib/node/adminClient.d.ts +2136 -4
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +2150 -4
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
- package/lib/node/auctionSubscriber/index.d.ts +6 -0
- package/lib/node/auctionSubscriber/index.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/index.js +6 -0
- package/lib/node/auctionSubscriber/types.d.ts +7 -0
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +33 -0
- package/lib/node/blockhashSubscriber/index.d.ts +5 -0
- package/lib/node/blockhashSubscriber/index.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/index.js +5 -0
- package/lib/node/blockhashSubscriber/types.d.ts +5 -0
- package/lib/node/blockhashSubscriber/types.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.d.ts +24 -0
- package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.js +22 -0
- package/lib/node/config.d.ts +58 -4
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +88 -21
- package/lib/node/constants/numericConstants.d.ts +67 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +68 -1
- package/lib/node/constants/perpMarkets.d.ts +10 -0
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +40 -908
- package/lib/node/constants/spotMarkets.d.ts +13 -0
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +16 -742
- package/lib/node/constants/txConstants.d.ts +1 -0
- package/lib/node/constants/txConstants.d.ts.map +1 -1
- package/lib/node/constants/txConstants.js +1 -0
- package/lib/node/core/VelocityCore.d.ts +285 -8
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +281 -8
- package/lib/node/core/instructions/deposit.d.ts +22 -0
- package/lib/node/core/instructions/deposit.d.ts.map +1 -1
- package/lib/node/core/instructions/deposit.js +22 -0
- package/lib/node/core/instructions/fill.d.ts +17 -0
- package/lib/node/core/instructions/fill.d.ts.map +1 -1
- package/lib/node/core/instructions/fill.js +17 -0
- package/lib/node/core/instructions/funding.d.ts +12 -0
- package/lib/node/core/instructions/funding.d.ts.map +1 -1
- package/lib/node/core/instructions/funding.js +12 -0
- package/lib/node/core/instructions/liquidation.d.ts +18 -0
- package/lib/node/core/instructions/liquidation.d.ts.map +1 -1
- package/lib/node/core/instructions/liquidation.js +18 -0
- package/lib/node/core/instructions/orders.d.ts +28 -0
- package/lib/node/core/instructions/orders.d.ts.map +1 -1
- package/lib/node/core/instructions/orders.js +28 -0
- package/lib/node/core/instructions/perpOrders.d.ts +106 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
- package/lib/node/core/instructions/perpOrders.js +106 -0
- package/lib/node/core/instructions/settlement.d.ts +14 -0
- package/lib/node/core/instructions/settlement.d.ts.map +1 -1
- package/lib/node/core/instructions/settlement.js +14 -0
- package/lib/node/core/instructions/trigger.d.ts +15 -0
- package/lib/node/core/instructions/trigger.d.ts.map +1 -1
- package/lib/node/core/instructions/trigger.js +15 -0
- package/lib/node/core/instructions/withdraw.d.ts +21 -0
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/core/instructions/withdraw.js +21 -0
- package/lib/node/core/remainingAccounts.d.ts +47 -3
- package/lib/node/core/remainingAccounts.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.js +20 -0
- package/lib/node/core/signedMsg.d.ts +38 -0
- package/lib/node/core/signedMsg.d.ts.map +1 -1
- package/lib/node/core/signedMsg.js +33 -0
- package/lib/node/decode/customCoder.d.ts +39 -3
- package/lib/node/decode/customCoder.d.ts.map +1 -1
- package/lib/node/decode/customCoder.js +45 -3
- package/lib/node/decode/user.d.ts +22 -0
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +22 -0
- package/lib/node/dlob/DLOB.d.ts +502 -53
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +540 -98
- package/lib/node/dlob/DLOBNode.d.ts +86 -4
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +37 -4
- package/lib/node/dlob/DLOBSubscriber.d.ts +39 -12
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +42 -12
- package/lib/node/dlob/NodeList.d.ts +69 -0
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.js +66 -0
- package/lib/node/dlob/orderBookLevels.d.ts +106 -13
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +84 -14
- package/lib/node/dlob/types.d.ts +15 -0
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/events/eventList.d.ts +14 -0
- package/lib/node/events/eventList.d.ts.map +1 -1
- package/lib/node/events/eventList.js +14 -0
- package/lib/node/events/eventSubscriber.d.ts +87 -10
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +93 -8
- package/lib/node/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
- package/lib/node/events/eventsServerLogProvider.js +27 -0
- package/lib/node/events/fetchLogs.d.ts +31 -0
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.js +46 -1
- package/lib/node/events/parse.d.ts +23 -0
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/events/parse.js +23 -0
- package/lib/node/events/pollingLogProvider.d.ts +24 -0
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
- package/lib/node/events/pollingLogProvider.js +24 -0
- package/lib/node/events/sort.d.ts +11 -0
- package/lib/node/events/sort.d.ts.map +1 -1
- package/lib/node/events/sort.js +12 -0
- package/lib/node/events/txEventCache.d.ts +13 -3
- package/lib/node/events/txEventCache.d.ts.map +1 -1
- package/lib/node/events/txEventCache.js +19 -7
- package/lib/node/events/types.d.ts +118 -2
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +11 -0
- package/lib/node/events/webSocketLogProvider.d.ts +23 -0
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
- package/lib/node/events/webSocketLogProvider.js +28 -0
- package/lib/node/factory/oracleClient.js +2 -2
- package/lib/node/idl/velocity.d.ts +4 -4
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +4 -4
- package/lib/node/keypair.d.ts +8 -0
- package/lib/node/keypair.d.ts.map +1 -1
- package/lib/node/keypair.js +8 -0
- package/lib/node/marginCalculation.d.ts +134 -2
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marginCalculation.js +121 -0
- package/lib/node/math/amm.d.ts +348 -29
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +310 -32
- package/lib/node/math/auction.d.ts +95 -19
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +118 -28
- package/lib/node/math/bankruptcy.d.ts +46 -0
- package/lib/node/math/bankruptcy.d.ts.map +1 -1
- package/lib/node/math/bankruptcy.js +89 -1
- package/lib/node/math/builder.d.ts +64 -8
- package/lib/node/math/builder.d.ts.map +1 -1
- package/lib/node/math/builder.js +71 -9
- package/lib/node/math/conversion.d.ts +21 -0
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/conversion.js +21 -0
- package/lib/node/math/exchangeStatus.d.ts +91 -0
- package/lib/node/math/exchangeStatus.d.ts.map +1 -1
- package/lib/node/math/exchangeStatus.js +106 -3
- package/lib/node/math/funding.d.ts +57 -20
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +63 -23
- package/lib/node/math/insurance.d.ts +62 -0
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +62 -0
- package/lib/node/math/liquidation.d.ts +127 -11
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/liquidation.js +182 -19
- package/lib/node/math/margin.d.ts +79 -13
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +80 -14
- package/lib/node/math/market.d.ts +135 -15
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +145 -17
- package/lib/node/math/oracles.d.ts +113 -0
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +118 -1
- package/lib/node/math/orders.d.ts +115 -10
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +130 -19
- package/lib/node/math/position.d.ts +80 -33
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +80 -33
- package/lib/node/math/repeg.d.ts +48 -10
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/repeg.js +48 -10
- package/lib/node/math/spotBalance.d.ts +200 -5
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +239 -10
- package/lib/node/math/spotMarket.d.ts +36 -3
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +36 -3
- package/lib/node/math/spotPosition.d.ts +72 -0
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/spotPosition.js +62 -0
- package/lib/node/math/state.d.ts +31 -0
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/state.js +31 -0
- package/lib/node/math/superStake.d.ts +126 -2
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +123 -3
- package/lib/node/math/tiers.d.ts +29 -0
- package/lib/node/math/tiers.d.ts.map +1 -1
- package/lib/node/math/tiers.js +29 -0
- package/lib/node/math/trade.d.ts +102 -51
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +101 -55
- package/lib/node/math/utils.d.ts +71 -9
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/math/utils.js +71 -9
- package/lib/node/memcmp.d.ts +94 -0
- package/lib/node/memcmp.d.ts.map +1 -1
- package/lib/node/memcmp.js +103 -2
- package/lib/node/oracles/oracleClientCache.d.ts +16 -0
- package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
- package/lib/node/oracles/oracleClientCache.js +16 -0
- package/lib/node/oracles/oracleId.d.ts +31 -0
- package/lib/node/oracles/oracleId.d.ts.map +1 -1
- package/lib/node/oracles/oracleId.js +39 -8
- package/lib/node/oracles/prelaunchOracleClient.d.ts +20 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +20 -0
- package/lib/node/oracles/pythClient.d.ts +31 -0
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.js +32 -1
- package/lib/node/oracles/pythLazerClient.d.ts +34 -0
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +35 -1
- package/lib/node/oracles/quoteAssetOracleClient.d.ts +18 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/quoteAssetOracleClient.js +18 -0
- package/lib/node/oracles/strictOraclePrice.d.ts +21 -0
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/strictOraclePrice.js +21 -0
- package/lib/node/oracles/types.d.ts +45 -0
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +20 -0
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/oracles/utils.js +20 -0
- package/lib/node/orderParams.d.ts +42 -4
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderParams.js +42 -4
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +56 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +56 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts +11 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/PollingSubscription.js +11 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +18 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/WebsocketSubscription.js +18 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts +16 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +16 -0
- package/lib/node/orderSubscriber/types.d.ts +9 -0
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/averageOverSlotsStrategy.js +1 -0
- package/lib/node/priorityFee/averageStrategy.d.ts +1 -0
- package/lib/node/priorityFee/averageStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/averageStrategy.js +1 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts +10 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/ewmaStrategy.js +10 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/heliusPriorityFeeMethod.js +9 -2
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/maxOverSlotsStrategy.js +1 -0
- package/lib/node/priorityFee/maxStrategy.d.ts +1 -0
- package/lib/node/priorityFee/maxStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/maxStrategy.js +1 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +39 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +39 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +21 -2
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/solanaPriorityFeeMethod.js +10 -0
- package/lib/node/priorityFee/types.d.ts +32 -0
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/types.js +5 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.js +8 -0
- package/lib/node/slot/SlotSubscriber.d.ts +18 -0
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.js +16 -0
- package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlothashSubscriber.js +25 -1
- package/lib/node/tx/baseTxSender.d.ts +163 -0
- package/lib/node/tx/baseTxSender.d.ts.map +1 -1
- package/lib/node/tx/baseTxSender.js +174 -6
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts.map +1 -1
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts.map +1 -1
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.d.ts +47 -0
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.js +48 -1
- package/lib/node/tx/forwardOnlyTxSender.d.ts +48 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -1
- package/lib/node/tx/forwardOnlyTxSender.js +48 -0
- package/lib/node/tx/reportTransactionError.d.ts +18 -6
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
- package/lib/node/tx/reportTransactionError.js +18 -6
- package/lib/node/tx/retryTxSender.d.ts +40 -0
- package/lib/node/tx/retryTxSender.d.ts.map +1 -1
- package/lib/node/tx/retryTxSender.js +39 -0
- package/lib/node/tx/txHandler.d.ts +146 -35
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +132 -32
- package/lib/node/tx/txParamProcessor.d.ts +47 -0
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
- package/lib/node/tx/txParamProcessor.js +47 -0
- package/lib/node/tx/types.d.ts +46 -0
- package/lib/node/tx/types.d.ts.map +1 -1
- package/lib/node/tx/types.js +5 -0
- package/lib/node/tx/utils.d.ts +26 -0
- package/lib/node/tx/utils.d.ts.map +1 -1
- package/lib/node/tx/utils.js +26 -0
- package/lib/node/tx/whileValidTxSender.d.ts +82 -0
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.js +81 -0
- package/lib/node/types.d.ts +781 -13
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +126 -9
- package/lib/node/user.d.ts +645 -84
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +779 -96
- package/lib/node/userMap/PollingSubscription.d.ts +10 -0
- package/lib/node/userMap/PollingSubscription.d.ts.map +1 -1
- package/lib/node/userMap/PollingSubscription.js +14 -2
- package/lib/node/userMap/WebsocketSubscription.d.ts +9 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/userMap/WebsocketSubscription.js +9 -0
- package/lib/node/userMap/grpcSubscription.d.ts +8 -0
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
- package/lib/node/userMap/grpcSubscription.js +8 -0
- package/lib/node/userMap/referrerMap.d.ts +72 -2
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +84 -2
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +37 -10
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +38 -11
- package/lib/node/userMap/userMap.d.ts +81 -3
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +81 -4
- package/lib/node/userMap/userMapConfig.d.ts +23 -0
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +22 -0
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +22 -0
- package/lib/node/userName.d.ts +16 -0
- package/lib/node/userName.d.ts.map +1 -1
- package/lib/node/userName.js +16 -0
- package/lib/node/userStats.d.ts +28 -1
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +28 -1
- package/lib/node/util/TransactionConfirmationManager.d.ts +33 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
- package/lib/node/util/TransactionConfirmationManager.js +33 -0
- package/lib/node/util/chainClock.d.ts +24 -0
- package/lib/node/util/chainClock.d.ts.map +1 -1
- package/lib/node/util/chainClock.js +20 -0
- package/lib/node/util/computeUnits.d.ts +32 -0
- package/lib/node/util/computeUnits.d.ts.map +1 -1
- package/lib/node/util/computeUnits.js +32 -0
- package/lib/node/util/digest.d.ts +17 -0
- package/lib/node/util/digest.d.ts.map +1 -1
- package/lib/node/util/digest.js +17 -0
- package/lib/node/util/ed25519Utils.d.ts +12 -2
- package/lib/node/util/ed25519Utils.d.ts.map +1 -1
- package/lib/node/util/ed25519Utils.js +12 -2
- package/lib/node/util/promiseTimeout.d.ts +9 -0
- package/lib/node/util/promiseTimeout.d.ts.map +1 -1
- package/lib/node/util/promiseTimeout.js +9 -0
- package/lib/node/velocityClient.d.ts +3322 -215
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +3412 -245
- package/lib/node/wallet.d.ts +37 -0
- package/lib/node/wallet.d.ts.map +1 -1
- package/lib/node/wallet.js +37 -0
- package/package.json +2 -1
- package/src/accounts/basicUserAccountSubscriber.ts +18 -0
- package/src/accounts/basicUserStatsAccountSubscriber.ts +18 -0
- package/src/accounts/bulkAccountLoader.ts +52 -0
- package/src/accounts/bulkUserStatsSubscription.ts +9 -2
- package/src/accounts/bulkUserSubscription.ts +8 -2
- package/src/accounts/customizedCadenceBulkAccountLoader.ts +37 -0
- package/src/accounts/fetch.ts +59 -2
- package/src/accounts/grpcAccountSubscriber.ts +30 -0
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +16 -0
- package/src/accounts/grpcMultiAccountSubscriber.ts +121 -38
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +49 -11
- package/src/accounts/grpcProgramAccountSubscriber.ts +33 -0
- package/src/accounts/grpcUserAccountSubscriber.ts +15 -0
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +15 -0
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +41 -0
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +160 -1
- package/src/accounts/laserProgramAccountSubscriber.ts +34 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +19 -0
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +19 -0
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +31 -0
- package/src/accounts/pollingOracleAccountSubscriber.ts +21 -2
- package/src/accounts/pollingTokenAccountSubscriber.ts +22 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +32 -0
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +22 -0
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +84 -1
- package/src/accounts/testBulkAccountLoader.ts +8 -0
- package/src/accounts/types.ts +149 -0
- package/src/accounts/utils.ts +42 -24
- package/src/accounts/webSocketAccountSubscriber.ts +41 -0
- package/src/accounts/webSocketAccountSubscriberV2.ts +31 -23
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +27 -0
- package/src/accounts/webSocketProgramAccountSubscriber.ts +36 -0
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +26 -0
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +21 -0
- package/src/accounts/webSocketUserAccountSubscriber.ts +26 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +20 -0
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +127 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +110 -0
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +33 -0
- package/src/addresses/marketAddresses.ts +10 -0
- package/src/addresses/pda.ts +228 -12
- package/src/adminClient.ts +2156 -4
- package/src/auctionSubscriber/auctionSubscriber.ts +15 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +19 -0
- package/src/auctionSubscriber/index.ts +6 -0
- package/src/auctionSubscriber/types.ts +7 -0
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +33 -0
- package/src/blockhashSubscriber/index.ts +5 -0
- package/src/blockhashSubscriber/types.ts +5 -4
- package/src/clock/clockSubscriber.ts +24 -0
- package/src/config.ts +109 -22
- package/src/constants/numericConstants.ts +70 -0
- package/src/constants/perpMarkets.ts +45 -960
- package/src/constants/spotMarkets.ts +23 -793
- package/src/constants/txConstants.ts +1 -0
- package/src/core/VelocityCore.ts +286 -8
- package/src/core/instructions/deposit.ts +22 -0
- package/src/core/instructions/fill.ts +17 -0
- package/src/core/instructions/funding.ts +12 -0
- package/src/core/instructions/liquidation.ts +18 -0
- package/src/core/instructions/orders.ts +28 -0
- package/src/core/instructions/perpOrders.ts +106 -0
- package/src/core/instructions/settlement.ts +14 -0
- package/src/core/instructions/trigger.ts +15 -0
- package/src/core/instructions/withdraw.ts +21 -0
- package/src/core/remainingAccounts.ts +47 -3
- package/src/core/signedMsg.ts +38 -0
- package/src/decode/customCoder.ts +46 -3
- package/src/decode/user.ts +22 -0
- package/src/dlob/DLOB.ts +668 -97
- package/src/dlob/DLOBNode.ts +98 -6
- package/src/dlob/DLOBSubscriber.ts +49 -12
- package/src/dlob/NodeList.ts +69 -0
- package/src/dlob/orderBookLevels.ts +108 -14
- package/src/dlob/types.ts +15 -0
- package/src/events/eventList.ts +14 -0
- package/src/events/eventSubscriber.ts +100 -19
- package/src/events/eventsServerLogProvider.ts +28 -0
- package/src/events/fetchLogs.ts +52 -2
- package/src/events/parse.ts +23 -0
- package/src/events/pollingLogProvider.ts +24 -0
- package/src/events/sort.ts +12 -0
- package/src/events/txEventCache.ts +19 -7
- package/src/events/types.ts +131 -11
- package/src/events/webSocketLogProvider.ts +29 -0
- package/src/factory/oracleClient.ts +2 -2
- package/src/idl/velocity.json +4 -4
- package/src/idl/velocity.ts +4 -4
- package/src/keypair.ts +8 -0
- package/src/marginCalculation.ts +153 -2
- package/src/math/amm.ts +371 -36
- package/src/math/auction.ts +139 -30
- package/src/math/bankruptcy.ts +104 -1
- package/src/math/builder.ts +74 -8
- package/src/math/conversion.ts +21 -0
- package/src/math/exchangeStatus.ts +117 -2
- package/src/math/funding.ts +63 -23
- package/src/math/insurance.ts +62 -0
- package/src/math/liquidation.ts +227 -17
- package/src/math/margin.ts +80 -14
- package/src/math/market.ts +148 -17
- package/src/math/oracles.ts +124 -0
- package/src/math/orders.ts +141 -19
- package/src/math/position.ts +80 -33
- package/src/math/repeg.ts +48 -10
- package/src/math/spotBalance.ts +252 -12
- package/src/math/spotMarket.ts +36 -3
- package/src/math/spotPosition.ts +72 -0
- package/src/math/state.ts +31 -0
- package/src/math/superStake.ts +126 -3
- package/src/math/tiers.ts +29 -0
- package/src/math/trade.ts +125 -55
- package/src/math/utils.ts +71 -9
- package/src/memcmp.ts +104 -2
- package/src/oracles/oracleClientCache.ts +16 -0
- package/src/oracles/oracleId.ts +39 -6
- package/src/oracles/prelaunchOracleClient.ts +20 -0
- package/src/oracles/pythClient.ts +32 -1
- package/src/oracles/pythLazerClient.ts +35 -1
- package/src/oracles/quoteAssetOracleClient.ts +18 -0
- package/src/oracles/strictOraclePrice.ts +21 -0
- package/src/oracles/types.ts +45 -0
- package/src/oracles/utils.ts +20 -0
- package/src/orderParams.ts +42 -4
- package/src/orderSubscriber/OrderSubscriber.ts +56 -0
- package/src/orderSubscriber/PollingSubscription.ts +11 -0
- package/src/orderSubscriber/WebsocketSubscription.ts +18 -0
- package/src/orderSubscriber/grpcSubscription.ts +16 -0
- package/src/orderSubscriber/types.ts +9 -0
- package/src/priorityFee/averageOverSlotsStrategy.ts +1 -0
- package/src/priorityFee/averageStrategy.ts +1 -0
- package/src/priorityFee/ewmaStrategy.ts +10 -0
- package/src/priorityFee/heliusPriorityFeeMethod.ts +13 -2
- package/src/priorityFee/maxOverSlotsStrategy.ts +1 -0
- package/src/priorityFee/maxStrategy.ts +1 -0
- package/src/priorityFee/priorityFeeSubscriber.ts +39 -0
- package/src/priorityFee/priorityFeeSubscriberMap.ts +21 -2
- package/src/priorityFee/solanaPriorityFeeMethod.ts +12 -0
- package/src/priorityFee/types.ts +33 -15
- package/src/priorityFee/velocityPriorityFeeMethod.ts +11 -0
- package/src/slot/SlotSubscriber.ts +18 -0
- package/src/slot/SlothashSubscriber.ts +27 -1
- package/src/tx/baseTxSender.ts +185 -5
- package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +12 -0
- package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +15 -0
- package/src/tx/blockhashFetcher/types.ts +4 -0
- package/src/tx/fastSingleTxSender.ts +58 -4
- package/src/tx/forwardOnlyTxSender.ts +48 -0
- package/src/tx/reportTransactionError.ts +18 -6
- package/src/tx/retryTxSender.ts +40 -0
- package/src/tx/txHandler.ts +146 -35
- package/src/tx/txParamProcessor.ts +47 -0
- package/src/tx/types.ts +46 -0
- package/src/tx/utils.ts +26 -0
- package/src/tx/whileValidTxSender.ts +82 -0
- package/src/types.ts +777 -24
- package/src/user.ts +869 -110
- package/src/userMap/PollingSubscription.ts +16 -2
- package/src/userMap/WebsocketSubscription.ts +9 -0
- package/src/userMap/grpcSubscription.ts +8 -0
- package/src/userMap/referrerMap.ts +92 -3
- package/src/userMap/revenueShareEscrowMap.ts +38 -11
- package/src/userMap/userMap.ts +82 -4
- package/src/userMap/userMapConfig.ts +23 -10
- package/src/userMap/userStatsMap.ts +22 -0
- package/src/userName.ts +16 -0
- package/src/userStats.ts +28 -1
- package/src/util/TransactionConfirmationManager.ts +33 -0
- package/src/util/chainClock.ts +24 -0
- package/src/util/computeUnits.ts +32 -0
- package/src/util/digest.ts +17 -0
- package/src/util/ed25519Utils.ts +12 -2
- package/src/util/promiseTimeout.ts +9 -0
- package/src/velocityClient.ts +3439 -249
- package/src/wallet.ts +37 -0
- package/tests/VelocityCore/builder_escrow.test.ts +121 -0
- package/tests/amm/test.ts +102 -0
- package/tests/builder/builderFee.test.ts +42 -0
- package/tests/dlob/tickSizeStandardization.ts +545 -0
- package/tests/exchangeStatus/test.ts +45 -0
- package/tests/liquidation/test.ts +125 -0
- package/tests/oracles/mmOracleGate.test.ts +379 -0
- package/tests/oracles/pythPegSnap.test.ts +76 -0
- package/tests/sdkParity/enumParity.test.ts +84 -0
- package/tests/sdkParity/marginCategoryFill.test.ts +143 -0
- package/tests/sdkParity/memcmpOffsets.test.ts +139 -0
- package/tests/spot/test.ts +55 -0
- package/tests/user/bankruptcy.ts +165 -0
- package/tests/user/feeAndWithdrawLimits.ts +284 -0
- package/tests/user/getMarginCalculation.ts +226 -1
- package/tests/user/test.ts +8 -4
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* - Manages the program account subscription lifecycle (markets, oracles, user accounts).
|
|
11
11
|
* - Provides oracle price reads, market config lookups, and PDA derivation helpers.
|
|
12
12
|
*
|
|
13
|
-
* Admin operations (market init, fee updates, oracle config) live in
|
|
14
|
-
* Read-only user account queries (margin, positions, PnL) live in
|
|
13
|
+
* Admin operations (market init, fee updates, oracle config) live in `AdminClient` (adminClient.ts).
|
|
14
|
+
* Read-only user account queries (margin, positions, PnL) live in `User` (user.ts).
|
|
15
15
|
*
|
|
16
16
|
* Instruction → on-chain handler mapping: see ARCHITECTURE.md § SDK↔Instruction Mapping.
|
|
17
17
|
*/
|
|
@@ -48,7 +48,22 @@ export type SwapClient = TitanClient | JupiterClient;
|
|
|
48
48
|
type RemainingAccountParams = import('./core/remainingAccounts').RemainingAccountParams;
|
|
49
49
|
/**
|
|
50
50
|
* # VelocityClient
|
|
51
|
-
*
|
|
51
|
+
* Main entry point for interacting with Velocity Exchange from TypeScript. A single instance wraps
|
|
52
|
+
* one `authority` wallet (optionally trading on behalf of multiple sub-accounts via
|
|
53
|
+
* `authoritySubAccountMap`, or as a delegate via `includeDelegates`) and owns:
|
|
54
|
+
* - the Anchor `program` handle and RPC `connection`/`provider`,
|
|
55
|
+
* - the account subscription (`accountSubscriber`) that streams State, PerpMarket, SpotMarket,
|
|
56
|
+
* and oracle accounts (websocket, polling, or grpc — selected via `VelocityClientConfig.accountSubscription`),
|
|
57
|
+
* - the set of loaded `User` / `UserStats` objects for this authority's sub-accounts,
|
|
58
|
+
* - the `txSender` / `txHandler` used to build, sign, and send every instruction the class exposes.
|
|
59
|
+
*
|
|
60
|
+
* Most instruction-building methods come in pairs: `doThing(...)` builds the instruction(s), wraps
|
|
61
|
+
* them in a transaction, signs, sends, and confirms; `getDoThingIx(...)` (or `getDoThingIxs(...)`)
|
|
62
|
+
* only builds and returns the raw `TransactionInstruction`(s) for callers composing their own
|
|
63
|
+
* transaction (e.g. bundling several instructions, or using a custom `txParams`/lookup-table setup).
|
|
64
|
+
*
|
|
65
|
+
* Almost every account-touching method requires `subscribe()` to have resolved and the target
|
|
66
|
+
* sub-account's `User` to be loaded first — see `subscribe`, `addUser`, `switchActiveUser`.
|
|
52
67
|
*/
|
|
53
68
|
export declare class VelocityClient {
|
|
54
69
|
connection: Connection;
|
|
@@ -83,95 +98,307 @@ export declare class VelocityClient {
|
|
|
83
98
|
txParams: TxParams;
|
|
84
99
|
enableMetricsEvents?: boolean;
|
|
85
100
|
txHandler: TxHandler;
|
|
101
|
+
/**
|
|
102
|
+
* Whether this client has completed `subscribe()` and its underlying `accountSubscriber` is
|
|
103
|
+
* still actively streaming account updates. Most account-reading and instruction-building
|
|
104
|
+
* methods assume this is `true`; call `subscribe()` first if it is `false`.
|
|
105
|
+
*/
|
|
86
106
|
get isSubscribed(): boolean;
|
|
87
107
|
private getPrePlaceOrderIxs;
|
|
108
|
+
/**
|
|
109
|
+
* Overrides the internal subscribed flag directly, without touching `accountSubscriber`. Intended
|
|
110
|
+
* for advanced/test callers managing subscription state manually; regular callers should use
|
|
111
|
+
* `subscribe()` / `unsubscribe()` instead.
|
|
112
|
+
* @param val - New value for the internal subscribed flag.
|
|
113
|
+
*/
|
|
88
114
|
set isSubscribed(val: boolean);
|
|
115
|
+
/**
|
|
116
|
+
* Constructs a `VelocityClient` from a `VelocityClientConfig`. Does not perform any network I/O —
|
|
117
|
+
* it wires up the Anchor `program`/`provider`, resolves the account-subscription strategy
|
|
118
|
+
* (websocket/polling/grpc), and constructs the `txSender`/`txHandler` used by every instruction
|
|
119
|
+
* method, but does not fetch or subscribe to any accounts. Call `subscribe()` afterwards before
|
|
120
|
+
* using the client.
|
|
121
|
+
*
|
|
122
|
+
* Config interplay of note:
|
|
123
|
+
* - `authority` defaults to `config.wallet.publicKey`; `activeSubAccountId` defaults to `0`.
|
|
124
|
+
* - Exactly one of `includeDelegates`, `subAccountIds`, or `authoritySubAccountMap` may be set —
|
|
125
|
+
* passing more than one throws. `subAccountIds` is shorthand for
|
|
126
|
+
* `authoritySubAccountMap = { [authority]: subAccountIds }`.
|
|
127
|
+
* - `txVersion` defaults based on whether `config.wallet` supports versioned transactions.
|
|
128
|
+
* - `txParams.computeUnits` defaults to `600_000` and `computeUnitsPrice` to `0` (no priority fee)
|
|
129
|
+
* when not provided.
|
|
130
|
+
* - `config.accountSubscription.type` selects `PollingVelocityClientAccountSubscriber`,
|
|
131
|
+
* a grpc subscriber, or (default) `WebSocketVelocityClientAccountSubscriber`.
|
|
132
|
+
* - `config.userStats` (default falsy) additionally constructs a `UserStats` instance for the
|
|
133
|
+
* authority.
|
|
134
|
+
* - `config.marketLookupTables` defaults to the lookup tables from `configs[env]` for the
|
|
135
|
+
* resolved `env` (default `'mainnet-beta'`).
|
|
136
|
+
* @param config - Client configuration; see `VelocityClientConfig` (velocityClientConfig.ts).
|
|
137
|
+
* @throws if more than one of `includeDelegates`/`subAccountIds`/`authoritySubAccountMap` is set.
|
|
138
|
+
*/
|
|
89
139
|
constructor(config: VelocityClientConfig);
|
|
140
|
+
/**
|
|
141
|
+
* Builds the internal `Map` key used to index `this.users` for a given sub-account/authority pair.
|
|
142
|
+
* @param subAccountId - Sub-account id.
|
|
143
|
+
* @param authority - Owning (or delegated) authority public key for the sub-account.
|
|
144
|
+
* @returns A string key of the form `"<subAccountId>_<authority>"`.
|
|
145
|
+
*/
|
|
90
146
|
getUserMapKey(subAccountId: number, authority: PublicKey): string;
|
|
147
|
+
/**
|
|
148
|
+
* Constructs (but does not subscribe) a `User` for the given sub-account/authority.
|
|
149
|
+
* @param subAccountId - Sub-account id to derive the user account PDA for.
|
|
150
|
+
* @param accountSubscriptionConfig - Subscription strategy to use for the new `User`.
|
|
151
|
+
* @param authority - Authority owning the sub-account; defaults to `this.authority`.
|
|
152
|
+
* @returns An unsubscribed `User` instance.
|
|
153
|
+
*/
|
|
91
154
|
createUser(subAccountId: number, accountSubscriptionConfig: UserSubscriptionConfig, authority?: PublicKey): User;
|
|
155
|
+
/**
|
|
156
|
+
* Subscribes the client to on-chain state: loads and subscribes to the sub-account(s) implied by
|
|
157
|
+
* the constructor/`updateWallet` config (`addAndSubscribeToUsers`), subscribes the `accountSubscriber`
|
|
158
|
+
* (State, PerpMarket, SpotMarket, oracle accounts), and, if `userStats` was configured, subscribes
|
|
159
|
+
* it too. Must be called (and resolve `true`) before using most other methods on this class.
|
|
160
|
+
* @returns `true` if every subscription succeeded; `false` if any failed. Also updates `isSubscribed`.
|
|
161
|
+
*/
|
|
92
162
|
subscribe(): Promise<boolean>;
|
|
163
|
+
/**
|
|
164
|
+
* Subscribes every currently-loaded `User` in `this.users`. Does not add new users or subscribe
|
|
165
|
+
* `accountSubscriber`/`userStats` — see `subscribe()` for full client subscription.
|
|
166
|
+
* @returns One subscribe promise per loaded user, resolving to that user's subscribe success.
|
|
167
|
+
*/
|
|
93
168
|
subscribeUsers(): Promise<boolean>[];
|
|
94
169
|
/**
|
|
95
|
-
*
|
|
170
|
+
* Forces every loaded `User`, the `accountSubscriber`, and (if present) `userStats` to fetch fresh
|
|
171
|
+
* account data from RPC immediately, bypassing the normal websocket/polling cadence. Useful in
|
|
172
|
+
* tests (e.g. local validator) where a just-landed transaction's effects need to be visible
|
|
173
|
+
* without waiting for the next update.
|
|
96
174
|
*/
|
|
97
175
|
fetchAccounts(): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Unsubscribes all loaded users, the `accountSubscriber`, and (if present) `userStats`, and sets
|
|
178
|
+
* `isSubscribed` to `false`. Does not clear `this.users` — the `User` objects remain but stop
|
|
179
|
+
* receiving updates until re-subscribed.
|
|
180
|
+
*/
|
|
98
181
|
unsubscribe(): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Unsubscribes every currently-loaded `User` in `this.users` without clearing the map or touching
|
|
184
|
+
* `accountSubscriber`/`userStats`.
|
|
185
|
+
* @returns One unsubscribe promise per loaded user.
|
|
186
|
+
*/
|
|
99
187
|
unsubscribeUsers(): Promise<void>[];
|
|
100
188
|
statePublicKey?: PublicKey;
|
|
189
|
+
/**
|
|
190
|
+
* Returns the `State` account PDA for this program, computing and caching it on first call.
|
|
191
|
+
* @returns The `State` account public key.
|
|
192
|
+
*/
|
|
101
193
|
getStatePublicKey(): Promise<PublicKey>;
|
|
102
194
|
signerPublicKey?: PublicKey;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the program's PDA signer (used as the authority for vault CPIs), computing and caching
|
|
197
|
+
* it on first call. Synchronous — the signer PDA has no seeds that require an on-chain lookup.
|
|
198
|
+
* @returns The velocity signer public key.
|
|
199
|
+
*/
|
|
103
200
|
getSignerPublicKey(): PublicKey;
|
|
201
|
+
/**
|
|
202
|
+
* Returns the last account-subscriber-cached `State` account. Does not hit RPC.
|
|
203
|
+
* @returns The current `StateAccount` snapshot.
|
|
204
|
+
* @throws if `subscribe()` has not been called (or the state account has never loaded).
|
|
205
|
+
*/
|
|
104
206
|
getStateAccount(): StateAccount;
|
|
105
207
|
/**
|
|
106
|
-
*
|
|
208
|
+
* Like `getStateAccount` but forces a fresh RPC fetch first. Useful for anchor tests where an
|
|
209
|
+
* update needs to be observed immediately rather than waiting for the next subscription push.
|
|
210
|
+
* @returns The freshly-fetched `StateAccount`.
|
|
107
211
|
*/
|
|
108
212
|
forceGetStateAccount(): Promise<StateAccount>;
|
|
213
|
+
/**
|
|
214
|
+
* Returns the last account-subscriber-cached `PerpMarketAccount` for a market index. Does not hit
|
|
215
|
+
* RPC. The market must be one of the indexes/lookup-tables this client subscribed to.
|
|
216
|
+
* @param marketIndex - Perp market index.
|
|
217
|
+
* @returns The cached `PerpMarketAccount`, or `undefined` if not loaded/subscribed.
|
|
218
|
+
*/
|
|
109
219
|
getPerpMarketAccount(marketIndex: number): PerpMarketAccount | undefined;
|
|
110
220
|
/**
|
|
111
|
-
* Like
|
|
221
|
+
* Like `getPerpMarketAccount` but throws if the market is not loaded,
|
|
112
222
|
* for call sites that require a guaranteed account.
|
|
223
|
+
* @param marketIndex - Perp market index.
|
|
224
|
+
* @returns The cached `PerpMarketAccount`.
|
|
225
|
+
* @throws if the market is not loaded.
|
|
113
226
|
*/
|
|
114
227
|
getPerpMarketAccountOrThrow(marketIndex: number): PerpMarketAccount;
|
|
115
228
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
229
|
+
* Like `getPerpMarketAccount` but forces a fresh RPC fetch, retrying up to 10 times (one fetch per
|
|
230
|
+
* attempt) until the market account appears. Useful in anchor tests right after
|
|
231
|
+
* `initializePerpMarket` where the market may not yet be visible to the subscriber.
|
|
232
|
+
* @param marketIndex - Perp market index.
|
|
233
|
+
* @returns The `PerpMarketAccount`, or `undefined` if still not found after 10 attempts.
|
|
118
234
|
*/
|
|
119
235
|
forceGetPerpMarketAccount(marketIndex: number): Promise<PerpMarketAccount | undefined>;
|
|
236
|
+
/**
|
|
237
|
+
* Returns all currently-loaded `PerpMarketAccount`s (does not hit RPC).
|
|
238
|
+
* @returns Array of loaded perp market accounts, in subscriber order.
|
|
239
|
+
*/
|
|
120
240
|
getPerpMarketAccounts(): PerpMarketAccount[];
|
|
241
|
+
/**
|
|
242
|
+
* Returns the last account-subscriber-cached `SpotMarketAccount` for a market index. Does not hit
|
|
243
|
+
* RPC.
|
|
244
|
+
* @param marketIndex - Spot market index.
|
|
245
|
+
* @returns The cached `SpotMarketAccount`, or `undefined` if not loaded/subscribed.
|
|
246
|
+
*/
|
|
121
247
|
getSpotMarketAccount(marketIndex: number): SpotMarketAccount | undefined;
|
|
122
248
|
/**
|
|
123
|
-
* Like
|
|
249
|
+
* Like `getSpotMarketAccount` but throws if the market is not loaded,
|
|
124
250
|
* for call sites that require a guaranteed account.
|
|
251
|
+
* @param marketIndex - Spot market index.
|
|
252
|
+
* @returns The cached `SpotMarketAccount`.
|
|
253
|
+
* @throws if the market is not loaded.
|
|
125
254
|
*/
|
|
126
255
|
getSpotMarketAccountOrThrow(marketIndex: number): SpotMarketAccount;
|
|
127
256
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
257
|
+
* Like `getSpotMarketAccount` but forces a fresh RPC fetch first. Useful for anchor tests where an
|
|
258
|
+
* update needs to be observed immediately.
|
|
259
|
+
* @param marketIndex - Spot market index.
|
|
260
|
+
* @returns The freshly-fetched `SpotMarketAccount`, or `undefined` if not found.
|
|
130
261
|
*/
|
|
131
262
|
forceGetSpotMarketAccount(marketIndex: number): Promise<SpotMarketAccount | undefined>;
|
|
263
|
+
/**
|
|
264
|
+
* Returns all currently-loaded `SpotMarketAccount`s (does not hit RPC).
|
|
265
|
+
* @returns Array of loaded spot market accounts, in subscriber order.
|
|
266
|
+
*/
|
|
132
267
|
getSpotMarketAccounts(): SpotMarketAccount[];
|
|
268
|
+
/**
|
|
269
|
+
* Convenience accessor for the quote spot market (`QUOTE_SPOT_MARKET_INDEX`, always index 0), i.e.
|
|
270
|
+
* the USDC market used to denominate collateral/PnL across the protocol.
|
|
271
|
+
* @returns The quote `SpotMarketAccount`.
|
|
272
|
+
* @throws if the quote spot market is not loaded.
|
|
273
|
+
*/
|
|
133
274
|
getQuoteSpotMarketAccount(): SpotMarketAccount;
|
|
275
|
+
/**
|
|
276
|
+
* Returns the last subscriber-cached oracle price data for a given oracle account/source. Does not
|
|
277
|
+
* hit RPC.
|
|
278
|
+
* @param oraclePublicKey - Oracle account public key.
|
|
279
|
+
* @param oracleSource - Oracle protocol/feed variant (Pyth, Pyth Lazer, Switchboard, etc.) that
|
|
280
|
+
* determines how the account is decoded.
|
|
281
|
+
* @returns The cached oracle price data and the slot it was observed at, or `undefined` if this
|
|
282
|
+
* oracle isn't subscribed.
|
|
283
|
+
*/
|
|
134
284
|
getOraclePriceDataAndSlot(oraclePublicKey: PublicKey, oracleSource: OracleSource): DataAndSlot<OraclePriceData> | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* Fetches and caches the `AddressLookupTableAccount`s for `this.marketLookupTables`, so
|
|
287
|
+
* transaction builders can include them to shrink versioned-transaction size. Subsequent calls
|
|
288
|
+
* return the cached result.
|
|
289
|
+
* @returns The resolved lookup table accounts (entries that don't exist on-chain are filtered out).
|
|
290
|
+
*/
|
|
135
291
|
fetchAllLookupTableAccounts(): Promise<AddressLookupTableAccount[]>;
|
|
136
292
|
private getTxVersionForNewWallet;
|
|
137
293
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
294
|
+
* Swaps the wallet/authority this client transacts and subscribes as, rebuilding the Anchor
|
|
295
|
+
* `provider`/`program`, `txSender`, `txHandler`, `userStats`, and (if already subscribed) every
|
|
296
|
+
* loaded `User` for the new authority. Use this instead of constructing a new `VelocityClient` when
|
|
297
|
+
* a UI wallet-adapter connection changes.
|
|
298
|
+
*
|
|
299
|
+
* At most one of `includeDelegates`, `subAccountIds`, or `authoritySubaccountMap` may be passed
|
|
300
|
+
* (mirrors the constructor's mutual-exclusion rule); `subAccountIds` is shorthand for
|
|
301
|
+
* `authoritySubaccountMap = { [newWallet.publicKey]: subAccountIds }`.
|
|
302
|
+
* @param newWallet - Wallet to switch to; becomes the new `authority`.
|
|
303
|
+
* @param subAccountIds - Sub-account ids to load for `newWallet`'s authority. Mutually exclusive
|
|
304
|
+
* with `includeDelegates` and `authoritySubaccountMap`.
|
|
305
|
+
* @param activeSubAccountId - Sub-account id to make active after the switch.
|
|
306
|
+
* @param includeDelegates - If `true`, load every sub-account this wallet is a delegate for, in
|
|
307
|
+
* addition to sub-accounts it owns directly. Mutually exclusive with `subAccountIds` and
|
|
308
|
+
* `authoritySubaccountMap`.
|
|
309
|
+
* @param authoritySubaccountMap - Explicit map of authority (as string) to sub-account ids to load,
|
|
310
|
+
* for managing multiple authorities from one wallet. Mutually exclusive with `subAccountIds` and
|
|
311
|
+
* `includeDelegates`.
|
|
312
|
+
* @returns `true` if re-subscribing users (when previously subscribed) succeeded; otherwise `false`.
|
|
313
|
+
* @throws if more than one of `includeDelegates`/`subAccountIds`/`authoritySubaccountMap` is set.
|
|
143
314
|
*/
|
|
144
315
|
updateWallet(newWallet: IWallet, subAccountIds?: number[], activeSubAccountId?: number, includeDelegates?: boolean, authoritySubaccountMap?: Map<string, number[]>): Promise<boolean>;
|
|
145
316
|
/**
|
|
146
317
|
* Update the subscribed accounts to a given authority, while leaving the
|
|
147
318
|
* connected wallet intact. This allows a user to emulate another user's
|
|
148
319
|
* account on the UI and sign permissionless transactions with their own wallet.
|
|
149
|
-
*
|
|
320
|
+
*
|
|
321
|
+
* `authority` is repointed to `emulateAuthority` and `includeDelegates` is forced to `true`, but the
|
|
322
|
+
* connected `wallet` (and thus its signing key) is unchanged — instructions that require the
|
|
323
|
+
* emulated authority's own signature (e.g. deposits from its wallet) will still fail; only actions
|
|
324
|
+
* the connected wallet is independently authorized for (e.g. as a delegate, or read-only views)
|
|
325
|
+
* will succeed.
|
|
326
|
+
* @param emulateAuthority - Authority public key to view/act as.
|
|
327
|
+
* @returns `true` if re-subscribing users (when previously subscribed) succeeded; otherwise `false`.
|
|
150
328
|
*/
|
|
151
329
|
emulateAccount(emulateAuthority: PublicKey): Promise<boolean>;
|
|
330
|
+
/**
|
|
331
|
+
* Sets the client's `activeSubAccountId`/`authority` (the sub-account used by default when a
|
|
332
|
+
* method's `subAccountId` param is omitted). If `authority` changes, re-derives and re-subscribes
|
|
333
|
+
* `userStats` for the new authority (assumed unnecessary when only the sub-account id changes for
|
|
334
|
+
* the same authority). Does not load or subscribe the target `User` itself — call `addUser` first
|
|
335
|
+
* if it isn't already loaded.
|
|
336
|
+
* @param subAccountId - Sub-account id to make active.
|
|
337
|
+
* @param authority - Authority to switch to; defaults to the current `this.authority` (no change).
|
|
338
|
+
*/
|
|
152
339
|
switchActiveUser(subAccountId: number, authority?: PublicKey): Promise<void>;
|
|
340
|
+
/**
|
|
341
|
+
* Loads and subscribes a `User` for a sub-account, adding it to `this.users`. If a subscribed
|
|
342
|
+
* `User` for this sub-account/authority is already loaded, returns `true` immediately without
|
|
343
|
+
* re-subscribing.
|
|
344
|
+
* @param subAccountId - Sub-account id to load.
|
|
345
|
+
* @param authority - Authority owning the sub-account; defaults to `this.authority`.
|
|
346
|
+
* @param userAccount - Optional pre-fetched `UserAccount` data to seed the subscription with,
|
|
347
|
+
* avoiding an extra RPC round-trip (e.g. when the caller already has it from a prior fetch).
|
|
348
|
+
* @returns `true` if the user was already loaded or subscribed successfully; `false` if
|
|
349
|
+
* subscription failed (e.g. the on-chain user account doesn't exist).
|
|
350
|
+
*/
|
|
153
351
|
addUser(subAccountId: number, authority?: PublicKey, userAccount?: UserAccount): Promise<boolean>;
|
|
154
352
|
/**
|
|
155
353
|
* Adds and subscribes to users based on params set by the constructor or by updateWallet.
|
|
354
|
+
*
|
|
355
|
+
* If `authoritySubAccountMap` is non-empty, loads exactly the (authority, subAccountId) pairs it
|
|
356
|
+
* lists. Otherwise fetches every on-chain `UserAccount` owned by `authority` (defaulting to
|
|
357
|
+
* `this.wallet.publicKey`), plus (when `includeDelegates` is `true`) every account this authority
|
|
358
|
+
* is a delegate for, and loads all of them. If `activeSubAccountId` is not already set, the first
|
|
359
|
+
* loaded account becomes active. A no-op returning `true` if `skipLoadUsers` is set (e.g. no real
|
|
360
|
+
* wallet configured).
|
|
361
|
+
* @param authority - Authority to load accounts for; defaults to `this.wallet.publicKey`. Ignored
|
|
362
|
+
* when `authoritySubAccountMap` is set (its keys are used instead).
|
|
363
|
+
* @returns `true` if every implied user loaded/subscribed successfully.
|
|
156
364
|
*/
|
|
157
365
|
addAndSubscribeToUsers(authority?: PublicKey): Promise<boolean>;
|
|
158
366
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* @
|
|
367
|
+
* Builds the instructions to initialize a user (sub-account) for `this.authority`, without sending
|
|
368
|
+
* a transaction. For `subAccountId === 0`, also prepends `initializeUserStats` if the authority's
|
|
369
|
+
* `UserStats` account doesn't already exist on-chain (every authority needs exactly one, created
|
|
370
|
+
* alongside its first sub-account).
|
|
371
|
+
* @param subAccountId - Sub-account id to create; defaults to `0`. Must not already exist.
|
|
372
|
+
* @param name - Display name (max 32 bytes, UTF-8), stored on-chain. Defaults to `DEFAULT_USER_NAME`
|
|
373
|
+
* for sub-account 0, or `"Subaccount {subAccountId + 1}"` otherwise.
|
|
374
|
+
* @param referrerInfo - Referrer's `referrer`/`referrerStats` public keys to attribute this account
|
|
375
|
+
* to a referrer at creation time (fee-share eligibility); omit if there is no referrer.
|
|
376
|
+
* @param poolId - If provided, appends an instruction to set the sub-account's isolated pool id
|
|
377
|
+
* after creation.
|
|
378
|
+
* @returns A tuple of `[instructions, userAccountPublicKey]` — the caller is responsible for
|
|
379
|
+
* building/sending the transaction.
|
|
164
380
|
*/
|
|
165
381
|
getInitializeUserAccountIxs(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, poolId?: number): Promise<[TransactionInstruction[], PublicKey]>;
|
|
166
382
|
/**
|
|
167
|
-
* Initializes a user account
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* @param
|
|
171
|
-
* @param
|
|
172
|
-
* @
|
|
383
|
+
* Initializes a new user (sub-account) for `this.authority` on-chain, then loads and subscribes it
|
|
384
|
+
* into `this.users` via `addUser`. See `getInitializeUserAccountIxs` for parameter semantics and
|
|
385
|
+
* the implicit `UserStats` creation for `subAccountId === 0`.
|
|
386
|
+
* @param subAccountId - Sub-account id to create; defaults to `0`.
|
|
387
|
+
* @param name - Display name (max 32 bytes); see `getInitializeUserAccountIxs` for the default.
|
|
388
|
+
* @param referrerInfo - Referrer's `referrer`/`referrerStats` public keys, if attributing this
|
|
389
|
+
* account to a referrer.
|
|
390
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
391
|
+
* @returns A tuple of `[transactionSignature, userAccountPublicKey]`.
|
|
173
392
|
*/
|
|
174
393
|
initializeUserAccount(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
394
|
+
/**
|
|
395
|
+
* Builds the `initializeUserStats` instruction for `this.authority`. Every authority needs exactly
|
|
396
|
+
* one `UserStats` account (created automatically by `getInitializeUserAccountIxs`/
|
|
397
|
+
* `initializeUserAccount` alongside sub-account 0 if missing); call this directly only when
|
|
398
|
+
* building a custom initialization flow.
|
|
399
|
+
* @param overrides.externalWallet - Pays for account creation instead of `this.wallet`, if set.
|
|
400
|
+
* @returns The `initializeUserStats` instruction.
|
|
401
|
+
*/
|
|
175
402
|
getInitializeUserStatsIx(overrides?: {
|
|
176
403
|
/**
|
|
177
404
|
* Optional external wallet to use as payer. If provided, this wallet will pay
|
|
@@ -179,7 +406,25 @@ export declare class VelocityClient {
|
|
|
179
406
|
*/
|
|
180
407
|
externalWallet?: PublicKey;
|
|
181
408
|
}): Promise<TransactionInstruction>;
|
|
409
|
+
/**
|
|
410
|
+
* Initializes the `SignedMsgUserOrders` account for `authority`, which caches recently-submitted
|
|
411
|
+
* off-chain signed (SignedMsg / "swift") order messages so keepers can look them up and verify
|
|
412
|
+
* duplicates on-chain. Required once per authority before that authority's signed-message orders
|
|
413
|
+
* can be placed.
|
|
414
|
+
* @param authority - Authority the account is created for.
|
|
415
|
+
* @param numOrders - Number of order-message slots to allocate; determines account rent/size.
|
|
416
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
417
|
+
* @returns A tuple of `[transactionSignature, signedMsgUserAccountPublicKey]`.
|
|
418
|
+
*/
|
|
182
419
|
initializeSignedMsgUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
420
|
+
/**
|
|
421
|
+
* Builds the `initializeSignedMsgUserOrders` instruction. See `initializeSignedMsgUserOrders` for
|
|
422
|
+
* semantics.
|
|
423
|
+
* @param authority - Authority the account is created for.
|
|
424
|
+
* @param numOrders - Number of order-message slots to allocate.
|
|
425
|
+
* @param overrides.externalWallet - Pays for account creation instead of `this.wallet`, if set.
|
|
426
|
+
* @returns A tuple of `[signedMsgUserAccountPublicKey, instruction]`.
|
|
427
|
+
*/
|
|
183
428
|
getInitializeSignedMsgUserOrdersAccountIx(authority: PublicKey, numOrders: number, overrides?: {
|
|
184
429
|
/**
|
|
185
430
|
* Optional external wallet to use as payer. If provided, this wallet will pay
|
|
@@ -187,102 +432,483 @@ export declare class VelocityClient {
|
|
|
187
432
|
*/
|
|
188
433
|
externalWallet?: PublicKey;
|
|
189
434
|
}): Promise<[PublicKey, TransactionInstruction]>;
|
|
435
|
+
/**
|
|
436
|
+
* Grows an existing `SignedMsgUserOrders` account to hold more order-message slots. The program
|
|
437
|
+
* only allows growing, never shrinking.
|
|
438
|
+
* @param authority - Authority whose account is resized.
|
|
439
|
+
* @param numOrders - New (larger) number of order-message slots.
|
|
440
|
+
* @param userSubaccountId - Sub-account id used to derive the `user` account passed to the
|
|
441
|
+
* instruction; defaults to `0`.
|
|
442
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
443
|
+
* @returns The transaction signature.
|
|
444
|
+
*/
|
|
190
445
|
resizeSignedMsgUserOrders(authority: PublicKey, numOrders: number, userSubaccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
446
|
+
/**
|
|
447
|
+
* Builds the `resizeSignedMsgUserOrders` instruction. See `resizeSignedMsgUserOrders` for
|
|
448
|
+
* semantics.
|
|
449
|
+
* @param authority - Authority whose account is resized.
|
|
450
|
+
* @param numOrders - New (larger) number of order-message slots.
|
|
451
|
+
* @param userSubaccountId - Sub-account id used to derive the `user` account; defaults to `0`.
|
|
452
|
+
* @returns The resize instruction.
|
|
453
|
+
*/
|
|
191
454
|
getResizeSignedMsgUserOrdersInstruction(authority: PublicKey, numOrders: number, userSubaccountId?: number): Promise<TransactionInstruction>;
|
|
455
|
+
/**
|
|
456
|
+
* Initializes `authority`'s `SignedMsgWsDelegates` account, which lists wallets authorized to
|
|
457
|
+
* co-sign/relay that authority's signed-message ("swift") orders over a websocket connection
|
|
458
|
+
* without holding general trading authority.
|
|
459
|
+
* @param authority - Authority the delegates account is created for.
|
|
460
|
+
* @param delegates - Initial set of delegate public keys; defaults to an empty list.
|
|
461
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
462
|
+
* @returns The transaction signature.
|
|
463
|
+
*/
|
|
192
464
|
initializeSignedMsgWsDelegatesAccount(authority: PublicKey, delegates?: PublicKey[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
465
|
+
/**
|
|
466
|
+
* Builds the `initializeSignedMsgWsDelegates` instruction. See
|
|
467
|
+
* `initializeSignedMsgWsDelegatesAccount` for semantics.
|
|
468
|
+
* @param authority - Authority the delegates account is created for.
|
|
469
|
+
* @param delegates - Initial set of delegate public keys; defaults to an empty list.
|
|
470
|
+
* @returns The initialize instruction.
|
|
471
|
+
*/
|
|
193
472
|
getInitializeSignedMsgWsDelegatesAccountIx(authority: PublicKey, delegates?: PublicKey[]): Promise<TransactionInstruction>;
|
|
473
|
+
/**
|
|
474
|
+
* Initializes the per-authority `RevenueShare` account, which accumulates that authority's
|
|
475
|
+
* lifetime referrer and builder fee-share rewards. One per authority (not per sub-account); an
|
|
476
|
+
* authority must have this before it can earn referrer or builder revenue share.
|
|
477
|
+
* @param authority - Authority the account is created for.
|
|
478
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
479
|
+
* @returns The transaction signature.
|
|
480
|
+
*/
|
|
194
481
|
initializeRevenueShare(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
482
|
+
/**
|
|
483
|
+
* Builds the `initializeRevenueShare` instruction. See `initializeRevenueShare` for semantics.
|
|
484
|
+
* @param authority - Authority the account is created for.
|
|
485
|
+
* @param overrides.payer - Pays for account creation instead of `this.wallet`, if set.
|
|
486
|
+
* @returns The initialize instruction.
|
|
487
|
+
*/
|
|
195
488
|
getInitializeRevenueShareIx(authority: PublicKey, overrides?: {
|
|
196
489
|
payer?: PublicKey;
|
|
197
490
|
}): Promise<TransactionInstruction>;
|
|
491
|
+
/**
|
|
492
|
+
* Initializes `authority`'s `RevenueShareEscrow` account — the per-user account that tracks
|
|
493
|
+
* pending builder-fee orders and the list of builders this user has approved (`approvedBuilders`),
|
|
494
|
+
* required to place orders carrying a builder fee. On creation, `escrow.referrer` is copied from
|
|
495
|
+
* the authority's existing `UserStats.referrer`, if any.
|
|
496
|
+
* @param authority - Authority the escrow is created for.
|
|
497
|
+
* @param numOrders - Number of pending-order slots to allocate; determines account rent/size. Can
|
|
498
|
+
* be grown later with `resizeRevenueShareEscrowOrders` (never shrunk).
|
|
499
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
500
|
+
* @returns The transaction signature.
|
|
501
|
+
*/
|
|
198
502
|
initializeRevenueShareEscrow(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
503
|
+
/**
|
|
504
|
+
* Builds the `initializeRevenueShareEscrow` instruction. See `initializeRevenueShareEscrow` for
|
|
505
|
+
* semantics.
|
|
506
|
+
* @param authority - Authority the escrow is created for.
|
|
507
|
+
* @param numOrders - Number of pending-order slots to allocate.
|
|
508
|
+
* @param overrides.payer - Pays for account creation instead of `this.wallet`, if set.
|
|
509
|
+
* @returns The initialize instruction.
|
|
510
|
+
*/
|
|
199
511
|
getInitializeRevenueShareEscrowIx(authority: PublicKey, numOrders: number, overrides?: {
|
|
200
512
|
payer?: PublicKey;
|
|
201
513
|
}): Promise<TransactionInstruction>;
|
|
514
|
+
/**
|
|
515
|
+
* Grows `authority`'s `RevenueShareEscrow` order slots. On-chain rejects `numOrders` smaller than
|
|
516
|
+
* the current slot count (shrinking is not supported).
|
|
517
|
+
* @param authority - Authority whose escrow is resized.
|
|
518
|
+
* @param numOrders - New (larger or equal) number of pending-order slots.
|
|
519
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
520
|
+
* @returns The transaction signature.
|
|
521
|
+
* @throws (on-chain `InvalidRevenueShareResize`) if `numOrders` is less than the current slot count.
|
|
522
|
+
*/
|
|
202
523
|
resizeRevenueShareEscrowOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
524
|
+
/**
|
|
525
|
+
* Builds the `resizeRevenueShareEscrowOrders` instruction. See `resizeRevenueShareEscrowOrders` for
|
|
526
|
+
* semantics.
|
|
527
|
+
* @param authority - Authority whose escrow is resized.
|
|
528
|
+
* @param numOrders - New (larger or equal) number of pending-order slots.
|
|
529
|
+
* @returns The resize instruction.
|
|
530
|
+
*/
|
|
203
531
|
getResizeRevenueShareEscrowOrdersIx(authority: PublicKey, numOrders: number): Promise<TransactionInstruction>;
|
|
204
532
|
/**
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
533
|
+
* Adds, updates, or revokes an approved builder in the caller's own `RevenueShareEscrow`
|
|
534
|
+
* (`this.wallet.publicKey` unless `overrides.authority` is set on the underlying ix). This is the
|
|
535
|
+
* *user's* opt-in that lets `builder` attach a builder fee (capped at `maxFeeTenthBps`) to orders
|
|
536
|
+
* this user places — it does not itself submit any order. `maxFeeTenthBps` is in tenths of a basis
|
|
537
|
+
* point (1 unit = 0.001%, i.e. `10_000` tenth-bps = 1%).
|
|
538
|
+
* @param builder - The public key of the builder to add or update. Must differ from the escrow's
|
|
539
|
+
* own authority.
|
|
540
|
+
* @param maxFeeTenthBps - The maximum fee, in tenths of a basis point, the builder may charge.
|
|
210
541
|
* @param add - Whether to add or update the builder. If the builder already exists, `add = true` will update the `maxFeeTenthBps`, otherwise it will add the builder. If `add = false`, the builder's `maxFeeTenthBps` will be set to 0.
|
|
211
542
|
* @param txParams - The transaction parameters to use for the transaction.
|
|
212
543
|
* @returns The transaction to add or update an approved builder.
|
|
544
|
+
* @throws (on-chain `CannotRevokeBuilderWithOpenOrders`) if `add` is `false` and the builder has
|
|
545
|
+
* open (unsettled) orders outstanding — those must be cancelled/settled first.
|
|
213
546
|
*/
|
|
214
547
|
changeApprovedBuilder(builder: PublicKey, maxFeeTenthBps: number, add: boolean, txParams?: TxParams): Promise<TransactionSignature>;
|
|
215
548
|
/**
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
549
|
+
* Builds the `changeApprovedBuilder` instruction. See `changeApprovedBuilder` for semantics; unlike
|
|
550
|
+
* the wrapper, `overrides.authority` lets you target an escrow other than the connected wallet's.
|
|
219
551
|
* @param builder - The public key of the builder to add or update.
|
|
220
|
-
* @param maxFeeTenthBps - The maximum fee
|
|
552
|
+
* @param maxFeeTenthBps - The maximum fee, in tenths of a basis point (1 unit = 0.001%).
|
|
221
553
|
* @param add - Whether to add or update the builder. If the builder already exists, `add = true` will update the `maxFeeTenthBps`, otherwise it will add the builder. If `add = false`, the builder's `maxFeeTenthBps` will be set to 0.
|
|
554
|
+
* @param overrides.authority - Escrow authority to target; defaults to `this.wallet.publicKey`.
|
|
555
|
+
* @param overrides.payer - Pays for any account resize instead of `this.wallet`, if set.
|
|
222
556
|
* @returns The transaction instruction to add or update an approved builder.
|
|
223
557
|
*/
|
|
224
558
|
getChangeApprovedBuilderIx(builder: PublicKey, maxFeeTenthBps: number, add: boolean, overrides?: {
|
|
225
559
|
authority?: PublicKey;
|
|
226
560
|
payer?: PublicKey;
|
|
227
561
|
}): Promise<TransactionInstruction>;
|
|
562
|
+
/**
|
|
563
|
+
* Authorizes `delegate` on `authority`'s existing `SignedMsgWsDelegates` account (must already be
|
|
564
|
+
* initialized via `initializeSignedMsgWsDelegatesAccount`). Signed by `this.wallet.publicKey`,
|
|
565
|
+
* which must be `authority`.
|
|
566
|
+
* @param authority - Authority whose delegates list is updated.
|
|
567
|
+
* @param delegate - Delegate public key to authorize.
|
|
568
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
569
|
+
* @returns The transaction signature.
|
|
570
|
+
*/
|
|
228
571
|
addSignedMsgWsDelegate(authority: PublicKey, delegate: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
572
|
+
/**
|
|
573
|
+
* Builds the `changeSignedMsgWsDelegateStatus` instruction with `add = true`. See
|
|
574
|
+
* `addSignedMsgWsDelegate` for semantics.
|
|
575
|
+
* @param authority - Authority whose delegates list is updated.
|
|
576
|
+
* @param delegate - Delegate public key to authorize.
|
|
577
|
+
* @returns The instruction.
|
|
578
|
+
*/
|
|
229
579
|
getAddSignedMsgWsDelegateIx(authority: PublicKey, delegate: PublicKey): Promise<TransactionInstruction>;
|
|
580
|
+
/**
|
|
581
|
+
* Revokes `delegate`'s authorization on `authority`'s `SignedMsgWsDelegates` account. Signed by
|
|
582
|
+
* `this.wallet.publicKey`, which must be `authority`.
|
|
583
|
+
* @param authority - Authority whose delegates list is updated.
|
|
584
|
+
* @param delegate - Delegate public key to revoke.
|
|
585
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
586
|
+
* @returns The transaction signature.
|
|
587
|
+
*/
|
|
230
588
|
removeSignedMsgWsDelegate(authority: PublicKey, delegate: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
589
|
+
/**
|
|
590
|
+
* Builds the `changeSignedMsgWsDelegateStatus` instruction with `add = false`. See
|
|
591
|
+
* `removeSignedMsgWsDelegate` for semantics.
|
|
592
|
+
* @param authority - Authority whose delegates list is updated.
|
|
593
|
+
* @param delegate - Delegate public key to revoke.
|
|
594
|
+
* @returns The instruction.
|
|
595
|
+
*/
|
|
231
596
|
getRemoveSignedMsgWsDelegateIx(authority: PublicKey, delegate: PublicKey): Promise<TransactionInstruction>;
|
|
232
597
|
private getInitializeUserInstructions;
|
|
598
|
+
/**
|
|
599
|
+
* Returns the sub-account id that would be assigned to the next sub-account created for
|
|
600
|
+
* `this.wallet.publicKey` (i.e. `UserStats.numberOfSubAccountsCreated`, which increments on every
|
|
601
|
+
* `initializeUser` and never reuses ids after `deleteUser`). Prefers the already-loaded `userStats`
|
|
602
|
+
* subscription; falls back to an RPC fetch if it isn't loaded or has no cached account yet.
|
|
603
|
+
* @returns The next sub-account id to be created.
|
|
604
|
+
* @throws if no `UserStats` account exists on-chain for `this.wallet.publicKey` (i.e. sub-account 0
|
|
605
|
+
* has never been initialized).
|
|
606
|
+
*/
|
|
233
607
|
getNextSubAccountId(): Promise<number>;
|
|
608
|
+
/**
|
|
609
|
+
* Registers `this.wallet`'s sub-account 0 as a referrer under a human-readable `name`, creating a
|
|
610
|
+
* `ReferrerNameAccount` PDA keyed by that name. Other users can then look up this authority's
|
|
611
|
+
* `referrer`/`referrerStats` public keys by name (see `getReferrerNameAccountsForAuthority`) when
|
|
612
|
+
* passing `referrerInfo` to `initializeUserAccount`. Fails if the name is already taken (PDA
|
|
613
|
+
* already initialized).
|
|
614
|
+
* @param name - Referrer name to register (encoded/truncated the same way as user names).
|
|
615
|
+
* @returns The transaction signature.
|
|
616
|
+
*/
|
|
234
617
|
initializeReferrerName(name: string): Promise<TransactionSignature>;
|
|
618
|
+
/**
|
|
619
|
+
* Updates the display name stored on a sub-account. Signed by `this.wallet.publicKey`, which must
|
|
620
|
+
* be the sub-account's authority.
|
|
621
|
+
* @param name - New display name (max 32 bytes, UTF-8).
|
|
622
|
+
* @param subAccountId - Sub-account id to rename; defaults to `0`.
|
|
623
|
+
* @returns The transaction signature.
|
|
624
|
+
*/
|
|
235
625
|
updateUserName(name: string, subAccountId?: number): Promise<TransactionSignature>;
|
|
626
|
+
/**
|
|
627
|
+
* Sets a per-sub-account custom (higher) minimum margin ratio for one or more sub-accounts in a
|
|
628
|
+
* single transaction, self-imposing a lower max leverage than the market default. Signed by
|
|
629
|
+
* `this.wallet.publicKey` for each sub-account's authority.
|
|
630
|
+
* @param updates - List of `{ marginRatio, subAccountId }` updates to apply.
|
|
631
|
+
* `marginRatio` is in `MARGIN_PRECISION` (1e4 = 100%), e.g. `2000` = 20% margin ratio = 5x max
|
|
632
|
+
* leverage.
|
|
633
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
634
|
+
* @returns The transaction signature.
|
|
635
|
+
*/
|
|
236
636
|
updateUserCustomMarginRatio(updates: {
|
|
237
637
|
marginRatio: number;
|
|
238
638
|
subAccountId: number;
|
|
239
639
|
}[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
640
|
+
/**
|
|
641
|
+
* Builds the `updateUserCustomMarginRatio` instruction for a single sub-account. As a side effect,
|
|
642
|
+
* ensures the target sub-account is loaded via `addUser` before building the instruction. See
|
|
643
|
+
* `updateUserCustomMarginRatio` for unit/semantics.
|
|
644
|
+
* @param marginRatio - Minimum margin ratio, in `MARGIN_PRECISION` (1e4 = 100%).
|
|
645
|
+
* @param subAccountId - Sub-account id to update; defaults to `0`.
|
|
646
|
+
* @returns The instruction.
|
|
647
|
+
*/
|
|
240
648
|
getUpdateUserCustomMarginRatioIx(marginRatio: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
649
|
+
/**
|
|
650
|
+
* Builds the instruction to set a custom minimum margin ratio for a single open perp position
|
|
651
|
+
* (rather than the whole sub-account), letting a position use different effective max leverage than
|
|
652
|
+
* the sub-account default. Used internally by `getPrePlaceOrderIxs` to implement per-order
|
|
653
|
+
* `positionMaxLev`.
|
|
654
|
+
* @param perpMarketIndex - Perp market index of the position to constrain.
|
|
655
|
+
* @param marginRatio - Minimum margin ratio for this position, in `MARGIN_PRECISION` (1e4 = 100%).
|
|
656
|
+
* @param subAccountId - Sub-account id owning the position; defaults to `0`.
|
|
657
|
+
* @param overrides.userAccountPublicKey - Explicit user account PDA, skipping derivation.
|
|
658
|
+
* @param overrides.authority - Authority to derive the user account PDA for if
|
|
659
|
+
* `userAccountPublicKey` isn't given; defaults to `this.authority`.
|
|
660
|
+
* @param overrides.signingAuthority - Signer passed to the instruction; defaults to
|
|
661
|
+
* `this.wallet.publicKey`.
|
|
662
|
+
* @returns The instruction.
|
|
663
|
+
*/
|
|
241
664
|
getUpdateUserPerpPositionCustomMarginRatioIx(perpMarketIndex: number, marginRatio: number, subAccountId?: number, overrides?: {
|
|
242
665
|
userAccountPublicKey?: PublicKey;
|
|
243
666
|
authority?: PublicKey;
|
|
244
667
|
signingAuthority?: PublicKey;
|
|
245
668
|
}): Promise<TransactionInstruction>;
|
|
669
|
+
/**
|
|
670
|
+
* Sends the instruction built by `getUpdateUserPerpPositionCustomMarginRatioIx`. See that method
|
|
671
|
+
* for semantics/units.
|
|
672
|
+
* @param perpMarketIndex - Perp market index of the position to constrain.
|
|
673
|
+
* @param marginRatio - Minimum margin ratio for this position, in `MARGIN_PRECISION` (1e4 = 100%).
|
|
674
|
+
* @param subAccountId - Sub-account id owning the position; defaults to `0`.
|
|
675
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
676
|
+
* @returns The transaction signature.
|
|
677
|
+
*/
|
|
246
678
|
updateUserPerpPositionCustomMarginRatio(perpMarketIndex: number, marginRatio: number, subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
679
|
+
/**
|
|
680
|
+
* Builds the instruction to toggle a sub-account's "margin trading enabled" flag, which permits
|
|
681
|
+
* borrowing against spot collateral (multiple simultaneous spot borrows / cross-margined spot). It
|
|
682
|
+
* is incompatible with holding a position in an `Isolated`-tier perp market — enabling it while
|
|
683
|
+
* such a position is open, or opening one while it's enabled, is rejected on-chain. As a side
|
|
684
|
+
* effect, ensures the target sub-account is loaded via `addUser`.
|
|
685
|
+
* @param marginTradingEnabled - New value for the flag.
|
|
686
|
+
* @param subAccountId - Sub-account id to update; defaults to `0`.
|
|
687
|
+
* @param userAccountPublicKey - Explicit user account PDA, skipping derivation from
|
|
688
|
+
* `this.wallet.publicKey`/`subAccountId`.
|
|
689
|
+
* @returns The instruction.
|
|
690
|
+
*/
|
|
247
691
|
getUpdateUserMarginTradingEnabledIx(marginTradingEnabled: boolean, subAccountId?: number, userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
692
|
+
/**
|
|
693
|
+
* Sends instructions built by `getUpdateUserMarginTradingEnabledIx` for one or more sub-accounts in
|
|
694
|
+
* a single transaction. See that method for semantics.
|
|
695
|
+
* @param updates - List of `{ marginTradingEnabled, subAccountId }` updates to apply.
|
|
696
|
+
* @returns The transaction signature.
|
|
697
|
+
*/
|
|
248
698
|
updateUserMarginTradingEnabled(updates: {
|
|
249
699
|
marginTradingEnabled: boolean;
|
|
250
700
|
subAccountId: number;
|
|
251
701
|
}[]): Promise<TransactionSignature>;
|
|
702
|
+
/**
|
|
703
|
+
* Builds the instruction to set (or clear, with `PublicKey.default`) the delegate authority on a
|
|
704
|
+
* sub-account. The delegate can sign most trading instructions (place/cancel orders, etc.) on the
|
|
705
|
+
* sub-account's behalf, but `withdraw` always requires the true owning `authority`'s own signature
|
|
706
|
+
* (delegates can never withdraw). A delegate-initiated internal transfer of the sub-account's
|
|
707
|
+
* collateral to another of the owner's sub-accounts is possible only via `transferDepositByDelegate`,
|
|
708
|
+
* and only once the owner has separately opted in via `updateUserAllowDelegateTransfer`.
|
|
709
|
+
* @param delegate - New delegate public key; pass `PublicKey.default` to remove the delegate.
|
|
710
|
+
* @param overrides.subAccountId - Sub-account id to update; defaults to `this.activeSubAccountId`.
|
|
711
|
+
* @param overrides.userAccountPublicKey - Explicit user account PDA, skipping derivation.
|
|
712
|
+
* @param overrides.authority - Signer for the instruction; defaults to `this.wallet.publicKey`.
|
|
713
|
+
* @returns The instruction.
|
|
714
|
+
*/
|
|
252
715
|
getUpdateUserDelegateIx(delegate: PublicKey, overrides: {
|
|
253
716
|
subAccountId?: number;
|
|
254
717
|
userAccountPublicKey?: PublicKey;
|
|
255
718
|
authority?: PublicKey;
|
|
256
719
|
}): Promise<TransactionInstruction>;
|
|
720
|
+
/**
|
|
721
|
+
* Sends the `updateUserDelegate` instruction for `this.wallet.publicKey`'s sub-account. See
|
|
722
|
+
* `getUpdateUserDelegateIx` for full semantics.
|
|
723
|
+
* @param delegate - New delegate public key; pass `PublicKey.default` to remove the delegate.
|
|
724
|
+
* @param subAccountId - Sub-account id to update; defaults to `0`.
|
|
725
|
+
* @returns The transaction signature.
|
|
726
|
+
*/
|
|
257
727
|
updateUserDelegate(delegate: PublicKey, subAccountId?: number): Promise<TransactionSignature>;
|
|
728
|
+
/**
|
|
729
|
+
* Builds the instruction to set the `allowDelegateTransfer` opt-in flag on `this.wallet.publicKey`'s
|
|
730
|
+
* `UserStats` account. This flag gates `transferDepositByDelegate` across *all* of this authority's
|
|
731
|
+
* sub-accounts — if it is `false` (the default), any delegate-initiated internal transfer attempt
|
|
732
|
+
* is rejected on-chain regardless of that sub-account's delegate. It does not affect direct
|
|
733
|
+
* deposits/withdrawals, which are unaffected by delegate status.
|
|
734
|
+
* @param allowDelegateTransfer - New value for the flag.
|
|
735
|
+
* @returns The instruction.
|
|
736
|
+
*/
|
|
258
737
|
getUpdateUserAllowDelegateTransferIx(allowDelegateTransfer: boolean): Promise<TransactionInstruction>;
|
|
738
|
+
/**
|
|
739
|
+
* Sends the instruction built by `getUpdateUserAllowDelegateTransferIx`. See that method for
|
|
740
|
+
* semantics.
|
|
741
|
+
* @param allowDelegateTransfer - New value for the flag.
|
|
742
|
+
* @returns The transaction signature.
|
|
743
|
+
*/
|
|
259
744
|
updateUserAllowDelegateTransfer(allowDelegateTransfer: boolean): Promise<TransactionSignature>;
|
|
745
|
+
/**
|
|
746
|
+
* Sends instructions built by `getUpdateAdvancedDlpIx` for one or more sub-accounts.
|
|
747
|
+
*
|
|
748
|
+
* **Currently non-functional**: the on-chain `update_user_advanced_lp` instruction handler is
|
|
749
|
+
* commented out of the program's Anchor `#[program]` module (see `programs/velocity/src/lib.rs`)
|
|
750
|
+
* and is absent from the generated IDL, so `program.instruction.updateUserAdvancedLp` does not
|
|
751
|
+
* exist and this call will throw at runtime until the instruction is re-enabled on-chain.
|
|
752
|
+
* @param updates - List of `{ advancedLp, subAccountId }` updates to apply.
|
|
753
|
+
* @returns The transaction signature.
|
|
754
|
+
* @throws always, until `update_user_advanced_lp` is re-enabled on-chain and regenerated into the IDL.
|
|
755
|
+
*/
|
|
260
756
|
updateUserAdvancedLp(updates: {
|
|
261
757
|
advancedLp: boolean;
|
|
262
758
|
subAccountId: number;
|
|
263
759
|
}[]): Promise<TransactionSignature>;
|
|
760
|
+
/**
|
|
761
|
+
* Builds the (currently unavailable — see `updateUserAdvancedLp`) `updateUserAdvancedLp`
|
|
762
|
+
* instruction, which would flag a sub-account as an "advanced LP" participant.
|
|
763
|
+
* @param advancedLp - New value for the flag.
|
|
764
|
+
* @param subAccountId - Sub-account id to update.
|
|
765
|
+
* @returns The instruction, if the on-chain ix existed.
|
|
766
|
+
* @throws always, since `program.instruction.updateUserAdvancedLp` is not defined in the current IDL.
|
|
767
|
+
*/
|
|
264
768
|
getUpdateAdvancedDlpIx(advancedLp: boolean, subAccountId: number): Promise<any>;
|
|
769
|
+
/**
|
|
770
|
+
* Sends instructions built by `getUpdateUserReduceOnlyIx` for one or more sub-accounts in a single
|
|
771
|
+
* transaction. See that method for semantics.
|
|
772
|
+
* @param updates - List of `{ reduceOnly, subAccountId }` updates to apply.
|
|
773
|
+
* @returns The transaction signature.
|
|
774
|
+
*/
|
|
265
775
|
updateUserReduceOnly(updates: {
|
|
266
776
|
reduceOnly: boolean;
|
|
267
777
|
subAccountId: number;
|
|
268
778
|
}[]): Promise<TransactionSignature>;
|
|
779
|
+
/**
|
|
780
|
+
* Builds the instruction to toggle a sub-account's reduce-only status. When reduce-only, orders on
|
|
781
|
+
* the sub-account may only decrease existing positions, never open or increase one.
|
|
782
|
+
* @param reduceOnly - New value for the flag.
|
|
783
|
+
* @param subAccountId - Sub-account id to update.
|
|
784
|
+
* @returns The instruction.
|
|
785
|
+
* @throws (on-chain `LiquidationsOngoing`) if the sub-account is currently being liquidated.
|
|
786
|
+
*/
|
|
269
787
|
getUpdateUserReduceOnlyIx(reduceOnly: boolean, subAccountId: number): Promise<TransactionInstruction>;
|
|
788
|
+
/**
|
|
789
|
+
* Sends instructions built by `getUpdateUserPoolIdIx` for one or more sub-accounts in a single
|
|
790
|
+
* transaction. See that method for semantics.
|
|
791
|
+
* @param updates - List of `{ poolId, subAccountId }` updates to apply.
|
|
792
|
+
* @returns The transaction signature.
|
|
793
|
+
*/
|
|
270
794
|
updateUserPoolId(updates: {
|
|
271
795
|
poolId: number;
|
|
272
796
|
subAccountId: number;
|
|
273
797
|
}[]): Promise<TransactionSignature>;
|
|
798
|
+
/**
|
|
799
|
+
* Builds the instruction to move a sub-account into a different isolated pool. On-chain,
|
|
800
|
+
* re-validates the sub-account still meets its initial margin requirement after the switch using
|
|
801
|
+
* only markets/oracles passed via `remaining_accounts` — the caller (this method doesn't add any)
|
|
802
|
+
* must supply those if the sub-account has open deposits/positions, or the ix will fail.
|
|
803
|
+
* @param poolId - New pool id for the sub-account.
|
|
804
|
+
* @param subAccountId - Sub-account id to update.
|
|
805
|
+
* @returns The instruction.
|
|
806
|
+
* @throws (on-chain) if the sub-account has deposits/positions in markets outside the new pool, or
|
|
807
|
+
* otherwise fails the initial margin check after the switch.
|
|
808
|
+
*/
|
|
274
809
|
getUpdateUserPoolIdIx(poolId: number, subAccountId: number): Promise<TransactionInstruction>;
|
|
810
|
+
/**
|
|
811
|
+
* Fetches every `User` account that exists on-chain for this program via `getProgramAccounts` (with
|
|
812
|
+
* a `memcmp` filter, not restricted to this client's authority). Expensive — intended for indexers/
|
|
813
|
+
* admin tooling, not per-trade calls.
|
|
814
|
+
* @param includeIdle - If `false`, filters out idle (inactive) user accounts server-side; defaults
|
|
815
|
+
* to `true` (return all).
|
|
816
|
+
* @returns All matching `User` program accounts with their addresses.
|
|
817
|
+
*/
|
|
275
818
|
fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>;
|
|
819
|
+
/**
|
|
820
|
+
* Fetches (via RPC `memcmp` filter, not the account subscriber) every on-chain `User` account whose
|
|
821
|
+
* `delegate` field equals `delegate`, i.e. every sub-account this wallet can trade on behalf of as a
|
|
822
|
+
* delegate.
|
|
823
|
+
* @param delegate - Delegate public key to search for.
|
|
824
|
+
* @returns Matching `UserAccount`s, sorted by `subAccountId` ascending.
|
|
825
|
+
*/
|
|
276
826
|
getUserAccountsForDelegate(delegate: PublicKey): Promise<UserAccount[]>;
|
|
827
|
+
/**
|
|
828
|
+
* Fetches (via RPC, not the account subscriber) every on-chain `User` account owned by `authority`,
|
|
829
|
+
* with each account's PDA address included.
|
|
830
|
+
* @param authority - Authority to search for.
|
|
831
|
+
* @returns Matching `UserAccount`s and their addresses, in RPC-returned order (not sorted).
|
|
832
|
+
*/
|
|
277
833
|
getUserAccountsAndAddressesForAuthority(authority: PublicKey): Promise<ProgramAccount<UserAccount>[]>;
|
|
834
|
+
/**
|
|
835
|
+
* Fetches (via RPC, not the account subscriber) every on-chain `User` account owned by `authority`.
|
|
836
|
+
* Used internally by `addAndSubscribeToUsers` to discover an authority's sub-accounts.
|
|
837
|
+
* @param authority - Authority to search for.
|
|
838
|
+
* @returns Matching `UserAccount`s, sorted by `subAccountId` ascending.
|
|
839
|
+
*/
|
|
278
840
|
getUserAccountsForAuthority(authority: PublicKey): Promise<UserAccount[]>;
|
|
841
|
+
/**
|
|
842
|
+
* Fetches (via RPC `memcmp` filter) every `UserStats` account whose `referrer` field equals
|
|
843
|
+
* `referrer`, i.e. every authority that was referred by this referrer.
|
|
844
|
+
* @param referrer - Referrer authority public key to search for.
|
|
845
|
+
* @returns Matching `UserStatsAccount`s, in RPC-returned order.
|
|
846
|
+
*/
|
|
279
847
|
getReferredUserStatsAccountsByReferrer(referrer: PublicKey): Promise<UserStatsAccount[]>;
|
|
848
|
+
/**
|
|
849
|
+
* Fetches (via RPC `memcmp` filter) every `ReferrerNameAccount` registered by `authority` via
|
|
850
|
+
* `initializeReferrerName`.
|
|
851
|
+
* @param authority - Authority to search for.
|
|
852
|
+
* @returns Matching `ReferrerNameAccount`s, in RPC-returned order.
|
|
853
|
+
*/
|
|
280
854
|
getReferrerNameAccountsForAuthority(authority: PublicKey): Promise<ReferrerNameAccount[]>;
|
|
855
|
+
/**
|
|
856
|
+
* Deletes a sub-account owned by `this.wallet.publicKey` and unsubscribes/removes it from
|
|
857
|
+
* `this.users`. On-chain requires the sub-account to be fully closed out: no open perp/spot
|
|
858
|
+
* positions, no open orders, not bankrupt, not being liquidated, and (unless idle) sub-account 0 of
|
|
859
|
+
* a referrer cannot be deleted at all. If the protocol charges a `maxInitializeUserFee` and the
|
|
860
|
+
* account's `UserStats` is younger than ~13 days, the sub-account must also be marked `idle`.
|
|
861
|
+
* @param subAccountId - Sub-account id to delete; defaults to `0`.
|
|
862
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
863
|
+
* @returns The transaction signature.
|
|
864
|
+
* @throws (on-chain `UserCantBeDeleted`) if any of the above preconditions aren't met.
|
|
865
|
+
*/
|
|
281
866
|
deleteUser(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
867
|
+
/**
|
|
868
|
+
* Builds the `deleteUser` instruction. See `deleteUser` for on-chain preconditions.
|
|
869
|
+
* @param userAccountPublicKey - User account PDA to delete.
|
|
870
|
+
* @returns The instruction.
|
|
871
|
+
*/
|
|
282
872
|
getUserDeletionIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
873
|
+
/**
|
|
874
|
+
* Keeper-only instruction: force-cancels all open orders and deletes/closes an inactive, near-zero
|
|
875
|
+
* equity user account, refunding remaining rent to `userAccount.authority`. Requires the signer
|
|
876
|
+
* (`this.wallet.publicKey`) to hold the `UserFlag` hot-role. On-chain, requires the account's
|
|
877
|
+
* total equity to be under `QUOTE_PRECISION / 20` (0.05 USDC, QUOTE_PRECISION = 1e6) and (outside
|
|
878
|
+
* `anchor-test` builds) at least ~3 months of inactivity since `lastActiveSlot`. Not for
|
|
879
|
+
* self-service account deletion — see `deleteUser` for that.
|
|
880
|
+
* @param userAccountPublicKey - PDA of the user account to force-delete.
|
|
881
|
+
* @param userAccount - The account's current on-chain data, used to build `remaining_accounts` for
|
|
882
|
+
* the markets it holds positions in.
|
|
883
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
884
|
+
* @returns The transaction signature.
|
|
885
|
+
* @throws (on-chain) if the signer lacks the `UserFlag` hot-role, if equity exceeds the dust
|
|
886
|
+
* threshold, or if the account has been active too recently.
|
|
887
|
+
*/
|
|
283
888
|
forceDeleteUser(userAccountPublicKey: PublicKey, userAccount: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
889
|
+
/**
|
|
890
|
+
* Builds the keeper-only `forceDeleteUser` instruction, assembling `remaining_accounts` for the
|
|
891
|
+
* account's non-empty spot positions, its revenue-share escrow (if any order carries a builder
|
|
892
|
+
* fee), and every mint/token-program needed for its open spot balances. See `forceDeleteUser` for
|
|
893
|
+
* on-chain preconditions.
|
|
894
|
+
* @param userAccountPublicKey - PDA of the user account to force-delete.
|
|
895
|
+
* @param userAccount - The account's current on-chain data.
|
|
896
|
+
* @returns The instruction.
|
|
897
|
+
*/
|
|
284
898
|
getForceDeleteUserIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
|
|
899
|
+
/**
|
|
900
|
+
* Closes `this.wallet.publicKey`'s `SignedMsgUserOrders` account, refunding its rent to the
|
|
901
|
+
* authority. Requires the account to exist (see `isSignedMsgUserOrdersAccountInitialized`).
|
|
902
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
903
|
+
* @returns The transaction signature.
|
|
904
|
+
*/
|
|
285
905
|
deleteSignedMsgUserOrders(txParams?: TxParams): Promise<TransactionSignature>;
|
|
906
|
+
/**
|
|
907
|
+
* Builds the `deleteSignedMsgUserOrders` instruction, signed by `this.wallet.publicKey`. See
|
|
908
|
+
* `deleteSignedMsgUserOrders` for semantics.
|
|
909
|
+
* @param authority - Authority whose `SignedMsgUserOrders` PDA is derived and closed.
|
|
910
|
+
* @returns The instruction.
|
|
911
|
+
*/
|
|
286
912
|
getSignedMsgUserOrdersDeletionIx(authority: PublicKey): Promise<any>;
|
|
287
913
|
/**
|
|
288
914
|
* Checks if a SignedMsg User Orders account exists for the given authority.
|
|
@@ -293,64 +919,180 @@ export declare class VelocityClient {
|
|
|
293
919
|
* @returns Promise that resolves to true if the account exists, false otherwise
|
|
294
920
|
*/
|
|
295
921
|
isSignedMsgUserOrdersAccountInitialized(authority: PublicKey): Promise<boolean>;
|
|
922
|
+
/**
|
|
923
|
+
* Reclaims any lamports on a sub-account's `User` PDA in excess of the rent-exempt minimum for its
|
|
924
|
+
* current size (e.g. left over after the account was resized smaller), transferring them to
|
|
925
|
+
* `this.wallet.publicKey`.
|
|
926
|
+
* @param subAccountId - Sub-account id to reclaim rent from; defaults to `0`.
|
|
927
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
928
|
+
* @returns The transaction signature.
|
|
929
|
+
* @throws (on-chain `CantReclaimRent`) if there are no excess lamports, or if the account's
|
|
930
|
+
* `UserStats` is younger than ~13 days while the protocol enforces a max sub-account count.
|
|
931
|
+
*/
|
|
296
932
|
reclaimRent(subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
933
|
+
/**
|
|
934
|
+
* Builds the `reclaimRent` instruction. See `reclaimRent` for semantics/preconditions.
|
|
935
|
+
* @param userAccountPublicKey - User account PDA to reclaim excess rent from.
|
|
936
|
+
* @returns The instruction.
|
|
937
|
+
*/
|
|
297
938
|
getReclaimRentIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
939
|
+
/**
|
|
940
|
+
* Looks up an already-loaded `User` from `this.users` (does not fetch or subscribe).
|
|
941
|
+
* @param subAccountId - Sub-account id; defaults to `this.activeSubAccountId`.
|
|
942
|
+
* @param authority - Authority owning the sub-account; defaults to `this.authority`.
|
|
943
|
+
* @returns The loaded `User`.
|
|
944
|
+
* @throws if `subAccountId`/`authority` can't be resolved, or no matching user is loaded (call
|
|
945
|
+
* `addUser` first).
|
|
946
|
+
*/
|
|
298
947
|
getUser(subAccountId?: number, authority?: PublicKey): User;
|
|
948
|
+
/**
|
|
949
|
+
* Checks whether a `User` for the given sub-account/authority is currently loaded in `this.users`,
|
|
950
|
+
* without throwing. Safe to call with unresolvable `subAccountId`/`authority` (returns `false`).
|
|
951
|
+
* @param subAccountId - Sub-account id; defaults to `this.activeSubAccountId`.
|
|
952
|
+
* @param authority - Authority owning the sub-account; defaults to `this.authority`.
|
|
953
|
+
* @returns `true` if a matching `User` is loaded.
|
|
954
|
+
*/
|
|
299
955
|
hasUser(subAccountId?: number, authority?: PublicKey): boolean;
|
|
956
|
+
/**
|
|
957
|
+
* Returns every currently-loaded `User`, with sub-accounts owned directly by `this.wallet.publicKey`
|
|
958
|
+
* first, followed by delegated sub-accounts (owned by other authorities this wallet delegates for).
|
|
959
|
+
* @returns All loaded `User`s in that order.
|
|
960
|
+
*/
|
|
300
961
|
getUsers(): User[];
|
|
962
|
+
/**
|
|
963
|
+
* Returns the `UserStats` instance for `this.authority`, if one was constructed (via
|
|
964
|
+
* `config.userStats`, `updateWallet`, `emulateAccount`, or `switchActiveUser`).
|
|
965
|
+
* @returns The `UserStats` instance, or `undefined` if none exists.
|
|
966
|
+
*/
|
|
301
967
|
getUserStats(): UserStats | undefined;
|
|
302
968
|
/**
|
|
303
|
-
* Like
|
|
969
|
+
* Like `getUserStats` but throws if there is no UserStats
|
|
304
970
|
* subscription, for call sites that require a guaranteed account.
|
|
305
971
|
*/
|
|
306
972
|
getUserStatsOrThrow(): UserStats;
|
|
973
|
+
/**
|
|
974
|
+
* Fetches (via RPC, not the account subscriber) the `ReferrerNameAccount` registered for a given
|
|
975
|
+
* name via `initializeReferrerName`.
|
|
976
|
+
* @param name - Referrer name to look up.
|
|
977
|
+
* @returns The `ReferrerNameAccount`.
|
|
978
|
+
* @throws if no `ReferrerNameAccount` is registered under `name`.
|
|
979
|
+
*/
|
|
307
980
|
fetchReferrerNameAccount(name: string): Promise<ReferrerNameAccount | undefined>;
|
|
981
|
+
/**
|
|
982
|
+
* Returns the `UserStats` account PDA for `this.authority`, computing and caching it on first call
|
|
983
|
+
* (or after `this.authority` changes, since callers like `updateWallet`/`switchActiveUser` reset the
|
|
984
|
+
* cache).
|
|
985
|
+
* @returns The `UserStats` account public key.
|
|
986
|
+
*/
|
|
308
987
|
getUserStatsAccountPublicKey(): PublicKey;
|
|
988
|
+
/**
|
|
989
|
+
* Returns the user account PDA for an already-loaded sub-account (does not derive/compute a PDA
|
|
990
|
+
* for a sub-account that hasn't been loaded).
|
|
991
|
+
* @param subAccountId - Sub-account id; defaults to `this.activeSubAccountId`.
|
|
992
|
+
* @param authority - Authority owning the sub-account; defaults to `this.authority`.
|
|
993
|
+
* @returns The user account public key.
|
|
994
|
+
* @throws if no matching user is loaded — see `getUser`.
|
|
995
|
+
*/
|
|
309
996
|
getUserAccountPublicKey(subAccountId?: number, authority?: PublicKey): Promise<PublicKey>;
|
|
997
|
+
/**
|
|
998
|
+
* Returns the last subscriber-cached `UserAccount` data for a loaded sub-account. Does not hit RPC.
|
|
999
|
+
* @param subAccountId - Sub-account id; defaults to `this.activeSubAccountId`.
|
|
1000
|
+
* @param authority - Authority owning the sub-account; defaults to `this.authority`.
|
|
1001
|
+
* @returns The cached `UserAccount`, or `undefined` if not yet loaded.
|
|
1002
|
+
* @throws if no matching `User` is loaded — see `getUser`.
|
|
1003
|
+
*/
|
|
310
1004
|
getUserAccount(subAccountId?: number, authority?: PublicKey): UserAccount | undefined;
|
|
311
1005
|
/**
|
|
312
|
-
* Like
|
|
1006
|
+
* Like `getUserAccount` but throws a named error instead of returning
|
|
313
1007
|
* `undefined` when the account has not been loaded yet. Use at call sites
|
|
314
1008
|
* that structurally require a loaded account.
|
|
315
1009
|
*/
|
|
316
1010
|
getUserAccountOrThrow(subAccountId?: number, authority?: PublicKey): UserAccount;
|
|
317
1011
|
/**
|
|
318
|
-
*
|
|
319
|
-
*
|
|
1012
|
+
* Like `getUserAccount` but forces a fresh RPC fetch first. Useful for anchor tests where an
|
|
1013
|
+
* update needs to be observed immediately.
|
|
1014
|
+
* @param subAccountId - Sub-account id; defaults to `this.activeSubAccountId`.
|
|
1015
|
+
* @param authority - Authority owning the sub-account; defaults to `this.authority`.
|
|
1016
|
+
* @returns The freshly-fetched `UserAccount`, or `undefined` if not found.
|
|
1017
|
+
* @throws if no matching `User` is loaded — see `getUser`.
|
|
320
1018
|
*/
|
|
321
1019
|
forceGetUserAccount(subAccountId?: number, authority?: PublicKey): Promise<UserAccount | undefined>;
|
|
1020
|
+
/**
|
|
1021
|
+
* Like `getUserAccount` but also returns the slot the data was last observed at.
|
|
1022
|
+
* @param subAccountId - Sub-account id; defaults to `this.activeSubAccountId`.
|
|
1023
|
+
* @param authority - Authority owning the sub-account; defaults to `this.authority`.
|
|
1024
|
+
* @returns The cached `UserAccount` and its slot, or `undefined` if not yet loaded.
|
|
1025
|
+
* @throws if no matching `User` is loaded — see `getUser`.
|
|
1026
|
+
*/
|
|
322
1027
|
getUserAccountAndSlot(subAccountId?: number, authority?: PublicKey): DataAndSlot<UserAccount> | undefined;
|
|
1028
|
+
/**
|
|
1029
|
+
* Returns a sub-account's spot balance entry for a market, if it holds one.
|
|
1030
|
+
* @param marketIndex - Spot market index.
|
|
1031
|
+
* @param subAccountId - Sub-account id; defaults to `this.activeSubAccountId`.
|
|
1032
|
+
* @returns The `SpotPosition`, or `undefined` if the sub-account has no balance in this market.
|
|
1033
|
+
* @throws if the sub-account is not loaded — see `getUserAccountOrThrow`.
|
|
1034
|
+
*/
|
|
323
1035
|
getSpotPosition(marketIndex: number, subAccountId?: number): SpotPosition | undefined;
|
|
1036
|
+
/**
|
|
1037
|
+
* Convenience accessor for the active sub-account's quote (USDC) token amount.
|
|
1038
|
+
* @returns Signed token amount, in the quote spot market's token precision (positive if a deposit,
|
|
1039
|
+
* negative if a borrow). See `getTokenAmount`.
|
|
1040
|
+
*/
|
|
324
1041
|
getQuoteAssetTokenAmount(): BN;
|
|
1042
|
+
/**
|
|
1043
|
+
* Returns the isolated deposit token amount backing a sub-account's isolated perp position in a
|
|
1044
|
+
* given market (the collateral segregated into that position via
|
|
1045
|
+
* `transferIsolatedPerpPositionDeposit`, distinct from the sub-account's general/cross balances).
|
|
1046
|
+
* @param perpMarketIndex - Perp market index of the isolated position.
|
|
1047
|
+
* @param subAccountId - Sub-account id; defaults to `this.activeSubAccountId`.
|
|
1048
|
+
* @returns Token amount in the quote spot market's token precision.
|
|
1049
|
+
*/
|
|
325
1050
|
getIsolatedPerpPositionTokenAmount(perpMarketIndex: number, subAccountId?: number): BN;
|
|
326
1051
|
/**
|
|
327
|
-
* Returns the
|
|
328
|
-
*
|
|
329
|
-
* @param marketIndex
|
|
1052
|
+
* Returns the active sub-account's balance in a spot market, converted from the internal scaled
|
|
1053
|
+
* balance representation to actual token units.
|
|
1054
|
+
* @param marketIndex - Spot market index.
|
|
1055
|
+
* @returns Token amount in the spot market's own token precision (`10^mint.decimals`, e.g.
|
|
1056
|
+
* QUOTE_PRECISION (1e6) for USDC). Positive if a deposit, negative if a borrow. `ZERO` if the
|
|
1057
|
+
* sub-account has no balance in this market.
|
|
330
1058
|
*/
|
|
331
1059
|
getTokenAmount(marketIndex: number): BN;
|
|
332
1060
|
/**
|
|
333
|
-
* Converts
|
|
334
|
-
*
|
|
335
|
-
*
|
|
1061
|
+
* Converts a human-readable (UI) amount to a market's on-chain spot precision (`10^mint.decimals`).
|
|
1062
|
+
* A plain `number` is scaled up via `castNumberToSpotPrecision`; a `BN` is assumed to already be a
|
|
1063
|
+
* whole-token count and is scaled by the same factor.
|
|
1064
|
+
* @param marketIndex - Spot market index whose token decimals determine the scale factor.
|
|
1065
|
+
* @param amount - UI amount to convert.
|
|
1066
|
+
* @returns The amount in the spot market's token precision.
|
|
336
1067
|
*/
|
|
337
1068
|
convertToSpotPrecision(marketIndex: number, amount: BN | number): BN;
|
|
338
1069
|
/**
|
|
339
|
-
* Converts
|
|
340
|
-
*
|
|
1070
|
+
* Converts a human-readable (UI) base-asset amount to `BASE_PRECISION` (1e9), the precision used for
|
|
1071
|
+
* perp/spot order base amounts.
|
|
1072
|
+
* @param amount - UI base amount to convert. A `number` is scaled via a precision-safe helper; a
|
|
1073
|
+
* `BN` is assumed to already be a whole-unit count and is multiplied directly by `BASE_PRECISION`.
|
|
1074
|
+
* @returns The amount in `BASE_PRECISION` (1e9).
|
|
341
1075
|
*/
|
|
342
1076
|
convertToPerpPrecision(amount: BN | number): BN;
|
|
343
1077
|
/**
|
|
344
|
-
* Converts
|
|
345
|
-
* @param amount
|
|
1078
|
+
* Converts a human-readable (UI) price to `PRICE_PRECISION` (1e6).
|
|
1079
|
+
* @param amount - UI price to convert.
|
|
1080
|
+
* @returns The amount in `PRICE_PRECISION` (1e6) when `amount` is a `number` (uses
|
|
1081
|
+
* `numberToSafeBN(amount, PRICE_PRECISION)`).
|
|
1082
|
+
* **Note:** when `amount` is a `BN`, this multiplies by `BASE_PRECISION` (1e9), not
|
|
1083
|
+
* `PRICE_PRECISION` (1e6) — that is very likely a bug (1000x too large) rather than intended
|
|
1084
|
+
* behavior; pass a `number` for correct scaling until this is fixed.
|
|
346
1085
|
*/
|
|
347
1086
|
convertToPricePrecision(amount: BN | number): BN;
|
|
348
1087
|
/**
|
|
349
|
-
* Each velocity instruction must include perp and
|
|
1088
|
+
* Each velocity instruction must include perp and spot market accounts in the ix remaining accounts.
|
|
350
1089
|
* Use this function to force a subset of markets to be included in the remaining accounts for every ix
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
1090
|
+
* built by this client going forward (accumulates into `mustIncludePerpMarketIndexes` /
|
|
1091
|
+
* `mustIncludeSpotMarketIndexes`; there is no corresponding "unset" — construct a new client to
|
|
1092
|
+
* reset). Useful when an instruction's own logic can't infer every market/oracle it needs (e.g. a
|
|
1093
|
+
* cross-margin health check spanning markets the user has no position in yet).
|
|
1094
|
+
* @param perpMarketIndexes - Perp market indexes to always include.
|
|
1095
|
+
* @param spotMarketIndexes - Spot market indexes to always include.
|
|
354
1096
|
*/
|
|
355
1097
|
mustIncludeMarketsInIx({ perpMarketIndexes, spotMarketIndexes, }: {
|
|
356
1098
|
perpMarketIndexes: number[];
|
|
@@ -358,10 +1100,55 @@ export declare class VelocityClient {
|
|
|
358
1100
|
}): void;
|
|
359
1101
|
private cachePerpMarketSlot;
|
|
360
1102
|
private cacheSpotMarketSlot;
|
|
1103
|
+
/**
|
|
1104
|
+
* Builds the `remaining_accounts` list (perp/spot market + oracle accounts, plus any accounts
|
|
1105
|
+
* derived from the given `userAccounts`) that most instructions need appended so the on-chain
|
|
1106
|
+
* handler can load the markets/oracles it touches. Always includes markets registered via
|
|
1107
|
+
* `mustIncludeMarketsInIx`, in addition to whatever `params` (e.g. `userAccounts`,
|
|
1108
|
+
* `writableSpotMarketIndexes`) implies. Used internally by nearly every instruction-building method
|
|
1109
|
+
* on this class; exposed publicly for callers assembling custom instructions.
|
|
1110
|
+
* @param params - Describes which markets/users to derive remaining accounts for; see
|
|
1111
|
+
* `RemainingAccountParams` (core/remainingAccounts.ts).
|
|
1112
|
+
* @returns The `AccountMeta[]` to append to an instruction's accounts.
|
|
1113
|
+
*/
|
|
361
1114
|
getRemainingAccounts(params: RemainingAccountParams): AccountMeta[];
|
|
1115
|
+
/**
|
|
1116
|
+
* Adds a perp market's account meta (and its oracle and quote spot market) into the shared maps used
|
|
1117
|
+
* to de-duplicate remaining accounts across multiple markets in one instruction. The oracle is
|
|
1118
|
+
* marked writable only for `prelaunch`-sourced oracles being written to.
|
|
1119
|
+
* @param marketIndex - Perp market index to include.
|
|
1120
|
+
* @param writable - Whether the perp market account meta should be writable.
|
|
1121
|
+
* @param oracleAccountMap - Shared map (keyed by oracle pubkey string) mutated in place.
|
|
1122
|
+
* @param spotMarketAccountMap - Shared map (keyed by spot market index) mutated in place.
|
|
1123
|
+
* @param perpMarketAccountMap - Shared map (keyed by perp market index) mutated in place.
|
|
1124
|
+
*/
|
|
362
1125
|
addPerpMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>, perpMarketAccountMap: Map<number, AccountMeta>): void;
|
|
1126
|
+
/**
|
|
1127
|
+
* Adds a spot market's account meta (and its oracle, if any) into the shared maps used to
|
|
1128
|
+
* de-duplicate remaining accounts across multiple markets in one instruction.
|
|
1129
|
+
* @param marketIndex - Spot market index to include.
|
|
1130
|
+
* @param writable - Whether the spot market account meta should be writable.
|
|
1131
|
+
* @param oracleAccountMap - Shared map (keyed by oracle pubkey string) mutated in place.
|
|
1132
|
+
* @param spotMarketAccountMap - Shared map (keyed by spot market index) mutated in place.
|
|
1133
|
+
*/
|
|
363
1134
|
addSpotMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>): void;
|
|
1135
|
+
/**
|
|
1136
|
+
* Appends each builder's `User` (sub-account 0) and `RevenueShare` account metas to
|
|
1137
|
+
* `remainingAccounts` (writable), deduping by pubkey so an authority that is both a builder and a
|
|
1138
|
+
* referrer isn't pushed twice — the on-chain revenue-share account loader rejects duplicates and
|
|
1139
|
+
* would abort the whole instruction.
|
|
1140
|
+
* @param builders - Builder authority public keys to include.
|
|
1141
|
+
* @param remainingAccounts - Array mutated in place by appending the builder account metas.
|
|
1142
|
+
*/
|
|
364
1143
|
addBuilderToRemainingAccounts(builders: PublicKey[], remainingAccounts: AccountMeta[]): void;
|
|
1144
|
+
/**
|
|
1145
|
+
* Builds the deduplicated oracle/spot-market/perp-market account-meta maps needed to cover every
|
|
1146
|
+
* non-empty position across a set of user accounts (e.g. taker + makers in a fill), including the
|
|
1147
|
+
* quote spot market whenever a spot position has open orders. All accounts are added read-only.
|
|
1148
|
+
* @param userAccounts - User accounts whose open positions determine which markets to include.
|
|
1149
|
+
* @returns The three account-meta maps, keyed by oracle pubkey string / spot market index / perp
|
|
1150
|
+
* market index respectively.
|
|
1151
|
+
*/
|
|
365
1152
|
getRemainingAccountMapsForUsers(userAccounts: UserAccount[]): {
|
|
366
1153
|
oracleAccountMap: Map<string, AccountMeta>;
|
|
367
1154
|
spotMarketAccountMap: Map<number, AccountMeta>;
|
|
@@ -372,7 +1159,7 @@ export declare class VelocityClient {
|
|
|
372
1159
|
*
|
|
373
1160
|
* `orderId` is the monotonically incrementing u32 counter that the program assigns at
|
|
374
1161
|
* placement time — it is not known until the place instruction executes on-chain. Use
|
|
375
|
-
*
|
|
1162
|
+
* `getOrderByUserId` when you need to look up an order by the caller-supplied
|
|
376
1163
|
* `userOrderId` instead.
|
|
377
1164
|
*
|
|
378
1165
|
* Returns `undefined` when the order is not found (already filled, cancelled, or the
|
|
@@ -382,54 +1169,164 @@ export declare class VelocityClient {
|
|
|
382
1169
|
/**
|
|
383
1170
|
* Look up an open order by the caller-supplied `userOrderId` from the cached user account.
|
|
384
1171
|
*
|
|
385
|
-
* `userOrderId` is a 1-255 slot chosen by the caller in
|
|
1172
|
+
* `userOrderId` is a 1-255 slot chosen by the caller in `OrderParams` and is stable
|
|
386
1173
|
* across the life of the order — useful when you need to reference an order before the
|
|
387
|
-
* program-assigned
|
|
388
|
-
* waiting for confirmation). Use
|
|
1174
|
+
* program-assigned `Order.orderId` is known (e.g. immediately after placing without
|
|
1175
|
+
* waiting for confirmation). Use `getOrder` when you have the program-assigned ID.
|
|
389
1176
|
*
|
|
390
1177
|
* Returns `undefined` when the order is not found (already filled, cancelled, or the
|
|
391
1178
|
* account cache is stale).
|
|
392
1179
|
*/
|
|
393
1180
|
getOrderByUserId(userOrderId: number, subAccountId?: number): Order | undefined;
|
|
394
1181
|
/**
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
1182
|
+
* Resolves the token account to use for a spot market's mint. For the wrapped-SOL market with
|
|
1183
|
+
* `useNative = true` (the default), returns `authority` itself (native SOL, no wrapping) rather
|
|
1184
|
+
* than an SPL associated token account; for every other market (or `useNative = false`), returns
|
|
1185
|
+
* the derived associated token account address (not guaranteed to exist on-chain — see
|
|
1186
|
+
* `getAssociatedTokenAccountCreationIx`).
|
|
1187
|
+
* @param marketIndex - Spot market index whose mint the token account is for.
|
|
1188
|
+
* @param useNative - If `true` (default) and the market is wrapped SOL, return `authority` directly
|
|
1189
|
+
* instead of an ATA.
|
|
1190
|
+
* @param tokenProgram - Token program the mint belongs to; defaults to the classic SPL Token program.
|
|
1191
|
+
* @param authority - Wallet the token account belongs to; defaults to `this.wallet.publicKey`.
|
|
1192
|
+
* @param allowOwnerOffCurve - Passed through to `getAssociatedTokenAddress`; set `true` for PDA owners.
|
|
1193
|
+
* @returns The resolved token account address (or `authority`, for native SOL).
|
|
399
1194
|
*/
|
|
400
1195
|
getAssociatedTokenAccount(marketIndex: number, useNative?: boolean, tokenProgram?: PublicKey, authority?: PublicKey, allowOwnerOffCurve?: boolean): Promise<PublicKey>;
|
|
1196
|
+
/**
|
|
1197
|
+
* Builds an `CreateIdempotent` associated-token-account instruction (creates `account` if it
|
|
1198
|
+
* doesn't already exist; no-ops without failing if it does), constructed manually rather than via
|
|
1199
|
+
* `@solana/spl-token`'s helper.
|
|
1200
|
+
* @param account - Associated token account address to create.
|
|
1201
|
+
* @param payer - Pays for the account creation; must sign the transaction.
|
|
1202
|
+
* @param owner - Token account owner.
|
|
1203
|
+
* @param mint - Mint the token account is for.
|
|
1204
|
+
* @param tokenProgram - Token program the mint belongs to; defaults to the classic SPL Token program.
|
|
1205
|
+
* @returns The `CreateIdempotent` instruction.
|
|
1206
|
+
*/
|
|
401
1207
|
createAssociatedTokenAccountIdempotentInstruction(account: PublicKey, payer: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgram?: PublicKey): TransactionInstruction;
|
|
1208
|
+
/**
|
|
1209
|
+
* Builds the full instruction sequence for a deposit, without sending a transaction. If
|
|
1210
|
+
* `associatedTokenAccount` equals the signer and the market is wrapped SOL, transparently wraps
|
|
1211
|
+
* native SOL first (creates a temporary wrapped-SOL account funded with `amount`, deposits from it,
|
|
1212
|
+
* then closes it at the end of the same transaction, refunding rent to the signer) — otherwise
|
|
1213
|
+
* deposits directly from `associatedTokenAccount`.
|
|
1214
|
+
* @param amount - Amount to deposit, in the spot market's own token precision (`10^mint.decimals`).
|
|
1215
|
+
* @param marketIndex - Spot market index to deposit into.
|
|
1216
|
+
* @param associatedTokenAccount - Source token account (or the signer's own pubkey, for native SOL).
|
|
1217
|
+
* @param subAccountId - Sub-account id to credit; defaults to `this.activeSubAccountId`.
|
|
1218
|
+
* @param reduceOnly - If `true`, the deposit is capped so it cannot flip/increase a net borrow
|
|
1219
|
+
* position beyond what's needed to reach zero (used to repay a borrow without over-depositing).
|
|
1220
|
+
* @param overrides.authority - Signer/depositor authority; defaults to `this.wallet.publicKey`.
|
|
1221
|
+
* @returns The ordered list of instructions (wrap SOL, deposit, unwrap SOL as applicable).
|
|
1222
|
+
*/
|
|
402
1223
|
getDepositTxnIx(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, overrides?: {
|
|
403
1224
|
authority?: PublicKey;
|
|
404
1225
|
}): Promise<TransactionInstruction[]>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Builds (but does not send) a single transaction that deposits collateral and then places a
|
|
1228
|
+
* pre-signed SignedMsg ("swift") taker perp order in one atomic bundle — useful for funding a new
|
|
1229
|
+
* or under-collateralized account immediately before submitting an off-chain-signed order.
|
|
1230
|
+
* Optionally also initializes the taker's `SignedMsgUserOrders` account (with 8 order slots) first,
|
|
1231
|
+
* if it doesn't already exist.
|
|
1232
|
+
* @param signedOrderParams - The pre-signed SignedMsg order message/params to place.
|
|
1233
|
+
* @param takerInfo - Taker's user/user-stats accounts, loaded `UserAccount` data, and the signing
|
|
1234
|
+
* authority for the order message.
|
|
1235
|
+
* @param depositAmount - Amount to deposit, in `depositSpotMarketIndex`'s token precision.
|
|
1236
|
+
* @param depositSpotMarketIndex - Spot market index to deposit into.
|
|
1237
|
+
* @param tradePerpMarketIndex - Perp market index the signed order trades.
|
|
1238
|
+
* @param subAccountId - Sub-account id to deposit into and place the order for.
|
|
1239
|
+
* @param takerAssociatedTokenAccount - Source token account for the deposit.
|
|
1240
|
+
* @param initSwiftAccount - If `true`, initializes the taker's `SignedMsgUserOrders` account first
|
|
1241
|
+
* when it doesn't already exist; defaults to `false`.
|
|
1242
|
+
* @returns Nothing — currently discards the built transaction rather than returning or sending it
|
|
1243
|
+
* (likely a bug: the built `VersionedTransaction`/`Transaction` from `buildTransaction` is neither
|
|
1244
|
+
* returned nor passed to `sendTransaction`).
|
|
1245
|
+
*/
|
|
405
1246
|
buildSwiftDepositTx(signedOrderParams: SignedMsgOrderParams, takerInfo: {
|
|
406
1247
|
taker: PublicKey;
|
|
407
1248
|
takerStats: PublicKey;
|
|
408
1249
|
takerUserAccount: UserAccount;
|
|
409
1250
|
signingAuthority: PublicKey;
|
|
410
1251
|
}, depositAmount: BN, depositSpotMarketIndex: number, tradePerpMarketIndex: number, subAccountId: number, takerAssociatedTokenAccount: PublicKey, initSwiftAccount?: boolean): Promise<void>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Builds (via `getDepositTxnIx`) and wraps a full deposit transaction, without sending it.
|
|
1254
|
+
* Optionally also initializes the depositor's `SignedMsgUserOrders` account first, if it doesn't
|
|
1255
|
+
* already exist. Forces `computeUnits` to `800_000` regardless of `txParams`/`this.txParams`.
|
|
1256
|
+
* @param amount - Amount to deposit, in the spot market's own token precision.
|
|
1257
|
+
* @param marketIndex - Spot market index to deposit into.
|
|
1258
|
+
* @param associatedTokenAccount - Source token account (or the signer's own pubkey, for native SOL).
|
|
1259
|
+
* @param subAccountId - Sub-account id to credit; defaults to `this.activeSubAccountId`.
|
|
1260
|
+
* @param reduceOnly - If `true`, caps the deposit so it cannot exceed what's needed to zero out an
|
|
1261
|
+
* existing borrow.
|
|
1262
|
+
* @param txParams - Optional compute-unit-price/other overrides; `computeUnits` is always
|
|
1263
|
+
* overridden to `800_000`.
|
|
1264
|
+
* @param initSwiftAccount - If `true`, initializes the signer's `SignedMsgUserOrders` account first
|
|
1265
|
+
* when it doesn't already exist; defaults to `false`.
|
|
1266
|
+
* @param overrides.authority - Signer/depositor authority; defaults to `this.wallet.publicKey`.
|
|
1267
|
+
* @returns The built (unsigned/unsent) transaction.
|
|
1268
|
+
*/
|
|
411
1269
|
createDepositTxn(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams, initSwiftAccount?: boolean, overrides?: {
|
|
412
1270
|
authority?: PublicKey;
|
|
413
1271
|
}): Promise<VersionedTransaction | Transaction>;
|
|
414
1272
|
/**
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
* @param
|
|
419
|
-
*
|
|
420
|
-
* @param
|
|
421
|
-
* @param
|
|
422
|
-
*
|
|
423
|
-
* @param
|
|
424
|
-
* @param
|
|
1273
|
+
* Deposits collateral into a spot market for a sub-account: builds (`createDepositTxn`), signs, and
|
|
1274
|
+
* sends the transaction, then caches the confirming slot for this market so subsequent instructions
|
|
1275
|
+
* built by this client can use the freshest oracle/market data.
|
|
1276
|
+
* @param amount - Amount to deposit, in the spot market's own token precision (`10^mint.decimals`,
|
|
1277
|
+
* e.g. QUOTE_PRECISION (1e6) for USDC).
|
|
1278
|
+
* @param marketIndex - Spot market index to deposit into.
|
|
1279
|
+
* @param associatedTokenAccount - Source token account; can be the wallet's own public key when
|
|
1280
|
+
* depositing native SOL into the wrapped-SOL market (see `getAssociatedTokenAccount`).
|
|
1281
|
+
* @param subAccountId - Sub-account id to credit; defaults to `this.activeSubAccountId`.
|
|
1282
|
+
* @param reduceOnly - If `true`, caps the deposit so it cannot exceed what's needed to fully repay
|
|
1283
|
+
* an existing borrow (never opens/increases a deposit position); defaults to `false`.
|
|
1284
|
+
* @param txParams - Optional transaction parameters; `computeUnits` is always forced to `800_000`.
|
|
1285
|
+
* @param initSwiftAccount - If `true`, also initializes the signer's `SignedMsgUserOrders` account
|
|
1286
|
+
* first if it doesn't exist; defaults to `false`.
|
|
1287
|
+
* @param overrides.authority - Signer/depositor authority; defaults to `this.wallet.publicKey`.
|
|
1288
|
+
* @returns The transaction signature.
|
|
1289
|
+
* @throws (on-chain) if the sub-account's `poolId` doesn't match the spot market's pool, the market
|
|
1290
|
+
* is uninitialized/paused for deposits, or `amount` is `0`.
|
|
425
1291
|
*/
|
|
426
1292
|
deposit(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams, initSwiftAccount?: boolean, overrides?: {
|
|
427
1293
|
authority?: PublicKey;
|
|
428
1294
|
}): Promise<TransactionSignature>;
|
|
1295
|
+
/**
|
|
1296
|
+
* Builds the raw `deposit` instruction (no SOL-wrapping helpers — see `getDepositTxnIx` for the
|
|
1297
|
+
* full sequence). Assembles `remaining_accounts` from the target sub-account's current positions
|
|
1298
|
+
* (forcing a fresh fetch when `userInitialized` is `true`) plus the market's mint and, if the mint
|
|
1299
|
+
* uses a transfer hook, its extra account metas.
|
|
1300
|
+
* @param amount - Amount to deposit, in the spot market's own token precision.
|
|
1301
|
+
* @param marketIndex - Spot market index to deposit into.
|
|
1302
|
+
* @param userTokenAccount - Source token account for the deposit.
|
|
1303
|
+
* @param subAccountId - Sub-account id to credit; defaults to `this.activeSubAccountId`.
|
|
1304
|
+
* @param reduceOnly - If `true`, caps the deposit at what's needed to repay an existing borrow.
|
|
1305
|
+
* @param userInitialized - Set `false` only when depositing as part of creating a brand-new user
|
|
1306
|
+
* account in the same transaction (skips fetching/using existing position data).
|
|
1307
|
+
* @param overrides.authority - Signer/depositor authority; defaults to `this.wallet.publicKey`.
|
|
1308
|
+
* @returns The `deposit` instruction.
|
|
1309
|
+
* @throws if `userInitialized` is `true` but the user account fails to load after a forced fetch.
|
|
1310
|
+
*/
|
|
429
1311
|
getDepositInstruction(amount: BN, marketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, userInitialized?: boolean, overrides?: {
|
|
430
1312
|
authority?: PublicKey;
|
|
431
1313
|
}): Promise<TransactionInstruction>;
|
|
432
1314
|
private checkIfAccountExists;
|
|
1315
|
+
/**
|
|
1316
|
+
* Builds the instructions to create and fund a temporary wrapped-SOL token account (via
|
|
1317
|
+
* `createAccountWithSeed` + `initializeAccount`, no keypair required — derived deterministically
|
|
1318
|
+
* from `authority` and a random seed). The caller is responsible for closing it after use (see the
|
|
1319
|
+
* `createCloseAccountInstruction` pattern in `getDepositTxnIx`).
|
|
1320
|
+
* @param amount - Lamport amount to wrap (native SOL to make available as wrapped SOL).
|
|
1321
|
+
* @param includeRent - If `true`, funds the account with `amount` plus an extra
|
|
1322
|
+
* `LAMPORTS_PER_SOL / 100` (0.01 SOL) rent buffer; if falsy, funds with only the rent buffer (no
|
|
1323
|
+
* `amount`).
|
|
1324
|
+
* @param overrides.authority - Owner/payer of the wrapped-SOL account; defaults to
|
|
1325
|
+
* `this.wallet.publicKey`.
|
|
1326
|
+
* @returns `ixs` (create + initialize instructions), `pubkey` (the new wrapped-SOL account
|
|
1327
|
+
* address), and `signers` (always empty — no keypair signature is needed for a seed-derived
|
|
1328
|
+
* account).
|
|
1329
|
+
*/
|
|
433
1330
|
getWrappedSolAccountCreationIxs(amount: BN, includeRent?: boolean, overrides?: {
|
|
434
1331
|
authority?: PublicKey;
|
|
435
1332
|
}): Promise<{
|
|
@@ -438,12 +1335,84 @@ export declare class VelocityClient {
|
|
|
438
1335
|
signers: Signer[];
|
|
439
1336
|
pubkey: PublicKey;
|
|
440
1337
|
}>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Returns the correct SPL token program (classic or Token-2022) for a spot market's mint, based on
|
|
1340
|
+
* its `tokenProgramFlag`.
|
|
1341
|
+
* @param spotMarketAccount - Spot market whose mint's token program is needed.
|
|
1342
|
+
* @returns `TOKEN_2022_PROGRAM_ID` or `TOKEN_PROGRAM_ID`.
|
|
1343
|
+
*/
|
|
441
1344
|
getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
|
|
1345
|
+
/**
|
|
1346
|
+
* Checks whether a spot market's mint belongs to the Token-2022 program.
|
|
1347
|
+
* @param spotMarketAccount - Spot market to check.
|
|
1348
|
+
* @returns `true` if the market's `tokenProgramFlag` has the `Token2022` bit set.
|
|
1349
|
+
*/
|
|
442
1350
|
isToken2022(spotMarketAccount: SpotMarketAccount): boolean;
|
|
1351
|
+
/**
|
|
1352
|
+
* Checks whether a spot market's mint has a Token-2022 transfer hook, requiring extra account
|
|
1353
|
+
* metas to be appended on any instruction that moves its tokens.
|
|
1354
|
+
* @param spotMarketAccount - Spot market to check.
|
|
1355
|
+
* @returns `true` if the market's `tokenProgramFlag` has the `TransferHook` bit set.
|
|
1356
|
+
*/
|
|
443
1357
|
isTransferHook(spotMarketAccount: SpotMarketAccount): boolean;
|
|
1358
|
+
/**
|
|
1359
|
+
* Appends a spot market's mint as a read-only remaining account, but only when the mint is
|
|
1360
|
+
* Token-2022 (the classic SPL Token program doesn't need the mint passed for transfers). No-op for
|
|
1361
|
+
* classic SPL Token mints.
|
|
1362
|
+
* @param spotMarketAccount - Spot market whose mint may need to be included.
|
|
1363
|
+
* @param remainingAccounts - Array mutated in place by appending the mint account meta, if needed.
|
|
1364
|
+
*/
|
|
444
1365
|
addTokenMintToRemainingAccounts(spotMarketAccount: SpotMarketAccount, remainingAccounts: AccountMeta[]): void;
|
|
1366
|
+
/**
|
|
1367
|
+
* Resolves and appends the Token-2022 transfer-hook program's extra required account metas for a
|
|
1368
|
+
* mint. Required on any instruction transferring tokens for a mint where `isTransferHook` is `true`
|
|
1369
|
+
* (e.g. deposits/withdrawals/transfers involving that market).
|
|
1370
|
+
* @param mint - Transfer-hook mint to resolve extra accounts for.
|
|
1371
|
+
* @param remainingAccounts - Array mutated in place by appending the resolved extra account metas.
|
|
1372
|
+
*/
|
|
445
1373
|
addExtraAccountMetasToRemainingAccounts(mint: PublicKey, remainingAccounts: AccountMeta[]): Promise<void>;
|
|
1374
|
+
/**
|
|
1375
|
+
* Builds a (non-idempotent) instruction to create an associated token account owned by
|
|
1376
|
+
* `this.wallet.publicKey`, paid for by `this.wallet.publicKey`.
|
|
1377
|
+
* @param tokenMintAddress - Mint the associated token account is for.
|
|
1378
|
+
* @param associatedTokenAddress - Associated token account address to create.
|
|
1379
|
+
* @param tokenProgram - Token program the mint belongs to.
|
|
1380
|
+
* @returns The create-associated-token-account instruction.
|
|
1381
|
+
*/
|
|
446
1382
|
getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey, tokenProgram: PublicKey): TransactionInstruction;
|
|
1383
|
+
/**
|
|
1384
|
+
* Builds the full instruction sequence to create a new sub-account and fund it with an initial
|
|
1385
|
+
* deposit in one transaction, without sending it. Handles: initializing `UserStats` (for
|
|
1386
|
+
* `subAccountId === 0`) and the `SignedMsgUserOrders` account if missing, wrapping native SOL when
|
|
1387
|
+
* depositing/donating SOL, creating the depositor's associated token account for Token-2022 mints
|
|
1388
|
+
* if it doesn't exist, sourcing the deposit either from a token account or (if `fromSubAccountId` is
|
|
1389
|
+
* given) via an internal transfer from another of the authority's sub-accounts, an optional donation
|
|
1390
|
+
* to the market's revenue pool, an optional custom margin ratio, and unwrapping any temporary SOL
|
|
1391
|
+
* account at the end.
|
|
1392
|
+
* @param amount - Amount to deposit, in `marketIndex`'s token precision.
|
|
1393
|
+
* @param userTokenAccount - Source token account for the deposit (ignored if `fromSubAccountId` is
|
|
1394
|
+
* set, or replaced with a temporary wrapped-SOL account for a SOL deposit from the depositor).
|
|
1395
|
+
* @param marketIndex - Spot market index to deposit into; defaults to `0` (quote/USDC).
|
|
1396
|
+
* @param subAccountId - New sub-account id to create; defaults to `0`.
|
|
1397
|
+
* @param name - Display name for the new sub-account; see `getInitializeUserAccountIxs` for the
|
|
1398
|
+
* default.
|
|
1399
|
+
* @param fromSubAccountId - If set, sources the deposit via an internal transfer from this other
|
|
1400
|
+
* sub-account of the same authority instead of from `userTokenAccount`.
|
|
1401
|
+
* @param referrerInfo - Referrer's `referrer`/`referrerStats` public keys, if attributing this
|
|
1402
|
+
* account to a referrer.
|
|
1403
|
+
* @param donateAmount - Additional lamport amount to donate to spot market index `1`'s (SOL's, in
|
|
1404
|
+
* the default market configs) revenue pool in the same transaction, funded via a temporary
|
|
1405
|
+
* wrapped-SOL account regardless of `marketIndex`; defaults to none. Note the destination market for
|
|
1406
|
+
* the donation is hardcoded to index `1`, not derived from `marketIndex`.
|
|
1407
|
+
* @param customMaxMarginRatio - If set, also sets this sub-account's custom margin ratio (in
|
|
1408
|
+
* `MARGIN_PRECISION`, 1e4 = 100%) at creation time.
|
|
1409
|
+
* @param poolId - If set, also assigns the sub-account to this isolated pool at creation time.
|
|
1410
|
+
* @param overrides.externalWallet - Optional external wallet to deposit/pay from instead of
|
|
1411
|
+
* `this.wallet.publicKey` (the sub-account's owning `authority` is unaffected).
|
|
1412
|
+
* @returns The ordered instructions and the new user account's public key.
|
|
1413
|
+
* @throws if a SOL/donation amount requires a temporary wrapped-SOL account but it fails to be
|
|
1414
|
+
* created.
|
|
1415
|
+
*/
|
|
447
1416
|
createInitializeUserAccountAndDepositCollateralIxs(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, customMaxMarginRatio?: number, poolId?: number, overrides?: {
|
|
448
1417
|
/**
|
|
449
1418
|
* Optional external wallet to deposit from. If provided, the deposit will be made
|
|
@@ -454,74 +1423,450 @@ export declare class VelocityClient {
|
|
|
454
1423
|
ixs: TransactionInstruction[];
|
|
455
1424
|
userAccountPublicKey: PublicKey;
|
|
456
1425
|
}>;
|
|
1426
|
+
/**
|
|
1427
|
+
* Builds (via `createInitializeUserAccountAndDepositCollateralIxs`) and wraps the full
|
|
1428
|
+
* initialize-and-deposit transaction, without sending it. See that method for parameter semantics.
|
|
1429
|
+
* @returns The built (unsigned/unsent) transaction and the new user account's public key.
|
|
1430
|
+
*/
|
|
457
1431
|
createInitializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number, poolId?: number, overrides?: {
|
|
458
1432
|
externalWallet?: PublicKey;
|
|
459
1433
|
}): Promise<[Transaction | VersionedTransaction, PublicKey]>;
|
|
460
1434
|
/**
|
|
461
|
-
* Creates
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
* @param marketIndex
|
|
465
|
-
* @param
|
|
466
|
-
* @param
|
|
467
|
-
* @param
|
|
468
|
-
* @param
|
|
469
|
-
* @param
|
|
470
|
-
*
|
|
471
|
-
* @param
|
|
472
|
-
* @param
|
|
1435
|
+
* Creates a new sub-account and deposits initial collateral into it in a single transaction, then
|
|
1436
|
+
* loads and subscribes the new sub-account via `addUser`. See
|
|
1437
|
+
* `createInitializeUserAccountAndDepositCollateralIxs` for full parameter semantics.
|
|
1438
|
+
* @param amount - Amount to deposit, in `marketIndex`'s token precision.
|
|
1439
|
+
* @param userTokenAccount - Source token account for the deposit.
|
|
1440
|
+
* @param marketIndex - Spot market index to deposit into; defaults to `0` (quote/USDC).
|
|
1441
|
+
* @param subAccountId - New sub-account id to create; defaults to `0`.
|
|
1442
|
+
* @param name - Display name for the new sub-account.
|
|
1443
|
+
* @param fromSubAccountId - If set, sources the deposit via internal transfer from this sub-account
|
|
1444
|
+
* instead of `userTokenAccount`.
|
|
1445
|
+
* @param referrerInfo - Referrer's `referrer`/`referrerStats` public keys, if applicable.
|
|
1446
|
+
* @param donateAmount - Additional amount to donate to the (hardcoded index `1`) revenue pool.
|
|
1447
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1448
|
+
* @param customMaxMarginRatio - If set, custom margin ratio in `MARGIN_PRECISION` (1e4 = 100%).
|
|
1449
|
+
* @param poolId - If set, isolated pool id to assign the sub-account to at creation time.
|
|
473
1450
|
* @param overrides - Optional overrides including externalWallet for depositing from a different wallet
|
|
474
|
-
* @returns
|
|
1451
|
+
* @returns A tuple of `[transactionSignature, userAccountPublicKey]`.
|
|
475
1452
|
*/
|
|
476
1453
|
initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: number, subAccountId?: number, name?: string, fromSubAccountId?: number, referrerInfo?: ReferrerInfo, donateAmount?: BN, txParams?: TxParams, customMaxMarginRatio?: number, poolId?: number, overrides?: {
|
|
477
1454
|
externalWallet?: PublicKey;
|
|
478
1455
|
}): Promise<[TransactionSignature, PublicKey]>;
|
|
1456
|
+
/**
|
|
1457
|
+
* Devnet/test-only convenience: mints test tokens from a `TokenFaucet` into a fresh associated
|
|
1458
|
+
* token account, then creates a new sub-account and deposits the minted amount, all in one
|
|
1459
|
+
* transaction. Not usable on mainnet (no faucet exists there).
|
|
1460
|
+
* @param subAccountId - New sub-account id to create; defaults to `0`.
|
|
1461
|
+
* @param name - Display name for the new sub-account; defaults to `DEFAULT_USER_NAME`.
|
|
1462
|
+
* @param marketIndex - Spot market index to deposit the minted tokens into.
|
|
1463
|
+
* @param tokenFaucet - Faucet client used to mint test tokens.
|
|
1464
|
+
* @param amount - Amount to mint and deposit, in `marketIndex`'s token precision.
|
|
1465
|
+
* @param referrerInfo - Referrer's `referrer`/`referrerStats` public keys, if applicable.
|
|
1466
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1467
|
+
* @returns A tuple of `[transactionSignature, userAccountPublicKey]`.
|
|
1468
|
+
*/
|
|
479
1469
|
initializeUserAccountForDevnet(subAccountId: number | undefined, name: string | undefined, marketIndex: number, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<[TransactionSignature, PublicKey]>;
|
|
1470
|
+
/**
|
|
1471
|
+
* Builds the full instruction sequence for a withdrawal, without sending a transaction. If
|
|
1472
|
+
* `associatedTokenAddress` equals the signer and the market is wrapped SOL, creates a temporary
|
|
1473
|
+
* wrapped-SOL account to receive the withdrawal and closes it (unwrapping to native SOL) at the end
|
|
1474
|
+
* of the same transaction; otherwise, creates the destination associated token account first if it
|
|
1475
|
+
* doesn't already exist.
|
|
1476
|
+
* @param amount - Amount to withdraw, in the spot market's own token precision.
|
|
1477
|
+
* @param marketIndex - Spot market index to withdraw from.
|
|
1478
|
+
* @param associatedTokenAddress - Destination token account (or the signer's own pubkey, for native
|
|
1479
|
+
* SOL).
|
|
1480
|
+
* @param reduceOnly - If `true`, caps the withdrawal at the sub-account's existing deposit (and the
|
|
1481
|
+
* max amount withdrawable while remaining within margin requirements) so it can never flip the
|
|
1482
|
+
* position into a borrow; defaults to `false`.
|
|
1483
|
+
* @param subAccountId - Sub-account id to withdraw from; defaults to `this.activeSubAccountId`.
|
|
1484
|
+
* @returns The ordered list of instructions (create ATA / wrap SOL, withdraw, unwrap SOL as
|
|
1485
|
+
* applicable).
|
|
1486
|
+
*/
|
|
480
1487
|
getWithdrawalIxs(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean, subAccountId?: number): Promise<TransactionInstruction[]>;
|
|
481
1488
|
/**
|
|
482
|
-
* Withdraws from a user account. If deposit doesn't already exist, creates a borrow
|
|
483
|
-
*
|
|
484
|
-
*
|
|
1489
|
+
* Withdraws from a user account. If deposit doesn't already exist, creates a borrow (or increases an
|
|
1490
|
+
* existing one) — unless `reduceOnly` is set. Always requires the sub-account's true owning
|
|
1491
|
+
* authority to sign (`this.wallet.publicKey`); a delegate cannot withdraw at all, even with
|
|
1492
|
+
* `allowDelegateTransfer` enabled.
|
|
1493
|
+
* @param amount - Amount to withdraw, in the spot market's own token precision (`10^mint.decimals`,
|
|
1494
|
+
* e.g. QUOTE_PRECISION (1e6) for USDC).
|
|
1495
|
+
* @param marketIndex - Spot market index to withdraw from.
|
|
485
1496
|
* @param associatedTokenAddress - the token account to withdraw to. can be the wallet public key if using native sol
|
|
486
|
-
* @param reduceOnly
|
|
1497
|
+
* @param reduceOnly - If `true`, caps the withdrawal so it can never open/increase a borrow; the
|
|
1498
|
+
* on-chain amount is clamped to `min(requested, max withdrawable within margin, existing deposit)`.
|
|
1499
|
+
* @param subAccountId - Sub-account id to withdraw from; defaults to `this.activeSubAccountId`.
|
|
1500
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1501
|
+
* @returns The transaction signature.
|
|
1502
|
+
* @throws (on-chain `ReduceOnlyWithdrawIncreasedRisk`) if `reduceOnly` is set but the sub-account's
|
|
1503
|
+
* position in this market is already a borrow (nothing to reduce).
|
|
487
1504
|
*/
|
|
488
1505
|
withdraw(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean, subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1506
|
+
/**
|
|
1507
|
+
* Fully withdraws every spot market position on a sub-account too small to be worth carrying
|
|
1508
|
+
* ("dust", as determined by `User.getSpotMarketAccountsWithDustPosition`), in one transaction. Each
|
|
1509
|
+
* withdrawal requests 2x the current token amount with `reduceOnly = true` so the on-chain clamp
|
|
1510
|
+
* (see `withdraw`) withdraws exactly the full balance without risking a borrow, regardless of
|
|
1511
|
+
* balance drift between calculation and execution.
|
|
1512
|
+
* @param subAccountId - Sub-account id to sweep; defaults to `this.activeSubAccountId`.
|
|
1513
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1514
|
+
* @param opts.dustPositionCountCallback - Called once with the number of dust positions found
|
|
1515
|
+
* (`0` if none), before building/sending the transaction.
|
|
1516
|
+
* @returns The transaction signature, or `undefined` if there were no dust positions to withdraw.
|
|
1517
|
+
*/
|
|
489
1518
|
withdrawAllDustPositions(subAccountId?: number, txParams?: TxParams, opts?: {
|
|
490
1519
|
dustPositionCountCallback?: (count: number) => void;
|
|
491
1520
|
}): Promise<TransactionSignature | undefined>;
|
|
1521
|
+
/**
|
|
1522
|
+
* Builds the raw `withdraw` instruction (no SOL-wrapping/ATA-creation helpers — see
|
|
1523
|
+
* `getWithdrawalIxs` for the full sequence). Signed by `this.wallet.publicKey`, which must be the
|
|
1524
|
+
* sub-account's true owning authority (delegates cannot withdraw).
|
|
1525
|
+
* @param amount - Amount to withdraw, in the spot market's own token precision.
|
|
1526
|
+
* @param marketIndex - Spot market index to withdraw from.
|
|
1527
|
+
* @param userTokenAccount - Destination token account for the withdrawal.
|
|
1528
|
+
* @param reduceOnly - If `true`, caps the withdrawal so it can never open/increase a borrow.
|
|
1529
|
+
* @param subAccountId - Sub-account id to withdraw from; defaults to `this.activeSubAccountId`.
|
|
1530
|
+
* @returns The `withdraw` instruction.
|
|
1531
|
+
*/
|
|
492
1532
|
getWithdrawIx(amount: BN, marketIndex: number, userTokenAccount: PublicKey, reduceOnly?: boolean, subAccountId?: number): Promise<TransactionInstruction>;
|
|
493
1533
|
/**
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
* @param
|
|
1534
|
+
* Transfers a spot balance directly between two sub-accounts owned by `this.wallet.publicKey`
|
|
1535
|
+
* (withdraws from `fromSubAccountId`, deposits into `toSubAccountId`) without leaving the program —
|
|
1536
|
+
* no token account round-trip. Signed by `this.wallet.publicKey`, which must literally be the
|
|
1537
|
+
* `authority` on *both* sub-accounts (this is the owner-to-owner path; a delegate must use
|
|
1538
|
+
* `transferDepositByDelegate` instead).
|
|
1539
|
+
* @param amount - Amount to transfer, in the spot market's own token precision.
|
|
1540
|
+
* @param marketIndex - Spot market index of the balance to transfer.
|
|
1541
|
+
* @param fromSubAccountId - Sub-account id to debit.
|
|
1542
|
+
* @param toSubAccountId - Sub-account id to credit.
|
|
1543
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1544
|
+
* @returns The transaction signature.
|
|
1545
|
+
* @throws (on-chain `UserBankrupt`) if either sub-account is bankrupt, or
|
|
1546
|
+
* (`CantTransferBetweenSameUserAccount`) if `fromSubAccountId === toSubAccountId`.
|
|
500
1547
|
*/
|
|
501
1548
|
transferDeposit(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1549
|
+
/**
|
|
1550
|
+
* Builds the `transferDeposit` instruction. See `transferDeposit` for semantics/preconditions.
|
|
1551
|
+
* Uses an already-loaded `from` sub-account's cached data if available (to build
|
|
1552
|
+
* `remaining_accounts` from its current positions); otherwise fetches it directly via RPC.
|
|
1553
|
+
* @param amount - Amount to transfer, in the spot market's own token precision.
|
|
1554
|
+
* @param marketIndex - Spot market index of the balance to transfer.
|
|
1555
|
+
* @param fromSubAccountId - Sub-account id to debit.
|
|
1556
|
+
* @param toSubAccountId - Sub-account id to credit.
|
|
1557
|
+
* @returns The instruction.
|
|
1558
|
+
*/
|
|
502
1559
|
getTransferDepositIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
|
|
1560
|
+
/**
|
|
1561
|
+
* Like `transferDeposit`, but signed by a *delegate* (`this.wallet.publicKey`) rather than the
|
|
1562
|
+
* sub-accounts' owning authority. On-chain requires all of:
|
|
1563
|
+
* - the owner has opted in via `updateUserAllowDelegateTransfer(true)` on their `UserStats` — the
|
|
1564
|
+
* transfer is rejected outright otherwise, regardless of delegate status on the sub-accounts;
|
|
1565
|
+
* - `this.wallet.publicKey` is set as the `delegate` on **both** `fromSubAccountId` and
|
|
1566
|
+
* `toSubAccountId` (see `updateUserDelegate`) — a delegate for only one side is not sufficient;
|
|
1567
|
+
* - both sub-accounts share the same owning `authority` (this only moves funds within one owner's
|
|
1568
|
+
* sub-accounts, never across different owners);
|
|
1569
|
+
* - neither sub-account is bankrupt, and `fromSubAccountId !== toSubAccountId`.
|
|
1570
|
+
* @param amount - Amount to transfer, in the spot market's own token precision.
|
|
1571
|
+
* @param marketIndex - Spot market index of the balance to transfer.
|
|
1572
|
+
* @param fromSubAccountId - Sub-account id to debit.
|
|
1573
|
+
* @param toSubAccountId - Sub-account id to credit.
|
|
1574
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1575
|
+
* @returns The transaction signature.
|
|
1576
|
+
* @throws (on-chain) if `allowDelegateTransfer` is not enabled, if the signer is not the delegate on
|
|
1577
|
+
* both sub-accounts, if the sub-accounts have different owners, if either is bankrupt, or if
|
|
1578
|
+
* `fromSubAccountId === toSubAccountId`.
|
|
1579
|
+
*/
|
|
503
1580
|
transferDepositByDelegate(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1581
|
+
/**
|
|
1582
|
+
* Builds the `transferDepositByDelegate` instruction. See `transferDepositByDelegate` for the full
|
|
1583
|
+
* set of on-chain preconditions. Uses an already-loaded `from` sub-account's cached data if
|
|
1584
|
+
* available; otherwise fetches it directly via RPC. Sub-accounts are derived under `this.authority`
|
|
1585
|
+
* (the sub-accounts' owner), not `this.wallet.publicKey` (the delegate signer).
|
|
1586
|
+
* @param amount - Amount to transfer, in the spot market's own token precision.
|
|
1587
|
+
* @param marketIndex - Spot market index of the balance to transfer.
|
|
1588
|
+
* @param fromSubAccountId - Sub-account id to debit.
|
|
1589
|
+
* @param toSubAccountId - Sub-account id to credit.
|
|
1590
|
+
* @returns The instruction.
|
|
1591
|
+
*/
|
|
504
1592
|
getTransferDepositByDelegateIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
|
|
1593
|
+
/**
|
|
1594
|
+
* Moves a deposit balance and/or a borrow balance for the same underlying mint between two
|
|
1595
|
+
* sub-accounts owned by `this.wallet.publicKey` that sit in *different* isolated pools, in one
|
|
1596
|
+
* on-chain instruction (`transferPools`). Unlike `transferDeposit` (which only moves a single spot
|
|
1597
|
+
* balance and requires same-pool markets), this requires: `depositFromMarketIndex`/
|
|
1598
|
+
* `depositToMarketIndex` to share a mint but different `poolId`s, `borrowFromMarketIndex`/
|
|
1599
|
+
* `borrowToMarketIndex` to likewise share a mint but different pool ids, and the deposit-from/
|
|
1600
|
+
* borrow-from markets to share `fromSubAccountId`'s pool while the deposit-to/borrow-to markets
|
|
1601
|
+
* share `toSubAccountId`'s pool. Both sub-accounts must be re-validated against their initial
|
|
1602
|
+
* margin requirement after the move.
|
|
1603
|
+
* @param depositFromMarketIndex - Spot market to debit the deposit leg from.
|
|
1604
|
+
* @param depositToMarketIndex - Spot market to credit the deposit leg to (same mint, different pool).
|
|
1605
|
+
* @param borrowFromMarketIndex - Spot market to credit (repay) the borrow leg from.
|
|
1606
|
+
* @param borrowToMarketIndex - Spot market to debit (re-open) the borrow leg on.
|
|
1607
|
+
* @param depositAmount - Deposit amount to move, in the deposit market's token precision;
|
|
1608
|
+
* `undefined`/omitted moves the entire existing deposit token amount; `0` skips the deposit leg
|
|
1609
|
+
* entirely.
|
|
1610
|
+
* @param borrowAmount - Borrow amount to move, in the borrow market's token precision; `undefined`
|
|
1611
|
+
* moves the entire existing borrow token amount; `0` skips the borrow leg entirely.
|
|
1612
|
+
* @param fromSubAccountId - Sub-account id to debit.
|
|
1613
|
+
* @param toSubAccountId - Sub-account id to credit.
|
|
1614
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1615
|
+
* @returns The transaction signature.
|
|
1616
|
+
* @throws (on-chain `InvalidPoolId`) if the mint/pool relationships above don't hold, or
|
|
1617
|
+
* (`UserBankrupt`/`CantTransferBetweenSameUserAccount`) for the same preconditions as `transferDeposit`.
|
|
1618
|
+
*/
|
|
505
1619
|
transferPools(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1620
|
+
/**
|
|
1621
|
+
* Builds the `transferPools` instruction. See `transferPools` for full semantics/preconditions.
|
|
1622
|
+
* @param depositFromMarketIndex - Spot market to debit the deposit leg from.
|
|
1623
|
+
* @param depositToMarketIndex - Spot market to credit the deposit leg to.
|
|
1624
|
+
* @param borrowFromMarketIndex - Spot market to credit (repay) the borrow leg from.
|
|
1625
|
+
* @param borrowToMarketIndex - Spot market to debit (re-open) the borrow leg on.
|
|
1626
|
+
* @param depositAmount - Deposit amount to move, in the deposit market's token precision;
|
|
1627
|
+
* `undefined` moves the entire deposit, `0` skips the deposit leg.
|
|
1628
|
+
* @param borrowAmount - Borrow amount to move, in the borrow market's token precision; `undefined`
|
|
1629
|
+
* moves the entire borrow, `0` skips the borrow leg.
|
|
1630
|
+
* @param fromSubAccountId - Sub-account id to debit.
|
|
1631
|
+
* @param toSubAccountId - Sub-account id to credit.
|
|
1632
|
+
* @param isToNewSubAccount - If `true`, skips including `toSubAccountId`'s current `UserAccount` data
|
|
1633
|
+
* when building `remaining_accounts` (use when `toSubAccountId` is being created in the same
|
|
1634
|
+
* transaction and has no on-chain data yet).
|
|
1635
|
+
* @returns The instruction.
|
|
1636
|
+
*/
|
|
506
1637
|
getTransferPoolsIx(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, isToNewSubAccount?: boolean): Promise<TransactionInstruction>;
|
|
1638
|
+
/**
|
|
1639
|
+
* Moves all or part of an open perp position from one sub-account to another via the
|
|
1640
|
+
* `transferPerpPosition` instruction, settling funding on both sides first. The signer
|
|
1641
|
+
* (`this.wallet.publicKey`) must independently satisfy `can_sign_for_user` (be the owning
|
|
1642
|
+
* `authority` or the sub-account's `delegate`) on *both* `fromSubAccountId` and `toSubAccountId` —
|
|
1643
|
+
* unlike `transferDepositByDelegate`, there is no separate `allowDelegateTransfer` opt-in gate, and
|
|
1644
|
+
* the two sub-accounts are not required to share the same owning authority.
|
|
1645
|
+
* @param fromSubAccountId - Sub-account id to debit the position from.
|
|
1646
|
+
* @param toSubAccountId - Sub-account id to credit the position to.
|
|
1647
|
+
* @param marketIndex - Perp market index of the position to transfer.
|
|
1648
|
+
* @param amount - Signed base amount to transfer, in `BASE_PRECISION` (1e9). Must have the same sign
|
|
1649
|
+
* as `fromSubAccountId`'s existing position (i.e. it only reduces/closes that position, never
|
|
1650
|
+
* flips it) and a magnitude at most the position's size and a multiple of the market's step size;
|
|
1651
|
+
* pass `undefined` to transfer the entire position.
|
|
1652
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1653
|
+
* @returns The transaction signature.
|
|
1654
|
+
* @throws (on-chain `UserBankrupt`/`CantTransferBetweenSameUserAccount`) for the standard transfer
|
|
1655
|
+
* preconditions, or `InvalidTransferPerpPosition` if the oracle is invalid, fills are paused for
|
|
1656
|
+
* `marketIndex`, `amount`'s sign/magnitude/step-size don't satisfy the constraints above, or
|
|
1657
|
+
* `fromSubAccountId` has no position in `marketIndex`.
|
|
1658
|
+
*/
|
|
507
1659
|
transferPerpPosition(fromSubAccountId: number, toSubAccountId: number, marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1660
|
+
/**
|
|
1661
|
+
* Builds the `transferPerpPosition` instruction. See `transferPerpPosition` for full semantics.
|
|
1662
|
+
* @param fromSubAccountId - Sub-account id to debit the position from.
|
|
1663
|
+
* @param toSubAccountId - Sub-account id to credit the position to.
|
|
1664
|
+
* @param marketIndex - Perp market index of the position to transfer.
|
|
1665
|
+
* @param amount - Signed base amount to transfer, in `BASE_PRECISION` (1e9); `undefined`/`null`
|
|
1666
|
+
* transfers the entire position. See `transferPerpPosition` for sign/magnitude constraints.
|
|
1667
|
+
* @returns The instruction.
|
|
1668
|
+
*/
|
|
508
1669
|
getTransferPerpPositionIx(fromSubAccountId: number, toSubAccountId: number, marketIndex: number, amount: BN): Promise<TransactionInstruction>;
|
|
1670
|
+
/**
|
|
1671
|
+
* Special-account-only: transfers all or part of a position on the protocol's designated "vAMM
|
|
1672
|
+
* hedger" account directly into the AMM's own inventory, offsetting the vAMM's synthetic position.
|
|
1673
|
+
* On-chain requires `userAccountPublicKey`'s `specialUserStatus` to be `VammHedger`, the position's
|
|
1674
|
+
* direction to already be opposite the AMM's net inventory (`amm.baseAssetAmountWithAmm`), and the
|
|
1675
|
+
* transferred amount to fit within the AMM's available capacity for that direction. Not usable on a
|
|
1676
|
+
* regular trading sub-account.
|
|
1677
|
+
* @param userAccountPublicKey - The vAMM-hedger `User` PDA to transfer from; must already be loaded
|
|
1678
|
+
* in `this.users` (see `getUsers`).
|
|
1679
|
+
* @param marketIndex - Perp market index of the position to transfer.
|
|
1680
|
+
* @param amount - Signed base amount to transfer, in `BASE_PRECISION` (1e9), matching the position's
|
|
1681
|
+
* sign and capped at its size and a multiple of the market's step size; omit to transfer the entire
|
|
1682
|
+
* position.
|
|
1683
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1684
|
+
* @returns The transaction signature.
|
|
1685
|
+
* @throws (on-chain) if the account isn't a `VammHedger`, has no (or a same-direction-as-AMM)
|
|
1686
|
+
* position in `marketIndex`, or `amount` fails the sign/magnitude/step-size/AMM-capacity checks.
|
|
1687
|
+
*/
|
|
509
1688
|
specialTransferPerpPositionToVamm(userAccountPublicKey: PublicKey, marketIndex: number, amount?: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1689
|
+
/**
|
|
1690
|
+
* Builds the `specialTransferPerpPositionToVamm` instruction. See
|
|
1691
|
+
* `specialTransferPerpPositionToVamm` for full semantics/preconditions.
|
|
1692
|
+
* @param userAccountPublicKey - The vAMM-hedger `User` PDA to transfer from.
|
|
1693
|
+
* @param marketIndex - Perp market index of the position to transfer.
|
|
1694
|
+
* @param amount - Signed base amount to transfer, in `BASE_PRECISION` (1e9); omit to transfer the
|
|
1695
|
+
* entire position.
|
|
1696
|
+
* @returns The instruction.
|
|
1697
|
+
* @throws if `userAccountPublicKey` isn't among `this.getUsers()`.
|
|
1698
|
+
*/
|
|
510
1699
|
getSpecialTransferPerpPositionToVammIx(userAccountPublicKey: PublicKey, marketIndex: number, amount?: BN): Promise<TransactionInstruction>;
|
|
1700
|
+
/**
|
|
1701
|
+
* Deposits collateral from a token account directly into an isolated perp position's own segregated
|
|
1702
|
+
* balance (as opposed to `deposit`, which credits the sub-account's general/cross balance). The
|
|
1703
|
+
* position's quote spot market is derived from `perpMarketIndex`'s `quoteSpotMarketIndex`.
|
|
1704
|
+
* @param amount - Amount to deposit, in the position's quote spot market's token precision.
|
|
1705
|
+
* @param perpMarketIndex - Perp market index of the isolated position to fund.
|
|
1706
|
+
* @param userTokenAccount - Source token account for the deposit.
|
|
1707
|
+
* @param subAccountId - Sub-account id owning the position; defaults to `this.activeSubAccountId`.
|
|
1708
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1709
|
+
* @returns The transaction signature.
|
|
1710
|
+
* @throws (on-chain `InvalidPoolId`) if the sub-account's pool doesn't match the spot/perp markets'.
|
|
1711
|
+
*/
|
|
511
1712
|
depositIntoIsolatedPerpPosition(amount: BN, perpMarketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1713
|
+
/**
|
|
1714
|
+
* Builds the `depositIntoIsolatedPerpPosition` instruction. See `depositIntoIsolatedPerpPosition` for
|
|
1715
|
+
* semantics.
|
|
1716
|
+
* @param amount - Amount to deposit, in the position's quote spot market's token precision.
|
|
1717
|
+
* @param perpMarketIndex - Perp market index of the isolated position to fund.
|
|
1718
|
+
* @param userTokenAccount - Source token account for the deposit.
|
|
1719
|
+
* @param subAccountId - Sub-account id owning the position; defaults to `this.activeSubAccountId`.
|
|
1720
|
+
* @returns The instruction.
|
|
1721
|
+
*/
|
|
512
1722
|
getDepositIntoIsolatedPerpPositionIx(amount: BN, perpMarketIndex: number, userTokenAccount: PublicKey, subAccountId?: number): Promise<TransactionInstruction>;
|
|
1723
|
+
/**
|
|
1724
|
+
* Moves collateral between an isolated perp position's segregated balance and the sub-account's
|
|
1725
|
+
* general/cross balance, in the same underlying quote spot market (derived from `perpMarketIndex`).
|
|
1726
|
+
* Positive `amount` moves collateral **from general into the isolated position**; negative moves it
|
|
1727
|
+
* **from the isolated position back to general**. If the requested outflow from the isolated
|
|
1728
|
+
* position would exceed its current deposit (i.e. it needs unrealized PnL to be realized first, or
|
|
1729
|
+
* the caller wants to withdraw everything), prepends a `TRY_SETTLE` settle-PnL instruction for
|
|
1730
|
+
* `perpMarketIndex` before the transfer.
|
|
1731
|
+
* @param amount - Signed amount to move, in the quote spot market's token precision (e.g.
|
|
1732
|
+
* QUOTE_PRECISION (1e6) for USDC); positive = into the isolated position, negative = out of it. Pass
|
|
1733
|
+
* `MIN_I64` to move the entire isolated deposit back to general.
|
|
1734
|
+
* @param perpMarketIndex - Perp market index of the isolated position.
|
|
1735
|
+
* @param subAccountId - Sub-account id owning the position; defaults to `this.activeSubAccountId`.
|
|
1736
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1737
|
+
* @param trySettle - If `true`, always prepends the `TRY_SETTLE` instruction even if not otherwise
|
|
1738
|
+
* inferred as necessary.
|
|
1739
|
+
* @param noBuffer - If `true`, sends `amount` unmodified; otherwise (default) adds a 0.5% buffer to
|
|
1740
|
+
* the requested amount to absorb price movement between build and execution. Has no effect when
|
|
1741
|
+
* `amount` is `MIN_I64`.
|
|
1742
|
+
* @returns The transaction signature. Sent with `skipPreflight: true`.
|
|
1743
|
+
*/
|
|
513
1744
|
transferIsolatedPerpPositionDeposit(amount: BN, perpMarketIndex: number, subAccountId?: number, txParams?: TxParams, trySettle?: boolean, noBuffer?: boolean): Promise<TransactionSignature>;
|
|
1745
|
+
/**
|
|
1746
|
+
* Builds the `transferIsolatedPerpPositionDeposit` instruction (without the `TRY_SETTLE` prepend —
|
|
1747
|
+
* see `transferIsolatedPerpPositionDeposit` for the full sequence). See that method for the
|
|
1748
|
+
* sign/precision convention of `amount`.
|
|
1749
|
+
* @param amount - Signed amount to move, in the quote spot market's token precision; positive = into
|
|
1750
|
+
* the isolated position, negative = out. Pass `MIN_I64` to move the entire isolated deposit out.
|
|
1751
|
+
* @param perpMarketIndex - Perp market index of the isolated position.
|
|
1752
|
+
* @param subAccountId - Sub-account id owning the position; defaults to `this.activeSubAccountId`.
|
|
1753
|
+
* @param noAmountBuffer - If `true`, sends `amount` unmodified; otherwise adds a 0.5% buffer
|
|
1754
|
+
* (ignored when `amount` is `MIN_I64`).
|
|
1755
|
+
* @param signingAuthority - Signer for the instruction; defaults to `this.wallet.publicKey`.
|
|
1756
|
+
* @returns The instruction.
|
|
1757
|
+
*/
|
|
514
1758
|
getTransferIsolatedPerpPositionDepositIx(amount: BN, perpMarketIndex: number, subAccountId?: number, noAmountBuffer?: boolean, signingAuthority?: PublicKey): Promise<TransactionInstruction>;
|
|
1759
|
+
/**
|
|
1760
|
+
* Withdraws collateral out of the protocol directly from an isolated perp position's segregated
|
|
1761
|
+
* balance to a token account (as opposed to `withdraw`, which draws from the sub-account's
|
|
1762
|
+
* general/cross balance). See `getWithdrawFromIsolatedPerpPositionIxsBundle` for the settle-PnL and
|
|
1763
|
+
* amount-clamping logic applied first.
|
|
1764
|
+
* @param amount - Amount to withdraw, in the position's quote spot market's token precision.
|
|
1765
|
+
* @param perpMarketIndex - Perp market index of the isolated position to withdraw from.
|
|
1766
|
+
* @param userTokenAccount - Destination token account for the withdrawal.
|
|
1767
|
+
* @param subAccountId - Sub-account id owning the position; defaults to `this.activeSubAccountId`.
|
|
1768
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1769
|
+
* @returns The transaction signature.
|
|
1770
|
+
*/
|
|
515
1771
|
withdrawFromIsolatedPerpPosition(amount: BN, perpMarketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1772
|
+
/**
|
|
1773
|
+
* Builds the full instruction sequence for `withdrawFromIsolatedPerpPosition`: computes the position's
|
|
1774
|
+
* claimable unrealized PnL, and clamps `amount` to the isolated deposit plus that claimable PnL —
|
|
1775
|
+
* the on-chain `amount` is `u64` with no "withdraw all" sentinel (unlike the sibling
|
|
1776
|
+
* `transferIsolatedPerpPositionDeposit`, whose `i64` `amount` treats `i64::MIN` as one), so passing
|
|
1777
|
+
* `BN` values larger than the withdrawable balance is how a caller requests "withdraw everything".
|
|
1778
|
+
* Also prepends a `TRY_SETTLE` settle-PnL instruction for `perpMarketIndex` whenever the request
|
|
1779
|
+
* draws into unrealized (unsettled) PnL. Note the clamp is a build-time estimate: if the settle
|
|
1780
|
+
* realizes less than the claimable PnL (e.g. the market's PnL pool is short), the withdraw can still
|
|
1781
|
+
* fail on-chain with `InsufficientCollateral`.
|
|
1782
|
+
* @param amount - Amount to withdraw, in the position's quote spot market's token precision. Values
|
|
1783
|
+
* exceeding the withdrawable balance are clamped to it (i.e. pass a huge value to withdraw all).
|
|
1784
|
+
* @param perpMarketIndex - Perp market index of the isolated position to withdraw from.
|
|
1785
|
+
* @param subAccountId - Sub-account id owning the position; defaults to `this.activeSubAccountId`.
|
|
1786
|
+
* @param userTokenAccount - Destination token account; defaults to the signer's own associated token
|
|
1787
|
+
* account for the position's quote spot market.
|
|
1788
|
+
* @returns The ordered instructions (optional settle-PnL, then withdraw).
|
|
1789
|
+
* @throws if `subAccountId` has no perp position in `perpMarketIndex`, or if the position has no
|
|
1790
|
+
* withdrawable collateral (deposit plus claimable PnL is zero or negative).
|
|
1791
|
+
*/
|
|
516
1792
|
getWithdrawFromIsolatedPerpPositionIxsBundle(amount: BN, perpMarketIndex: number, subAccountId?: number, userTokenAccount?: PublicKey): Promise<TransactionInstruction[]>;
|
|
1793
|
+
/**
|
|
1794
|
+
* Builds the raw `withdrawFromIsolatedPerpPosition` instruction (no settle-PnL/clamping — see
|
|
1795
|
+
* `getWithdrawFromIsolatedPerpPositionIxsBundle` for the full sequence).
|
|
1796
|
+
* @param amount - Amount to withdraw, in the position's quote spot market's token precision.
|
|
1797
|
+
* The on-chain `amount` arg is `u64` (unsigned) with no "withdraw all" sentinel — the exact amount
|
|
1798
|
+
* is withdrawn, and it must not exceed the isolated position's token balance. Use
|
|
1799
|
+
* `getWithdrawFromIsolatedPerpPositionIxsBundle` for withdraw-all/clamping behavior.
|
|
1800
|
+
* @param perpMarketIndex - Perp market index of the isolated position to withdraw from.
|
|
1801
|
+
* @param userTokenAccount - Destination token account for the withdrawal.
|
|
1802
|
+
* @param subAccountId - Sub-account id owning the position; defaults to `this.activeSubAccountId`.
|
|
1803
|
+
* @returns The instruction.
|
|
1804
|
+
*/
|
|
517
1805
|
getWithdrawFromIsolatedPerpPositionIx(amount: BN, perpMarketIndex: number, userTokenAccount: PublicKey, subAccountId?: number): Promise<TransactionInstruction>;
|
|
1806
|
+
/**
|
|
1807
|
+
* Permissionless crank: forces a spot market to accrue interest (updating
|
|
1808
|
+
* `cumulativeDepositInterest`/`cumulativeBorrowInterest` and TWAP stats) up to the current slot. The
|
|
1809
|
+
* instruction's accounts impose no authority/hot-role check beyond the transaction fee payer —
|
|
1810
|
+
* anyone can call this to keep a market's interest current between organic deposit/withdraw/borrow
|
|
1811
|
+
* activity.
|
|
1812
|
+
* @param marketIndex - Spot market index to update.
|
|
1813
|
+
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1814
|
+
* @returns The transaction signature.
|
|
1815
|
+
*/
|
|
518
1816
|
updateSpotMarketCumulativeInterest(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1817
|
+
/**
|
|
1818
|
+
* Builds the `updateSpotMarketCumulativeInterest` instruction. See
|
|
1819
|
+
* `updateSpotMarketCumulativeInterest` for semantics.
|
|
1820
|
+
* @param marketIndex - Spot market index to update.
|
|
1821
|
+
* @returns The instruction.
|
|
1822
|
+
*/
|
|
519
1823
|
updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
520
1824
|
/**
|
|
521
|
-
*
|
|
1825
|
+
* Opens/increases a perp position with a market order (or a limit order if `limitPrice` is
|
|
1826
|
+
* given), filled immediately against the AMM/makers via `placeAndTakePerpOrder`.
|
|
1827
|
+
* @deprecated use `placePerpOrder` or `placeAndTakePerpOrder` instead.
|
|
1828
|
+
* @param direction - `LONG` or `SHORT`.
|
|
1829
|
+
* @param amount - Base asset amount to trade, BASE_PRECISION (1e9).
|
|
1830
|
+
* @param marketIndex - Perp market index.
|
|
1831
|
+
* @param limitPrice - Optional limit price, PRICE_PRECISION (1e6); omit for a pure market order.
|
|
1832
|
+
* @param subAccountId - Sub-account to trade from; defaults to the active sub-account.
|
|
1833
|
+
* @returns The transaction signature.
|
|
522
1834
|
*/
|
|
523
1835
|
openPosition(direction: PositionDirection, amount: BN, marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>;
|
|
1836
|
+
/**
|
|
1837
|
+
* Submits and confirms a transaction that has already been fully signed elsewhere (e.g. by an
|
|
1838
|
+
* external/hardware wallet flow), skipping this client's normal build-and-sign step entirely. Not
|
|
1839
|
+
* order/instruction-specific — works for any pre-signed `Transaction`/`VersionedTransaction`.
|
|
1840
|
+
* @param tx - The already-signed transaction to send.
|
|
1841
|
+
* @param opts - Confirmation options; defaults to `this.opts`.
|
|
1842
|
+
* @returns The transaction signature.
|
|
1843
|
+
*/
|
|
524
1844
|
sendSignedTx(tx: Transaction | VersionedTransaction, opts?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1845
|
+
/**
|
|
1846
|
+
* Builds (without sending) the set of transactions needed to place a market order and,
|
|
1847
|
+
* for legacy (non-versioned) transactions, a companion transaction that fills it against
|
|
1848
|
+
* the AMM. Also builds optional companion transactions to cancel the market's existing
|
|
1849
|
+
* orders first and/or settle PnL after the fill. Used by `sendMarketOrderAndGetSignedFillTx`.
|
|
1850
|
+
* @param orderParams - Order to place; `orderParams.baseAssetAmount` is BASE_PRECISION (1e9)
|
|
1851
|
+
* for perp (token-mint precision for spot), `orderParams.price` is PRICE_PRECISION (1e6).
|
|
1852
|
+
* @param userAccountPublicKey - Public key of the placing user account (used for the
|
|
1853
|
+
* post-fill settle-PnL instruction).
|
|
1854
|
+
* @param userAccount - Decoded user account; supplies `subAccountId` and `nextOrderId`.
|
|
1855
|
+
* @param makerInfo - Maker account(s) to include as fill counterparties, if any.
|
|
1856
|
+
* @param txParams - Optional compute-unit/priority-fee overrides applied to all built transactions.
|
|
1857
|
+
* @param bracketOrdersParams - Additional orders (e.g. TP/SL) placed in the same transaction as the market order.
|
|
1858
|
+
* @param cancelExistingOrders - If `true` and `orderParams.marketType` is perp, also builds a
|
|
1859
|
+
* transaction cancelling all existing open orders in that market — intended for auto-cancelling
|
|
1860
|
+
* TP/SL orders when closing a position. Ignored for spot.
|
|
1861
|
+
* @param settlePnl - If `true` and `orderParams.marketType` is perp, also builds a
|
|
1862
|
+
* settle-PnL transaction for `orderParams.marketIndex`.
|
|
1863
|
+
* @param positionMaxLev - If set, prepends an instruction to set a custom max-leverage margin
|
|
1864
|
+
* ratio (`MARGIN_PRECISION`, 1e4, derived as `1 / positionMaxLev`) for the position before placing.
|
|
1865
|
+
* @param isolatedPositionDepositAmount - If set and the order increases the position, prepends a
|
|
1866
|
+
* transfer-into-isolated-position deposit instruction (token-mint precision) before placing.
|
|
1867
|
+
* @returns An object with `marketOrderTx` (always present) and optional `cancelExistingOrdersTx`,
|
|
1868
|
+
* `settlePnlTx`, `fillTx` (only built when `this.txVersion === 0`, i.e. legacy transactions).
|
|
1869
|
+
*/
|
|
525
1870
|
prepareMarketOrderTxs(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], cancelExistingOrders?: boolean, settlePnl?: boolean, positionMaxLev?: number, isolatedPositionDepositAmount?: BN): Promise<{
|
|
526
1871
|
cancelExistingOrdersTx?: Transaction | VersionedTransaction;
|
|
527
1872
|
settlePnlTx?: Transaction | VersionedTransaction;
|
|
@@ -529,15 +1874,24 @@ export declare class VelocityClient {
|
|
|
529
1874
|
marketOrderTx: Transaction | VersionedTransaction;
|
|
530
1875
|
}>;
|
|
531
1876
|
/**
|
|
532
|
-
* Sends a market order and
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
* @param
|
|
538
|
-
*
|
|
539
|
-
* @param
|
|
540
|
-
* @
|
|
1877
|
+
* Sends a market order transaction and, for legacy (non-versioned) transactions, also returns
|
|
1878
|
+
* a co-signed fill transaction the caller can broadcast themselves to fill the order against
|
|
1879
|
+
* the AMM (useful when the caller wants to control fill timing/submission rather than relying
|
|
1880
|
+
* on a keeper). Internally builds transactions via `prepareMarketOrderTxs`, signs them all, then
|
|
1881
|
+
* sends only `marketOrderTx`.
|
|
1882
|
+
* @param orderParams - Order to place; `baseAssetAmount` is BASE_PRECISION (1e9) for perp
|
|
1883
|
+
* (token-mint precision for spot), `price` is PRICE_PRECISION (1e6).
|
|
1884
|
+
* @param userAccountPublicKey - Public key of the placing user account.
|
|
1885
|
+
* @param userAccount - Decoded user account; supplies `subAccountId` and `nextOrderId`.
|
|
1886
|
+
* @param makerInfo - Maker account(s) to include as fill counterparties, if any.
|
|
1887
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
1888
|
+
* @param bracketOrdersParams - Additional orders (e.g. TP/SL) placed alongside the market order.
|
|
1889
|
+
* @param cancelExistingOrders - Builds and returns an extra transaction to cancel the existing orders in the same perp market. Intended use is to auto-cancel TP/SL orders when closing a position. Ignored if orderParams.marketType is not MarketType.PERP.
|
|
1890
|
+
* @param settlePnl - If `true` and the order is a perp order, also builds and returns a signed settle-PnL transaction for the order's market.
|
|
1891
|
+
* @returns `txSig` for the sent market-order transaction, plus `signedFillTx` (only when
|
|
1892
|
+
* `this.txVersion === 0`), `signedCancelExistingOrdersTx`, and `signedSettlePnlTx` — each
|
|
1893
|
+
* `undefined` when not applicable/requested. None of the returned side transactions are sent;
|
|
1894
|
+
* the caller must broadcast them.
|
|
541
1895
|
*/
|
|
542
1896
|
sendMarketOrderAndGetSignedFillTx(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], cancelExistingOrders?: boolean, settlePnl?: boolean): Promise<{
|
|
543
1897
|
txSig: TransactionSignature;
|
|
@@ -545,6 +1899,20 @@ export declare class VelocityClient {
|
|
|
545
1899
|
signedCancelExistingOrdersTx?: Transaction;
|
|
546
1900
|
signedSettlePnlTx?: Transaction;
|
|
547
1901
|
}>;
|
|
1902
|
+
/**
|
|
1903
|
+
* Places a single perp order without attempting to fill it in the same instruction — the
|
|
1904
|
+
* order rests until a keeper (or a `placeAndTake*`/signed-msg fill) matches it. Use
|
|
1905
|
+
* `placeAndTakePerpOrder` instead if the caller wants an immediate attempt to fill against
|
|
1906
|
+
* the AMM/makers.
|
|
1907
|
+
* @param orderParams - Order to place; `baseAssetAmount` is BASE_PRECISION (1e9), `price` /
|
|
1908
|
+
* `triggerPrice` / `oraclePriceOffset` (signed) / `auctionStartPrice` / `auctionEndPrice` are
|
|
1909
|
+
* PRICE_PRECISION (1e6).
|
|
1910
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
1911
|
+
* @param subAccountId - Sub-account to place the order for; defaults to the active sub-account.
|
|
1912
|
+
* @param isolatedPositionDepositAmount - If set and the order increases the position, a transfer
|
|
1913
|
+
* into an isolated-margin position (token-mint precision) is prepended in the same transaction.
|
|
1914
|
+
* @returns The transaction signature.
|
|
1915
|
+
*/
|
|
548
1916
|
placePerpOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number, isolatedPositionDepositAmount?: BN): Promise<TransactionSignature>;
|
|
549
1917
|
/**
|
|
550
1918
|
* Returns the RevenueShareEscrow account meta for the placing user when `orderParams`
|
|
@@ -564,15 +1932,58 @@ export declare class VelocityClient {
|
|
|
564
1932
|
* Throws when `takerEscrow` does not belong to `takerAuthority`.
|
|
565
1933
|
*/
|
|
566
1934
|
private getTakerEscrowAccountMeta;
|
|
1935
|
+
/**
|
|
1936
|
+
* Builds the `placePerpOrder` instruction. See `placePerpOrder` for semantics. Automatically
|
|
1937
|
+
* attaches the placing user's `RevenueShareEscrow` account when `orderParams` carries a
|
|
1938
|
+
* builder code (`builderIdx`/`builderFeeTenthBps`).
|
|
1939
|
+
* @param orderParams - Order to place; see `placePerpOrder` for field precisions.
|
|
1940
|
+
* @param subAccountId - Sub-account to place the order for; defaults to the active sub-account.
|
|
1941
|
+
* @param depositToTradeArgs - Pass when composing this instruction ahead of the user account
|
|
1942
|
+
* actually existing on-chain yet (e.g. deposit-to-trade in the same transaction as account
|
|
1943
|
+
* creation): `isMakingNewAccount` skips loading the (not-yet-existing) user account for
|
|
1944
|
+
* `remainingAccounts`, and `depositMarketIndex` marks the deposit's spot market as readable.
|
|
1945
|
+
* @returns The instruction.
|
|
1946
|
+
*/
|
|
567
1947
|
getPlacePerpOrderIx(orderParams: OptionalOrderParams, subAccountId?: number, depositToTradeArgs?: {
|
|
568
1948
|
isMakingNewAccount: boolean;
|
|
569
1949
|
depositMarketIndex: number;
|
|
570
1950
|
}): Promise<TransactionInstruction>;
|
|
571
1951
|
updateAMMs(marketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
572
1952
|
getUpdateAMMsIx(marketIndexes: number[]): Promise<TransactionInstruction>;
|
|
1953
|
+
/**
|
|
1954
|
+
* Admin instruction: finalizes settlement pricing for a perp market that has already been put
|
|
1955
|
+
* into `Settlement` status (`market.status === MarketStatus.SETTLEMENT`), snapping the market's
|
|
1956
|
+
* settlement price/oracle-twap so every position can subsequently be closed at that fixed price
|
|
1957
|
+
* via `settlePNL`. Requires a warm- or cold-tier admin signer (`check_warm`).
|
|
1958
|
+
* @param marketIndex - Perp market index to settle.
|
|
1959
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
1960
|
+
* @returns The transaction signature.
|
|
1961
|
+
*/
|
|
573
1962
|
settleExpiredMarket(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1963
|
+
/**
|
|
1964
|
+
* Builds the `settleExpiredMarket` instruction. See `settleExpiredMarket` for semantics. Signs
|
|
1965
|
+
* with `this.wallet.publicKey` when not subscribed, or the state's `coldAdmin` when subscribed —
|
|
1966
|
+
* the on-chain constraint accepts either a warm- or cold-tier admin, so passing `coldAdmin`
|
|
1967
|
+
* always satisfies it regardless of which tier the actual signer holds.
|
|
1968
|
+
* @param marketIndex - Perp market index to settle.
|
|
1969
|
+
* @returns The instruction.
|
|
1970
|
+
*/
|
|
574
1971
|
getSettleExpiredMarketIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
1972
|
+
/**
|
|
1973
|
+
* Admin instruction: sweeps a settled (`MarketStatus.SETTLEMENT`) perp market's remaining fee
|
|
1974
|
+
* pool and PnL pool balances into the quote spot market's revenue pool, once all user positions
|
|
1975
|
+
* in the market have been settled out. Requires a warm- or cold-tier admin signer.
|
|
1976
|
+
* @param marketIndex - Perp market index to sweep.
|
|
1977
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
1978
|
+
* @returns The transaction signature.
|
|
1979
|
+
*/
|
|
575
1980
|
settleExpiredMarketPoolsToRevenuePool(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1981
|
+
/**
|
|
1982
|
+
* Builds the `settleExpiredMarketPoolsToRevenuePool` instruction. See
|
|
1983
|
+
* `settleExpiredMarketPoolsToRevenuePool` for semantics.
|
|
1984
|
+
* @param perpMarketIndex - Perp market index to sweep.
|
|
1985
|
+
* @returns The instruction.
|
|
1986
|
+
*/
|
|
576
1987
|
getSettleExpiredMarketPoolsToRevenuePoolIx(perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
577
1988
|
/**
|
|
578
1989
|
* Cancel an open order and broadcast the transaction.
|
|
@@ -586,7 +1997,15 @@ export declare class VelocityClient {
|
|
|
586
1997
|
* is also provided, `getOrder` will return `undefined` (the ID is unknown client-side),
|
|
587
1998
|
* causing the withdraw path to throw — supply an explicit `orderId` in that case.
|
|
588
1999
|
*
|
|
589
|
-
* @
|
|
2000
|
+
* @param orderId - Program-assigned order ID to cancel; omit to cancel the most recently
|
|
2001
|
+
* placed order (resolved on-chain via `get_last_order_id`).
|
|
2002
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2003
|
+
* @param subAccountId - Sub-account the order belongs to; defaults to the active sub-account.
|
|
2004
|
+
* @param overrides.withdrawIsolatedDepositAmount - If set and > 0, appends an isolated-margin
|
|
2005
|
+
* withdrawal (token-mint precision) for the cancelled order's market in the same transaction;
|
|
2006
|
+
* requires an explicit `orderId` (see note above).
|
|
2007
|
+
* @returns The transaction signature.
|
|
2008
|
+
* @see `getCancelOrderIx` to obtain the instruction without sending.
|
|
590
2009
|
*/
|
|
591
2010
|
cancelOrder(orderId?: number, txParams?: TxParams, subAccountId?: number, overrides?: {
|
|
592
2011
|
withdrawIsolatedDepositAmount?: BN;
|
|
@@ -603,19 +2022,43 @@ export declare class VelocityClient {
|
|
|
603
2022
|
*
|
|
604
2023
|
* When `orderId` is supplied, only that specific order is cancelled.
|
|
605
2024
|
*
|
|
606
|
-
* @
|
|
607
|
-
*
|
|
2025
|
+
* @param orderId - Program-assigned order ID to cancel; omit (or `undefined`) to cancel the
|
|
2026
|
+
* most recently placed order.
|
|
2027
|
+
* @param subAccountId - Sub-account the order belongs to; defaults to the active sub-account.
|
|
2028
|
+
* @returns The instruction.
|
|
2029
|
+
* @see `cancelOrder` to send the transaction directly.
|
|
2030
|
+
* @see `getCancelOrderByUserIdIx` to cancel by the caller-supplied `userOrderId`.
|
|
608
2031
|
*/
|
|
609
2032
|
getCancelOrderIx(orderId?: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
2033
|
+
/**
|
|
2034
|
+
* Cancel an open order identified by its caller-supplied `userOrderId` and broadcast the
|
|
2035
|
+
* transaction.
|
|
2036
|
+
* @param userOrderId - Caller-chosen order slot (set via `OrderParams.userOrderId` at placement).
|
|
2037
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2038
|
+
* @param subAccountId - Sub-account the order belongs to; defaults to the active sub-account.
|
|
2039
|
+
* @returns The transaction signature.
|
|
2040
|
+
* @see `getCancelOrderByUserIdIx` to obtain the instruction without sending.
|
|
2041
|
+
*/
|
|
610
2042
|
cancelOrderByUserId(userOrderId: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
2043
|
+
/**
|
|
2044
|
+
* Builds the `cancelOrderByUserId` instruction. See `cancelOrderByUserId` for semantics.
|
|
2045
|
+
* @param userOrderId - Caller-chosen order slot (set via `OrderParams.userOrderId` at placement).
|
|
2046
|
+
* @param subAccountId - Sub-account the order belongs to; defaults to the active sub-account.
|
|
2047
|
+
* @throws If no open order with `userOrderId` is found in the cached user account (looked up
|
|
2048
|
+
* client-side to resolve the order's market/oracle for `remainingAccounts`).
|
|
2049
|
+
* @returns The instruction.
|
|
2050
|
+
* @see `getCancelOrderIx` to cancel by the program-assigned order ID instead.
|
|
2051
|
+
*/
|
|
611
2052
|
getCancelOrderByUserIdIx(userOrderId: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
612
2053
|
/**
|
|
613
2054
|
* Sends a transaction to cancel the provided order ids.
|
|
614
2055
|
*
|
|
615
|
-
* @param orderIds -
|
|
2056
|
+
* @param orderIds - Program-assigned order IDs to cancel; an order ID that no longer exists is
|
|
2057
|
+
* silently skipped. `undefined` sends an empty list on-chain, i.e. cancels nothing.
|
|
616
2058
|
* @param txParams - The transaction parameters.
|
|
617
2059
|
* @param subAccountId - The sub account id to cancel the orders for.
|
|
618
2060
|
* @param user - The user to cancel the orders for. If provided, it will be prioritized over the subAccountId.
|
|
2061
|
+
* @param overrides.authority - Signing authority to use instead of `this.wallet.publicKey`.
|
|
619
2062
|
* @returns The transaction signature.
|
|
620
2063
|
*/
|
|
621
2064
|
cancelOrdersByIds(orderIds?: number[], txParams?: TxParams, subAccountId?: number, user?: User, overrides?: {
|
|
@@ -624,67 +2067,254 @@ export declare class VelocityClient {
|
|
|
624
2067
|
/**
|
|
625
2068
|
* Returns the transaction instruction to cancel the provided order ids.
|
|
626
2069
|
*
|
|
627
|
-
* @param orderIds -
|
|
2070
|
+
* @param orderIds - Program-assigned order IDs to cancel; an order ID that no longer exists is
|
|
2071
|
+
* silently skipped. `undefined` sends an empty list on-chain, i.e. cancels nothing.
|
|
628
2072
|
* @param subAccountId - The sub account id to cancel the orders for.
|
|
629
2073
|
* @param user - The user to cancel the orders for. If provided, it will be prioritized over the subAccountId.
|
|
2074
|
+
* @param overrides.authority - Signing authority to use instead of `this.wallet.publicKey`.
|
|
630
2075
|
* @returns The transaction instruction to cancel the orders.
|
|
631
2076
|
*/
|
|
632
2077
|
getCancelOrdersByIdsIx(orderIds?: number[], subAccountId?: number, user?: User, overrides?: {
|
|
633
2078
|
authority?: PublicKey;
|
|
634
2079
|
}): Promise<TransactionInstruction>;
|
|
2080
|
+
/**
|
|
2081
|
+
* Cancel all of a user's open orders matching the given (optional) filters, and broadcast the
|
|
2082
|
+
* transaction. Any filter left `undefined` is not applied — calling with no filters cancels
|
|
2083
|
+
* every open order on the sub-account.
|
|
2084
|
+
* @param marketType - Only cancel orders of this market type (`PERP`/`SPOT`); combined with
|
|
2085
|
+
* `marketIndex` to scope to one perp or spot market.
|
|
2086
|
+
* @param marketIndex - Only cancel orders in this market index.
|
|
2087
|
+
* @param direction - Only cancel orders on this side (`LONG`/`SHORT`).
|
|
2088
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2089
|
+
* @param subAccountId - Sub-account to cancel orders for; defaults to the active sub-account.
|
|
2090
|
+
* @returns The transaction signature.
|
|
2091
|
+
* @see `getCancelOrdersIx` to obtain the instruction without sending.
|
|
2092
|
+
*/
|
|
635
2093
|
cancelOrders(marketType?: MarketType, marketIndex?: number, direction?: PositionDirection, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
2094
|
+
/**
|
|
2095
|
+
* Builds the `cancelOrders` instruction. See `cancelOrders` for filter semantics (`null`/`undefined`
|
|
2096
|
+
* on any of `marketType`/`marketIndex`/`direction` means "don't filter on that field").
|
|
2097
|
+
* @param marketType - Only cancel orders of this market type.
|
|
2098
|
+
* @param marketIndex - Only cancel orders in this market index.
|
|
2099
|
+
* @param direction - Only cancel orders on this side.
|
|
2100
|
+
* @param subAccountId - Sub-account to cancel orders for; defaults to the active sub-account.
|
|
2101
|
+
* @returns The instruction.
|
|
2102
|
+
*/
|
|
636
2103
|
getCancelOrdersIx(marketType: MarketType | null | undefined, marketIndex: number | null | undefined, direction: PositionDirection | null | undefined, subAccountId?: number): Promise<TransactionInstruction>;
|
|
2104
|
+
/**
|
|
2105
|
+
* Atomically cancels orders matching the given filters and places new orders in a single
|
|
2106
|
+
* transaction (cancel instruction first, then place). Useful for order replacement flows
|
|
2107
|
+
* (e.g. re-quoting) where the old orders must not be fillable in the gap before the new
|
|
2108
|
+
* ones land.
|
|
2109
|
+
* @param cancelOrderParams - Filters for which open orders to cancel; see `cancelOrders` for
|
|
2110
|
+
* semantics (`undefined` fields are not filtered on).
|
|
2111
|
+
* @param placeOrderParams - Orders to place after the cancel; `baseAssetAmount` is BASE_PRECISION
|
|
2112
|
+
* (1e9), `price`/`triggerPrice`/`oraclePriceOffset` are PRICE_PRECISION (1e6).
|
|
2113
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2114
|
+
* @param subAccountId - Sub-account to operate on; defaults to the active sub-account.
|
|
2115
|
+
* @returns The transaction signature.
|
|
2116
|
+
*/
|
|
637
2117
|
cancelAndPlaceOrders(cancelOrderParams: {
|
|
638
2118
|
marketType?: MarketType;
|
|
639
2119
|
marketIndex?: number;
|
|
640
2120
|
direction?: PositionDirection;
|
|
641
2121
|
}, placeOrderParams: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
2122
|
+
/**
|
|
2123
|
+
* Places a batch of orders (perp and/or spot) in a single instruction. None are filled
|
|
2124
|
+
* in-instruction — each rests until matched by a keeper or a subsequent fill/place-and-take.
|
|
2125
|
+
* @param params - Orders to place; `baseAssetAmount` is BASE_PRECISION (1e9) for perp
|
|
2126
|
+
* (token-mint precision for spot), `price`/`triggerPrice`/`oraclePriceOffset` are
|
|
2127
|
+
* PRICE_PRECISION (1e6).
|
|
2128
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2129
|
+
* @param subAccountId - Sub-account to place the orders for; defaults to the active sub-account.
|
|
2130
|
+
* @param optionalIxs - Extra instructions to prepend to the transaction.
|
|
2131
|
+
* @param isolatedPositionDepositAmount - If set and `params` has exactly one perp order that
|
|
2132
|
+
* increases the position, a transfer into an isolated-margin position (token-mint precision)
|
|
2133
|
+
* is prepended before placing. Ignored for batches of more than one order.
|
|
2134
|
+
* @returns The transaction signature.
|
|
2135
|
+
*/
|
|
642
2136
|
placeOrders(params: OrderParams[], txParams?: TxParams, subAccountId?: number, optionalIxs?: TransactionInstruction[], isolatedPositionDepositAmount?: BN): Promise<TransactionSignature>;
|
|
2137
|
+
/**
|
|
2138
|
+
* Builds (without sending) the `placeOrders` transaction. See `placeOrders` for semantics.
|
|
2139
|
+
* @param params - Orders to place; see `placeOrders` for field precisions.
|
|
2140
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2141
|
+
* @param subAccountId - Sub-account to place the orders for; defaults to the active sub-account.
|
|
2142
|
+
* @param optionalIxs - Extra instructions to prepend to the transaction.
|
|
2143
|
+
* @param isolatedPositionDepositAmount - See `placeOrders`; only applied when `params.length === 1`.
|
|
2144
|
+
* @returns An object with `placeOrdersTx`, the built (unsigned) transaction.
|
|
2145
|
+
*/
|
|
643
2146
|
preparePlaceOrdersTx(params: OrderParams[], txParams?: TxParams, subAccountId?: number, optionalIxs?: TransactionInstruction[], isolatedPositionDepositAmount?: BN): Promise<{
|
|
644
2147
|
placeOrdersTx: Transaction | VersionedTransaction;
|
|
645
2148
|
}>;
|
|
2149
|
+
/**
|
|
2150
|
+
* Builds the `placeOrders` instruction. See `placeOrders` for semantics. Attaches the placing
|
|
2151
|
+
* user's `RevenueShareEscrow` once (not per-order) when any order in the batch carries a
|
|
2152
|
+
* builder code — the on-chain handler expects a single escrow account for the whole batch.
|
|
2153
|
+
* @param params - Orders to place; every entry must set `marketType`. See `placeOrders` for
|
|
2154
|
+
* field precisions.
|
|
2155
|
+
* @param subAccountId - Sub-account to place the orders for; defaults to the active sub-account.
|
|
2156
|
+
* @param overrides - `authority` overrides the signing authority (defaults to `this.wallet.publicKey`).
|
|
2157
|
+
* @throws If any order in `params` omits `marketType`.
|
|
2158
|
+
* @returns The instruction.
|
|
2159
|
+
*/
|
|
646
2160
|
getPlaceOrdersIx(params: OptionalOrderParams[], subAccountId?: number, overrides?: {
|
|
647
2161
|
authority?: PublicKey;
|
|
648
2162
|
}): Promise<TransactionInstruction>;
|
|
2163
|
+
/**
|
|
2164
|
+
* Builds a `placeOrders` instruction followed by an instruction that sets a custom max-leverage
|
|
2165
|
+
* margin ratio on the position for `params[0]`'s market. Unlike `placeOrders`, this bypasses the
|
|
2166
|
+
* `RevenueShareEscrow` attachment for builder-coded orders (uses the raw `program.instruction`
|
|
2167
|
+
* call directly) — don't use it for batches containing a builder-coded order.
|
|
2168
|
+
* @param params - Orders to place; `baseAssetAmount` is BASE_PRECISION (1e9) for perp
|
|
2169
|
+
* (token-mint precision for spot), `price`/`triggerPrice`/`oraclePriceOffset` are PRICE_PRECISION (1e6).
|
|
2170
|
+
* @param positionMaxLev - Max leverage to apply to the position in `params[0].marketIndex`; converted
|
|
2171
|
+
* to a MARGIN_PRECISION (1e4) margin ratio as `1 / positionMaxLev`.
|
|
2172
|
+
* @param subAccountId - Sub-account to place the orders for; defaults to the active sub-account.
|
|
2173
|
+
* @returns A two-element array: `[placeOrdersIx, setPositionMaxLevIx]`.
|
|
2174
|
+
*/
|
|
649
2175
|
getPlaceOrdersAndSetPositionMaxLevIx(params: OptionalOrderParams[], positionMaxLev: number, subAccountId?: number): Promise<TransactionInstruction[]>;
|
|
650
2176
|
/**
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
* @param
|
|
654
|
-
*
|
|
655
|
-
* @
|
|
2177
|
+
* Places multiple limit orders (`params.orderCount`, 2-32) distributed across a price range
|
|
2178
|
+
* in a single instruction, none filled in-instruction — each rests until matched.
|
|
2179
|
+
* @param params - Scale order parameters: `totalBaseAssetAmount` is BASE_PRECISION (1e9),
|
|
2180
|
+
* `startPrice`/`endPrice` are PRICE_PRECISION (1e6); see `ScaleOrderParams` for the rest.
|
|
2181
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2182
|
+
* @param subAccountId - Sub-account to place the orders for; defaults to the active sub-account.
|
|
2183
|
+
* @returns The transaction signature.
|
|
656
2184
|
*/
|
|
657
2185
|
placeScaleOrders(params: ScaleOrderParams, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
2186
|
+
/**
|
|
2187
|
+
* Builds (without sending) the `placeScaleOrders` transaction. See `placeScaleOrders` for semantics.
|
|
2188
|
+
* @param params - Scale order parameters; see `placeScaleOrders` for field precisions.
|
|
2189
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2190
|
+
* @param subAccountId - Sub-account to place the orders for; defaults to the active sub-account.
|
|
2191
|
+
* @returns An object with `placeScaleOrdersTx`, the built (unsigned) transaction.
|
|
2192
|
+
*/
|
|
658
2193
|
preparePlaceScaleOrdersTx(params: ScaleOrderParams, txParams?: TxParams, subAccountId?: number): Promise<{
|
|
659
2194
|
placeScaleOrdersTx: Transaction | VersionedTransaction;
|
|
660
2195
|
}>;
|
|
2196
|
+
/**
|
|
2197
|
+
* Builds the `placeScaleOrders` instruction. See `placeScaleOrders` for semantics.
|
|
2198
|
+
* @param params - Scale order parameters; see `placeScaleOrders` for field precisions.
|
|
2199
|
+
* @param subAccountId - Sub-account to place the orders for; defaults to the active sub-account.
|
|
2200
|
+
* @returns The instruction.
|
|
2201
|
+
*/
|
|
661
2202
|
getPlaceScaleOrdersIx(params: ScaleOrderParams, subAccountId?: number): Promise<TransactionInstruction>;
|
|
2203
|
+
/**
|
|
2204
|
+
* Keeper instruction that fills a resting DLOB perp order against one or more makers (or the
|
|
2205
|
+
* AMM/vAMM when no maker matches). Permissionless — any signer can act as filler and earns the
|
|
2206
|
+
* filler reward. Does not place or cancel orders itself; it only matches an order that is
|
|
2207
|
+
* already on the book.
|
|
2208
|
+
* @param userAccountPublicKey - Public key of the order owner's user account.
|
|
2209
|
+
* @param user - Decoded user account of the order owner.
|
|
2210
|
+
* @param order - The order to fill (`marketIndex`/`orderId`); defaults to the owner's most
|
|
2211
|
+
* recently placed order (`nextOrderId - 1`) when omitted.
|
|
2212
|
+
* @param makerInfo - Maker(s) to attempt to cross against; a single `MakerInfo` or an array.
|
|
2213
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2214
|
+
* @param fillerSubAccountId - Filler's sub-account to credit; defaults to the active sub-account.
|
|
2215
|
+
* @param fillerAuthority - Filler's authority, if different from this client's wallet (e.g.
|
|
2216
|
+
* filling on behalf of a delegated sub-account); the filler user/user-stats PDAs are derived
|
|
2217
|
+
* from this authority instead of `this.wallet.publicKey`.
|
|
2218
|
+
* @param hasBuilderFee - Force-attach the taker's `RevenueShareEscrow` account, bypassing the
|
|
2219
|
+
* automatic builder-code detection performed by `getFillPerpOrderIx`.
|
|
2220
|
+
* @param takerEscrow - The taker's decoded `RevenueShareEscrow`. Required whenever the order
|
|
2221
|
+
* carries a builder code or the taker is referred — the program rejects the fill if the escrow
|
|
2222
|
+
* is owed but not attached.
|
|
2223
|
+
* @returns The transaction signature.
|
|
2224
|
+
*/
|
|
662
2225
|
fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, fillerSubAccountId?: number, fillerAuthority?: PublicKey, hasBuilderFee?: boolean, takerEscrow?: RevenueShareEscrowAccount): Promise<TransactionSignature>;
|
|
663
|
-
|
|
2226
|
+
/**
|
|
2227
|
+
* Builds the `fillPerpOrder` instruction. See `fillPerpOrder` for semantics. Assembles maker
|
|
2228
|
+
* accounts and the taker's `RevenueShareEscrow` (when owed) into `remainingAccounts` in the
|
|
2229
|
+
* order the on-chain handler expects: user/maker market+oracle accounts first, then each
|
|
2230
|
+
* maker's `(maker, makerStats)` pair, then the taker escrow meta last.
|
|
2231
|
+
* @param userAccountPublicKey - Public key of the order owner's user account.
|
|
2232
|
+
* @param userAccount - Decoded user account of the order owner.
|
|
2233
|
+
* @param order - The order to fill (`marketIndex`/`orderId`); defaults to the owner's most
|
|
2234
|
+
* recently placed order when omitted and `isSignedMsg` is false.
|
|
2235
|
+
* @param makerInfo - Maker(s) to attempt to cross against.
|
|
2236
|
+
* @param fillerSubAccountId - Filler's sub-account to credit; defaults to the active sub-account.
|
|
2237
|
+
* @param isSignedMsg - Whether this fills a signed-msg (swift) order that has not yet been
|
|
2238
|
+
* placed on-chain; when true, `order` is not required and the builder-escrow attachment is
|
|
2239
|
+
* done optimistically (the order's builder flag cannot be inspected before it lands).
|
|
2240
|
+
* @param fillerAuthority - Filler's authority if different from this client's wallet; the
|
|
2241
|
+
* filler user/user-stats PDAs are derived from this authority.
|
|
2242
|
+
* @param hasBuilderFee - Force-attach the taker escrow regardless of the detected builder flag.
|
|
2243
|
+
* @param takerEscrow - The taker's decoded `RevenueShareEscrow`. Required to attach the escrow
|
|
2244
|
+
* when the order has a builder code or the taker is referred with an initialized escrow — the
|
|
2245
|
+
* on-chain handler rejects the fill if an owed escrow is missing from `remainingAccounts`.
|
|
2246
|
+
* @throws If no order can be resolved to fill, or (for a non-signed-msg fill) `order` is omitted.
|
|
2247
|
+
* @returns The instruction.
|
|
2248
|
+
*/
|
|
2249
|
+
getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], fillerSubAccountId?: number, isSignedMsg?: boolean, fillerAuthority?: PublicKey, hasBuilderFee?: boolean, takerEscrow?: RevenueShareEscrowAccount, takerIsReferred?: boolean): Promise<TransactionInstruction>;
|
|
2250
|
+
/**
|
|
2251
|
+
* Builds the `revertFill` instruction. Used by keepers as a same-transaction fallback after a
|
|
2252
|
+
* simulated fill fails downstream (e.g. a subsequent instruction errors): it only asserts the
|
|
2253
|
+
* filler's `lastActiveSlot` equals the current slot and otherwise is a no-op, letting the
|
|
2254
|
+
* keeper's earlier fill CPI effects be discarded by the transaction failing cleanly rather than
|
|
2255
|
+
* with a confusing downstream error.
|
|
2256
|
+
* @param fillerPublicKey - Filler's user account public key; defaults to this client's own
|
|
2257
|
+
* user account.
|
|
2258
|
+
* @returns The instruction.
|
|
2259
|
+
*/
|
|
664
2260
|
getRevertFillIx(fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
2261
|
+
/**
|
|
2262
|
+
* Disabled. Spot DLOB trading (order placement/matching) is turned off in this deployment —
|
|
2263
|
+
* spot balances, deposits, withdrawals, and swaps remain available.
|
|
2264
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2265
|
+
*/
|
|
665
2266
|
placeSpotOrder(_orderParams: OptionalOrderParams, _txParams?: TxParams, _subAccountId?: number): Promise<TransactionSignature>;
|
|
2267
|
+
/**
|
|
2268
|
+
* Disabled. See `placeSpotOrder`.
|
|
2269
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2270
|
+
*/
|
|
666
2271
|
preparePlaceSpotOrderTx(_orderParams: OptionalOrderParams, _txParams?: TxParams, _subAccountId?: number): Promise<void>;
|
|
2272
|
+
/**
|
|
2273
|
+
* Disabled. See `placeSpotOrder`.
|
|
2274
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2275
|
+
*/
|
|
667
2276
|
getPlaceSpotOrderIx(_orderParams: OptionalOrderParams, _subAccountId?: number, _overrides?: {
|
|
668
2277
|
authority?: PublicKey;
|
|
669
2278
|
}): Promise<TransactionInstruction>;
|
|
2279
|
+
/**
|
|
2280
|
+
* Disabled. See `placeSpotOrder`.
|
|
2281
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2282
|
+
*/
|
|
670
2283
|
fillSpotOrder(_userAccountPublicKey: PublicKey, _user: UserAccount, _order?: Pick<Order, 'marketIndex' | 'orderId'>, _fulfillmentConfig?: unknown, _makerInfo?: MakerInfo | MakerInfo[], _txParams?: TxParams): Promise<TransactionSignature>;
|
|
2284
|
+
/**
|
|
2285
|
+
* Disabled. See `placeSpotOrder`.
|
|
2286
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2287
|
+
*/
|
|
671
2288
|
getFillSpotOrderIx(_userAccountPublicKey: PublicKey, _userAccount: UserAccount, _order?: Pick<Order, 'marketIndex' | 'orderId'>, _fulfillmentConfig?: unknown, _makerInfo?: MakerInfo | MakerInfo[], _fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
672
2289
|
/**
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
* @param
|
|
679
|
-
*
|
|
680
|
-
* @param
|
|
681
|
-
*
|
|
682
|
-
* @param
|
|
683
|
-
* @param
|
|
684
|
-
* @param
|
|
685
|
-
*
|
|
686
|
-
* @param
|
|
687
|
-
*
|
|
2290
|
+
* Swaps one spot-market token for another inside the user's velocity account: brackets the
|
|
2291
|
+
* external swap provider's instructions between the program's `beginSwap`/`endSwap`
|
|
2292
|
+
* instructions in a single transaction, so the swap is settled directly against the user's
|
|
2293
|
+
* deposits/vault balances rather than the wallet's own token accounts. Sends and confirms the
|
|
2294
|
+
* transaction.
|
|
2295
|
+
* @param swapClient - Swap client used to fetch routes/instructions (`UnifiedSwapClient` or a
|
|
2296
|
+
* `TitanClient`); dispatches to `getSwapIxV2` or `getTitanSwapIx` respectively.
|
|
2297
|
+
* @param jupiterClient - @deprecated Use `swapClient` instead. When passed (and `swapClient` is
|
|
2298
|
+
* not), dispatches to `getJupiterSwapIxV6`.
|
|
2299
|
+
* @param outMarketIndex - Spot market index of the token being bought.
|
|
2300
|
+
* @param inMarketIndex - Spot market index of the token being sold.
|
|
2301
|
+
* @param outAssociatedTokenAccount - Token account to receive the bought token; created
|
|
2302
|
+
* idempotently if omitted.
|
|
2303
|
+
* @param inAssociatedTokenAccount - Token account to source the sold token from; created
|
|
2304
|
+
* idempotently if omitted.
|
|
2305
|
+
* @param amount - Amount of the "in" token (or "out" token when `swapMode` is `ExactOut`, in
|
|
2306
|
+
* which case this is the desired output amount), in the token's own mint decimals — not a
|
|
2307
|
+
* fixed protocol precision.
|
|
2308
|
+
* @param slippageBps - Max slippage in basis points passed to the swap provider's routing API.
|
|
2309
|
+
* @param swapMode - `ExactIn` (default) or `ExactOut`.
|
|
2310
|
+
* @param reduceOnly - Whether the in/out token's position on the velocity account must reduce
|
|
2311
|
+
* (not flip sign); enforced by `endSwap` after the swap completes.
|
|
2312
|
+
* @param v6 - @deprecated Use `quote` instead. Pre-fetched Jupiter v6 quote response.
|
|
2313
|
+
* @param quote - Pre-fetched quote response (skips an extra round-trip to the swap provider).
|
|
2314
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2315
|
+
* @throws If neither `swapClient` nor `jupiterClient` is provided, or if `swapClient` is not a
|
|
2316
|
+
* recognized client type.
|
|
2317
|
+
* @returns The transaction signature.
|
|
688
2318
|
*/
|
|
689
2319
|
swap({ swapClient, jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, reduceOnly, txParams, v6, quote, onlyDirectRoutes, }: {
|
|
690
2320
|
swapClient?: UnifiedSwapClient | SwapClient;
|
|
@@ -705,6 +2335,15 @@ export declare class VelocityClient {
|
|
|
705
2335
|
};
|
|
706
2336
|
quote?: UnifiedQuoteResponse;
|
|
707
2337
|
}): Promise<TransactionSignature>;
|
|
2338
|
+
/**
|
|
2339
|
+
* Builds the instruction list for a Titan-routed swap: creates any missing associated token
|
|
2340
|
+
* accounts, wraps Titan's routing instructions between `beginSwap`/`endSwap`. See `swap` for
|
|
2341
|
+
* parameter semantics; `amount` is in the "in" token's mint decimals.
|
|
2342
|
+
* @param userAccountPublicKey - Optional user account override (e.g. when the account is being
|
|
2343
|
+
* created in the same transaction and not yet resolvable via `getUserAccountPublicKey`).
|
|
2344
|
+
* @returns `ixs` — instruction list (ATA creation, `beginSwap`, Titan swap instructions,
|
|
2345
|
+
* `endSwap`, in order) and `lookupTables` needed to fit it in a versioned transaction.
|
|
2346
|
+
*/
|
|
708
2347
|
getTitanSwapIx({ titanClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, reduceOnly, userAccountPublicKey, }: {
|
|
709
2348
|
titanClient: TitanClient;
|
|
710
2349
|
outMarketIndex: number;
|
|
@@ -721,6 +2360,17 @@ export declare class VelocityClient {
|
|
|
721
2360
|
ixs: TransactionInstruction[];
|
|
722
2361
|
lookupTables: AddressLookupTableAccount[];
|
|
723
2362
|
}>;
|
|
2363
|
+
/**
|
|
2364
|
+
* Builds the instruction list for a Jupiter v6-routed swap: fetches a quote if none is passed,
|
|
2365
|
+
* creates any missing associated token accounts, and wraps Jupiter's routing instructions
|
|
2366
|
+
* between `beginSwap`/`endSwap`. See `swap` for parameter semantics; `amount` is in the "in"
|
|
2367
|
+
* token's mint decimals.
|
|
2368
|
+
* @param userAccountPublicKey - Optional user account override (e.g. when the account is being
|
|
2369
|
+
* created in the same transaction).
|
|
2370
|
+
* @throws If no quote is passed and Jupiter's quote API returns none.
|
|
2371
|
+
* @returns `ixs` — instruction list (ATA creation, `beginSwap`, Jupiter swap instructions,
|
|
2372
|
+
* `endSwap`, in order) and `lookupTables` needed to fit it in a versioned transaction.
|
|
2373
|
+
*/
|
|
724
2374
|
getJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, quote, reduceOnly, userAccountPublicKey, }: {
|
|
725
2375
|
jupiterClient: JupiterClient;
|
|
726
2376
|
outMarketIndex: number;
|
|
@@ -739,16 +2389,25 @@ export declare class VelocityClient {
|
|
|
739
2389
|
lookupTables: AddressLookupTableAccount[];
|
|
740
2390
|
}>;
|
|
741
2391
|
/**
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
*
|
|
747
|
-
* @param
|
|
748
|
-
* @param
|
|
749
|
-
* @param
|
|
750
|
-
*
|
|
751
|
-
* @param
|
|
2392
|
+
* Builds the `beginSwap`/`endSwap` instruction pair that must bracket an external swap
|
|
2393
|
+
* provider's routing instructions in the same transaction. `beginSwap` snapshots the token
|
|
2394
|
+
* account balances and moves `amountIn` out of the in-market vault; `endSwap` reconciles the
|
|
2395
|
+
* post-swap token balances back into the user's velocity deposits, enforces `limitPrice` and
|
|
2396
|
+
* `reduceOnly`, and validates both spot markets' oracles are fresh/valid.
|
|
2397
|
+
* @param outMarketIndex - Spot market index of the token being bought.
|
|
2398
|
+
* @param inMarketIndex - Spot market index of the token being sold.
|
|
2399
|
+
* @param amountIn - Amount of the in-token released from the vault to the swap provider, in
|
|
2400
|
+
* the in-token's own mint decimals (not a fixed protocol precision).
|
|
2401
|
+
* @param inTokenAccount - Token account the sold tokens are moved through.
|
|
2402
|
+
* @param outTokenAccount - Token account the bought tokens are moved through.
|
|
2403
|
+
* @param limitPrice - Minimum acceptable `out/in` swap price, PRICE_PRECISION (1e6); `endSwap`
|
|
2404
|
+
* throws `SwapLimitPriceBreached` if the realized price is lower. Omit for no price check.
|
|
2405
|
+
* @param reduceOnly - Which side (`In`/`Out`) must not increase in magnitude after the swap;
|
|
2406
|
+
* enforced by `endSwap`.
|
|
2407
|
+
* @param userAccountPublicKey - Optional user account override; useful when the account is
|
|
2408
|
+
* being created within the same transaction and not yet resolvable via
|
|
2409
|
+
* `getUserAccountPublicKey`.
|
|
2410
|
+
* @returns `{ beginSwapIx, endSwapIx }` — insert the swap provider's instructions between them.
|
|
752
2411
|
*/
|
|
753
2412
|
getSwapIx({ outMarketIndex, inMarketIndex, amountIn, inTokenAccount, outTokenAccount, limitPrice, reduceOnly, userAccountPublicKey, }: {
|
|
754
2413
|
outMarketIndex: number;
|
|
@@ -763,6 +2422,17 @@ export declare class VelocityClient {
|
|
|
763
2422
|
beginSwapIx: TransactionInstruction;
|
|
764
2423
|
endSwapIx: TransactionInstruction;
|
|
765
2424
|
}>;
|
|
2425
|
+
/**
|
|
2426
|
+
* Builds the instruction list for a swap routed through a `UnifiedSwapClient` (the current
|
|
2427
|
+
* preferred swap path). Creates any missing associated token accounts and wraps the client's
|
|
2428
|
+
* routing instructions between `beginSwap`/`endSwap`. See `swap` for parameter semantics;
|
|
2429
|
+
* `amount` is in the "in" token's mint decimals (or "out" token's decimals when `swapMode` is
|
|
2430
|
+
* `ExactOut`).
|
|
2431
|
+
* @param userAccountPublicKey - Optional user account override (e.g. when the account is being
|
|
2432
|
+
* created in the same transaction).
|
|
2433
|
+
* @returns `ixs` — instruction list (ATA creation, `beginSwap`, routed swap instructions,
|
|
2434
|
+
* `endSwap`, in order) and `lookupTables` needed to fit it in a versioned transaction.
|
|
2435
|
+
*/
|
|
766
2436
|
getSwapIxV2({ swapClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, reduceOnly, quote, v6, userAccountPublicKey, }: {
|
|
767
2437
|
swapClient: UnifiedSwapClient;
|
|
768
2438
|
outMarketIndex: number;
|
|
@@ -783,128 +2453,494 @@ export declare class VelocityClient {
|
|
|
783
2453
|
ixs: TransactionInstruction[];
|
|
784
2454
|
lookupTables: AddressLookupTableAccount[];
|
|
785
2455
|
}>;
|
|
2456
|
+
/**
|
|
2457
|
+
* Converts a portion of the user's deposited wSOL (spot market index 1) into mSOL (spot market
|
|
2458
|
+
* index 2) by staking it with Marinade Finance, then swapping the resulting mSOL back into the
|
|
2459
|
+
* velocity deposit via `beginSwap`/`endSwap`. Sends and confirms the transaction.
|
|
2460
|
+
* @param amount - Amount of wSOL to stake, in lamports (wSOL mint decimals, 1e9).
|
|
2461
|
+
* @returns The transaction signature and confirmation slot.
|
|
2462
|
+
*/
|
|
786
2463
|
stakeForMSOL({ amount }: {
|
|
787
2464
|
amount: BN;
|
|
788
2465
|
}): Promise<TxSigAndSlot>;
|
|
2466
|
+
/**
|
|
2467
|
+
* Builds the instruction list for `stakeForMSOL`: wraps a Marinade `deposit` (wSOL to mSOL)
|
|
2468
|
+
* between the velocity `beginSwap`/`endSwap` pair so the mSOL lands back in the user's velocity
|
|
2469
|
+
* deposit for spot market index 2. Hardcodes wSOL as market index 1 and mSOL as market index 2.
|
|
2470
|
+
* @param amount - Amount of wSOL to stake, in lamports (wSOL mint decimals, 1e9).
|
|
2471
|
+
* @param userAccountPublicKey - Optional user account override; useful when the account is
|
|
2472
|
+
* being created within the same transaction.
|
|
2473
|
+
* @returns The ordered instruction list (WSOL ATA setup, `beginSwap`, close/recreate wSOL
|
|
2474
|
+
* account around the Marinade deposit, `endSwap`).
|
|
2475
|
+
*/
|
|
789
2476
|
getStakeForMSOLIx({ amount, userAccountPublicKey, }: {
|
|
790
2477
|
amount: BN;
|
|
791
2478
|
userAccountPublicKey?: PublicKey;
|
|
792
2479
|
}): Promise<TransactionInstruction[]>;
|
|
2480
|
+
/**
|
|
2481
|
+
* Keeper instruction: activates a resting trigger order (stop/take-profit, perp or spot) once
|
|
2482
|
+
* its `triggerPrice`/`triggerCondition` has been met, turning it into a fillable market/limit
|
|
2483
|
+
* order. Permissionless — any signer can act as filler and earns a small keeper fee. Does not
|
|
2484
|
+
* fill the order itself; a separate fill instruction (or place-and-take) is still required.
|
|
2485
|
+
* @param userAccountPublicKey - Public key of the order owner's user account.
|
|
2486
|
+
* @param user - Decoded user account for the order owner.
|
|
2487
|
+
* @param order - The trigger order to activate (`order.orderId`, `order.marketType`, `order.marketIndex`).
|
|
2488
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2489
|
+
* @param fillerPublicKey - Filler's user account public key; defaults to this client's own user account.
|
|
2490
|
+
* @returns The transaction signature.
|
|
2491
|
+
*/
|
|
793
2492
|
triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
2493
|
+
/**
|
|
2494
|
+
* Builds the `triggerOrder` instruction. See `triggerOrder` for semantics.
|
|
2495
|
+
* @param userAccountPublicKey - Public key of the order owner's user account.
|
|
2496
|
+
* @param userAccount - Decoded user account for the order owner.
|
|
2497
|
+
* @param order - The trigger order to activate.
|
|
2498
|
+
* @param fillerPublicKey - Filler's user account public key; defaults to this client's own user account.
|
|
2499
|
+
* @returns The instruction.
|
|
2500
|
+
*/
|
|
794
2501
|
getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
2502
|
+
/**
|
|
2503
|
+
* Keeper instruction: cancels a user's open, non-position-reducing orders when the user fails
|
|
2504
|
+
* their initial margin requirement (reverts with `SufficientCollateral` if the user still
|
|
2505
|
+
* meets it, or with `UserIsBeingLiquidated`/`UserBankrupt` if either is set). Charges the user a
|
|
2506
|
+
* per-cancelled-order fee paid to the filler. Permissionless — any signer can act as filler.
|
|
2507
|
+
* @param userAccountPublicKey - Public key of the target user's user account.
|
|
2508
|
+
* @param user - Decoded user account of the target user.
|
|
2509
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2510
|
+
* @param fillerPublicKey - Filler's user account public key; defaults to this client's own user account.
|
|
2511
|
+
* @returns The transaction signature.
|
|
2512
|
+
*/
|
|
795
2513
|
forceCancelOrders(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
2514
|
+
/**
|
|
2515
|
+
* Builds the `forceCancelOrders` instruction. See `forceCancelOrders` for semantics.
|
|
2516
|
+
* @param userAccountPublicKey - Public key of the target user's user account.
|
|
2517
|
+
* @param userAccount - Decoded user account of the target user.
|
|
2518
|
+
* @param fillerPublicKey - Filler's user account public key; defaults to this client's own user account.
|
|
2519
|
+
* @returns The instruction.
|
|
2520
|
+
*/
|
|
796
2521
|
getForceCancelOrdersIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
2522
|
+
/**
|
|
2523
|
+
* Keeper instruction: marks a user account idle after confirming (via `validate_user_is_idle`)
|
|
2524
|
+
* it has been inactive long enough — the inactivity window is shorter (accelerated) when the
|
|
2525
|
+
* user's equity is below 1000 USDC (QUOTE_PRECISION, 1e6). Idle users are excluded from some
|
|
2526
|
+
* keeper crank workloads. Permissionless — any signer can act as filler.
|
|
2527
|
+
* @param userAccountPublicKey - Public key of the target user's user account.
|
|
2528
|
+
* @param user - Decoded user account of the target user.
|
|
2529
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2530
|
+
* @param fillerPublicKey - Filler's user account public key; defaults to this client's own user account.
|
|
2531
|
+
* @throws If the user does not yet qualify as idle.
|
|
2532
|
+
* @returns The transaction signature.
|
|
2533
|
+
*/
|
|
797
2534
|
updateUserIdle(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
2535
|
+
/**
|
|
2536
|
+
* Builds the `updateUserIdle` instruction. See `updateUserIdle` for semantics.
|
|
2537
|
+
* @param userAccountPublicKey - Public key of the target user's user account.
|
|
2538
|
+
* @param userAccount - Decoded user account of the target user.
|
|
2539
|
+
* @param fillerPublicKey - Filler's user account public key; defaults to this client's own user account.
|
|
2540
|
+
* @returns The instruction.
|
|
2541
|
+
*/
|
|
798
2542
|
getUpdateUserIdleIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
2543
|
+
/**
|
|
2544
|
+
* Debug/monitoring instruction: emits the user's equity, each non-zero spot position's signed
|
|
2545
|
+
* token amount (native mint decimals), and each open perp position's unrealized PnL
|
|
2546
|
+
* (QUOTE_PRECISION, 1e6) as program logs. Has no on-chain state effect. Exchange must not be
|
|
2547
|
+
* paused.
|
|
2548
|
+
* @param userAccountPublicKey - Public key of the user account to log.
|
|
2549
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2550
|
+
* @returns The transaction signature.
|
|
2551
|
+
*/
|
|
799
2552
|
logUserBalances(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
2553
|
+
/**
|
|
2554
|
+
* Builds the `logUserBalances` instruction. See `logUserBalances` for semantics. Fetches the
|
|
2555
|
+
* user account fresh from the RPC (rather than relying on a cached/passed-in account) to build
|
|
2556
|
+
* `remainingAccounts`.
|
|
2557
|
+
* @param userAccountPublicKey - Public key of the user account to log.
|
|
2558
|
+
* @returns The instruction.
|
|
2559
|
+
*/
|
|
800
2560
|
getLogUserBalancesIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
2561
|
+
/**
|
|
2562
|
+
* Recomputes and updates the `isReferrer` flag on a `UserStats` account from its current
|
|
2563
|
+
* referrer-related fields. Permissionless — anyone can trigger the refresh for any authority.
|
|
2564
|
+
* @param userAuthority - Wallet authority whose `UserStats` PDA should be refreshed.
|
|
2565
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2566
|
+
* @returns The transaction signature.
|
|
2567
|
+
*/
|
|
801
2568
|
updateUserStatsReferrerStatus(userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
2569
|
+
/**
|
|
2570
|
+
* Builds the `updateUserStatsReferrerStatus` instruction. See `updateUserStatsReferrerStatus`
|
|
2571
|
+
* for semantics.
|
|
2572
|
+
* @param userAuthority - Wallet authority whose `UserStats` PDA should be refreshed.
|
|
2573
|
+
* @returns The instruction.
|
|
2574
|
+
*/
|
|
802
2575
|
getUpdateUserStatsReferrerStatusIx(userAuthority: PublicKey): Promise<TransactionInstruction>;
|
|
2576
|
+
/**
|
|
2577
|
+
* Keeper instruction: recounts `user.orders` and rewrites `openOrders`/`hasOpenOrder`/
|
|
2578
|
+
* `openAuctions`/`hasOpenAuction` to match the account's actual order state — a repair
|
|
2579
|
+
* instruction for when these cached counters have drifted. Permissionless — any signer can act
|
|
2580
|
+
* as filler.
|
|
2581
|
+
* @param userAccountPublicKey - Public key of the target user's user account.
|
|
2582
|
+
* @param user - Decoded user account of the target user.
|
|
2583
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2584
|
+
* @param fillerPublicKey - Filler's user account public key; defaults to this client's own user account.
|
|
2585
|
+
* @returns The transaction signature.
|
|
2586
|
+
*/
|
|
803
2587
|
updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
2588
|
+
/**
|
|
2589
|
+
* Builds the `updateUserOpenOrdersCount` instruction. See `updateUserOpenOrdersCount` for
|
|
2590
|
+
* semantics.
|
|
2591
|
+
* @param userAccountPublicKey - Public key of the target user's user account.
|
|
2592
|
+
* @param userAccount - Decoded user account of the target user.
|
|
2593
|
+
* @param fillerPublicKey - Filler's user account public key; defaults to this client's own user account.
|
|
2594
|
+
* @returns The instruction.
|
|
2595
|
+
*/
|
|
804
2596
|
getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
2597
|
+
/**
|
|
2598
|
+
* Places a perp order and immediately attempts to fill it in the same instruction against the
|
|
2599
|
+
* AMM and/or the supplied `makerInfo`. `orderParams.postOnly` must be `PostOnlyParams.NONE` —
|
|
2600
|
+
* the on-chain handler rejects post-only orders here (use `placeAndMakePerpOrder` instead for a
|
|
2601
|
+
* post-only maker order). If the order is immediate-or-cancel (or `successCondition`/
|
|
2602
|
+
* `auctionDurationPercentage` is set) and still open after the fill attempt, it is cancelled
|
|
2603
|
+
* in the same instruction.
|
|
2604
|
+
* @param orderParams - Order to place; `baseAssetAmount` is BASE_PRECISION (1e9), `price`/
|
|
2605
|
+
* `triggerPrice`/`oraclePriceOffset` (signed) are PRICE_PRECISION (1e6).
|
|
2606
|
+
* @param makerInfo - Maker account(s) to include as fill counterparties, if any.
|
|
2607
|
+
* @param successCondition - Require the fill to be a `PartialFill` or `FullFill`; the
|
|
2608
|
+
* instruction reverts with `PlaceAndTakeOrderSuccessConditionFailed` if not met. Omit for no check.
|
|
2609
|
+
* @param auctionDurationPercentage - Percent (0-100, default 100) of the order's auction that
|
|
2610
|
+
* must have elapsed before this fill attempt is allowed to cross the AMM/makers at the current
|
|
2611
|
+
* auction price; packed on-chain into the same `u32` as `successCondition`.
|
|
2612
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2613
|
+
* @param subAccountId - Sub-account to place the order for; defaults to the active sub-account.
|
|
2614
|
+
* @param takerEscrow - The placing user's (taker's) decoded `RevenueShareEscrow`. Required to
|
|
2615
|
+
* attach the escrow account when the taker is referred but the order itself carries no builder
|
|
2616
|
+
* code — the builder case is detected automatically from `orderParams`.
|
|
2617
|
+
* @returns The transaction signature.
|
|
2618
|
+
*/
|
|
805
2619
|
placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, txParams?: TxParams, subAccountId?: number, takerEscrow?: RevenueShareEscrowAccount): Promise<TransactionSignature>;
|
|
2620
|
+
/**
|
|
2621
|
+
* Builds (without sending) a `placeAndTakePerpOrder` transaction bundled with optional bracket
|
|
2622
|
+
* orders (e.g. TP/SL) in the same transaction, plus optional companion transactions to cancel
|
|
2623
|
+
* the market's existing orders first and/or settle PnL after. Reuses a single recent blockhash
|
|
2624
|
+
* across all built transactions to save RPC round trips.
|
|
2625
|
+
* @param orderParams - Order to place; see `placeAndTakePerpOrder` for field precisions.
|
|
2626
|
+
* @param makerInfo - Maker account(s) to include as fill counterparties, if any.
|
|
2627
|
+
* @param bracketOrdersParams - Additional orders placed in the same transaction as the place-and-take.
|
|
2628
|
+
* @param txParams - Compute-unit/priority-fee overrides. Required (throws otherwise) if
|
|
2629
|
+
* `txParams.useSimulatedComputeUnits` is set or `exitEarlyIfSimFails` is `true`.
|
|
2630
|
+
* @param subAccountId - Sub-account to place the order for; defaults to the active sub-account.
|
|
2631
|
+
* @param cancelExistingOrders - If `true` and the order is perp, also builds a transaction
|
|
2632
|
+
* cancelling all existing open orders in that market.
|
|
2633
|
+
* @param settlePnl - If `true` and the order is perp, also builds a settle-PnL transaction for the market.
|
|
2634
|
+
* @param exitEarlyIfSimFails - If `true`, simulates the place-and-take transaction first and
|
|
2635
|
+
* returns `null` without building the real transactions if the simulation fails.
|
|
2636
|
+
* @param auctionDurationPercentage - See `placeAndTakePerpOrder`.
|
|
2637
|
+
* @param optionalIxs - Extra instructions prepended to the place-and-take transaction (and to
|
|
2638
|
+
* the cancel/settle-PnL transactions).
|
|
2639
|
+
* @param isolatedPositionDepositAmount - If set and the order increases the position, a
|
|
2640
|
+
* transfer into an isolated-margin position (token-mint precision) is prepended before placing.
|
|
2641
|
+
* @returns `null` if `exitEarlyIfSimFails` triggered an early exit; otherwise an object with
|
|
2642
|
+
* `placeAndTakeTx` and optional `cancelExistingOrdersTx`/`settlePnlTx` (each `undefined` when
|
|
2643
|
+
* not applicable).
|
|
2644
|
+
*/
|
|
806
2645
|
preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean, auctionDurationPercentage?: number, optionalIxs?: TransactionInstruction[], isolatedPositionDepositAmount?: BN): Promise<{
|
|
807
2646
|
placeAndTakeTx: Transaction | VersionedTransaction | undefined;
|
|
808
2647
|
cancelExistingOrdersTx: Transaction | VersionedTransaction | undefined;
|
|
809
2648
|
settlePnlTx: Transaction | VersionedTransaction | undefined;
|
|
810
2649
|
} | null>;
|
|
2650
|
+
/**
|
|
2651
|
+
* Builds, signs, and sends a `placeAndTakePerpOrder` transaction bundled with bracket orders via
|
|
2652
|
+
* `preparePlaceAndTakePerpOrderWithAdditionalOrders`, and returns the signed (but unsent)
|
|
2653
|
+
* companion cancel/settle-PnL transactions for the caller to broadcast separately.
|
|
2654
|
+
* @param orderParams - Order to place; see `placeAndTakePerpOrder` for field precisions.
|
|
2655
|
+
* @param makerInfo - Maker account(s) to include as fill counterparties, if any.
|
|
2656
|
+
* @param bracketOrdersParams - Additional orders placed in the same transaction as the place-and-take.
|
|
2657
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2658
|
+
* @param subAccountId - Sub-account to place the order for; defaults to the active sub-account.
|
|
2659
|
+
* @param cancelExistingOrders - See `preparePlaceAndTakePerpOrderWithAdditionalOrders`.
|
|
2660
|
+
* @param settlePnl - See `preparePlaceAndTakePerpOrderWithAdditionalOrders`.
|
|
2661
|
+
* @param exitEarlyIfSimFails - If `true`, returns `null` without sending when the pre-flight
|
|
2662
|
+
* simulation of the place-and-take transaction fails.
|
|
2663
|
+
* @returns `null` if the simulation failed and `exitEarlyIfSimFails` was set; otherwise `txSig`
|
|
2664
|
+
* for the sent place-and-take transaction plus the signed (unsent) `signedCancelExistingOrdersTx`
|
|
2665
|
+
* / `signedSettlePnlTx`, each `undefined` when not applicable.
|
|
2666
|
+
* @throws If `placeAndTakeTx` was not built (should not happen unless simulation-related options are misused).
|
|
2667
|
+
*/
|
|
811
2668
|
placeAndTakePerpWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean): Promise<{
|
|
812
2669
|
txSig: TransactionSignature;
|
|
813
2670
|
signedCancelExistingOrdersTx?: Transaction;
|
|
814
2671
|
signedSettlePnlTx?: Transaction;
|
|
815
2672
|
} | null>;
|
|
2673
|
+
/**
|
|
2674
|
+
* Builds the `placeAndTakePerpOrder` instruction. See `placeAndTakePerpOrder` for semantics.
|
|
2675
|
+
* @param orderParams - Order to place; see `placeAndTakePerpOrder` for field precisions.
|
|
2676
|
+
* @param makerInfo - Maker account(s) to include as fill counterparties, if any.
|
|
2677
|
+
* @param successCondition - See `placeAndTakePerpOrder`.
|
|
2678
|
+
* @param auctionDurationPercentage - See `placeAndTakePerpOrder`.
|
|
2679
|
+
* @param subAccountId - Sub-account to place the order for; defaults to the active sub-account.
|
|
2680
|
+
* @param overrides - `authority` overrides the signing authority (defaults to `this.wallet.publicKey`).
|
|
2681
|
+
* @param takerEscrow - See `placeAndTakePerpOrder`.
|
|
2682
|
+
* @returns The instruction.
|
|
2683
|
+
*/
|
|
816
2684
|
getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, subAccountId?: number, overrides?: {
|
|
817
2685
|
authority?: PublicKey;
|
|
818
2686
|
}, takerEscrow?: RevenueShareEscrowAccount): Promise<TransactionInstruction>;
|
|
2687
|
+
/**
|
|
2688
|
+
* Places a resting maker order and, in the same instruction, fills a specific counterparty
|
|
2689
|
+
* taker order (`takerInfo.order`) against it. `orderParams` must be an immediate-or-cancel,
|
|
2690
|
+
* post-only (not `PostOnlyParams.NONE`) limit order — the on-chain handler rejects any other
|
|
2691
|
+
* shape with `InvalidOrderIOCPostOnly`.
|
|
2692
|
+
* @param orderParams - Maker order to place; `baseAssetAmount` is BASE_PRECISION (1e9), `price`
|
|
2693
|
+
* is PRICE_PRECISION (1e6). Must have `orderType: LIMIT`, `postOnly` set, and be IOC.
|
|
2694
|
+
* @param takerInfo - The taker account/order to fill against (`takerInfo.order.orderId` must be open).
|
|
2695
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2696
|
+
* @param subAccountId - Sub-account placing the maker order; defaults to the active sub-account.
|
|
2697
|
+
* @param takerEscrow - The taker's decoded `RevenueShareEscrow`. Required to attach the escrow
|
|
2698
|
+
* when the taker is referred but their order carries no builder code — the builder case is
|
|
2699
|
+
* detected automatically from `takerInfo.order`.
|
|
2700
|
+
* @returns The transaction signature.
|
|
2701
|
+
*/
|
|
819
2702
|
placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, txParams?: TxParams, subAccountId?: number, takerEscrow?: RevenueShareEscrowAccount): Promise<TransactionSignature>;
|
|
2703
|
+
/**
|
|
2704
|
+
* Builds the `placeAndMakePerpOrder` instruction. See `placeAndMakePerpOrder` for semantics.
|
|
2705
|
+
* @param orderParams - Maker order to place; see `placeAndMakePerpOrder` for field precisions
|
|
2706
|
+
* and required order shape.
|
|
2707
|
+
* @param takerInfo - The taker account/order to fill against.
|
|
2708
|
+
* @param subAccountId - Sub-account placing the maker order; defaults to the active sub-account.
|
|
2709
|
+
* @param takerEscrow - See `placeAndMakePerpOrder`.
|
|
2710
|
+
* @returns The instruction.
|
|
2711
|
+
*/
|
|
820
2712
|
getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, subAccountId?: number, takerEscrow?: RevenueShareEscrowAccount): Promise<TransactionInstruction>;
|
|
2713
|
+
/**
|
|
2714
|
+
* Borsh-encodes a swift/signed-msg order message and signs the resulting hex-encoded buffer
|
|
2715
|
+
* with `signMessage` (this client's wallet keypair by default). The returned payload is what a
|
|
2716
|
+
* swift/signed-msg service or a taker-facing `placeSignedMsgTakerOrder` expects.
|
|
2717
|
+
* @param orderParamsMessage - The order message to sign; use `SignedMsgOrderParamsDelegateMessage`
|
|
2718
|
+
* when signing on behalf of a delegated authority (`delegateSigner: true`), otherwise
|
|
2719
|
+
* `SignedMsgOrderParamsMessage`.
|
|
2720
|
+
* @param delegateSigner - Whether `orderParamsMessage` is the delegate-signer variant; must match
|
|
2721
|
+
* the message's actual shape or encoding/decoding elsewhere will misinterpret the buffer.
|
|
2722
|
+
* @returns `{ orderParams, signature }` — `orderParams` is the hex-encoded borsh buffer as a
|
|
2723
|
+
* `Buffer`, `signature` is the detached ed25519 signature over it.
|
|
2724
|
+
*/
|
|
821
2725
|
signSignedMsgOrderParamsMessage(orderParamsMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, delegateSigner?: boolean): SignedMsgOrderParams;
|
|
822
2726
|
/**
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
* @param
|
|
827
|
-
* @param
|
|
828
|
-
*
|
|
829
|
-
* @returns
|
|
2727
|
+
* Bundles a pre-signed deposit transaction with a signed swift/signed-msg order message into
|
|
2728
|
+
* the request shape the Swift service expects for a "deposit and place" flow (e.g. depositing
|
|
2729
|
+
* new collateral and placing an order off-chain in one round trip before either lands on-chain).
|
|
2730
|
+
* @param depositTx - The signed tx containing a velocity deposit (e.g. see `buildSwiftDepositTx`).
|
|
2731
|
+
* @param orderParamsMessage - The order parameters message to sign.
|
|
2732
|
+
* @param delegateSigner - Whether `orderParamsMessage` is signed by a delegate; see `signSignedMsgOrderParamsMessage`.
|
|
2733
|
+
* @returns `{ deposit_tx, swift_order }` — the serialized deposit transaction and the signed order payload.
|
|
830
2734
|
*/
|
|
831
2735
|
buildDepositAndPlaceSignedMsgOrderRequest(depositTx: VersionedTransaction, orderParamsMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, delegateSigner?: boolean): {
|
|
832
2736
|
deposit_tx: Buffer;
|
|
833
2737
|
swift_order: SignedMsgOrderParams;
|
|
834
2738
|
};
|
|
2739
|
+
/**
|
|
2740
|
+
* Borsh-encodes a swift/signed-msg order message using the program's IDL type coder. Used
|
|
2741
|
+
* internally by `signSignedMsgOrderParamsMessage`; call directly if you need the raw encoded
|
|
2742
|
+
* bytes without also signing them.
|
|
2743
|
+
* @param orderParamsMessage - The order message to encode.
|
|
2744
|
+
* @param delegateSigner - Whether `orderParamsMessage` is the delegate-signer variant
|
|
2745
|
+
* (`SignedMsgOrderParamsDelegateMessage`) rather than the regular one — selects which on-chain
|
|
2746
|
+
* type is used to encode.
|
|
2747
|
+
* @returns The borsh-encoded message bytes.
|
|
2748
|
+
*/
|
|
835
2749
|
encodeSignedMsgOrderParamsMessage(orderParamsMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, delegateSigner?: boolean): Buffer;
|
|
2750
|
+
/**
|
|
2751
|
+
* Decodes a borsh-encoded swift/signed-msg order message. Zero-pads the input by 128 bytes
|
|
2752
|
+
* before decoding so messages encoded by an older IDL (missing newer, all-`Option` fields)
|
|
2753
|
+
* still decode instead of throwing on a too-short buffer. Note: this padding assumes any
|
|
2754
|
+
* newer fields added to the message type are `Option`s — a 128+ byte non-optional field
|
|
2755
|
+
* addition could still fail to decode older messages correctly.
|
|
2756
|
+
* @param encodedMessage - The borsh-encoded message bytes (as produced by `encodeSignedMsgOrderParamsMessage`).
|
|
2757
|
+
* @param delegateSigner - Whether to decode as the delegate-signer variant
|
|
2758
|
+
* (`SignedMsgOrderParamsDelegateMessage`) rather than the regular one.
|
|
2759
|
+
* @returns The decoded order message.
|
|
2760
|
+
*/
|
|
836
2761
|
decodeSignedMsgOrderParamsMessage(encodedMessage: Buffer, delegateSigner?: boolean): SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage;
|
|
2762
|
+
/**
|
|
2763
|
+
* Signs arbitrary bytes with a raw ed25519 detached signature (not a Solana transaction
|
|
2764
|
+
* signature) — the primitive used to sign swift/signed-msg order messages.
|
|
2765
|
+
* @param message - Bytes to sign.
|
|
2766
|
+
* @param keypair - Keypair to sign with; defaults to `this.wallet.payer`.
|
|
2767
|
+
* @throws If no keypair is available (e.g. the configured wallet has no local `payer`, such as
|
|
2768
|
+
* a browser-extension wallet — that case must sign the message externally instead).
|
|
2769
|
+
* @returns The detached ed25519 signature.
|
|
2770
|
+
*/
|
|
837
2771
|
signMessage(message: Uint8Array, keypair?: Keypair | undefined): Buffer;
|
|
2772
|
+
/**
|
|
2773
|
+
* Submits a previously off-chain-signed swift/signed-msg taker order on-chain: verifies the
|
|
2774
|
+
* ed25519 signature via the sysvar-instructions program and records the order in the taker's
|
|
2775
|
+
* `SignedMsgUserOrders` account (see `initializeSignedMsgUserOrders`, required beforehand).
|
|
2776
|
+
* This only registers the order — it does not place or fill it against the market; a keeper
|
|
2777
|
+
* (or `placeAndMakeSignedMsgPerpOrder`) still performs the actual place/fill.
|
|
2778
|
+
* @param signedSignedMsgOrderParams - The signed order payload from `signSignedMsgOrderParamsMessage`.
|
|
2779
|
+
* @param marketIndex - Perp market index the signed order targets.
|
|
2780
|
+
* @param takerInfo - Taker's account/authority info; `signingAuthority` is the delegate or
|
|
2781
|
+
* direct authority that produced the signature (compared against `takerUserAccount.delegate`
|
|
2782
|
+
* to determine whether the message decodes as the delegate-signer variant).
|
|
2783
|
+
* @param precedingIxs - Instructions that will precede the returned ones in the final
|
|
2784
|
+
* transaction; used only to compute the correct sysvar-instructions index for signature
|
|
2785
|
+
* verification (has no other effect — the caller is still responsible for including them).
|
|
2786
|
+
* @param overrideCustomIxIndex - Explicit index of the ed25519-verify instruction within the
|
|
2787
|
+
* final transaction; overrides the value derived from `precedingIxs.length`.
|
|
2788
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2789
|
+
* @returns The transaction signature.
|
|
2790
|
+
*/
|
|
838
2791
|
placeSignedMsgTakerOrder(signedSignedMsgOrderParams: SignedMsgOrderParams, marketIndex: number, takerInfo: {
|
|
839
2792
|
taker: PublicKey;
|
|
840
2793
|
takerStats: PublicKey;
|
|
841
2794
|
takerUserAccount: UserAccount;
|
|
842
2795
|
signingAuthority: PublicKey;
|
|
843
2796
|
}, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
2797
|
+
/**
|
|
2798
|
+
* Builds the two instructions for `placeSignedMsgTakerOrder`: an ed25519-signature-verify
|
|
2799
|
+
* instruction (must be placed at the sysvar-instructions index this function assumes — see
|
|
2800
|
+
* `precedingIxs`/`overrideCustomIxIndex`) followed by the `placeSignedMsgTakerOrder` program
|
|
2801
|
+
* instruction. See `placeSignedMsgTakerOrder` for semantics.
|
|
2802
|
+
* @param signedSignedMsgOrderParams - The signed order payload.
|
|
2803
|
+
* @param marketIndex - Perp market index the signed order targets.
|
|
2804
|
+
* @param takerInfo - Taker's account/authority info; see `placeSignedMsgTakerOrder`.
|
|
2805
|
+
* @param precedingIxs - Instructions preceding these two in the final transaction (used only
|
|
2806
|
+
* to compute the ed25519-verify instruction's sysvar index).
|
|
2807
|
+
* @param overrideCustomIxIndex - Explicit sysvar-instructions index override.
|
|
2808
|
+
* @returns `[ed25519VerifyIx, placeSignedMsgTakerOrderIx]`.
|
|
2809
|
+
*/
|
|
844
2810
|
getPlaceSignedMsgTakerPerpOrderIxs(signedSignedMsgOrderParams: SignedMsgOrderParams, marketIndex: number, takerInfo: {
|
|
845
2811
|
taker: PublicKey;
|
|
846
2812
|
takerStats: PublicKey;
|
|
847
2813
|
takerUserAccount: UserAccount;
|
|
848
2814
|
signingAuthority: PublicKey;
|
|
849
2815
|
}, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number): Promise<TransactionInstruction[]>;
|
|
2816
|
+
/**
|
|
2817
|
+
* Verifies and registers a taker's off-chain signed swift/signed-msg order (same as
|
|
2818
|
+
* `placeSignedMsgTakerOrder`) and, in the same transaction, places a maker order and fills the
|
|
2819
|
+
* taker order against it in one shot — the signed-msg analog of `placeAndMakePerpOrder`.
|
|
2820
|
+
* `orderParams` (the maker order) is subject to the same IOC/post-only/limit requirement as
|
|
2821
|
+
* `placeAndMakePerpOrder`.
|
|
2822
|
+
* @param signedSignedMsgOrderParams - The taker's signed order payload.
|
|
2823
|
+
* @param signedMsgOrderUuid - UUID identifying the signed-msg order, used by the program to
|
|
2824
|
+
* dedupe/match it against the recorded `SignedMsgUserOrders` entry.
|
|
2825
|
+
* @param takerInfo - Taker's account/authority info; see `placeSignedMsgTakerOrder`.
|
|
2826
|
+
* @param orderParams - Maker order to place; `baseAssetAmount` is BASE_PRECISION (1e9), `price`
|
|
2827
|
+
* is PRICE_PRECISION (1e6). Must have `orderType: LIMIT`, `postOnly` set, and be IOC.
|
|
2828
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2829
|
+
* @param subAccountId - Sub-account placing the maker order; defaults to the active sub-account.
|
|
2830
|
+
* @param precedingIxs - Instructions preceding these in the final transaction (used only to
|
|
2831
|
+
* compute the ed25519-verify instruction's sysvar index).
|
|
2832
|
+
* @param overrideCustomIxIndex - Explicit sysvar-instructions index override.
|
|
2833
|
+
* @param takerEscrow - The taker's decoded `RevenueShareEscrow`. Required to attach the escrow
|
|
2834
|
+
* when the taker is referred but the signed order carries no builder code.
|
|
2835
|
+
* @returns The transaction signature.
|
|
2836
|
+
*/
|
|
850
2837
|
placeAndMakeSignedMsgPerpOrder(signedSignedMsgOrderParams: SignedMsgOrderParams, signedMsgOrderUuid: Uint8Array, takerInfo: {
|
|
851
2838
|
taker: PublicKey;
|
|
852
2839
|
takerStats: PublicKey;
|
|
853
2840
|
takerUserAccount: UserAccount;
|
|
854
2841
|
signingAuthority: PublicKey;
|
|
855
2842
|
}, orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number, takerEscrow?: RevenueShareEscrowAccount): Promise<TransactionSignature>;
|
|
2843
|
+
/**
|
|
2844
|
+
* Builds the instructions for `placeAndMakeSignedMsgPerpOrder`: the taker signature-verify +
|
|
2845
|
+
* registration instructions from `getPlaceSignedMsgTakerPerpOrderIxs`, followed by the
|
|
2846
|
+
* `placeAndMakeSignedMsgPerpOrder` program instruction. See `placeAndMakeSignedMsgPerpOrder`
|
|
2847
|
+
* for semantics.
|
|
2848
|
+
* @param signedSignedMsgOrderParams - The taker's signed order payload.
|
|
2849
|
+
* @param signedMsgOrderUuid - UUID identifying the signed-msg order.
|
|
2850
|
+
* @param takerInfo - Taker's account/authority info.
|
|
2851
|
+
* @param orderParams - Maker order to place; see `placeAndMakeSignedMsgPerpOrder` for field
|
|
2852
|
+
* precisions and required order shape.
|
|
2853
|
+
* @param subAccountId - Sub-account placing the maker order; defaults to the active sub-account.
|
|
2854
|
+
* @param precedingIxs - Instructions preceding these in the final transaction (used only to
|
|
2855
|
+
* compute the ed25519-verify instruction's sysvar index).
|
|
2856
|
+
* @param overrideCustomIxIndex - Explicit sysvar-instructions index override.
|
|
2857
|
+
* @param takerEscrow - See `placeAndMakeSignedMsgPerpOrder`.
|
|
2858
|
+
* @returns `[ed25519VerifyIx, placeSignedMsgTakerOrderIx, placeAndMakeSignedMsgPerpOrderIx]`.
|
|
2859
|
+
*/
|
|
856
2860
|
getPlaceAndMakeSignedMsgPerpOrderIxs(signedSignedMsgOrderParams: SignedMsgOrderParams, signedMsgOrderUuid: Uint8Array, takerInfo: {
|
|
857
2861
|
taker: PublicKey;
|
|
858
2862
|
takerStats: PublicKey;
|
|
859
2863
|
takerUserAccount: UserAccount;
|
|
860
2864
|
signingAuthority: PublicKey;
|
|
861
2865
|
}, orderParams: OptionalOrderParams, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number, takerEscrow?: RevenueShareEscrowAccount): Promise<TransactionInstruction[]>;
|
|
2866
|
+
/**
|
|
2867
|
+
* Disabled. See `placeSpotOrder`.
|
|
2868
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2869
|
+
*/
|
|
862
2870
|
preparePlaceAndTakeSpotOrder(_orderParams: OptionalOrderParams, _fulfillmentConfig?: unknown, _makerInfo?: MakerInfo, _txParams?: TxParams, _subAccountId?: number): Promise<void>;
|
|
2871
|
+
/**
|
|
2872
|
+
* Disabled. See `placeSpotOrder`.
|
|
2873
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2874
|
+
*/
|
|
863
2875
|
placeAndTakeSpotOrder(_orderParams: OptionalOrderParams, _fulfillmentConfig?: unknown, _makerInfo?: MakerInfo, _txParams?: TxParams, _subAccountId?: number): Promise<TransactionSignature>;
|
|
2876
|
+
/**
|
|
2877
|
+
* Disabled. See `placeSpotOrder`.
|
|
2878
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2879
|
+
*/
|
|
864
2880
|
getPlaceAndTakeSpotOrderIx(_orderParams: OptionalOrderParams, _fulfillmentConfig?: unknown, _makerInfo?: MakerInfo, _subAccountId?: number): Promise<TransactionInstruction>;
|
|
2881
|
+
/**
|
|
2882
|
+
* Disabled. See `placeSpotOrder`.
|
|
2883
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2884
|
+
*/
|
|
865
2885
|
placeAndMakeSpotOrder(_orderParams: OptionalOrderParams, _takerInfo: TakerInfo, _fulfillmentConfig?: unknown, _txParams?: TxParams, _subAccountId?: number): Promise<TransactionSignature>;
|
|
2886
|
+
/**
|
|
2887
|
+
* Disabled. See `placeSpotOrder`.
|
|
2888
|
+
* @throws Always throws with the spot-DLOB-disabled message.
|
|
2889
|
+
*/
|
|
866
2890
|
getPlaceAndMakeSpotOrderIx(_orderParams: OptionalOrderParams, _takerInfo: TakerInfo, _fulfillmentConfig?: unknown, _subAccountId?: number): Promise<TransactionInstruction>;
|
|
867
2891
|
/**
|
|
868
|
-
*
|
|
2892
|
+
* Closes (or reduces to zero) the caller's entire perp position in `marketIndex` with a
|
|
2893
|
+
* reduce-only market order (or limit order if `limitPrice` is given), filled immediately via
|
|
2894
|
+
* `placeAndTakePerpOrder`.
|
|
2895
|
+
* @deprecated use `placePerpOrder` or `placeAndTakePerpOrder` instead.
|
|
2896
|
+
* @param marketIndex - Perp market index of the position to close.
|
|
2897
|
+
* @param limitPrice - Optional limit price, PRICE_PRECISION (1e6); omit for a pure market order.
|
|
2898
|
+
* @param subAccountId - Sub-account holding the position; defaults to the active sub-account.
|
|
2899
|
+
* @throws If there is no open position in `marketIndex` for the sub-account.
|
|
2900
|
+
* @returns The transaction signature.
|
|
869
2901
|
*/
|
|
870
2902
|
closePosition(marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>;
|
|
871
2903
|
/**
|
|
872
2904
|
* Modifies an open order by closing it and replacing it with a new order.
|
|
873
|
-
* @deprecated use modifyOrder instead
|
|
874
|
-
* @param orderId
|
|
875
|
-
* @param newBaseAmount
|
|
876
|
-
* @param
|
|
877
|
-
* @param newOraclePriceOffset
|
|
878
|
-
* @returns
|
|
2905
|
+
* @deprecated use `modifyOrder` instead.
|
|
2906
|
+
* @param orderId - The open order to modify (program-assigned order ID).
|
|
2907
|
+
* @param newBaseAmount - The new base amount for the order, BASE_PRECISION (1e9). One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
2908
|
+
* @param newLimitPrice - The new limit price for the order, PRICE_PRECISION (1e6). One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
2909
|
+
* @param newOraclePriceOffset - The new oracle price offset for the order, PRICE_PRECISION (1e6), signed. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
2910
|
+
* @returns The transaction signature.
|
|
879
2911
|
*/
|
|
880
2912
|
modifyPerpOrder(orderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: BN): Promise<TransactionSignature>;
|
|
881
2913
|
/**
|
|
882
2914
|
* Modifies an open order by closing it and replacing it with a new order.
|
|
883
|
-
* @deprecated use modifyOrderByUserOrderId instead
|
|
884
|
-
* @param userOrderId
|
|
885
|
-
* @param newBaseAmount
|
|
886
|
-
* @param
|
|
887
|
-
* @param newOraclePriceOffset
|
|
888
|
-
* @returns
|
|
2915
|
+
* @deprecated use `modifyOrderByUserOrderId` instead.
|
|
2916
|
+
* @param userOrderId - The open order to modify (caller-supplied `userOrderId`).
|
|
2917
|
+
* @param newBaseAmount - The new base amount for the order, BASE_PRECISION (1e9). One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
2918
|
+
* @param newLimitPrice - The new limit price for the order, PRICE_PRECISION (1e6). One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
2919
|
+
* @param newOraclePriceOffset - The new oracle price offset for the order, PRICE_PRECISION (1e6), signed. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
|
|
2920
|
+
* @returns The transaction signature.
|
|
889
2921
|
*/
|
|
890
2922
|
modifyPerpOrderByUserOrderId(userOrderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: BN): Promise<TransactionSignature>;
|
|
891
2923
|
/**
|
|
892
|
-
* Modifies an open order (spot or perp) by closing it and replacing it with a new order
|
|
893
|
-
*
|
|
894
|
-
*
|
|
895
|
-
* @param orderParams.
|
|
896
|
-
* @param orderParams.
|
|
897
|
-
* @param orderParams.
|
|
898
|
-
* @param orderParams.
|
|
899
|
-
* @param orderParams.
|
|
900
|
-
* @param orderParams.
|
|
901
|
-
* @param orderParams.
|
|
902
|
-
* @param orderParams.
|
|
903
|
-
* @param orderParams.
|
|
904
|
-
* @param orderParams.
|
|
905
|
-
* @param orderParams.
|
|
906
|
-
* @param orderParams.
|
|
907
|
-
* @
|
|
2924
|
+
* Modifies an open order (spot or perp) by closing it and replacing it with a new order in one
|
|
2925
|
+
* instruction. Only fields present (non-`undefined`) in `orderParams` are changed; the rest of
|
|
2926
|
+
* the order is left as-is.
|
|
2927
|
+
* @param orderParams.orderId - The open order to modify (program-assigned order ID).
|
|
2928
|
+
* @param orderParams.newDirection - The new direction for the order.
|
|
2929
|
+
* @param orderParams.newBaseAmount - The new base amount for the order, BASE_PRECISION (1e9).
|
|
2930
|
+
* @param orderParams.newLimitPrice - The new limit price for the order, PRICE_PRECISION (1e6).
|
|
2931
|
+
* @param orderParams.newOraclePriceOffset - The new oracle price offset for the order, PRICE_PRECISION (1e6), signed.
|
|
2932
|
+
* @param orderParams.newTriggerPrice - Optional - the new trigger price for the order, PRICE_PRECISION (1e6).
|
|
2933
|
+
* @param orderParams.auctionDuration - Slots the auction lasts; only relevant for market/oracle orders.
|
|
2934
|
+
* @param orderParams.auctionStartPrice - PRICE_PRECISION (1e6), signed; only relevant for market/oracle orders.
|
|
2935
|
+
* @param orderParams.auctionEndPrice - PRICE_PRECISION (1e6), signed; only relevant for market/oracle orders.
|
|
2936
|
+
* @param orderParams.reduceOnly - Whether the modified order must only reduce the position.
|
|
2937
|
+
* @param orderParams.postOnly - Post-only behavior for the modified order.
|
|
2938
|
+
* @param orderParams.bitFlags - Bitmask, see `OrderParamsBitFlag`.
|
|
2939
|
+
* @param orderParams.policy - Bitmask of `ModifyOrderPolicy` (e.g. `MustModify`, `ExcludePreviousFill`).
|
|
2940
|
+
* @param orderParams.maxTs - Unix timestamp after which the order expires.
|
|
2941
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2942
|
+
* @param subAccountId - Sub-account the order belongs to; defaults to the active sub-account.
|
|
2943
|
+
* @returns The transaction signature.
|
|
908
2944
|
*/
|
|
909
2945
|
modifyOrder(orderParams: {
|
|
910
2946
|
orderId: number;
|
|
@@ -924,10 +2960,12 @@ export declare class VelocityClient {
|
|
|
924
2960
|
policy?: number;
|
|
925
2961
|
}, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
926
2962
|
/**
|
|
927
|
-
*
|
|
928
|
-
* @param
|
|
929
|
-
* @param
|
|
930
|
-
* @
|
|
2963
|
+
* Builds the `modifyOrder` instruction. See `modifyOrder` for field semantics/precisions.
|
|
2964
|
+
* @param orderParams - The parameters for the order to modify.
|
|
2965
|
+
* @param subAccountId - Optional - the sub-account ID of the user to modify the order for; ignored if `overrides.user` is set.
|
|
2966
|
+
* @param overrides - `user` supplies a fully-loaded `User` to modify on behalf of (takes precedence over `subAccountId`); `authority` overrides the signing authority (defaults to `overrides.user`'s authority, else `this.wallet.publicKey`).
|
|
2967
|
+
* @throws If `overrides.user` is provided but its `UserAccount` isn't loaded.
|
|
2968
|
+
* @returns The instruction.
|
|
931
2969
|
*/
|
|
932
2970
|
getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, bitFlags, maxTs, policy, }: {
|
|
933
2971
|
orderId: number;
|
|
@@ -950,22 +2988,29 @@ export declare class VelocityClient {
|
|
|
950
2988
|
authority?: PublicKey;
|
|
951
2989
|
}): Promise<TransactionInstruction>;
|
|
952
2990
|
/**
|
|
953
|
-
* Modifies an open order by
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
*
|
|
959
|
-
* @param orderParams.
|
|
960
|
-
* @param orderParams.
|
|
961
|
-
* @param orderParams.
|
|
962
|
-
* @param orderParams.
|
|
963
|
-
* @param orderParams.
|
|
964
|
-
* @param orderParams.
|
|
965
|
-
* @param orderParams.
|
|
966
|
-
* @param orderParams.
|
|
967
|
-
* @param orderParams.
|
|
968
|
-
* @
|
|
2991
|
+
* Modifies an open order (identified by its caller-supplied `userOrderId`) by closing it and
|
|
2992
|
+
* replacing it with a new order in one instruction.
|
|
2993
|
+
*
|
|
2994
|
+
* Note: unlike `modifyOrder`, omitted `reduceOnly`/`bitFlags` are sent as `false`/`null`
|
|
2995
|
+
* respectively rather than "leave unchanged" — passing this method's `orderParams` without
|
|
2996
|
+
* `reduceOnly` will explicitly clear an existing reduce-only flag on the order.
|
|
2997
|
+
* @param orderParams.userOrderId - The open order to modify (caller-supplied `userOrderId`).
|
|
2998
|
+
* @param orderParams.newDirection - The new direction for the order.
|
|
2999
|
+
* @param orderParams.newBaseAmount - The new base amount for the order, BASE_PRECISION (1e9).
|
|
3000
|
+
* @param orderParams.newLimitPrice - The new limit price for the order, PRICE_PRECISION (1e6).
|
|
3001
|
+
* @param orderParams.newOraclePriceOffset - The new oracle price offset for the order, PRICE_PRECISION (1e6), signed.
|
|
3002
|
+
* @param orderParams.newTriggerPrice - Optional - the new trigger price for the order, PRICE_PRECISION (1e6).
|
|
3003
|
+
* @param orderParams.auctionDuration - Only required if order type changed to market from something else; slots.
|
|
3004
|
+
* @param orderParams.auctionStartPrice - Only required if order type changed to market from something else; PRICE_PRECISION (1e6), signed.
|
|
3005
|
+
* @param orderParams.auctionEndPrice - Only required if order type changed to market from something else; PRICE_PRECISION (1e6), signed.
|
|
3006
|
+
* @param orderParams.reduceOnly - Whether the modified order must only reduce the position; defaults to `false` if omitted.
|
|
3007
|
+
* @param orderParams.postOnly - Post-only behavior for the modified order.
|
|
3008
|
+
* @param orderParams.bitFlags - Bitmask, see `OrderParamsBitFlag`; defaults to unset if omitted.
|
|
3009
|
+
* @param orderParams.policy - `ModifyOrderPolicy` bitmask (e.g. `MustModify`, `ExcludePreviousFill`).
|
|
3010
|
+
* @param orderParams.maxTs - Unix timestamp after which the order expires.
|
|
3011
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3012
|
+
* @param subAccountId - Sub-account the order belongs to; defaults to the active sub-account.
|
|
3013
|
+
* @returns The transaction signature.
|
|
969
3014
|
*/
|
|
970
3015
|
modifyOrderByUserOrderId(orderParams: {
|
|
971
3016
|
userOrderId: number;
|
|
@@ -984,6 +3029,13 @@ export declare class VelocityClient {
|
|
|
984
3029
|
policy?: ModifyOrderPolicy;
|
|
985
3030
|
maxTs?: BN;
|
|
986
3031
|
}, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
3032
|
+
/**
|
|
3033
|
+
* Builds the `modifyOrderByUserOrderId` instruction. See `modifyOrderByUserOrderId` for field
|
|
3034
|
+
* semantics/precisions, including the `reduceOnly`/`bitFlags` default-clearing note.
|
|
3035
|
+
* @param orderParams - The parameters for the order to modify.
|
|
3036
|
+
* @param subAccountId - Sub-account the order belongs to; defaults to the active sub-account.
|
|
3037
|
+
* @returns The instruction.
|
|
3038
|
+
*/
|
|
987
3039
|
getModifyOrderByUserIdIx({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, bitFlags, maxTs, policy, }: {
|
|
988
3040
|
userOrderId: number;
|
|
989
3041
|
newDirection?: PositionDirection;
|
|
@@ -1001,31 +3053,247 @@ export declare class VelocityClient {
|
|
|
1001
3053
|
policy?: ModifyOrderPolicy;
|
|
1002
3054
|
maxTs?: BN;
|
|
1003
3055
|
}, subAccountId?: number): Promise<TransactionInstruction>;
|
|
3056
|
+
/**
|
|
3057
|
+
* Keeper instruction: settles unrealized perp PnL to/from each user's quote spot balance for
|
|
3058
|
+
* every `(user, marketIndex)` pair, one `settlePnl` instruction per pair in a single
|
|
3059
|
+
* transaction. Permissionless — any signer can act as the settling authority. Defaults to
|
|
3060
|
+
* `computeUnits: 1_400_000` if `txParams` is not supplied, since settling several users/markets
|
|
3061
|
+
* in one transaction is compute-heavy.
|
|
3062
|
+
* @param users - Users to settle, each with their user account public key and decoded account.
|
|
3063
|
+
* @param marketIndexes - Perp market indexes to settle for every user in `users`.
|
|
3064
|
+
* @param opts.filterInvalidMarkets - When true, drops any market index whose oracle currently
|
|
3065
|
+
* fails `isOracleValid` (per the on-chain oracle guard rails) before building instructions,
|
|
3066
|
+
* instead of letting the transaction fail on-chain for that market.
|
|
3067
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3068
|
+
* @returns The transaction signature.
|
|
3069
|
+
*/
|
|
1004
3070
|
settlePNLs(users: {
|
|
1005
3071
|
settleeUserAccountPublicKey: PublicKey;
|
|
1006
3072
|
settleeUserAccount: UserAccount;
|
|
1007
3073
|
}[], marketIndexes: number[], opts?: {
|
|
1008
3074
|
filterInvalidMarkets?: boolean;
|
|
1009
3075
|
}, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3076
|
+
/**
|
|
3077
|
+
* Builds one `settlePnl` instruction per `(user, marketIndex)` combination in `users` x
|
|
3078
|
+
* `marketIndexes`. See `settlePNL`/`settlePNLIx` for per-instruction semantics.
|
|
3079
|
+
* @param users - Users to settle, each with their user account public key and decoded account.
|
|
3080
|
+
* @param marketIndexes - Perp market indexes to settle for every user in `users`.
|
|
3081
|
+
* @param revenueShareEscrowMap - Optional builder/referral escrow lookup; when a user's escrow
|
|
3082
|
+
* has completed builder or referral orders on a market being settled, its `RevenueShareEscrow`
|
|
3083
|
+
* and builder/referrer accounts are attached so the on-chain sweep can pay them out.
|
|
3084
|
+
* @returns The ordered instruction list.
|
|
3085
|
+
*/
|
|
1010
3086
|
getSettlePNLsIxs(users: {
|
|
1011
3087
|
settleeUserAccountPublicKey: PublicKey;
|
|
1012
3088
|
settleeUserAccount: UserAccount;
|
|
1013
3089
|
}[], marketIndexes: number[], revenueShareEscrowMap?: RevenueShareEscrowMap): Promise<Array<TransactionInstruction>>;
|
|
3090
|
+
/**
|
|
3091
|
+
* Keeper instruction: settles a single user's unrealized perp PnL on one market to/from their
|
|
3092
|
+
* quote spot balance. Reads the live oracle (falling back to the AMM's freshness check only if
|
|
3093
|
+
* the live oracle is degraded); requires the market not be in `Settlement` status (use
|
|
3094
|
+
* `settleExpiredMarket`/expired-position settlement for that) and the quote spot market vault
|
|
3095
|
+
* balance to reconcile afterward. Permissionless — any signer can act as the settling authority.
|
|
3096
|
+
* @param settleeUserAccountPublicKey - Public key of the user account to settle.
|
|
3097
|
+
* @param settleeUserAccount - Decoded user account to settle.
|
|
3098
|
+
* @param marketIndex - Perp market index to settle.
|
|
3099
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3100
|
+
* @param optionalIxs - Extra instructions prepended to the settle transaction.
|
|
3101
|
+
* @param revenueShareEscrowMap - Optional builder/referral escrow lookup; see `settlePNLIx`.
|
|
3102
|
+
* @returns The transaction signature.
|
|
3103
|
+
*/
|
|
1014
3104
|
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, txParams?: TxParams, optionalIxs?: TransactionInstruction[], revenueShareEscrowMap?: RevenueShareEscrowMap): Promise<TransactionSignature>;
|
|
3105
|
+
/**
|
|
3106
|
+
* Builds the `settlePnl` instruction. See `settlePNL` for semantics. When
|
|
3107
|
+
* `revenueShareEscrowMap` is passed, inspects the settlee's `RevenueShareEscrow` for
|
|
3108
|
+
* completed, unpaid builder-fee or referral-reward orders on `marketIndex` and, if found,
|
|
3109
|
+
* appends the escrow PDA plus each relevant builder/referrer authority to
|
|
3110
|
+
* `remainingAccounts` so the on-chain sweep can pay them during settlement. Falls back to
|
|
3111
|
+
* attaching just the escrow PDA (for lazy cleanup) when the settlee has any builder order but
|
|
3112
|
+
* isn't present in the map (stale-cache case).
|
|
3113
|
+
* @param settleeUserAccountPublicKey - Public key of the user account to settle.
|
|
3114
|
+
* @param settleeUserAccount - Decoded user account to settle.
|
|
3115
|
+
* @param marketIndex - Perp market index to settle.
|
|
3116
|
+
* @param revenueShareEscrowMap - Optional builder/referral escrow lookup keyed by authority.
|
|
3117
|
+
* @returns The instruction.
|
|
3118
|
+
*/
|
|
1015
3119
|
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, revenueShareEscrowMap?: RevenueShareEscrowMap): Promise<TransactionInstruction>;
|
|
3120
|
+
/**
|
|
3121
|
+
* Keeper instruction: settles one user's unrealized perp PnL across several markets in a
|
|
3122
|
+
* single `settleMultiplePnl` instruction/transaction. Fits at most ~4 markets per transaction
|
|
3123
|
+
* (see `settleMultiplePNLsMultipleTxs` for more). Permissionless — any signer can act as the
|
|
3124
|
+
* settling authority.
|
|
3125
|
+
* @param settleeUserAccountPublicKey - Public key of the user account to settle.
|
|
3126
|
+
* @param settleeUserAccount - Decoded user account to settle.
|
|
3127
|
+
* @param marketIndexes - Perp market indexes to settle (all in one transaction).
|
|
3128
|
+
* @param mode - `MustSettle` aborts the whole instruction if any per-market settlement fails;
|
|
3129
|
+
* `TrySettle` logs and skips failures so the remaining markets still settle.
|
|
3130
|
+
* @param revenueShareEscrowMap - Optional builder/referral escrow lookup; see `settlePNLIx`.
|
|
3131
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3132
|
+
* @returns The transaction signature.
|
|
3133
|
+
*/
|
|
1016
3134
|
settleMultiplePNLs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, revenueShareEscrowMap?: RevenueShareEscrowMap, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3135
|
+
/**
|
|
3136
|
+
* Settles one user's unrealized perp PnL across an arbitrary number of markets by splitting
|
|
3137
|
+
* `marketIndexes` into groups of 4 (more than ~4 markets' worth of accounts won't fit in a
|
|
3138
|
+
* single transaction) and sending one `settleMultiplePnl` transaction per group, sequentially.
|
|
3139
|
+
* Compute units scale with group size (`300_000` per market, capped at `1_400_000`).
|
|
3140
|
+
* @param settleeUserAccountPublicKey - Public key of the user account to settle.
|
|
3141
|
+
* @param settleeUserAccount - Decoded user account to settle.
|
|
3142
|
+
* @param marketIndexes - Perp market indexes to settle, in any quantity.
|
|
3143
|
+
* @param mode - `MustSettle` or `TrySettle`; see `settleMultiplePNLs`.
|
|
3144
|
+
* @param txParams - Optional compute-unit/priority-fee overrides (compute units are overridden
|
|
3145
|
+
* per group regardless of what is passed here).
|
|
3146
|
+
* @param optionalIxs - Extra instructions prepended to every group's transaction.
|
|
3147
|
+
* @param revenueShareEscrowMap - Optional builder/referral escrow lookup; see `settlePNLIx`.
|
|
3148
|
+
* @returns One transaction signature per group of up to 4 markets, in group order.
|
|
3149
|
+
*/
|
|
1017
3150
|
settleMultiplePNLsMultipleTxs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams, optionalIxs?: TransactionInstruction[], revenueShareEscrowMap?: RevenueShareEscrowMap): Promise<TransactionSignature[]>;
|
|
3151
|
+
/**
|
|
3152
|
+
* Builds the `settleMultiplePnl` instruction. See `settleMultiplePNLs` for semantics. Attaches
|
|
3153
|
+
* the settlee's `RevenueShareEscrow` and any relevant builder/referrer accounts when
|
|
3154
|
+
* `revenueShareEscrowMap` shows completed builder/referral orders on any of `marketIndexes`
|
|
3155
|
+
* (same logic as `settlePNLIx`, generalized across markets).
|
|
3156
|
+
* @param settleeUserAccountPublicKey - Public key of the user account to settle.
|
|
3157
|
+
* @param settleeUserAccount - Decoded user account to settle.
|
|
3158
|
+
* @param marketIndexes - Perp market indexes to settle.
|
|
3159
|
+
* @param mode - `MustSettle` or `TrySettle`; see `settleMultiplePNLs`.
|
|
3160
|
+
* @param overrides.authority - Settling authority override, if different from this client's wallet.
|
|
3161
|
+
* @param revenueShareEscrowMap - Optional builder/referral escrow lookup keyed by authority.
|
|
3162
|
+
* @returns The instruction.
|
|
3163
|
+
*/
|
|
1018
3164
|
settleMultiplePNLsIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, overrides?: {
|
|
1019
3165
|
authority?: PublicKey;
|
|
1020
3166
|
}, revenueShareEscrowMap?: RevenueShareEscrowMap): Promise<TransactionInstruction>;
|
|
3167
|
+
/**
|
|
3168
|
+
* Builds the `setUserStatusToBeingLiquidated` instruction. See `setUserStatusToBeingLiquidated`
|
|
3169
|
+
* for semantics.
|
|
3170
|
+
* @param userAccountPublicKey - Public key of the target user's user account.
|
|
3171
|
+
* @param userAccount - Decoded user account of the target user.
|
|
3172
|
+
* @returns The instruction.
|
|
3173
|
+
*/
|
|
1021
3174
|
getSetUserStatusToBeingLiquidatedIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
|
|
3175
|
+
/**
|
|
3176
|
+
* Keeper instruction: flags a user account as being liquidated (sets the `beingLiquidated`
|
|
3177
|
+
* status bit) without performing any liquidation itself. Used to "claim" a liquidation ahead of
|
|
3178
|
+
* the actual `liquidatePerp`/`liquidateSpot` call so a concurrent liquidator can't race it; the
|
|
3179
|
+
* on-chain handler re-checks the user is actually below maintenance margin before setting the
|
|
3180
|
+
* flag. Permissionless — any signer can act as liquidator.
|
|
3181
|
+
* @param userAccountPublicKey - Public key of the target user's user account.
|
|
3182
|
+
* @param userAccount - Decoded user account of the target user.
|
|
3183
|
+
* @returns The transaction signature.
|
|
3184
|
+
*/
|
|
1022
3185
|
setUserStatusToBeingLiquidated(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionSignature>;
|
|
3186
|
+
/**
|
|
3187
|
+
* Keeper instruction: liquidates part or all of a user's perp position in `marketIndex` when the
|
|
3188
|
+
* user is below maintenance margin (or already flagged `beingLiquidated`), transferring the
|
|
3189
|
+
* position to the calling liquidator's sub-account at the oracle price (subject to `limitPrice`
|
|
3190
|
+
* and the on-chain liquidation fee). Reverts if `userAccountPublicKey` equals the liquidator's
|
|
3191
|
+
* own user account. Permissionless — any signer can act as liquidator, taking on the position
|
|
3192
|
+
* and its PnL themselves.
|
|
3193
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3194
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3195
|
+
* @param marketIndex - Perp market index of the position to liquidate.
|
|
3196
|
+
* @param maxBaseAssetAmount - Maximum base amount the liquidator is willing to take on, BASE_PRECISION (1e9).
|
|
3197
|
+
* @param limitPrice - Optional worst acceptable price for the liquidator, PRICE_PRECISION (1e6).
|
|
3198
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3199
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3200
|
+
* @returns The transaction signature.
|
|
3201
|
+
*/
|
|
1023
3202
|
liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
3203
|
+
/**
|
|
3204
|
+
* Builds the `liquidatePerp` instruction. See `liquidatePerp` for semantics.
|
|
3205
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3206
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3207
|
+
* @param marketIndex - Perp market index of the position to liquidate.
|
|
3208
|
+
* @param maxBaseAssetAmount - Maximum base amount the liquidator is willing to take on, BASE_PRECISION (1e9).
|
|
3209
|
+
* @param limitPrice - Optional worst acceptable price for the liquidator, PRICE_PRECISION (1e6).
|
|
3210
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3211
|
+
* @returns The instruction.
|
|
3212
|
+
*/
|
|
1024
3213
|
getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
3214
|
+
/**
|
|
3215
|
+
* Keeper instruction: liquidates a user's perp position in `marketIndex` by filling it directly
|
|
3216
|
+
* against the supplied `makerInfos` (instead of transferring it to the liquidator's own
|
|
3217
|
+
* sub-account as `liquidatePerp` does). Reverts if `userAccountPublicKey` equals the liquidator's
|
|
3218
|
+
* own user account. Permissionless — any signer can act as liquidator/filler.
|
|
3219
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3220
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3221
|
+
* @param marketIndex - Perp market index of the position to liquidate.
|
|
3222
|
+
* @param makerInfos - Maker(s) to fill the liquidated position against.
|
|
3223
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3224
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3225
|
+
* @returns The transaction signature.
|
|
3226
|
+
*/
|
|
1025
3227
|
liquidatePerpWithFill(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, makerInfos: MakerInfo[], txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
3228
|
+
/**
|
|
3229
|
+
* Builds the `liquidatePerpWithFill` instruction. See `liquidatePerpWithFill` for semantics.
|
|
3230
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3231
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3232
|
+
* @param marketIndex - Perp market index of the position to liquidate.
|
|
3233
|
+
* @param makerInfos - Maker(s) to fill the liquidated position against; each contributes a
|
|
3234
|
+
* `(maker, makerStats)` pair appended to `remainingAccounts`.
|
|
3235
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3236
|
+
* @returns The instruction.
|
|
3237
|
+
*/
|
|
1026
3238
|
getLiquidatePerpWithFillIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, makerInfos: MakerInfo[], liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
3239
|
+
/**
|
|
3240
|
+
* Keeper instruction: liquidates a user's spot position by transferring `liabilityMarketIndex`
|
|
3241
|
+
* debt from the user to the liquidator's own sub-account in exchange for `assetMarketIndex`
|
|
3242
|
+
* collateral, when the user is below maintenance margin (or already flagged `beingLiquidated`).
|
|
3243
|
+
* Reverts if `userAccountPublicKey` equals the liquidator's own user account. Permissionless —
|
|
3244
|
+
* any signer can act as liquidator.
|
|
3245
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3246
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3247
|
+
* @param assetMarketIndex - Spot market index of the collateral the liquidator receives.
|
|
3248
|
+
* @param liabilityMarketIndex - Spot market index of the debt the liquidator repays/absorbs.
|
|
3249
|
+
* @param maxLiabilityTransfer - Maximum liability amount the liquidator is willing to take on, in
|
|
3250
|
+
* the liability spot market's token (mint) precision.
|
|
3251
|
+
* @param limitPrice - Optional worst acceptable asset/liability price ratio, PRICE_PRECISION (1e6).
|
|
3252
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3253
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3254
|
+
* @returns The transaction signature.
|
|
3255
|
+
*/
|
|
1027
3256
|
liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
3257
|
+
/**
|
|
3258
|
+
* Builds the `liquidateSpot` instruction. See `liquidateSpot` for semantics.
|
|
3259
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3260
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3261
|
+
* @param assetMarketIndex - Spot market index of the collateral the liquidator receives.
|
|
3262
|
+
* @param liabilityMarketIndex - Spot market index of the debt the liquidator repays/absorbs.
|
|
3263
|
+
* @param maxLiabilityTransfer - Maximum liability amount the liquidator is willing to take on, in
|
|
3264
|
+
* the liability spot market's token (mint) precision.
|
|
3265
|
+
* @param limitPrice - Optional worst acceptable asset/liability price ratio, PRICE_PRECISION (1e6).
|
|
3266
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3267
|
+
* @returns The instruction.
|
|
3268
|
+
*/
|
|
1028
3269
|
getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
3270
|
+
/**
|
|
3271
|
+
* Builds a Jupiter-routed spot-liquidation-with-swap instruction set: swaps the liquidator's
|
|
3272
|
+
* `assetMarketIndex` proceeds into `liabilityMarketIndex` tokens via Jupiter inside a
|
|
3273
|
+
* `beginSwap`/`endSwap` flash-loan sandwich (see `getLiquidateSpotWithSwapIx`), letting the
|
|
3274
|
+
* liquidator repay the user's debt without needing to already hold the liability token. Fetches a
|
|
3275
|
+
* quote from `jupiterClient` when `quote` is not supplied, and idempotently creates any missing
|
|
3276
|
+
* associated token accounts.
|
|
3277
|
+
* @param jupiterClient - Jupiter client used to fetch the quote/swap transaction.
|
|
3278
|
+
* @param liabilityMarketIndex - Spot market index of the debt being repaid (swap output).
|
|
3279
|
+
* @param assetMarketIndex - Spot market index of the collateral being sold (swap input).
|
|
3280
|
+
* @param swapAmount - Amount of `assetMarketIndex` token to sell, in that market's mint precision.
|
|
3281
|
+
* @param assetTokenAccount - Token account to debit for the swap input; defaults to this client's
|
|
3282
|
+
* associated token account for `assetMarketIndex`, created if missing.
|
|
3283
|
+
* @param liabilityTokenAccount - Token account to credit with the swap output; defaults to this
|
|
3284
|
+
* client's associated token account for `liabilityMarketIndex`, created if missing.
|
|
3285
|
+
* @param slippageBps - Max slippage in basis points passed to Jupiter.
|
|
3286
|
+
* @param swapMode - Jupiter swap mode (`ExactIn`/`ExactOut`).
|
|
3287
|
+
* @param onlyDirectRoutes - Restrict Jupiter to single-hop routes.
|
|
3288
|
+
* @param quote - Pre-fetched Jupiter quote (skips an extra round-trip).
|
|
3289
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3290
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3291
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3292
|
+
* @param maxAccounts - Caps the number of accounts Jupiter's route may use.
|
|
3293
|
+
* @throws If no quote can be fetched and `quote` was not supplied.
|
|
3294
|
+
* @returns The ordered instructions (pre-instructions, `beginSwap`, Jupiter swap, `endSwap`) and
|
|
3295
|
+
* any address lookup tables the Jupiter route requires.
|
|
3296
|
+
*/
|
|
1029
3297
|
getJupiterLiquidateSpotWithSwapIxV6({ jupiterClient, liabilityMarketIndex, assetMarketIndex, swapAmount, assetTokenAccount, liabilityTokenAccount, slippageBps, swapMode, onlyDirectRoutes, quote, userAccount, userAccountPublicKey, liquidatorSubAccountId, maxAccounts, }: {
|
|
1030
3298
|
jupiterClient: JupiterClient;
|
|
1031
3299
|
liabilityMarketIndex: number;
|
|
@@ -1046,15 +3314,22 @@ export declare class VelocityClient {
|
|
|
1046
3314
|
lookupTables: AddressLookupTableAccount[];
|
|
1047
3315
|
}>;
|
|
1048
3316
|
/**
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1054
|
-
*
|
|
1055
|
-
* @param
|
|
1056
|
-
* @param
|
|
1057
|
-
* @param
|
|
3317
|
+
* Builds the `liquidateSpotWithSwapBegin`/`...End` instruction pair that sandwiches an
|
|
3318
|
+
* external swap (e.g. Jupiter) so a liquidator can repay a user's `liabilityMarketIndex` debt
|
|
3319
|
+
* using proceeds from selling `assetMarketIndex` collateral within the same transaction, without
|
|
3320
|
+
* pre-funding the liability token. The on-chain handler validates the liability spot market's
|
|
3321
|
+
* flash-loan balance is unwound by `endSwap`. See `getJupiterLiquidateSpotWithSwapIxV6` for the
|
|
3322
|
+
* Jupiter-specific wrapper that assembles the full instruction list around this pair.
|
|
3323
|
+
* @param liabilityMarketIndex - Spot market index of the debt being repaid (swap output/buy side).
|
|
3324
|
+
* @param assetMarketIndex - Spot market index of the collateral being sold (swap input/sell side).
|
|
3325
|
+
* @param swapAmount - Amount of `assetMarketIndex` token to sell, in that market's mint precision.
|
|
3326
|
+
* @param assetTokenAccount - Token account to debit for the swap input.
|
|
3327
|
+
* @param liabilityTokenAccount - Token account to credit with the swap output.
|
|
3328
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3329
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3330
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3331
|
+
* @returns `beginSwapIx`/`endSwapIx` — the caller must place the external swap instructions
|
|
3332
|
+
* between them.
|
|
1058
3333
|
*/
|
|
1059
3334
|
getLiquidateSpotWithSwapIx({ liabilityMarketIndex, assetMarketIndex, swapAmount: swapAmount, assetTokenAccount, liabilityTokenAccount, userAccount, userAccountPublicKey, liquidatorSubAccountId, }: {
|
|
1060
3335
|
liabilityMarketIndex: number;
|
|
@@ -1069,28 +3344,271 @@ export declare class VelocityClient {
|
|
|
1069
3344
|
beginSwapIx: TransactionInstruction;
|
|
1070
3345
|
endSwapIx: TransactionInstruction;
|
|
1071
3346
|
}>;
|
|
3347
|
+
/**
|
|
3348
|
+
* Keeper instruction: liquidates a user by transferring `liabilityMarketIndex` spot debt from the
|
|
3349
|
+
* user to the liquidator in exchange for a matching amount of the user's positive unsettled perp
|
|
3350
|
+
* PnL in `perpMarketIndex`. Only usable once the user's position size in `perpMarketIndex` is
|
|
3351
|
+
* zero (the PnL must already be fully unrealized/settled-out, not backed by an open position).
|
|
3352
|
+
* Reverts if `userAccountPublicKey` equals the liquidator's own user account. Permissionless —
|
|
3353
|
+
* any signer can act as liquidator.
|
|
3354
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3355
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3356
|
+
* @param perpMarketIndex - Perp market index whose unsettled PnL backs the transfer, QUOTE_PRECISION (1e6).
|
|
3357
|
+
* @param liabilityMarketIndex - Spot market index of the debt being repaid.
|
|
3358
|
+
* @param maxLiabilityTransfer - Maximum liability amount the liquidator is willing to take on, in
|
|
3359
|
+
* the liability spot market's token (mint) precision.
|
|
3360
|
+
* @param limitPrice - Optional worst acceptable liability/PnL price ratio, PRICE_PRECISION (1e6).
|
|
3361
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3362
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3363
|
+
* @returns The transaction signature.
|
|
3364
|
+
*/
|
|
1072
3365
|
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
3366
|
+
/**
|
|
3367
|
+
* Builds the `liquidateBorrowForPerpPnl` instruction. See `liquidateBorrowForPerpPnl` for semantics.
|
|
3368
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3369
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3370
|
+
* @param perpMarketIndex - Perp market index whose unsettled PnL backs the transfer.
|
|
3371
|
+
* @param liabilityMarketIndex - Spot market index of the debt being repaid.
|
|
3372
|
+
* @param maxLiabilityTransfer - Maximum liability amount the liquidator is willing to take on, in
|
|
3373
|
+
* the liability spot market's token (mint) precision.
|
|
3374
|
+
* @param limitPrice - Optional worst acceptable liability/PnL price ratio, PRICE_PRECISION (1e6).
|
|
3375
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3376
|
+
* @returns The instruction.
|
|
3377
|
+
*/
|
|
1073
3378
|
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
3379
|
+
/**
|
|
3380
|
+
* Keeper instruction: liquidates a user by transferring negative unsettled perp PnL in
|
|
3381
|
+
* `perpMarketIndex` from the user to the liquidator in exchange for `assetMarketIndex` spot
|
|
3382
|
+
* collateral (the inverse of `liquidateBorrowForPerpPnl`). Only usable once the user's position
|
|
3383
|
+
* size in `perpMarketIndex` is zero. Reverts if `userAccountPublicKey` equals the liquidator's
|
|
3384
|
+
* own user account. Permissionless — any signer can act as liquidator.
|
|
3385
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3386
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3387
|
+
* @param perpMarketIndex - Perp market index of the negative unsettled PnL being absorbed.
|
|
3388
|
+
* @param assetMarketIndex - Spot market index of the collateral the liquidator receives.
|
|
3389
|
+
* @param maxPnlTransfer - Maximum PnL amount the liquidator is willing to absorb, QUOTE_PRECISION (1e6).
|
|
3390
|
+
* @param limitPrice - Optional worst acceptable PnL/asset price ratio, PRICE_PRECISION (1e6).
|
|
3391
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3392
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3393
|
+
* @returns The transaction signature.
|
|
3394
|
+
*/
|
|
1074
3395
|
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
3396
|
+
/**
|
|
3397
|
+
* Builds the `liquidatePerpPnlForDeposit` instruction. See `liquidatePerpPnlForDeposit` for semantics.
|
|
3398
|
+
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3399
|
+
* @param userAccount - Decoded user account being liquidated.
|
|
3400
|
+
* @param perpMarketIndex - Perp market index of the negative unsettled PnL being absorbed.
|
|
3401
|
+
* @param assetMarketIndex - Spot market index of the collateral the liquidator receives.
|
|
3402
|
+
* @param maxPnlTransfer - Maximum PnL amount the liquidator is willing to absorb, QUOTE_PRECISION (1e6).
|
|
3403
|
+
* @param limitPrice - Optional worst acceptable PnL/asset price ratio, PRICE_PRECISION (1e6).
|
|
3404
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3405
|
+
* @returns The instruction.
|
|
3406
|
+
*/
|
|
1075
3407
|
getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
3408
|
+
/**
|
|
3409
|
+
* Keeper instruction: resolves a user's perp bankruptcy in `marketIndex` (negative equity that
|
|
3410
|
+
* liquidation alone could not cover) by socializing the loss — first attempting to backstop it
|
|
3411
|
+
* from the quote spot market's insurance fund, then socializing any remainder across the market's
|
|
3412
|
+
* other position holders via the cumulative funding/PnL pool. Reverts if the resulting insurance
|
|
3413
|
+
* payout would fully drain the insurance fund vault, or if `userAccountPublicKey` equals the
|
|
3414
|
+
* liquidator's own user account. Permissionless — any signer can act as liquidator.
|
|
3415
|
+
* @param userAccountPublicKey - Public key of the bankrupt user's user account.
|
|
3416
|
+
* @param userAccount - Decoded user account of the bankrupt user.
|
|
3417
|
+
* @param marketIndex - Perp market index of the bankrupt position.
|
|
3418
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3419
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3420
|
+
* @returns The transaction signature.
|
|
3421
|
+
*/
|
|
1076
3422
|
resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
3423
|
+
/**
|
|
3424
|
+
* Builds the `resolvePerpBankruptcy` instruction. See `resolvePerpBankruptcy` for semantics.
|
|
3425
|
+
* Always settles against the quote spot market (`QUOTE_SPOT_MARKET_INDEX`).
|
|
3426
|
+
* @param userAccountPublicKey - Public key of the bankrupt user's user account.
|
|
3427
|
+
* @param userAccount - Decoded user account of the bankrupt user.
|
|
3428
|
+
* @param marketIndex - Perp market index of the bankrupt position.
|
|
3429
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3430
|
+
* @returns The instruction.
|
|
3431
|
+
*/
|
|
1077
3432
|
getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
3433
|
+
/**
|
|
3434
|
+
* Keeper instruction: resolves a user's spot bankruptcy (negative balance in `marketIndex` that
|
|
3435
|
+
* liquidation alone could not cover) by backstopping the deficit from that spot market's
|
|
3436
|
+
* insurance fund. Reverts if `userAccountPublicKey` equals the liquidator's own user account.
|
|
3437
|
+
* Permissionless — any signer can act as liquidator.
|
|
3438
|
+
* @param userAccountPublicKey - Public key of the bankrupt user's user account.
|
|
3439
|
+
* @param userAccount - Decoded user account of the bankrupt user.
|
|
3440
|
+
* @param marketIndex - Spot market index of the bankrupt balance.
|
|
3441
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3442
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3443
|
+
* @returns The transaction signature.
|
|
3444
|
+
*/
|
|
1078
3445
|
resolveSpotBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
3446
|
+
/**
|
|
3447
|
+
* Builds the `resolveSpotBankruptcy` instruction. See `resolveSpotBankruptcy` for semantics.
|
|
3448
|
+
* Adds the spot market's mint (and transfer-hook extra account metas, if applicable) to
|
|
3449
|
+
* `remainingAccounts` for the token transfer from the insurance fund vault.
|
|
3450
|
+
* @param userAccountPublicKey - Public key of the bankrupt user's user account.
|
|
3451
|
+
* @param userAccount - Decoded user account of the bankrupt user.
|
|
3452
|
+
* @param marketIndex - Spot market index of the bankrupt balance.
|
|
3453
|
+
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3454
|
+
* @returns The instruction.
|
|
3455
|
+
*/
|
|
1079
3456
|
getResolveSpotBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
3457
|
+
/**
|
|
3458
|
+
* Keeper instruction: recomputes and applies `marketIndex`'s hourly-anchored funding rate
|
|
3459
|
+
* (`cumulativeFundingRateLong`/`Short`, FUNDING_RATE_PRECISION, 1e9) from the current oracle/AMM
|
|
3460
|
+
* mark-price spread, then updates the market's oracle-derived TWAP stats. No-ops (via
|
|
3461
|
+
* `FundingWasNotUpdated`, which the underlying call surfaces as a failed transaction) if it is
|
|
3462
|
+
* not yet time for the next update — `perp_market.market_stats.funding_period` seconds since the
|
|
3463
|
+
* last update, on-the-hour aligned. Reverts if the market's funding is paused or the market is
|
|
3464
|
+
* not `Active`/`ReduceOnly`. Permissionless — any signer can act as keeper.
|
|
3465
|
+
* @param perpMarketIndex - Perp market index to update funding for.
|
|
3466
|
+
* @param oracle - The market's oracle account (`perpMarket.oracle`).
|
|
3467
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3468
|
+
* @returns The transaction signature.
|
|
3469
|
+
*/
|
|
1080
3470
|
updateFundingRate(perpMarketIndex: number, oracle: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3471
|
+
/**
|
|
3472
|
+
* Builds the `updateFundingRate` instruction. See `updateFundingRate` for semantics.
|
|
3473
|
+
* @param perpMarketIndex - Perp market index to update funding for.
|
|
3474
|
+
* @param oracle - The market's oracle account (`perpMarket.oracle`).
|
|
3475
|
+
* @returns The instruction.
|
|
3476
|
+
*/
|
|
1081
3477
|
getUpdateFundingRateIx(perpMarketIndex: number, oracle: PublicKey): Promise<TransactionInstruction>;
|
|
3478
|
+
/**
|
|
3479
|
+
* Keeper instruction: refreshes a `Prelaunch`-oracle-source perp market's synthetic oracle price
|
|
3480
|
+
* from its own recent trading activity (used for markets without a live external price feed,
|
|
3481
|
+
* e.g. pre-listing futures). Only valid when the market's `oracleSource` is `Prelaunch`.
|
|
3482
|
+
* Permissionless — any signer can act as keeper.
|
|
3483
|
+
* @param perpMarketIndex - Perp market index to update; must use the `Prelaunch` oracle source.
|
|
3484
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3485
|
+
* @throws If `perpMarketIndex`'s `oracleSource` is not `Prelaunch`.
|
|
3486
|
+
* @returns The transaction signature.
|
|
3487
|
+
*/
|
|
1082
3488
|
updatePrelaunchOracle(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3489
|
+
/**
|
|
3490
|
+
* Builds the `updatePrelaunchOracle` instruction. See `updatePrelaunchOracle` for semantics.
|
|
3491
|
+
* @param perpMarketIndex - Perp market index to update; must use the `Prelaunch` oracle source.
|
|
3492
|
+
* @throws If `perpMarketIndex`'s `oracleSource` is not `Prelaunch`.
|
|
3493
|
+
* @returns The instruction.
|
|
3494
|
+
*/
|
|
1083
3495
|
getUpdatePrelaunchOracleIx(perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
3496
|
+
/**
|
|
3497
|
+
* Keeper instruction: estimates the market's bid/ask price from the given makers' resting DLOB
|
|
3498
|
+
* orders (filtered to those within `BID_ASK_TWAP_MAX_ORACLE_DIVERGENCE_PERCENT` of the oracle
|
|
3499
|
+
* price) and folds the estimate into `lastBidPriceTwap`/`lastAskPriceTwap`. Restricted: the
|
|
3500
|
+
* calling wallet's `UserStats` must have `canUpdateBidAskTwap` set and at least 1000 USDC
|
|
3501
|
+
* (`QUOTE_PRECISION`, 1e6) staked in the insurance fund (`ifStakedQuoteAssetAmount`), or the
|
|
3502
|
+
* instruction reverts.
|
|
3503
|
+
* @param perpMarketIndex - Perp market index to update.
|
|
3504
|
+
* @param makers - `(maker, makerStats)` pairs whose resting orders are sampled for the estimate.
|
|
3505
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3506
|
+
* @returns The transaction signature.
|
|
3507
|
+
*/
|
|
1084
3508
|
updatePerpBidAskTwap(perpMarketIndex: number, makers: [PublicKey, PublicKey][], txParams?: TxParams): Promise<TransactionSignature>;
|
|
3509
|
+
/**
|
|
3510
|
+
* Builds the `updatePerpBidAskTwap` instruction. See `updatePerpBidAskTwap` for semantics.
|
|
3511
|
+
* @param perpMarketIndex - Perp market index to update.
|
|
3512
|
+
* @param makers - `(maker, makerStats)` pairs whose resting orders are sampled for the estimate.
|
|
3513
|
+
* @returns The instruction.
|
|
3514
|
+
*/
|
|
1085
3515
|
getUpdatePerpBidAskTwapIx(perpMarketIndex: number, makers: [PublicKey, PublicKey][]): Promise<TransactionInstruction>;
|
|
3516
|
+
/**
|
|
3517
|
+
* Keeper instruction: settles accrued funding payments into the quote balance of every perp
|
|
3518
|
+
* position the target user currently holds, using each market's latest
|
|
3519
|
+
* `cumulativeFundingRateLong`/`Short` (FUNDING_RATE_PRECISION, 1e9). Fetches the user account
|
|
3520
|
+
* fresh from the RPC (does not rely on this client's subscription cache) to determine which
|
|
3521
|
+
* markets to include. Permissionless — any signer can act as keeper.
|
|
3522
|
+
* @param userAccountPublicKey - Public key of the user account to settle funding for.
|
|
3523
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3524
|
+
* @returns The transaction signature.
|
|
3525
|
+
*/
|
|
1086
3526
|
settleFundingPayment(userAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3527
|
+
/**
|
|
3528
|
+
* Builds the `settleFundingPayment` instruction. See `settleFundingPayment` for semantics. Fetches
|
|
3529
|
+
* the user account directly via `program.account.user.fetch` and includes every market the user
|
|
3530
|
+
* has a non-empty position in as a writable remaining account.
|
|
3531
|
+
* @param userAccountPublicKey - Public key of the user account to settle funding for.
|
|
3532
|
+
* @returns The instruction.
|
|
3533
|
+
*/
|
|
1087
3534
|
getSettleFundingPaymentIx(userAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
3535
|
+
/**
|
|
3536
|
+
* Manually emits an event on this client's internal `eventEmitter`, as if it had come from the
|
|
3537
|
+
* account subscriber. Intended for tests/tooling that need to simulate account-update events;
|
|
3538
|
+
* not used by normal instruction-building code paths.
|
|
3539
|
+
* @param eventName - Name of the event to emit; see `VelocityClientAccountEvents`.
|
|
3540
|
+
* @param data - Optional event payload.
|
|
3541
|
+
*/
|
|
1088
3542
|
triggerEvent(eventName: keyof VelocityClientAccountEvents, data?: any): void;
|
|
3543
|
+
/**
|
|
3544
|
+
* Reads the last-known primary oracle price for a perp market from the account subscriber's
|
|
3545
|
+
* cache (no RPC call). This is the raw exchange oracle price, unadjusted by the market's MM
|
|
3546
|
+
* oracle — use `getMMOracleDataForPerpMarket` when you need the price the program actually uses
|
|
3547
|
+
* for fills/margin.
|
|
3548
|
+
* @param marketIndex - Perp market index.
|
|
3549
|
+
* @throws If subscribed oracle price data is not available for `marketIndex`.
|
|
3550
|
+
* @returns Oracle price data; `price`/`confidence` are PRICE_PRECISION (1e6).
|
|
3551
|
+
*/
|
|
1089
3552
|
getOracleDataForPerpMarket(marketIndex: number): OraclePriceData;
|
|
3553
|
+
/**
|
|
3554
|
+
* Resolves the effective oracle price the program uses for `marketIndex` — the market's MM
|
|
3555
|
+
* (market-maker-fed) oracle when it is fresher, valid, and not too divergent from the primary
|
|
3556
|
+
* exchange oracle; otherwise falls back to the primary oracle. Mirrors the on-chain
|
|
3557
|
+
* `get_mm_oracle_price_data` gating so client-side price reads (mark price, margin, liquidation
|
|
3558
|
+
* previews) match what a fill/settlement will actually see.
|
|
3559
|
+
*
|
|
3560
|
+
* Falls back to the primary oracle (`getOracleDataForPerpMarket`) when any of the following hold:
|
|
3561
|
+
* - the MM oracle price is zero (uninitialized) or its computed `OracleValidity` is
|
|
3562
|
+
* `NonPositive`/`TooVolatile` (per `state.oracleGuardRails`);
|
|
3563
|
+
* - the primary oracle is judged more recent than the MM oracle — by sequence-id ordering when
|
|
3564
|
+
* both oracles have a usable, closely-matched `sequenceId`, otherwise by slot comparison;
|
|
3565
|
+
* - the MM and primary oracle prices diverge by more than 1% (`PERCENTAGE_PRECISION`, 1e6 scale).
|
|
3566
|
+
*
|
|
3567
|
+
* Otherwise returns the MM oracle's price/slot/confidence.
|
|
3568
|
+
* @param marketIndex - Perp market index.
|
|
3569
|
+
* @throws If subscribed oracle price data is not available for `marketIndex`.
|
|
3570
|
+
* @returns Oracle price data (`price`/`confidence` at PRICE_PRECISION, 1e6) plus `isMMOracleActive`
|
|
3571
|
+
* indicating whether the market has an initialized MM oracle at all (independent of which price
|
|
3572
|
+
* was ultimately selected).
|
|
3573
|
+
*/
|
|
1090
3574
|
getMMOracleDataForPerpMarket(marketIndex: number): MMOraclePriceData;
|
|
3575
|
+
/**
|
|
3576
|
+
* Reads the last-known oracle price for a spot market from the account subscriber's cache (no
|
|
3577
|
+
* RPC call). Spot markets do not have an MM oracle — this is always the effective price used for
|
|
3578
|
+
* margin/borrow-lending calculations.
|
|
3579
|
+
* @param marketIndex - Spot market index.
|
|
3580
|
+
* @throws If subscribed oracle price data is not available for `marketIndex`.
|
|
3581
|
+
* @returns Oracle price data; `price`/`confidence` are PRICE_PRECISION (1e6).
|
|
3582
|
+
*/
|
|
1091
3583
|
getOracleDataForSpotMarket(marketIndex: number): OraclePriceData;
|
|
3584
|
+
/**
|
|
3585
|
+
* Creates this wallet's `InsuranceFundStake` PDA for `marketIndex`, required once before staking
|
|
3586
|
+
* into that market's insurance fund for the first time. A caller may only initialize their own
|
|
3587
|
+
* stake account. Reverts if insurance-fund init is paused for the market.
|
|
3588
|
+
* @param marketIndex - Spot market index whose insurance fund to stake into.
|
|
3589
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3590
|
+
* @returns The transaction signature.
|
|
3591
|
+
*/
|
|
1092
3592
|
initializeInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3593
|
+
/**
|
|
3594
|
+
* Builds the `initializeInsuranceFundStake` instruction. See `initializeInsuranceFundStake` for
|
|
3595
|
+
* semantics.
|
|
3596
|
+
* @param marketIndex - Spot market index whose insurance fund to stake into.
|
|
3597
|
+
* @returns The instruction.
|
|
3598
|
+
*/
|
|
1093
3599
|
getInitializeInsuranceFundStakeIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
3600
|
+
/**
|
|
3601
|
+
* Builds the `addInsuranceFundStake` instruction, transferring `amount` of the market's token
|
|
3602
|
+
* from `collateralAccountPublicKey` into its insurance fund vault and minting the caller's
|
|
3603
|
+
* `InsuranceFundStake` the corresponding IF shares. Reverts if `amount` is zero, the spot market
|
|
3604
|
+
* is not active, insurance-fund add is paused, or a withdraw request is already in progress on
|
|
3605
|
+
* the stake account. See `addInsuranceFundStake`/`getAddInsuranceFundStakeIxs` for a wrapper that
|
|
3606
|
+
* also handles account creation and funding from a sub-account.
|
|
3607
|
+
* @param marketIndex - Spot market index whose insurance fund to stake into.
|
|
3608
|
+
* @param amount - Amount to stake, in the spot market's token (mint) precision.
|
|
3609
|
+
* @param collateralAccountPublicKey - Token account to debit for the stake.
|
|
3610
|
+
* @returns The instruction.
|
|
3611
|
+
*/
|
|
1094
3612
|
getAddInsuranceFundStakeIx(marketIndex: number, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
1095
3613
|
/**
|
|
1096
3614
|
* Add to an insurance fund stake and optionally initialize the account
|
|
@@ -1137,17 +3655,125 @@ export declare class VelocityClient {
|
|
|
1137
3655
|
*/
|
|
1138
3656
|
fromSubaccount?: boolean;
|
|
1139
3657
|
}): Promise<TransactionInstruction[]>;
|
|
3658
|
+
/**
|
|
3659
|
+
* Starts the unstaking cooldown for this wallet's insurance fund stake in `marketIndex`, locking
|
|
3660
|
+
* in the number of IF shares corresponding to `amount` at the current share price. The actual
|
|
3661
|
+
* withdrawal must be completed with `removeInsuranceFundStake` after
|
|
3662
|
+
* `spotMarket.insuranceFund.unstakingPeriod` seconds have elapsed; only one request may be
|
|
3663
|
+
* in-flight per stake account (`cancelRequestRemoveInsuranceFundStake` to reset). A caller may
|
|
3664
|
+
* only act on their own stake account.
|
|
3665
|
+
* @param marketIndex - Spot market index of the insurance fund stake.
|
|
3666
|
+
* @param amount - Amount to request removal of, in the spot market's token (mint) precision;
|
|
3667
|
+
* converted to IF shares at the current vault share price.
|
|
3668
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3669
|
+
* @returns The transaction signature.
|
|
3670
|
+
*/
|
|
1140
3671
|
requestRemoveInsuranceFundStake(marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3672
|
+
/**
|
|
3673
|
+
* Cancels this wallet's in-progress `requestRemoveInsuranceFundStake` for `marketIndex`, clearing
|
|
3674
|
+
* the pending withdraw request so the stake resumes earning normally. Reverts if no withdraw
|
|
3675
|
+
* request is currently in progress. A caller may only act on their own stake account.
|
|
3676
|
+
* @param marketIndex - Spot market index of the insurance fund stake.
|
|
3677
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3678
|
+
* @returns The transaction signature.
|
|
3679
|
+
*/
|
|
1141
3680
|
cancelRequestRemoveInsuranceFundStake(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3681
|
+
/**
|
|
3682
|
+
* Completes a previously-requested insurance fund unstake for `marketIndex`, transferring the
|
|
3683
|
+
* requested shares' worth of tokens from the insurance fund vault to `collateralAccountPublicKey`
|
|
3684
|
+
* (creating it, and a temporary wrapped-SOL account if the market is SOL, when needed). Reverts
|
|
3685
|
+
* if `spotMarket.insuranceFund.unstakingPeriod` has not yet elapsed since the matching
|
|
3686
|
+
* `requestRemoveInsuranceFundStake`, or if the spot market's utilization is above the healthy
|
|
3687
|
+
* threshold. A caller may only act on their own stake account.
|
|
3688
|
+
* @param marketIndex - Spot market index of the insurance fund stake.
|
|
3689
|
+
* @param collateralAccountPublicKey - Token account to receive the withdrawn tokens.
|
|
3690
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3691
|
+
* @returns The transaction signature.
|
|
3692
|
+
*/
|
|
1142
3693
|
removeInsuranceFundStake(marketIndex: number, collateralAccountPublicKey: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3694
|
+
/**
|
|
3695
|
+
* Keeper instruction: refreshes `authority`'s quote-market (`QUOTE_SPOT_MARKET_INDEX`) insurance
|
|
3696
|
+
* fund stake bookkeeping (applies any pending rebase to the stake's share count/value) without
|
|
3697
|
+
* adding or removing funds. `insuranceFundStake` and `userStats` must belong to the same
|
|
3698
|
+
* authority. Permissionless — any signer can trigger the refresh for any staker.
|
|
3699
|
+
* @param authority - Authority whose quote-market insurance fund stake to refresh.
|
|
3700
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3701
|
+
* @returns The transaction signature.
|
|
3702
|
+
*/
|
|
1143
3703
|
updateUserQuoteAssetInsuranceStake(authority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3704
|
+
/**
|
|
3705
|
+
* Builds the `updateUserQuoteAssetInsuranceStake` instruction. See
|
|
3706
|
+
* `updateUserQuoteAssetInsuranceStake` for semantics. Always targets `QUOTE_SPOT_MARKET_INDEX`.
|
|
3707
|
+
* @param authority - Authority whose quote-market insurance fund stake to refresh.
|
|
3708
|
+
* @returns The instruction.
|
|
3709
|
+
*/
|
|
1144
3710
|
getUpdateUserQuoteAssetInsuranceStakeIx(authority: PublicKey): Promise<TransactionInstruction>;
|
|
3711
|
+
/**
|
|
3712
|
+
* Keeper instruction: sweeps the market's proportional share of accumulated protocol revenue from
|
|
3713
|
+
* its spot vault into its insurance fund vault. Only callable once per
|
|
3714
|
+
* `spotMarket.insuranceFund.revenueSettlePeriod` seconds (on-the-hour aligned from
|
|
3715
|
+
* `lastRevenueSettleTs`); reverts early with the remaining wait time otherwise. Reverts if the
|
|
3716
|
+
* market has `revenueSettlePeriod <= 0` (settling to IF disabled). Permissionless — any signer
|
|
3717
|
+
* can trigger the sweep.
|
|
3718
|
+
* @param spotMarketIndex - Spot market index to settle revenue for.
|
|
3719
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3720
|
+
* @returns The transaction signature.
|
|
3721
|
+
*/
|
|
1145
3722
|
settleRevenueToInsuranceFund(spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3723
|
+
/**
|
|
3724
|
+
* Builds the `settleRevenueToInsuranceFund` instruction. See `settleRevenueToInsuranceFund` for
|
|
3725
|
+
* semantics.
|
|
3726
|
+
* @param spotMarketIndex - Spot market index to settle revenue for.
|
|
3727
|
+
* @returns The instruction.
|
|
3728
|
+
*/
|
|
1146
3729
|
getSettleRevenueToInsuranceFundIx(spotMarketIndex: number): Promise<TransactionInstruction>;
|
|
3730
|
+
/**
|
|
3731
|
+
* Permissionless streaming-sweep keeper instruction: materializes a perp market's accrued pending
|
|
3732
|
+
* fee carveouts out of the PnL pool — `pendingProtocolFee` to the market's protocol fee pool
|
|
3733
|
+
* (runs first, buffer-exempt), then `pendingIfFee` to the quote spot market's revenue pool and
|
|
3734
|
+
* `pendingAmmProvision` into the AMM's fee pool (both leave `feePoolBufferTarget` behind). Every
|
|
3735
|
+
* drain reserves `max(netUserPnl, 0)` so user claims stay backed. This runs inline on every
|
|
3736
|
+
* `settlePNL` already — this instruction lets a keeper run it on demand without settling anyone's
|
|
3737
|
+
* PnL. Gates the oracle price used to value `netUserPnl` the same way `settlePNL` does (price-band
|
|
3738
|
+
* + validity/divergence checks when the market has curve updates enabled).
|
|
3739
|
+
* @param perpMarketIndex - Perp market index to sweep fees for.
|
|
3740
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3741
|
+
* @returns The transaction signature.
|
|
3742
|
+
*/
|
|
1147
3743
|
sweepPerpMarketFees(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3744
|
+
/**
|
|
3745
|
+
* Builds the `sweepPerpMarketFees` instruction. See `sweepPerpMarketFees` for semantics.
|
|
3746
|
+
* @param perpMarketIndex - Perp market index to sweep fees for.
|
|
3747
|
+
* @returns The instruction.
|
|
3748
|
+
*/
|
|
1148
3749
|
getSweepPerpMarketFeesIx(perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
3750
|
+
/**
|
|
3751
|
+
* Keeper instruction: backstops a perp market's negative PnL pool from the quote spot market's
|
|
3752
|
+
* insurance fund (first attempting a revenue-to-IF settlement so the vault balance is
|
|
3753
|
+
* up-to-date). `spotMarketIndex` must be `QUOTE_SPOT_MARKET_INDEX`. Permissionless — any signer
|
|
3754
|
+
* can trigger it.
|
|
3755
|
+
* @param spotMarketIndex - Spot market index backing the deficit; must be `QUOTE_SPOT_MARKET_INDEX`.
|
|
3756
|
+
* @param perpMarketIndex - Perp market index whose PnL pool deficit to resolve.
|
|
3757
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3758
|
+
* @throws (on-chain) if `spotMarketIndex` is not the quote spot market.
|
|
3759
|
+
* @returns The transaction signature.
|
|
3760
|
+
*/
|
|
1149
3761
|
resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3762
|
+
/**
|
|
3763
|
+
* Builds the `resolvePerpPnlDeficit` instruction. See `resolvePerpPnlDeficit` for semantics.
|
|
3764
|
+
* @param spotMarketIndex - Spot market index backing the deficit; must be `QUOTE_SPOT_MARKET_INDEX`.
|
|
3765
|
+
* @param perpMarketIndex - Perp market index whose PnL pool deficit to resolve.
|
|
3766
|
+
* @returns The instruction.
|
|
3767
|
+
*/
|
|
1150
3768
|
getResolvePerpPnlDeficitIx(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
3769
|
+
/**
|
|
3770
|
+
* Builds the `depositIntoSpotMarketRevenuePool` instruction. See `depositIntoSpotMarketRevenuePool`
|
|
3771
|
+
* for semantics.
|
|
3772
|
+
* @param marketIndex - Spot market index whose revenue pool to donate into.
|
|
3773
|
+
* @param amount - Amount to donate, in the spot market's token (mint) precision.
|
|
3774
|
+
* @param userTokenAccountPublicKey - Token account to debit for the donation.
|
|
3775
|
+
* @returns The instruction.
|
|
3776
|
+
*/
|
|
1151
3777
|
getDepositIntoSpotMarketRevenuePoolIx(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
|
1152
3778
|
/**
|
|
1153
3779
|
* This ix will donate your funds to velocity revenue pool. It does not deposit into your user account
|
|
@@ -1157,14 +3783,24 @@ export declare class VelocityClient {
|
|
|
1157
3783
|
* @returns
|
|
1158
3784
|
*/
|
|
1159
3785
|
depositIntoSpotMarketRevenuePool(marketIndex: number, amount: BN, userTokenAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
3786
|
+
/**
|
|
3787
|
+
* Computes display/risk metadata for a perp market from currently-subscribed account state (no
|
|
3788
|
+
* RPC call): minimum order size, maintenance margin ratio, PnL pool value, contract tier, and the
|
|
3789
|
+
* maximum insurance available to the market.
|
|
3790
|
+
* @param marketIndex - Perp market index.
|
|
3791
|
+
* @returns `minOrderSize`/`marginMaintenance` in the market's native units; `pnlPoolValue` and
|
|
3792
|
+
* `availableInsurance` in QUOTE_PRECISION (1e6).
|
|
3793
|
+
*/
|
|
1160
3794
|
getPerpMarketExtendedInfo(marketIndex: number): PerpMarketExtendedInfo;
|
|
1161
3795
|
/**
|
|
1162
3796
|
* Calculates taker / maker fee (as a percentage, e.g. .001 = 10 basis points) for particular marketType
|
|
1163
3797
|
* @param marketType
|
|
1164
3798
|
* @param positionMarketIndex
|
|
3799
|
+
* @param user
|
|
3800
|
+
* @param orderParams When it carries a builder code, the builder fee (quoteAssetAmount * builderFeeTenthBps / 100_000) is added to takerFee.
|
|
1165
3801
|
* @returns : {takerFee: number, makerFee: number} Precision None
|
|
1166
3802
|
*/
|
|
1167
|
-
getMarketFees(marketType: MarketType, marketIndex?: number, user?: User): {
|
|
3803
|
+
getMarketFees(marketType: MarketType, marketIndex?: number, user?: User, orderParams?: Pick<OrderParams, 'builderIdx' | 'builderFeeTenthBps'>): {
|
|
1168
3804
|
takerFee: number;
|
|
1169
3805
|
makerFee: number;
|
|
1170
3806
|
};
|
|
@@ -1178,31 +3814,282 @@ export declare class VelocityClient {
|
|
|
1178
3814
|
marketIndex: number;
|
|
1179
3815
|
marketType: MarketType;
|
|
1180
3816
|
} | undefined;
|
|
3817
|
+
/**
|
|
3818
|
+
* Posts a signed Pyth Lazer price update on-chain for one or more feeds, prepended with the
|
|
3819
|
+
* Ed25519 signature-verification instruction the handler requires. Permissionless — any signer
|
|
3820
|
+
* can post a valid, correctly-signed update.
|
|
3821
|
+
* @param feedIds - Pyth Lazer feed IDs to update, in the same order as the encoded message.
|
|
3822
|
+
* @param pythMessageHex - Hex-encoded, Pyth-signed Lazer update message.
|
|
3823
|
+
* @returns The transaction signature.
|
|
3824
|
+
*/
|
|
1181
3825
|
postPythLazerOracleUpdate(feedIds: number[], pythMessageHex: string): Promise<string>;
|
|
3826
|
+
/**
|
|
3827
|
+
* Builds the `postPythLazerOracleUpdate` instruction pair. See `postPythLazerOracleUpdate` for
|
|
3828
|
+
* semantics.
|
|
3829
|
+
* @param feedIds - Pyth Lazer feed IDs to update, in the same order as the encoded message.
|
|
3830
|
+
* @param pythMessageHex - Hex-encoded, Pyth-signed Lazer update message.
|
|
3831
|
+
* @param precedingIxs - Instructions that will be placed before the returned pair in the final
|
|
3832
|
+
* transaction; only their count is used, to compute the Ed25519 verify instruction's index.
|
|
3833
|
+
* @param overrideCustomIxIndex - Explicit index of the verify instruction within the transaction,
|
|
3834
|
+
* overriding the `precedingIxs.length + 1` default.
|
|
3835
|
+
* @returns `[verifyIx, updateIx]` — the Ed25519 signature-verification instruction followed by the
|
|
3836
|
+
* oracle-update instruction; both must be included, in order, in the same transaction.
|
|
3837
|
+
*/
|
|
1182
3838
|
getPostPythLazerOracleUpdateIxs(feedIds: number[], pythMessageHex: string, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number): Promise<TransactionInstruction[]>;
|
|
3839
|
+
/**
|
|
3840
|
+
* Builds the `pauseSpotMarketDepositWithdraw` instruction. See `pauseSpotMarketDepositWithdraw`
|
|
3841
|
+
* for semantics.
|
|
3842
|
+
* @param spotMarketIndex - Spot market index to pause.
|
|
3843
|
+
* @returns The instruction.
|
|
3844
|
+
*/
|
|
1183
3845
|
getPauseSpotMarketDepositWithdrawIx(spotMarketIndex: number): Promise<TransactionInstruction>;
|
|
3846
|
+
/**
|
|
3847
|
+
* Emergency circuit-breaker instruction: pauses deposits and withdrawals for a spot market, but
|
|
3848
|
+
* only when the on-chain handler detects the spot market's vault invariant has already been
|
|
3849
|
+
* violated (actual vault balance diverges from the market's tracked deposit/borrow balances,
|
|
3850
|
+
* e.g. from an exploit) — it reverts with an error if the vault amount is still valid, so this
|
|
3851
|
+
* cannot be used to arbitrarily pause a healthy market. Permissionless — any signer can trigger
|
|
3852
|
+
* it once the invariant is broken.
|
|
3853
|
+
* @param spotMarketIndex - Spot market index to pause.
|
|
3854
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3855
|
+
* @throws (on-chain) if the spot market's vault amount is still valid (invariant not violated).
|
|
3856
|
+
* @returns The transaction signature.
|
|
3857
|
+
*/
|
|
1184
3858
|
pauseSpotMarketDepositWithdraw(spotMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
3859
|
+
/**
|
|
3860
|
+
* Updates a perp market's market-maker (MM) oracle price using the program's high-frequency
|
|
3861
|
+
* custom native entrypoint (bypasses Anchor's account deserialization overhead — see
|
|
3862
|
+
* `createNativeInstructionDiscriminatorBuffer`). Restricted to the state's configured
|
|
3863
|
+
* `hotMmOracleCrank` signer in production (unchecked under the `anchor-test` feature) and can be
|
|
3864
|
+
* disabled entirely via a state feature-bit-flag kill switch. See `getMMOracleDataForPerpMarket`
|
|
3865
|
+
* for how this price is subsequently gated against the primary oracle before use.
|
|
3866
|
+
* @param marketIndex - Perp market index whose MM oracle to update.
|
|
3867
|
+
* @param oraclePrice - New MM oracle price, PRICE_PRECISION (1e6). A value of `0` is a no-op.
|
|
3868
|
+
* @param oracleSequenceId - Monotonically increasing sequence id for this update, used for
|
|
3869
|
+
* recency comparisons against the primary oracle.
|
|
3870
|
+
* @returns The transaction signature.
|
|
3871
|
+
*/
|
|
1185
3872
|
updateMmOracleNative(marketIndex: number, oraclePrice: BN, oracleSequenceId: BN): Promise<TransactionSignature>;
|
|
3873
|
+
/**
|
|
3874
|
+
* Builds the `updateMmOracleNative` instruction. See `updateMmOracleNative` for semantics. Hand-
|
|
3875
|
+
* assembles the instruction (perp market, signer, clock sysvar, state) rather than going through
|
|
3876
|
+
* `this.program.instruction`, since this targets the native (non-Anchor) entrypoint.
|
|
3877
|
+
* @param marketIndex - Perp market index whose MM oracle to update.
|
|
3878
|
+
* @param oraclePrice - New MM oracle price, PRICE_PRECISION (1e6). A value of `0` is a no-op.
|
|
3879
|
+
* @param oracleSequenceId - Monotonically increasing sequence id for this update.
|
|
3880
|
+
* @returns The instruction.
|
|
3881
|
+
*/
|
|
1186
3882
|
getUpdateMmOracleNativeIx(marketIndex: number, oraclePrice: BN, oracleSequenceId: BN): Promise<TransactionInstruction>;
|
|
3883
|
+
/**
|
|
3884
|
+
* Updates a perp market's AMM spread adjustment using the program's high-frequency custom native
|
|
3885
|
+
* entrypoint. Restricted to the state's configured `hotAmmSpreadAdjust` signer in production
|
|
3886
|
+
* (unchecked under the `anchor-test` feature).
|
|
3887
|
+
* @param marketIndex - Perp market index whose AMM spread adjustment to update.
|
|
3888
|
+
* @param ammSpreadAdjustment - Percentage adjustment to the AMM's base long/short spread, as a
|
|
3889
|
+
* signed byte (-128 to 127): negative narrows the spread by that percent, positive widens it,
|
|
3890
|
+
* `0` is no adjustment.
|
|
3891
|
+
* @returns The transaction signature.
|
|
3892
|
+
*/
|
|
1187
3893
|
updateAmmSpreadAdjustmentNative(marketIndex: number, ammSpreadAdjustment: number): Promise<TransactionSignature>;
|
|
3894
|
+
/**
|
|
3895
|
+
* Builds the `updateAmmSpreadAdjustmentNative` instruction. See `updateAmmSpreadAdjustmentNative`
|
|
3896
|
+
* for semantics. Hand-assembles the instruction (perp market, signer, state) rather than going
|
|
3897
|
+
* through `this.program.instruction`, since this targets the native (non-Anchor) entrypoint.
|
|
3898
|
+
* @param marketIndex - Perp market index whose AMM spread adjustment to update.
|
|
3899
|
+
* @param ammSpreadAdjustment - Percentage adjustment to the AMM's base spread, signed byte (i8).
|
|
3900
|
+
* @returns The instruction.
|
|
3901
|
+
*/
|
|
1188
3902
|
getUpdateAmmSpreadAdjustmentNativeIx(marketIndex: number, ammSpreadAdjustment: number): Promise<TransactionInstruction>;
|
|
3903
|
+
/**
|
|
3904
|
+
* Fetches an LP pool account by ID directly from the RPC (not from this client's subscription
|
|
3905
|
+
* cache). An LP pool ("VLP") is a basket of spot-market "constituent" tokens that mints/redeems a
|
|
3906
|
+
* pool token against deposits/withdrawals and absorbs perp AMM PnL to hedge the protocol's
|
|
3907
|
+
* inventory risk (see `settlePerpToLpPool`).
|
|
3908
|
+
* @param lpPoolId - LP pool ID.
|
|
3909
|
+
* @returns The decoded LP pool account.
|
|
3910
|
+
*/
|
|
1189
3911
|
getLpPoolAccount(lpPoolId: number): Promise<LPPoolAccount>;
|
|
3912
|
+
/**
|
|
3913
|
+
* Fetches the target-base weights for an LP pool's constituents directly from the RPC. Target
|
|
3914
|
+
* base is each constituent's ideal share of the pool, derived from the AMMs it backs
|
|
3915
|
+
* (`updateLpConstituentTargetBase`); swap/add/remove-liquidity fees are priced off deviation from
|
|
3916
|
+
* these targets.
|
|
3917
|
+
* @param lpPoolId - LP pool ID.
|
|
3918
|
+
* @returns The decoded constituent target-base account.
|
|
3919
|
+
*/
|
|
1190
3920
|
getConstituentTargetBaseAccount(lpPoolId: number): Promise<ConstituentTargetBaseAccount>;
|
|
3921
|
+
/**
|
|
3922
|
+
* Fetches the program's single global AMM cache account directly from the RPC — a snapshot of
|
|
3923
|
+
* each hedge-enabled perp market's inventory/price/PnL used by LP pool AUM, target-base, and
|
|
3924
|
+
* settlement instructions without having to reload every perp market individually.
|
|
3925
|
+
* @returns The decoded AMM cache account.
|
|
3926
|
+
*/
|
|
1191
3927
|
getAmmCache(): Promise<AmmCache>;
|
|
3928
|
+
/**
|
|
3929
|
+
* Keeper instruction: recomputes each listed constituent's target-base weight from the current
|
|
3930
|
+
* AMM cache (each hedge-enabled perp market's inventory relative to its constituents), used to
|
|
3931
|
+
* price LP pool swap/add/remove-liquidity fees. Requires `updateAmmCache` to have run recently
|
|
3932
|
+
* for the relevant markets. Permissionless — any signer can act as keeper.
|
|
3933
|
+
* @param lpPoolId - LP pool ID.
|
|
3934
|
+
* @param constituents - Constituent account public keys to recompute target base for.
|
|
3935
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3936
|
+
* @returns The transaction signature.
|
|
3937
|
+
*/
|
|
1192
3938
|
updateLpConstituentTargetBase(lpPoolId: number, constituents: PublicKey[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
3939
|
+
/**
|
|
3940
|
+
* Builds the `updateLpConstituentTargetBase` instruction. See `updateLpConstituentTargetBase` for
|
|
3941
|
+
* semantics.
|
|
3942
|
+
* @param lpPoolId - LP pool ID.
|
|
3943
|
+
* @param constituents - Constituent account public keys to recompute target base for, passed as
|
|
3944
|
+
* read-only remaining accounts.
|
|
3945
|
+
* @returns The instruction.
|
|
3946
|
+
*/
|
|
1193
3947
|
getUpdateLpConstituentTargetBaseIx(lpPoolId: number, constituents: PublicKey[]): Promise<TransactionInstruction>;
|
|
3948
|
+
/**
|
|
3949
|
+
* Keeper instruction: recomputes an LP pool's total AUM and per-constituent value from each
|
|
3950
|
+
* constituent's spot market and vault balance, refreshing `lastAumSlot`. Swaps and add/remove
|
|
3951
|
+
* liquidity revert with `LpPoolAumDelayed` if this has not run within `LP_POOL_SWAP_AUM_UPDATE_DELAY`
|
|
3952
|
+
* slots of the action, so it must typically precede those instructions in the same transaction
|
|
3953
|
+
* (see `getAllUpdateLpPoolAumIxs`). Permissionless — any signer can act as keeper.
|
|
3954
|
+
* @param lpPool - Decoded LP pool account to update.
|
|
3955
|
+
* @param spotMarketIndexOfConstituents - Spot market index of every constituent in the pool, in
|
|
3956
|
+
* the same order the pool's constituents were configured.
|
|
3957
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3958
|
+
* @returns The transaction signature.
|
|
3959
|
+
*/
|
|
1194
3960
|
updateLpPoolAum(lpPool: LPPoolAccount, spotMarketIndexOfConstituents: number[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
3961
|
+
/**
|
|
3962
|
+
* Builds the `updateLpPoolAum` instruction. See `updateLpPoolAum` for semantics.
|
|
3963
|
+
* @param lpPool - Decoded LP pool account to update.
|
|
3964
|
+
* @param spotMarketIndexOfConstituents - Spot market index of every constituent in the pool.
|
|
3965
|
+
* @returns The instruction.
|
|
3966
|
+
*/
|
|
1195
3967
|
getUpdateLpPoolAumIxs(lpPool: LPPoolAccount, spotMarketIndexOfConstituents: number[]): Promise<TransactionInstruction>;
|
|
3968
|
+
/**
|
|
3969
|
+
* Keeper instruction: refreshes the global AMM cache's per-market inventory/price/PnL snapshot
|
|
3970
|
+
* for the given hedge-enabled perp markets, feeding LP pool AUM, target-base, and settlement
|
|
3971
|
+
* math. Permissionless — any signer can act as keeper.
|
|
3972
|
+
* @param perpMarketIndexes - Perp market indexes to refresh; at most 50 per call.
|
|
3973
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
3974
|
+
* @throws If more than 50 market indexes are supplied.
|
|
3975
|
+
* @returns The transaction signature.
|
|
3976
|
+
*/
|
|
1196
3977
|
updateAmmCache(perpMarketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
3978
|
+
/**
|
|
3979
|
+
* Builds the `updateAmmCache` instruction. See `updateAmmCache` for semantics.
|
|
3980
|
+
* @param perpMarketIndexes - Perp market indexes to refresh; at most 50.
|
|
3981
|
+
* @throws If more than 50 market indexes are supplied.
|
|
3982
|
+
* @returns The instruction.
|
|
3983
|
+
*/
|
|
1197
3984
|
getUpdateAmmCacheIx(perpMarketIndexes: number[]): Promise<TransactionInstruction>;
|
|
3985
|
+
/**
|
|
3986
|
+
* Keeper instruction: refreshes a single LP pool constituent's cached oracle price/slot from its
|
|
3987
|
+
* spot market's oracle. Called ahead of AUM/target-base updates that need a fresh price for that
|
|
3988
|
+
* constituent. Permissionless — any signer can act as keeper.
|
|
3989
|
+
* @param constituent - Decoded constituent account to refresh.
|
|
3990
|
+
* @returns The transaction signature.
|
|
3991
|
+
*/
|
|
1198
3992
|
updateConstituentOracleInfo(constituent: ConstituentAccount): Promise<TransactionSignature>;
|
|
3993
|
+
/**
|
|
3994
|
+
* Builds the `updateConstituentOracleInfo` instruction. See `updateConstituentOracleInfo` for
|
|
3995
|
+
* semantics.
|
|
3996
|
+
* @param constituent - Decoded constituent account to refresh.
|
|
3997
|
+
* @returns The instruction.
|
|
3998
|
+
*/
|
|
1199
3999
|
getUpdateConstituentOracleInfoIx(constituent: ConstituentAccount): Promise<TransactionInstruction>;
|
|
4000
|
+
/**
|
|
4001
|
+
* Swaps `inMarketIndex` tokens for `outMarketIndex` tokens directly against an LP pool's
|
|
4002
|
+
* constituent vaults (not the DLOB/AMM), paying a fee priced off each constituent's deviation
|
|
4003
|
+
* from its target-base weight. Reverts if pool swaps are disabled, `inMarketIndex` equals
|
|
4004
|
+
* `outMarketIndex`, or `updateLpPoolAum` has not run within `LP_POOL_SWAP_AUM_UPDATE_DELAY` slots
|
|
4005
|
+
* (see `getAllLpPoolSwapIxs` for a wrapper that prepends the required AUM refresh).
|
|
4006
|
+
* @param inMarketIndex - Spot market index of the token being sold.
|
|
4007
|
+
* @param outMarketIndex - Spot market index of the token being bought.
|
|
4008
|
+
* @param inAmount - Amount of `inMarketIndex` token to sell, in that market's mint precision.
|
|
4009
|
+
* @param minOutAmount - Minimum acceptable amount of `outMarketIndex` token to receive, in that
|
|
4010
|
+
* market's mint precision.
|
|
4011
|
+
* @param lpPool - LP pool public key.
|
|
4012
|
+
* @param userAuthority - Authority whose associated token accounts fund/receive the swap.
|
|
4013
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
4014
|
+
* @returns The transaction signature.
|
|
4015
|
+
*/
|
|
1200
4016
|
lpPoolSwap(inMarketIndex: number, outMarketIndex: number, inAmount: BN, minOutAmount: BN, lpPool: PublicKey, userAuthority: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
4017
|
+
/**
|
|
4018
|
+
* Builds the `lpPoolSwap` instruction. See `lpPoolSwap` for semantics.
|
|
4019
|
+
* @param inMarketIndex - Spot market index of the token being sold.
|
|
4020
|
+
* @param outMarketIndex - Spot market index of the token being bought.
|
|
4021
|
+
* @param inAmount - Amount of `inMarketIndex` token to sell, in that market's mint precision.
|
|
4022
|
+
* @param minOutAmount - Minimum acceptable amount of `outMarketIndex` token to receive, in that
|
|
4023
|
+
* market's mint precision.
|
|
4024
|
+
* @param lpPool - LP pool public key.
|
|
4025
|
+
* @param userAuthority - Authority whose associated token accounts fund/receive the swap.
|
|
4026
|
+
* @returns The instruction.
|
|
4027
|
+
*/
|
|
1201
4028
|
getLpPoolSwapIx(inMarketIndex: number, outMarketIndex: number, inAmount: BN, minOutAmount: BN, lpPool: PublicKey, userAuthority: PublicKey): Promise<TransactionInstruction>;
|
|
4029
|
+
/**
|
|
4030
|
+
* Simulation-only instruction: computes what `lpPoolSwap` would charge for the given swap without
|
|
4031
|
+
* moving any funds (intended to be run via `simulateTransaction`/a view call, not actually
|
|
4032
|
+
* confirmed on-chain). Useful for quoting a swap's fee before submitting it.
|
|
4033
|
+
* @param inMarketIndex - Spot market index of the token being sold.
|
|
4034
|
+
* @param outMarketIndex - Spot market index of the token being bought.
|
|
4035
|
+
* @param inAmount - Amount of `inMarketIndex` token to sell, in that market's mint precision.
|
|
4036
|
+
* @param inTargetWeight - Assumed target-base weight for the in-constituent (PERCENTAGE_PRECISION, 1e6).
|
|
4037
|
+
* @param outTargetWeight - Assumed target-base weight for the out-constituent (PERCENTAGE_PRECISION, 1e6).
|
|
4038
|
+
* @param lpPool - LP pool public key.
|
|
4039
|
+
* @param constituentTargetBase - The pool's constituent target-base account.
|
|
4040
|
+
* @param constituentInTokenAccount - In-constituent's vault token account.
|
|
4041
|
+
* @param constituentOutTokenAccount - Out-constituent's vault token account.
|
|
4042
|
+
* @param inConstituent - In-constituent account.
|
|
4043
|
+
* @param outConstituent - Out-constituent account.
|
|
4044
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
4045
|
+
* @returns The transaction signature (intended for simulation, not confirmation).
|
|
4046
|
+
*/
|
|
1202
4047
|
viewLpPoolSwapFees(inMarketIndex: number, outMarketIndex: number, inAmount: BN, inTargetWeight: BN, outTargetWeight: BN, lpPool: PublicKey, constituentTargetBase: PublicKey, constituentInTokenAccount: PublicKey, constituentOutTokenAccount: PublicKey, inConstituent: PublicKey, outConstituent: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
4048
|
+
/**
|
|
4049
|
+
* Builds the `viewLpPoolSwapFees` instruction. See `viewLpPoolSwapFees` for semantics.
|
|
4050
|
+
* @param inMarketIndex - Spot market index of the token being sold.
|
|
4051
|
+
* @param outMarketIndex - Spot market index of the token being bought.
|
|
4052
|
+
* @param inAmount - Amount of `inMarketIndex` token to sell, in that market's mint precision.
|
|
4053
|
+
* @param inTargetWeight - Assumed target-base weight for the in-constituent (PERCENTAGE_PRECISION, 1e6).
|
|
4054
|
+
* @param outTargetWeight - Assumed target-base weight for the out-constituent (PERCENTAGE_PRECISION, 1e6).
|
|
4055
|
+
* @param lpPool - LP pool public key.
|
|
4056
|
+
* @param constituentTargetBase - The pool's constituent target-base account.
|
|
4057
|
+
* @param constituentInTokenAccount - In-constituent's vault token account.
|
|
4058
|
+
* @param constituentOutTokenAccount - Out-constituent's vault token account.
|
|
4059
|
+
* @param inConstituent - In-constituent account.
|
|
4060
|
+
* @param outConstituent - Out-constituent account.
|
|
4061
|
+
* @returns The instruction.
|
|
4062
|
+
*/
|
|
1203
4063
|
getViewLpPoolSwapFeesIx(inMarketIndex: number, outMarketIndex: number, inAmount: BN, inTargetWeight: BN, outTargetWeight: BN, lpPool: PublicKey, constituentTargetBase: PublicKey, constituentInTokenAccount: PublicKey, constituentOutTokenAccount: PublicKey, inConstituent: PublicKey, outConstituent: PublicKey): Promise<TransactionInstruction>;
|
|
4064
|
+
/**
|
|
4065
|
+
* Builds an idempotent instruction creating this wallet's associated token account for an LP
|
|
4066
|
+
* pool's mint, needed before receiving pool tokens from `lpPoolAddLiquidity`.
|
|
4067
|
+
* @param lpPool - Decoded LP pool account whose mint to create an account for.
|
|
4068
|
+
* @returns The instruction.
|
|
4069
|
+
*/
|
|
1204
4070
|
getCreateLpPoolTokenAccountIx(lpPool: LPPoolAccount): Promise<TransactionInstruction>;
|
|
4071
|
+
/**
|
|
4072
|
+
* Creates this wallet's associated token account for an LP pool's mint. See
|
|
4073
|
+
* `getCreateLpPoolTokenAccountIx`.
|
|
4074
|
+
* @param lpPool - Decoded LP pool account whose mint to create an account for.
|
|
4075
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
4076
|
+
* @returns The transaction signature.
|
|
4077
|
+
*/
|
|
1205
4078
|
createLpPoolTokenAccount(lpPool: LPPoolAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
4079
|
+
/**
|
|
4080
|
+
* Deposits `inMarketIndex` tokens into an LP pool's matching constituent and mints LP pool tokens
|
|
4081
|
+
* in return, priced at the pool's current AUM-derived share price. Reverts if mint/redeem is
|
|
4082
|
+
* disabled, the constituent doesn't allow deposits (or is reduce-only and this isn't a
|
|
4083
|
+
* reducing deposit), the pool is gated by a whitelist mint this wallet doesn't hold, or
|
|
4084
|
+
* `updateLpPoolAum` has not run within `LP_POOL_SWAP_AUM_UPDATE_DELAY` slots (see
|
|
4085
|
+
* `getAllLpPoolAddLiquidityIxs` for a wrapper that prepends the required AUM refresh).
|
|
4086
|
+
* @param inMarketIndex - Spot market index of the token being deposited.
|
|
4087
|
+
* @param inAmount - Amount to deposit, in `inMarketIndex`'s mint precision.
|
|
4088
|
+
* @param minMintAmount - Minimum acceptable LP pool tokens to receive, in the pool mint's precision.
|
|
4089
|
+
* @param lpPool - Decoded LP pool account to deposit into.
|
|
4090
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
4091
|
+
* @returns The transaction signature.
|
|
4092
|
+
*/
|
|
1206
4093
|
lpPoolAddLiquidity({ inMarketIndex, inAmount, minMintAmount, lpPool, txParams, }: {
|
|
1207
4094
|
inMarketIndex: number;
|
|
1208
4095
|
inAmount: BN;
|
|
@@ -1210,23 +4097,62 @@ export declare class VelocityClient {
|
|
|
1210
4097
|
lpPool: LPPoolAccount;
|
|
1211
4098
|
txParams?: TxParams;
|
|
1212
4099
|
}): Promise<TransactionSignature>;
|
|
4100
|
+
/**
|
|
4101
|
+
* Builds the `lpPoolAddLiquidity` instruction (plus any needed wrapped-SOL / associated-token-
|
|
4102
|
+
* account setup and teardown instructions). See `lpPoolAddLiquidity` for semantics.
|
|
4103
|
+
* @param inMarketIndex - Spot market index of the token being deposited.
|
|
4104
|
+
* @param inAmount - Amount to deposit, in `inMarketIndex`'s mint precision.
|
|
4105
|
+
* @param minMintAmount - Minimum acceptable LP pool tokens to receive, in the pool mint's precision.
|
|
4106
|
+
* @param lpPool - Decoded LP pool account to deposit into.
|
|
4107
|
+
* @returns The ordered instructions to include in the transaction.
|
|
4108
|
+
*/
|
|
1213
4109
|
getLpPoolAddLiquidityIx({ inMarketIndex, inAmount, minMintAmount, lpPool, }: {
|
|
1214
4110
|
inMarketIndex: number;
|
|
1215
4111
|
inAmount: BN;
|
|
1216
4112
|
minMintAmount: BN;
|
|
1217
4113
|
lpPool: LPPoolAccount;
|
|
1218
4114
|
}): Promise<TransactionInstruction[]>;
|
|
4115
|
+
/**
|
|
4116
|
+
* Simulation-only instruction: computes what `lpPoolAddLiquidity` would mint/charge for the given
|
|
4117
|
+
* deposit without moving any funds (intended for `simulateTransaction`, not confirmation).
|
|
4118
|
+
* @param inMarketIndex - Spot market index of the token being deposited.
|
|
4119
|
+
* @param inAmount - Amount to deposit, in `inMarketIndex`'s mint precision.
|
|
4120
|
+
* @param lpPool - Decoded LP pool account to deposit into.
|
|
4121
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
4122
|
+
* @returns The transaction signature (intended for simulation, not confirmation).
|
|
4123
|
+
*/
|
|
1219
4124
|
viewLpPoolAddLiquidityFees({ inMarketIndex, inAmount, lpPool, txParams, }: {
|
|
1220
4125
|
inMarketIndex: number;
|
|
1221
4126
|
inAmount: BN;
|
|
1222
4127
|
lpPool: LPPoolAccount;
|
|
1223
4128
|
txParams?: TxParams;
|
|
1224
4129
|
}): Promise<TransactionSignature>;
|
|
4130
|
+
/**
|
|
4131
|
+
* Builds the `viewLpPoolAddLiquidityFees` instruction. See `viewLpPoolAddLiquidityFees` for semantics.
|
|
4132
|
+
* @param inMarketIndex - Spot market index of the token being deposited.
|
|
4133
|
+
* @param inAmount - Amount to deposit, in `inMarketIndex`'s mint precision.
|
|
4134
|
+
* @param lpPool - Decoded LP pool account to deposit into.
|
|
4135
|
+
* @returns The instruction.
|
|
4136
|
+
*/
|
|
1225
4137
|
getViewLpPoolAddLiquidityFeesIx({ inMarketIndex, inAmount, lpPool, }: {
|
|
1226
4138
|
inMarketIndex: number;
|
|
1227
4139
|
inAmount: BN;
|
|
1228
4140
|
lpPool: LPPoolAccount;
|
|
1229
4141
|
}): Promise<TransactionInstruction>;
|
|
4142
|
+
/**
|
|
4143
|
+
* Burns LP pool tokens and withdraws `outMarketIndex` tokens from the pool's matching constituent
|
|
4144
|
+
* in return, priced at the pool's current AUM-derived share price. Reverts if mint/redeem is
|
|
4145
|
+
* disabled, the constituent doesn't allow withdrawals, or `updateLpPoolAum` has not run within
|
|
4146
|
+
* `LP_POOL_SWAP_AUM_UPDATE_DELAY` slots (see `getAllLpPoolRemoveLiquidityIxs` for a wrapper that
|
|
4147
|
+
* prepends the required perp settlement and AUM refresh).
|
|
4148
|
+
* @param outMarketIndex - Spot market index of the token being withdrawn.
|
|
4149
|
+
* @param lpToBurn - Amount of LP pool tokens to burn, in the pool mint's precision.
|
|
4150
|
+
* @param minAmountOut - Minimum acceptable `outMarketIndex` tokens to receive, in that market's
|
|
4151
|
+
* mint precision.
|
|
4152
|
+
* @param lpPool - Decoded LP pool account to withdraw from.
|
|
4153
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
4154
|
+
* @returns The transaction signature.
|
|
4155
|
+
*/
|
|
1230
4156
|
lpPoolRemoveLiquidity({ outMarketIndex, lpToBurn, minAmountOut, lpPool, txParams, }: {
|
|
1231
4157
|
outMarketIndex: number;
|
|
1232
4158
|
lpToBurn: BN;
|
|
@@ -1234,40 +4160,158 @@ export declare class VelocityClient {
|
|
|
1234
4160
|
lpPool: LPPoolAccount;
|
|
1235
4161
|
txParams?: TxParams;
|
|
1236
4162
|
}): Promise<TransactionSignature>;
|
|
4163
|
+
/**
|
|
4164
|
+
* Builds the `lpPoolRemoveLiquidity` instruction (plus an idempotent associated-token-account
|
|
4165
|
+
* creation instruction for a wrapped-SOL output, if needed). See `lpPoolRemoveLiquidity` for
|
|
4166
|
+
* semantics.
|
|
4167
|
+
* @param outMarketIndex - Spot market index of the token being withdrawn.
|
|
4168
|
+
* @param lpToBurn - Amount of LP pool tokens to burn, in the pool mint's precision.
|
|
4169
|
+
* @param minAmountOut - Minimum acceptable `outMarketIndex` tokens to receive, in that market's
|
|
4170
|
+
* mint precision.
|
|
4171
|
+
* @param lpPool - Decoded LP pool account to withdraw from.
|
|
4172
|
+
* @returns The ordered instructions to include in the transaction.
|
|
4173
|
+
*/
|
|
1237
4174
|
getLpPoolRemoveLiquidityIx({ outMarketIndex, lpToBurn, minAmountOut, lpPool, }: {
|
|
1238
4175
|
outMarketIndex: number;
|
|
1239
4176
|
lpToBurn: BN;
|
|
1240
4177
|
minAmountOut: BN;
|
|
1241
4178
|
lpPool: LPPoolAccount;
|
|
1242
4179
|
}): Promise<TransactionInstruction[]>;
|
|
4180
|
+
/**
|
|
4181
|
+
* Simulation-only instruction: computes what `lpPoolRemoveLiquidity` would return for the given
|
|
4182
|
+
* burn without moving any funds (intended for `simulateTransaction`, not confirmation).
|
|
4183
|
+
* @param outMarketIndex - Spot market index of the token being withdrawn.
|
|
4184
|
+
* @param lpToBurn - Amount of LP pool tokens to burn, in the pool mint's precision.
|
|
4185
|
+
* @param lpPool - Decoded LP pool account to withdraw from.
|
|
4186
|
+
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
4187
|
+
* @returns The transaction signature (intended for simulation, not confirmation).
|
|
4188
|
+
*/
|
|
1243
4189
|
viewLpPoolRemoveLiquidityFees({ outMarketIndex, lpToBurn, lpPool, txParams, }: {
|
|
1244
4190
|
outMarketIndex: number;
|
|
1245
4191
|
lpToBurn: BN;
|
|
1246
4192
|
lpPool: LPPoolAccount;
|
|
1247
4193
|
txParams?: TxParams;
|
|
1248
4194
|
}): Promise<TransactionSignature>;
|
|
4195
|
+
/**
|
|
4196
|
+
* Builds the `viewLpPoolRemoveLiquidityFees` instruction. See `viewLpPoolRemoveLiquidityFees` for
|
|
4197
|
+
* semantics.
|
|
4198
|
+
* @param outMarketIndex - Spot market index of the token being withdrawn.
|
|
4199
|
+
* @param lpToBurn - Amount of LP pool tokens to burn, in the pool mint's precision.
|
|
4200
|
+
* @param lpPool - Decoded LP pool account to withdraw from.
|
|
4201
|
+
* @returns The instruction.
|
|
4202
|
+
*/
|
|
1249
4203
|
getViewLpPoolRemoveLiquidityFeesIx({ outMarketIndex, lpToBurn, lpPool, }: {
|
|
1250
4204
|
outMarketIndex: number;
|
|
1251
4205
|
lpToBurn: BN;
|
|
1252
4206
|
lpPool: LPPoolAccount;
|
|
1253
4207
|
}): Promise<TransactionInstruction>;
|
|
4208
|
+
/**
|
|
4209
|
+
* Convenience wrapper that prepends the AUM refresh `lpPoolAddLiquidity` requires (an
|
|
4210
|
+
* `updateConstituentOracleInfo` per constituent, then `updateLpPoolAum`) ahead of either the real
|
|
4211
|
+
* add-liquidity instruction or, when `view` is set, its fee-simulation counterpart.
|
|
4212
|
+
* @param inMarketIndex - Spot market index of the token being deposited.
|
|
4213
|
+
* @param inAmount - Amount to deposit, in `inMarketIndex`'s mint precision.
|
|
4214
|
+
* @param minMintAmount - Minimum acceptable LP pool tokens to receive, in the pool mint's precision.
|
|
4215
|
+
* @param lpPool - Decoded LP pool account to deposit into.
|
|
4216
|
+
* @param constituentMap - All of the pool's constituents, used to refresh oracle info and AUM.
|
|
4217
|
+
* @param includeUpdateConstituentOracleInfo - Whether to prepend an oracle-info refresh per
|
|
4218
|
+
* constituent; defaults to `true`.
|
|
4219
|
+
* @param view - When `true`, appends `getViewLpPoolAddLiquidityFeesIx` instead of the real deposit;
|
|
4220
|
+
* defaults to `false`.
|
|
4221
|
+
* @returns The ordered instructions to include in the transaction.
|
|
4222
|
+
*/
|
|
1254
4223
|
getAllLpPoolAddLiquidityIxs({ inMarketIndex, inAmount, minMintAmount, lpPool, }: {
|
|
1255
4224
|
inMarketIndex: number;
|
|
1256
4225
|
inAmount: BN;
|
|
1257
4226
|
minMintAmount: BN;
|
|
1258
4227
|
lpPool: LPPoolAccount;
|
|
1259
4228
|
}, constituentMap: ConstituentMap, includeUpdateConstituentOracleInfo?: boolean, view?: boolean): Promise<TransactionInstruction[]>;
|
|
4229
|
+
/**
|
|
4230
|
+
* Convenience wrapper that prepends what `lpPoolRemoveLiquidity` requires: settling every hedge-
|
|
4231
|
+
* enabled perp market's PnL into the pool (`getAllSettlePerpToLpPoolIxs`) and refreshing AUM
|
|
4232
|
+
* (`getAllUpdateLpPoolAumIxs`), ahead of either the real remove-liquidity instruction or, when
|
|
4233
|
+
* `view` is set, its fee-simulation counterpart.
|
|
4234
|
+
* @param outMarketIndex - Spot market index of the token being withdrawn.
|
|
4235
|
+
* @param lpToBurn - Amount of LP pool tokens to burn, in the pool mint's precision.
|
|
4236
|
+
* @param minAmountOut - Minimum acceptable `outMarketIndex` tokens to receive, in that market's
|
|
4237
|
+
* mint precision.
|
|
4238
|
+
* @param lpPool - Decoded LP pool account to withdraw from.
|
|
4239
|
+
* @param constituentMap - All of the pool's constituents, used to refresh oracle info and AUM.
|
|
4240
|
+
* @param includeUpdateConstituentOracleInfo - Whether to prepend an oracle-info refresh per
|
|
4241
|
+
* constituent; defaults to `true`.
|
|
4242
|
+
* @param view - When `true`, appends `getViewLpPoolRemoveLiquidityFeesIx` instead of the real
|
|
4243
|
+
* withdrawal; defaults to `false`.
|
|
4244
|
+
* @returns The ordered instructions to include in the transaction.
|
|
4245
|
+
*/
|
|
1260
4246
|
getAllLpPoolRemoveLiquidityIxs({ outMarketIndex, lpToBurn, minAmountOut, lpPool, }: {
|
|
1261
4247
|
outMarketIndex: number;
|
|
1262
4248
|
lpToBurn: BN;
|
|
1263
4249
|
minAmountOut: BN;
|
|
1264
4250
|
lpPool: LPPoolAccount;
|
|
1265
4251
|
}, constituentMap: ConstituentMap, includeUpdateConstituentOracleInfo?: boolean, view?: boolean): Promise<TransactionInstruction[]>;
|
|
4252
|
+
/**
|
|
4253
|
+
* Builds the full instruction set to refresh an LP pool's AUM: one `updateConstituentOracleInfo`
|
|
4254
|
+
* per constituent (optional) followed by `updateLpPoolAum` across all of them.
|
|
4255
|
+
* @param lpPool - Decoded LP pool account to update.
|
|
4256
|
+
* @param constituentMap - All of the pool's constituents.
|
|
4257
|
+
* @param includeUpdateConstituentOracleInfo - Whether to prepend an oracle-info refresh per
|
|
4258
|
+
* constituent; defaults to `true`. Pass `false` when a caller has already refreshed oracle info
|
|
4259
|
+
* earlier in the same transaction.
|
|
4260
|
+
* @returns The ordered instructions to include in the transaction.
|
|
4261
|
+
*/
|
|
1266
4262
|
getAllUpdateLpPoolAumIxs(lpPool: LPPoolAccount, constituentMap: ConstituentMap, includeUpdateConstituentOracleInfo?: boolean): Promise<TransactionInstruction[]>;
|
|
4263
|
+
/**
|
|
4264
|
+
* Builds the full instruction set to refresh an LP pool's constituent target-base weights:
|
|
4265
|
+
* `updateAmmCache` for the given markets, an optional `updateConstituentOracleInfo` per
|
|
4266
|
+
* constituent, `updateLpConstituentTargetBase`, then a full AUM refresh
|
|
4267
|
+
* (`getAllUpdateLpPoolAumIxs`, oracle info not repeated).
|
|
4268
|
+
* @param perpMarketIndexes - Hedge-enabled perp market indexes to refresh in the AMM cache.
|
|
4269
|
+
* @param lpPool - Decoded LP pool account to update.
|
|
4270
|
+
* @param constituentMap - All of the pool's constituents.
|
|
4271
|
+
* @param includeUpdateConstituentOracleInfo - Whether to include an oracle-info refresh per
|
|
4272
|
+
* constituent; defaults to `true`.
|
|
4273
|
+
* @returns The ordered instructions to include in the transaction.
|
|
4274
|
+
*/
|
|
1267
4275
|
getAllUpdateConstituentTargetBaseIxs(perpMarketIndexes: number[], lpPool: LPPoolAccount, constituentMap: ConstituentMap, includeUpdateConstituentOracleInfo?: boolean): Promise<TransactionInstruction[]>;
|
|
4276
|
+
/**
|
|
4277
|
+
* Convenience wrapper that prepends the AUM refresh `lpPoolSwap` requires ahead of the swap
|
|
4278
|
+
* instruction itself.
|
|
4279
|
+
* @param lpPool - Decoded LP pool account to swap against.
|
|
4280
|
+
* @param constituentMap - All of the pool's constituents, used to refresh AUM.
|
|
4281
|
+
* @param inMarketIndex - Spot market index of the token being sold.
|
|
4282
|
+
* @param outMarketIndex - Spot market index of the token being bought.
|
|
4283
|
+
* @param inAmount - Amount of `inMarketIndex` token to sell, in that market's mint precision.
|
|
4284
|
+
* @param minOutAmount - Minimum acceptable amount of `outMarketIndex` token to receive, in that
|
|
4285
|
+
* market's mint precision.
|
|
4286
|
+
* @param userAuthority - Authority whose associated token accounts fund/receive the swap.
|
|
4287
|
+
* @returns The ordered instructions to include in the transaction.
|
|
4288
|
+
*/
|
|
1268
4289
|
getAllLpPoolSwapIxs(lpPool: LPPoolAccount, constituentMap: ConstituentMap, inMarketIndex: number, outMarketIndex: number, inAmount: BN, minOutAmount: BN, userAuthority: PublicKey): Promise<TransactionInstruction[]>;
|
|
4290
|
+
/**
|
|
4291
|
+
* Keeper instruction: settles quote PnL owed between one or more hedge-enabled perp markets' fee
|
|
4292
|
+
* and PnL pools and the LP pool's quote constituent, bounded by the pool's settle cap. Requires
|
|
4293
|
+
* `updateAmmCache` to have run recently for the given markets. Permissionless — any signer can
|
|
4294
|
+
* act as keeper.
|
|
4295
|
+
* @param lpPoolId - LP pool ID.
|
|
4296
|
+
* @param perpMarketIndexes - Hedge-enabled perp market indexes to settle.
|
|
4297
|
+
* @returns The transaction signature.
|
|
4298
|
+
*/
|
|
1269
4299
|
settlePerpToLpPool(lpPoolId: number, perpMarketIndexes: number[]): Promise<TransactionSignature>;
|
|
4300
|
+
/**
|
|
4301
|
+
* Builds the `settlePerpToLpPool` instruction. See `settlePerpToLpPool` for semantics.
|
|
4302
|
+
* @param lpPoolId - LP pool ID.
|
|
4303
|
+
* @param perpMarketIndexes - Hedge-enabled perp market indexes to settle, passed as writable
|
|
4304
|
+
* remaining accounts.
|
|
4305
|
+
* @returns The instruction.
|
|
4306
|
+
*/
|
|
1270
4307
|
getSettlePerpToLpPoolIx(lpPoolId: number, perpMarketIndexes: number[]): Promise<TransactionInstruction>;
|
|
4308
|
+
/**
|
|
4309
|
+
* Builds the full instruction set to settle perp PnL into an LP pool: `updateAmmCache` for the
|
|
4310
|
+
* given markets followed by `settlePerpToLpPool`.
|
|
4311
|
+
* @param lpPoolId - LP pool ID.
|
|
4312
|
+
* @param marketIndexes - Hedge-enabled perp market indexes to settle.
|
|
4313
|
+
* @returns The ordered instructions to include in the transaction.
|
|
4314
|
+
*/
|
|
1271
4315
|
getAllSettlePerpToLpPoolIxs(lpPoolId: number, marketIndexes: number[]): Promise<TransactionInstruction[]>;
|
|
1272
4316
|
/**
|
|
1273
4317
|
* Below here are the transaction sending functions
|
|
@@ -1276,18 +4320,68 @@ export declare class VelocityClient {
|
|
|
1276
4320
|
private handlePreSignedTransaction;
|
|
1277
4321
|
private isVersionedTransaction;
|
|
1278
4322
|
/**
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1281
|
-
*
|
|
1282
|
-
* @param
|
|
1283
|
-
* @param
|
|
1284
|
-
* @param
|
|
1285
|
-
* @
|
|
4323
|
+
* Signs (unless `preSigned`) and sends a transaction via this client's `txSender`, dispatching to
|
|
4324
|
+
* `sendVersionedTransaction` or `send` based on whether `tx` is a `VersionedTransaction`. The
|
|
4325
|
+
* shared low-level send path underlying nearly every instruction-building method on this class.
|
|
4326
|
+
* @param tx - Transaction to send; legacy `Transaction` or `VersionedTransaction`.
|
|
4327
|
+
* @param additionalSigners - Extra signers beyond this client's wallet (e.g. newly-created accounts).
|
|
4328
|
+
* @param opts - Confirmation options; falls back to `this.opts` if not provided.
|
|
4329
|
+
* @param preSigned - If `true`, `tx` is assumed already fully signed and is submitted as-is.
|
|
4330
|
+
* @returns The transaction signature and the slot it was confirmed at.
|
|
1286
4331
|
*/
|
|
1287
4332
|
sendTransaction(tx: Transaction | VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
4333
|
+
/**
|
|
4334
|
+
* Assembles one or more instructions into a single unsigned transaction via `this.txHandler`,
|
|
4335
|
+
* applying compute-unit/priority-fee instructions from `txParams`, resolving address lookup
|
|
4336
|
+
* tables for versioned transactions, and fetching a recent blockhash if not supplied. Used by
|
|
4337
|
+
* nearly every instruction-building method on this class before sending.
|
|
4338
|
+
* @param instructions - Instruction(s) to include.
|
|
4339
|
+
* @param txParams - Optional compute-unit/priority-fee overrides; defaults to `this.txParams`.
|
|
4340
|
+
* @param txVersion - Legacy (`0`) vs versioned transaction; defaults to `this.txVersion`.
|
|
4341
|
+
* @param lookupTables - Additional address lookup tables to use, beyond the client's configured
|
|
4342
|
+
* market lookup tables.
|
|
4343
|
+
* @param forceVersionedTransaction - Force a `VersionedTransaction` even if `txVersion` implies legacy.
|
|
4344
|
+
* @param recentBlockhash - Pre-fetched blockhash to reuse instead of requesting a new one.
|
|
4345
|
+
* @param optionalIxs - Instructions to append opportunistically if space/compute budget allows
|
|
4346
|
+
* (dropped rather than causing failure if they don't fit).
|
|
4347
|
+
* @returns The assembled (unsigned) transaction.
|
|
4348
|
+
*/
|
|
1288
4349
|
buildTransaction(instructions: TransactionInstruction | TransactionInstruction[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean, recentBlockhash?: BlockhashWithExpiryBlockHeight, optionalIxs?: TransactionInstruction[]): Promise<Transaction | VersionedTransaction>;
|
|
4350
|
+
/**
|
|
4351
|
+
* Builds many independent transactions in one call — each entry in `instructions` becomes its own
|
|
4352
|
+
* transaction via the same path as `buildTransaction`. An entry may build to `undefined` if the
|
|
4353
|
+
* underlying `txHandler` implementation skips it (e.g. empty instruction list).
|
|
4354
|
+
* @param instructions - One instruction-list per transaction to build.
|
|
4355
|
+
* @param txParams - Optional compute-unit/priority-fee overrides applied to every transaction.
|
|
4356
|
+
* @param txVersion - Legacy (`0`) vs versioned transaction; defaults to `this.txVersion`.
|
|
4357
|
+
* @param lookupTables - Additional address lookup tables to use for every transaction.
|
|
4358
|
+
* @param forceVersionedTransaction - Force `VersionedTransaction`s even if `txVersion` implies legacy.
|
|
4359
|
+
* @returns The assembled (unsigned) transactions, in the same order as `instructions`.
|
|
4360
|
+
*/
|
|
1289
4361
|
buildBulkTransactions(instructions: (TransactionInstruction | TransactionInstruction[])[], txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<(Transaction | VersionedTransaction | undefined)[]>;
|
|
4362
|
+
/**
|
|
4363
|
+
* Like `buildBulkTransactions`, but keyed by caller-chosen labels instead of array position — each
|
|
4364
|
+
* value in `instructionsMap` becomes its own transaction, returned under the same key.
|
|
4365
|
+
* @param instructionsMap - Instruction-list(s) to build, keyed by an arbitrary caller-defined label.
|
|
4366
|
+
* @param txParams - Optional compute-unit/priority-fee overrides applied to every transaction.
|
|
4367
|
+
* @param txVersion - Legacy (`0`) vs versioned transaction; defaults to `this.txVersion`.
|
|
4368
|
+
* @param lookupTables - Additional address lookup tables to use for every transaction.
|
|
4369
|
+
* @param forceVersionedTransaction - Force `VersionedTransaction`s even if `txVersion` implies legacy.
|
|
4370
|
+
* @returns A map from each input key to its assembled (unsigned) transaction.
|
|
4371
|
+
*/
|
|
1290
4372
|
buildTransactionsMap(instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>, txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<MappedRecord<Record<string, TransactionInstruction | TransactionInstruction[]>, Transaction | VersionedTransaction>>;
|
|
4373
|
+
/**
|
|
4374
|
+
* Like `buildTransactionsMap`, but additionally signs every built transaction with this client's
|
|
4375
|
+
* wallet before returning — useful for batching several independent, pre-signed transactions
|
|
4376
|
+
* (e.g. to submit separately or hand off to `sendSignedTx`).
|
|
4377
|
+
* @param instructionsMap - Instruction-list(s) to build and sign, keyed by an arbitrary
|
|
4378
|
+
* caller-defined label.
|
|
4379
|
+
* @param txParams - Optional compute-unit/priority-fee overrides applied to every transaction.
|
|
4380
|
+
* @param txVersion - Legacy (`0`) vs versioned transaction; defaults to `this.txVersion`.
|
|
4381
|
+
* @param lookupTables - Additional address lookup tables to use for every transaction.
|
|
4382
|
+
* @param forceVersionedTransaction - Force `VersionedTransaction`s even if `txVersion` implies legacy.
|
|
4383
|
+
* @returns A map from each input key to its signed transaction.
|
|
4384
|
+
*/
|
|
1291
4385
|
buildAndSignTransactionsMap(instructionsMap: Record<string, TransactionInstruction | TransactionInstruction[]>, txParams?: TxParams, txVersion?: TransactionVersion, lookupTables?: AddressLookupTableAccount[], forceVersionedTransaction?: boolean): Promise<{
|
|
1292
4386
|
signedTxMap: Record<string, Transaction>;
|
|
1293
4387
|
signedTxData: SignedTxData[];
|
|
@@ -1295,6 +4389,19 @@ export declare class VelocityClient {
|
|
|
1295
4389
|
signedTxMap: MappedRecord<Record<string, TransactionInstruction | TransactionInstruction[]>, Transaction | VersionedTransaction>;
|
|
1296
4390
|
signedTxData: SignedTxData[];
|
|
1297
4391
|
}>;
|
|
4392
|
+
/**
|
|
4393
|
+
* Determines whether placing `orderParams` would increase the magnitude of the sub-account's
|
|
4394
|
+
* existing perp position in that market (same-direction add, or opening a new position) as
|
|
4395
|
+
* opposed to reducing/flattening/flipping it. Used by `placePerpOrder`/`placeOrders`/
|
|
4396
|
+
* `preparePlaceOrdersTx` to decide whether an `isolatedPositionDepositAmount` transfer should be
|
|
4397
|
+
* prepended — that transfer only makes sense when the order grows the position.
|
|
4398
|
+
* @param orderParams - Order to evaluate; `baseAssetAmount` is BASE_PRECISION (1e9).
|
|
4399
|
+
* @param subAccountId - Sub-account whose existing position to compare against; defaults to the
|
|
4400
|
+
* active sub-account.
|
|
4401
|
+
* @returns `true` if there is no existing position in the market, the existing position is flat
|
|
4402
|
+
* (zero), or the order's signed base amount increases the position's absolute size; `false` if it
|
|
4403
|
+
* reduces, flattens, or flips it.
|
|
4404
|
+
*/
|
|
1298
4405
|
isOrderIncreasingPosition(orderParams: OptionalOrderParams, subAccountId?: number): boolean;
|
|
1299
4406
|
}
|
|
1300
4407
|
export {};
|