@velocity-exchange/sdk 0.2.5 → 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 +93 -0
- package/README.md +3 -3
- 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 +2139 -5
- package/lib/browser/adminClient.js +2173 -11
- 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 +50 -1
- package/lib/browser/idl/velocity.json +50 -1
- 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 +92 -0
- package/lib/browser/math/exchangeStatus.js +111 -1
- 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 -7
- package/lib/browser/math/orders.js +133 -18
- 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 +32 -1
- 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 +129 -7
- 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 +67 -2
- 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/swift/swiftOrderSubscriber.js +2 -2
- package/lib/browser/tokenFaucet.d.ts +2 -2
- package/lib/browser/tokenFaucet.js +11 -4
- 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 +786 -13
- package/lib/browser/types.js +133 -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 +3323 -216
- package/lib/browser/velocityClient.js +3428 -249
- 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 +2139 -5
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +2173 -11
- 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 +50 -1
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +50 -1
- 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 +92 -0
- package/lib/node/math/exchangeStatus.d.ts.map +1 -1
- package/lib/node/math/exchangeStatus.js +111 -1
- 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 -7
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +133 -18
- 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 +32 -1
- 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 +129 -7
- 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 +67 -2
- 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/swift/swiftOrderSubscriber.js +2 -2
- package/lib/node/tokenFaucet.d.ts +2 -2
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +11 -4
- 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 +786 -13
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +133 -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 +3323 -216
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +3428 -249
- 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 +2184 -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 +50 -1
- package/src/idl/velocity.ts +50 -1
- 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 +125 -0
- 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 +144 -18
- 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 +32 -1
- 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 +131 -7
- 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 +74 -2
- 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/swift/swiftOrderSubscriber.ts +2 -2
- package/src/tokenFaucet.ts +10 -7
- 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 +783 -22
- 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 +3456 -254
- 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/helpers.ts +1 -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
package/src/adminClient.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AdminClient — governance and protocol administration instruction builders.
|
|
3
|
-
* Extends
|
|
3
|
+
* Extends `VelocityClient`; all trading/keeper methods are also available.
|
|
4
4
|
*
|
|
5
5
|
* Covers: perp/spot market initialization and updates, oracle guard rail config,
|
|
6
6
|
* fee structure updates, insurance fund operations, vault management, IF rebalancing,
|
|
7
|
-
* pause/unpause exchange, and all
|
|
7
|
+
* pause/unpause exchange, and all admin instruction handlers in `instructions/admin.rs`.
|
|
8
|
+
*
|
|
9
|
+
* Most methods require a specific admin tier, enforced on-chain by `state.cold_admin` /
|
|
10
|
+
* `state.warm_admin` / per-role `state.hot_*` keys (see `programs/velocity/src/auth.rs`).
|
|
11
|
+
* Tiers are additive — cold ⊇ warm ⊇ hot(role) — so the cold admin can always call a
|
|
12
|
+
* warm- or hot-gated instruction. Each method's doc below states the minimum tier
|
|
13
|
+
* required by the on-chain constraint; passing a lower-tier wallet fails the transaction
|
|
14
|
+
* with `Unauthorized`, not client-side.
|
|
8
15
|
*/
|
|
9
16
|
import {
|
|
10
17
|
AccountMeta,
|
|
@@ -22,6 +29,7 @@ import {
|
|
|
22
29
|
OracleGuardRails,
|
|
23
30
|
OracleSource,
|
|
24
31
|
ExchangeStatus,
|
|
32
|
+
SolvencyStatus,
|
|
25
33
|
MarketStatus,
|
|
26
34
|
ContractTier,
|
|
27
35
|
AssetTier,
|
|
@@ -83,6 +91,19 @@ import { JupiterClient, QuoteResponse } from './jupiter/jupiterClient';
|
|
|
83
91
|
import { SwapMode } from './swap/UnifiedSwapClient';
|
|
84
92
|
|
|
85
93
|
export class AdminClient extends VelocityClient {
|
|
94
|
+
/**
|
|
95
|
+
* Creates the protocol's singleton `State` account (one-time setup). Fails client-side
|
|
96
|
+
* if `State` already exists. On a real mainnet build the on-chain `Initialize` accounts
|
|
97
|
+
* struct additionally locks the signer to `ids::state_init_authority` so the one-time
|
|
98
|
+
* init cannot be front-run; on devnet/localnet or the `anchor-test` build any signer may
|
|
99
|
+
* call it. Seeds `cold_admin` and `warm_admin` to the calling wallet and `pause_admin` to
|
|
100
|
+
* the default (unassigned) pubkey — rotate them afterward via `updateAdmin` /
|
|
101
|
+
* `updateWarmAdmin` / `updatePauseAdmin`.
|
|
102
|
+
* @param usdcMint - Mint of the protocol's quote asset (must have 6 decimals; becomes
|
|
103
|
+
* `state.quoteAssetMint`).
|
|
104
|
+
* @param _adminControlsPrices - Unused; retained for call-site compatibility.
|
|
105
|
+
* @returns Tuple containing the transaction signature.
|
|
106
|
+
*/
|
|
86
107
|
public async initialize(
|
|
87
108
|
usdcMint: PublicKey,
|
|
88
109
|
_adminControlsPrices: boolean
|
|
@@ -118,6 +139,39 @@ export class AdminClient extends VelocityClient {
|
|
|
118
139
|
return [txSig];
|
|
119
140
|
}
|
|
120
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Initializes a new spot market: creates the `SpotMarket` PDA plus its token vault and
|
|
144
|
+
* insurance-fund vault, and appends it at `state.numberOfSpotMarkets` (or `marketIndex`
|
|
145
|
+
* if explicitly supplied — the on-chain handler asserts it matches the next sequential
|
|
146
|
+
* index). Requires warm admin (`check_warm`); if `activeStatus` is `true` the on-chain
|
|
147
|
+
* handler additionally requires the **cold** admin specifically (a market cannot be
|
|
148
|
+
* launched active by a warm-only signer). For `oracleSource: QuoteAsset` (used only for
|
|
149
|
+
* the index-0 quote market), `oracle` must be `PublicKey.default`.
|
|
150
|
+
* @param mint - Spot market's token mint. Must have >= 5 decimals (exactly 6 for the
|
|
151
|
+
* quote/index-0 market).
|
|
152
|
+
* @param optimalUtilization - Utilization at the borrow-rate kink, SPOT_UTILIZATION_PRECISION (1e6, 100% = 1e6).
|
|
153
|
+
* @param optimalRate - Borrow rate at `optimalUtilization`, SPOT_RATE_PRECISION (1e6, 100% APR = 1e6).
|
|
154
|
+
* @param maxRate - Borrow rate at 100% utilization, SPOT_RATE_PRECISION (1e6).
|
|
155
|
+
* @param oracle - Oracle account for this market's price feed (`PublicKey.default` for `OracleSource.QuoteAsset`).
|
|
156
|
+
* @param oracleSource - Oracle provider/format for `oracle`.
|
|
157
|
+
* @param initialAssetWeight - Initial (deposit) asset weight, SPOT_WEIGHT_PRECISION (1e4, 100% = 1e4).
|
|
158
|
+
* @param maintenanceAssetWeight - Maintenance asset weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
159
|
+
* @param initialLiabilityWeight - Initial (borrow) liability weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
160
|
+
* @param maintenanceLiabilityWeight - Maintenance liability weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
161
|
+
* @param imfFactor - Increases weight penalty as position size grows, SPOT_IMF_PRECISION (1e6). Default 0.
|
|
162
|
+
* @param liquidatorFee - Fee paid to liquidators, LIQUIDATION_FEE_PRECISION (1e6). Default 0.
|
|
163
|
+
* @param ifLiquidationFee - Portion of the liquidation fee routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6). Default 0.
|
|
164
|
+
* @param activeStatus - If `true`, market is `Active` immediately; otherwise `Initialized` (trading disabled until a later status update). Requires cold admin when `true`. Default `true`.
|
|
165
|
+
* @param assetTier - Collateral tier gating cross-margin usability. Default `AssetTier.COLLATERAL`.
|
|
166
|
+
* @param scaleInitialAssetWeightStart - Deposit-token-amount threshold, QUOTE_PRECISION (1e6) equivalent notional, above which `initialAssetWeight` scales down. Default 0 (disabled).
|
|
167
|
+
* @param withdrawGuardThreshold - Token-amount threshold, market's native decimals, above which large single withdraws/borrows are blocked. Default 0.
|
|
168
|
+
* @param orderTickSize - Minimum price increment for spot orders, PRICE_PRECISION (1e6). Default 1.
|
|
169
|
+
* @param orderStepSize - Minimum base size increment for spot orders, market's native decimals. Also seeds `minOrderSize`. Default 1.
|
|
170
|
+
* @param ifTotalFactor - Insurance fund fee share of the total spot fee, IF_FACTOR_PRECISION (1e6). Default 0.
|
|
171
|
+
* @param name - Market display name, UTF-8 encoded and padded/truncated to 32 bytes. Default `DEFAULT_MARKET_NAME`.
|
|
172
|
+
* @param marketIndex - Explicit spot market index; defaults to `state.numberOfSpotMarkets` (the next free slot) when omitted.
|
|
173
|
+
* @returns Transaction signature.
|
|
174
|
+
*/
|
|
121
175
|
public async initializeSpotMarket(
|
|
122
176
|
mint: PublicKey,
|
|
123
177
|
optimalUtilization: number,
|
|
@@ -184,6 +238,14 @@ export class AdminClient extends VelocityClient {
|
|
|
184
238
|
return txSig;
|
|
185
239
|
}
|
|
186
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Builds the `initializeSpotMarket` instruction without sending it. See `initializeSpotMarket`
|
|
243
|
+
* for parameter units and the cold-admin-if-`activeStatus` rule. Looks up `mint`'s owning
|
|
244
|
+
* token program on-chain (throws if the mint account doesn't exist) and resolves the admin
|
|
245
|
+
* signer to `wallet.publicKey` when `useHotWalletAdmin` is set, otherwise to `state.coldAdmin`
|
|
246
|
+
* (or the wallet if not yet subscribed).
|
|
247
|
+
* @returns The unsigned `initializeSpotMarket` instruction.
|
|
248
|
+
*/
|
|
187
249
|
public async getInitializeSpotMarketIx(
|
|
188
250
|
mint: PublicKey,
|
|
189
251
|
optimalUtilization: number,
|
|
@@ -276,6 +338,15 @@ export class AdminClient extends VelocityClient {
|
|
|
276
338
|
return initializeIx;
|
|
277
339
|
}
|
|
278
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Closes a mis-initialized spot market and refunds rent to the admin. Requires warm admin
|
|
343
|
+
* (`check_warm`). On-chain the handler only allows deleting the **most recently created**
|
|
344
|
+
* market (`marketIndex == state.numberOfSpotMarkets - 1`), still in `Initialized` status
|
|
345
|
+
* (never activated), with zero deposit and borrow balances and empty vaults — otherwise it
|
|
346
|
+
* throws `InvalidMarketAccountforDeletion`.
|
|
347
|
+
* @param marketIndex - Index of the spot market to delete; must be the last-created, unactivated, empty market.
|
|
348
|
+
* @returns Transaction signature.
|
|
349
|
+
*/
|
|
279
350
|
public async deleteInitializedSpotMarket(
|
|
280
351
|
marketIndex: number
|
|
281
352
|
): Promise<TransactionSignature> {
|
|
@@ -289,6 +360,12 @@ export class AdminClient extends VelocityClient {
|
|
|
289
360
|
return txSig;
|
|
290
361
|
}
|
|
291
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Builds the `deleteInitializedSpotMarket` instruction without sending it. See
|
|
365
|
+
* `deleteInitializedSpotMarket` for the on-chain preconditions.
|
|
366
|
+
* @param marketIndex - Index of the spot market to delete.
|
|
367
|
+
* @returns The unsigned `deleteInitializedSpotMarket` instruction.
|
|
368
|
+
*/
|
|
292
369
|
public async getDeleteInitializedSpotMarketIx(
|
|
293
370
|
marketIndex: number
|
|
294
371
|
): Promise<TransactionInstruction> {
|
|
@@ -325,6 +402,45 @@ export class AdminClient extends VelocityClient {
|
|
|
325
402
|
);
|
|
326
403
|
}
|
|
327
404
|
|
|
405
|
+
/**
|
|
406
|
+
* Initializes a new perp market's `PerpMarket` PDA and seeds its AMM. Requires warm admin
|
|
407
|
+
* (`check_warm`); if `activeStatus` is `true` the on-chain handler additionally requires
|
|
408
|
+
* the **cold** admin (a market cannot launch active under a warm-only signer). The handler
|
|
409
|
+
* asserts `marketIndex === state.numberOfMarkets` (must be the next sequential index) and
|
|
410
|
+
* that `baseAssetReserve === quoteAssetReserve` (the initial mark price is exactly
|
|
411
|
+
* `pegMultiplier`). Does not add the market to the AMM cache — call `addMarketToAmmCache`
|
|
412
|
+
* separately (typically before the market can be traded/cranked).
|
|
413
|
+
* @param marketIndex - New market's index; must equal `state.numberOfMarkets`.
|
|
414
|
+
* @param priceOracle - Oracle account backing this market's price feed.
|
|
415
|
+
* @param baseAssetReserve - Initial AMM base reserve, BASE_PRECISION (1e9). Must equal `quoteAssetReserve`.
|
|
416
|
+
* @param quoteAssetReserve - Initial AMM quote reserve, BASE_PRECISION (1e9, AMM-internal units, not quote-asset dollars). Must equal `baseAssetReserve`.
|
|
417
|
+
* @param periodicity - Funding period, seconds (`market.marketStats.fundingPeriod`), as a BN.
|
|
418
|
+
* @param pegMultiplier - AMM peg, PEG_PRECISION (1e6). With equal reserves this fixes the initial mark price to `pegMultiplier`. Default `PEG_PRECISION` (price = 1.0).
|
|
419
|
+
* @param oracleSource - Oracle provider/format for `priceOracle`. Default `OracleSource.PYTH_LAZER`.
|
|
420
|
+
* @param contractTier - Risk/collateral tier for the contract. Default `ContractTier.SPECULATIVE`.
|
|
421
|
+
* @param marginRatioInitial - Initial margin ratio, MARGIN_PRECISION (1e4, e.g. 2000 = 20% = 5x max leverage). Default 2000.
|
|
422
|
+
* @param marginRatioMaintenance - Maintenance margin ratio, MARGIN_PRECISION (1e4). Default 500 (5%).
|
|
423
|
+
* @param liquidatorFee - Fee paid to liquidators, LIQUIDATION_FEE_PRECISION (1e6). Default 0.
|
|
424
|
+
* @param ifLiquidatorFee - Portion of the liquidation fee routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6). Default 10000 (1%).
|
|
425
|
+
* @param imfFactor - Increases the effective margin requirement as position size grows, PERCENTAGE_PRECISION-scaled (1e6). Default 0.
|
|
426
|
+
* @param activeStatus - If `true`, market is `Active` immediately; otherwise `Initialized`. Requires cold admin when `true`. Default `true`.
|
|
427
|
+
* @param baseSpread - Base bid/ask spread around the AMM reserve price, BID_ASK_SPREAD_PRECISION (1e6). Default 0.
|
|
428
|
+
* @param maxSpread - Maximum allowed total spread, BID_ASK_SPREAD_PRECISION (1e6). Default 142500 (14.25%).
|
|
429
|
+
* @param maxOpenInterest - Cap on base-asset open interest, BASE_PRECISION (1e9). Default 0 (unlimited — treated as no cap by downstream checks).
|
|
430
|
+
* @param maxRevenueWithdrawPerPeriod - Cap on revenue-pool withdrawals per settlement period, QUOTE_PRECISION (1e6). Default 0.
|
|
431
|
+
* @param quoteMaxInsurance - Lifetime cap on insurance draws for this market, QUOTE_PRECISION (1e6). Default 0.
|
|
432
|
+
* @param orderStepSize - Minimum base-size increment for orders, BASE_PRECISION (1e9). Default `BASE_PRECISION / 10000`.
|
|
433
|
+
* @param orderTickSize - Minimum price increment for orders, PRICE_PRECISION (1e6). Default `PRICE_PRECISION / 100000`.
|
|
434
|
+
* @param minOrderSize - Minimum base order size, BASE_PRECISION (1e9). Default `BASE_PRECISION / 10000`.
|
|
435
|
+
* @param concentrationCoefScale - Unitless divisor controlling AMM liquidity concentration around the peg (`concentrationCoef = CONCENTRATION_PRECISION + (MAX_CONCENTRATION_COEFFICIENT - CONCENTRATION_PRECISION) / scale`; must be > 0). Default `ONE` (widest allowed concentration). Larger scale narrows the depth band.
|
|
436
|
+
* @param curveUpdateIntensity - 0-100 knob controlling how aggressively the AMM curve/peg re-centers on repegs. Default 0 (disabled).
|
|
437
|
+
* @param ammJitIntensity - 0-100 knob controlling how aggressively the AMM just-in-time-fills maker orders. Default 0 (disabled).
|
|
438
|
+
* @param name - Market display name, UTF-8 encoded and padded/truncated to 32 bytes. Default `DEFAULT_MARKET_NAME`.
|
|
439
|
+
* @param lpPoolId - LP pool this market's hedge exposure is routed to; 0 means unassigned. Default 0.
|
|
440
|
+
* @param fundingClampThreshold - Dead-zone half-width before funding ramps up, basis points (BPS_PRECISION, 1e4). 0 falls back on-chain to 5 bps. Default 0.
|
|
441
|
+
* @param fundingRampSlope - Slope applied to the price spread beyond the dead zone, PERCENTAGE_PRECISION (1e6, 1e6 = 1.0x). 0 falls back on-chain to 1e6 (1.0x). Default 0.
|
|
442
|
+
* @returns Transaction signature.
|
|
443
|
+
*/
|
|
328
444
|
public async initializePerpMarket(
|
|
329
445
|
marketIndex: number,
|
|
330
446
|
priceOracle: PublicKey,
|
|
@@ -407,6 +523,11 @@ export class AdminClient extends VelocityClient {
|
|
|
407
523
|
return txSig;
|
|
408
524
|
}
|
|
409
525
|
|
|
526
|
+
/**
|
|
527
|
+
* Builds the `initializePerpMarket` instruction without sending it. See `initializePerpMarket`
|
|
528
|
+
* for parameter units and the cold-admin-if-`activeStatus` rule.
|
|
529
|
+
* @returns Single-element array containing the unsigned `initializePerpMarket` instruction.
|
|
530
|
+
*/
|
|
410
531
|
public async getInitializePerpMarketIx(
|
|
411
532
|
marketIndex: number,
|
|
412
533
|
priceOracle: PublicKey,
|
|
@@ -494,6 +615,11 @@ export class AdminClient extends VelocityClient {
|
|
|
494
615
|
return ixs;
|
|
495
616
|
}
|
|
496
617
|
|
|
618
|
+
/**
|
|
619
|
+
* Creates the protocol-wide singleton `AmmCache` PDA (one-time setup, empty until
|
|
620
|
+
* `addMarketToAmmCache` is called per market). Requires warm admin (`check_warm`).
|
|
621
|
+
* @returns Transaction signature.
|
|
622
|
+
*/
|
|
497
623
|
public async initializeAmmCache(
|
|
498
624
|
txParams?: TxParams
|
|
499
625
|
): Promise<TransactionSignature> {
|
|
@@ -506,6 +632,10 @@ export class AdminClient extends VelocityClient {
|
|
|
506
632
|
return txSig;
|
|
507
633
|
}
|
|
508
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Builds the `initializeAmmCache` instruction without sending it. See `initializeAmmCache`.
|
|
637
|
+
* @returns The unsigned `initializeAmmCache` instruction.
|
|
638
|
+
*/
|
|
509
639
|
public async getInitializeAmmCacheIx(): Promise<TransactionInstruction> {
|
|
510
640
|
return await this.program.instruction.initializeAmmCache({
|
|
511
641
|
accounts: {
|
|
@@ -520,6 +650,14 @@ export class AdminClient extends VelocityClient {
|
|
|
520
650
|
});
|
|
521
651
|
}
|
|
522
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Appends a perp market's entry to the `AmmCache` (reallocating it larger by one slot).
|
|
655
|
+
* Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if the market index
|
|
656
|
+
* is already present in the cache. A market must be added here before keeper cranks that
|
|
657
|
+
* rely on the AMM cache (e.g. LP-pool settlement) can process it.
|
|
658
|
+
* @param perpMarketIndex - Index of the perp market to add.
|
|
659
|
+
* @returns Transaction signature.
|
|
660
|
+
*/
|
|
523
661
|
public async addMarketToAmmCache(
|
|
524
662
|
perpMarketIndex: number,
|
|
525
663
|
txParams?: TxParams
|
|
@@ -535,6 +673,12 @@ export class AdminClient extends VelocityClient {
|
|
|
535
673
|
return txSig;
|
|
536
674
|
}
|
|
537
675
|
|
|
676
|
+
/**
|
|
677
|
+
* Builds the `addMarketToAmmCache` instruction without sending it. See `addMarketToAmmCache`.
|
|
678
|
+
* @param perpMarketIndex - Index of the perp market to add. Throws if the market is not
|
|
679
|
+
* already tracked by the local account subscriber.
|
|
680
|
+
* @returns The unsigned `addMarketToAmmCache` instruction.
|
|
681
|
+
*/
|
|
538
682
|
public async getAddMarketToAmmCacheIx(
|
|
539
683
|
perpMarketIndex: number
|
|
540
684
|
): Promise<TransactionInstruction> {
|
|
@@ -553,6 +697,12 @@ export class AdminClient extends VelocityClient {
|
|
|
553
697
|
});
|
|
554
698
|
}
|
|
555
699
|
|
|
700
|
+
/**
|
|
701
|
+
* Closes the `AmmCache` PDA, refunding rent to the admin. Requires warm admin
|
|
702
|
+
* (`check_warm`). Removes tracking for every market at once — there is no per-market
|
|
703
|
+
* inverse of `addMarketToAmmCache`.
|
|
704
|
+
* @returns Transaction signature.
|
|
705
|
+
*/
|
|
556
706
|
public async deleteAmmCache(
|
|
557
707
|
txParams?: TxParams
|
|
558
708
|
): Promise<TransactionSignature> {
|
|
@@ -565,6 +715,10 @@ export class AdminClient extends VelocityClient {
|
|
|
565
715
|
return txSig;
|
|
566
716
|
}
|
|
567
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Builds the `deleteAmmCache` instruction without sending it. See `deleteAmmCache`.
|
|
720
|
+
* @returns The unsigned `deleteAmmCache` instruction.
|
|
721
|
+
*/
|
|
568
722
|
public async getDeleteAmmCacheIx(): Promise<TransactionInstruction> {
|
|
569
723
|
return await this.program.instruction.deleteAmmCache({
|
|
570
724
|
accounts: {
|
|
@@ -577,6 +731,15 @@ export class AdminClient extends VelocityClient {
|
|
|
577
731
|
});
|
|
578
732
|
}
|
|
579
733
|
|
|
734
|
+
/**
|
|
735
|
+
* Refreshes the `AmmCache` entries for the given perp markets from their current on-chain
|
|
736
|
+
* state and oracle price (market stats, MM-oracle price/validity). Requires the `LpCache`
|
|
737
|
+
* hot key (or warm/cold). `perpMarketIndexes` are passed as readable perp markets in
|
|
738
|
+
* `remainingAccounts` (each market's oracle account must be resolvable via the local
|
|
739
|
+
* account subscriber); the quote spot market (index 0) is always included as readable.
|
|
740
|
+
* @param perpMarketIndexes - Perp market indexes to refresh in the cache.
|
|
741
|
+
* @returns Transaction signature.
|
|
742
|
+
*/
|
|
580
743
|
public async updateInitialAmmCacheInfo(
|
|
581
744
|
perpMarketIndexes: number[],
|
|
582
745
|
txParams?: TxParams
|
|
@@ -592,6 +755,12 @@ export class AdminClient extends VelocityClient {
|
|
|
592
755
|
return txSig;
|
|
593
756
|
}
|
|
594
757
|
|
|
758
|
+
/**
|
|
759
|
+
* Builds the `updateInitialAmmCacheInfo` instruction without sending it. See
|
|
760
|
+
* `updateInitialAmmCacheInfo`.
|
|
761
|
+
* @param perpMarketIndexes - Perp market indexes to refresh in the cache.
|
|
762
|
+
* @returns The unsigned `updateInitialAmmCacheInfo` instruction.
|
|
763
|
+
*/
|
|
595
764
|
public async getUpdateInitialAmmCacheInfoIx(
|
|
596
765
|
perpMarketIndexes: number[]
|
|
597
766
|
): Promise<TransactionInstruction> {
|
|
@@ -612,6 +781,26 @@ export class AdminClient extends VelocityClient {
|
|
|
612
781
|
});
|
|
613
782
|
}
|
|
614
783
|
|
|
784
|
+
/**
|
|
785
|
+
* Force-overwrites one market's `AmmCache` entry fields (admin escape hatch, e.g. to
|
|
786
|
+
* recover from a bad cache after an incident). Requires the `LpCache` hot key (or
|
|
787
|
+
* warm/cold). Only fields present in `params` are changed; omitted fields keep their
|
|
788
|
+
* current cached value. No-op (does not throw) if `perpMarketIndex` has no cache entry yet.
|
|
789
|
+
*
|
|
790
|
+
* Caution: despite its name, `params.lastSettleTs` is **not** forwarded to the
|
|
791
|
+
* instruction — `getOverrideAmmCacheInfoIx` expects `lastSettleSlot` and this wrapper
|
|
792
|
+
* passes `params` straight through, so any `lastSettleTs` value is silently dropped and
|
|
793
|
+
* the cache's `lastSettleSlot` is left unchanged. Call `getOverrideAmmCacheInfoIx` directly
|
|
794
|
+
* with `lastSettleSlot` if that field needs to be overridden.
|
|
795
|
+
* @param perpMarketIndex - Perp market whose cache entry to override.
|
|
796
|
+
* @param params.quoteOwedFromLpPool - Quote owed from the LP pool to this market's hedge, QUOTE_PRECISION (1e6), signed.
|
|
797
|
+
* @param params.lastSettleTs - Not applied by this method; see caution above.
|
|
798
|
+
* @param params.lastFeePoolTokenAmount - Cached fee-pool token balance, quote spot market's native decimals.
|
|
799
|
+
* @param params.lastNetPnlPoolTokenAmount - Cached net PnL-pool token balance, quote spot market's native decimals, signed.
|
|
800
|
+
* @param params.ammPositionScalar - Unitless 0-100 scalar applied to the AMM's hedge position sizing.
|
|
801
|
+
* @param params.ammInventoryLimit - Inventory limit for the AMM's hedge position, BASE_PRECISION (1e9), signed.
|
|
802
|
+
* @returns Transaction signature.
|
|
803
|
+
*/
|
|
615
804
|
public async overrideAmmCacheInfo(
|
|
616
805
|
perpMarketIndex: number,
|
|
617
806
|
params: {
|
|
@@ -635,6 +824,12 @@ export class AdminClient extends VelocityClient {
|
|
|
635
824
|
return txSig;
|
|
636
825
|
}
|
|
637
826
|
|
|
827
|
+
/**
|
|
828
|
+
* Builds the `overrideAmmCacheInfo` instruction without sending it. Unlike `overrideAmmCacheInfo`,
|
|
829
|
+
* this overload's `params` correctly uses `lastSettleSlot` (not `lastSettleTs`) and does
|
|
830
|
+
* forward it. See `overrideAmmCacheInfo` for field units.
|
|
831
|
+
* @returns The unsigned `overrideAmmCacheInfo` instruction.
|
|
832
|
+
*/
|
|
638
833
|
public async getOverrideAmmCacheInfoIx(
|
|
639
834
|
perpMarketIndex: number,
|
|
640
835
|
params: {
|
|
@@ -672,6 +867,17 @@ export class AdminClient extends VelocityClient {
|
|
|
672
867
|
);
|
|
673
868
|
}
|
|
674
869
|
|
|
870
|
+
/**
|
|
871
|
+
* Intended to reallocate the `AmmCache` to `state.numberOfMarkets` entries and reset it
|
|
872
|
+
* (`ResetAmmCache` accounts struct is gated on the `LpCache` hot key, or warm/cold, per
|
|
873
|
+
* `programs/velocity/src/instructions/admin.rs`). **Currently non-functional**: no
|
|
874
|
+
* `reset_amm_cache` handler is wired into the program's instruction dispatch, so this
|
|
875
|
+
* instruction does not exist in the IDL — `getResetAmmCacheIx` casts to `any` to bypass
|
|
876
|
+
* the missing type, but calling it throws at runtime (`program.instruction.resetAmmCache`
|
|
877
|
+
* is `undefined`). Use `deleteAmmCache` + `initializeAmmCache` + `addMarketToAmmCache` per
|
|
878
|
+
* market to achieve the same effect until this is wired up on-chain.
|
|
879
|
+
* @returns Transaction signature (in practice: throws before a transaction is built).
|
|
880
|
+
*/
|
|
675
881
|
public async resetAmmCache(
|
|
676
882
|
txParams?: TxParams
|
|
677
883
|
): Promise<TransactionSignature> {
|
|
@@ -683,6 +889,11 @@ export class AdminClient extends VelocityClient {
|
|
|
683
889
|
return txSig;
|
|
684
890
|
}
|
|
685
891
|
|
|
892
|
+
/**
|
|
893
|
+
* Builds the (currently non-existent) `resetAmmCache` instruction. See `resetAmmCache` —
|
|
894
|
+
* this throws because the program does not expose a `resetAmmCache` instruction.
|
|
895
|
+
* @returns Never resolves successfully; throws when the missing instruction is invoked.
|
|
896
|
+
*/
|
|
686
897
|
public async getResetAmmCacheIx(): Promise<TransactionInstruction> {
|
|
687
898
|
return (this.program.instruction as any).resetAmmCache({
|
|
688
899
|
accounts: {
|
|
@@ -696,6 +907,14 @@ export class AdminClient extends VelocityClient {
|
|
|
696
907
|
});
|
|
697
908
|
}
|
|
698
909
|
|
|
910
|
+
/**
|
|
911
|
+
* Closes a mis-initialized perp market and refunds rent to the admin. Requires warm admin
|
|
912
|
+
* (`check_warm`). On-chain the handler only allows deleting the **most recently created**
|
|
913
|
+
* market (`marketIndex == state.numberOfMarkets - 1`), still in `Initialized` status
|
|
914
|
+
* (never activated), with zero users — otherwise it throws `InvalidMarketAccountforDeletion`.
|
|
915
|
+
* @param marketIndex - Index of the perp market to delete; must be the last-created, unactivated, userless market.
|
|
916
|
+
* @returns Transaction signature.
|
|
917
|
+
*/
|
|
699
918
|
public async deleteInitializedPerpMarket(
|
|
700
919
|
marketIndex: number
|
|
701
920
|
): Promise<TransactionSignature> {
|
|
@@ -709,6 +928,12 @@ export class AdminClient extends VelocityClient {
|
|
|
709
928
|
return txSig;
|
|
710
929
|
}
|
|
711
930
|
|
|
931
|
+
/**
|
|
932
|
+
* Builds the `deleteInitializedPerpMarket` instruction without sending it. See
|
|
933
|
+
* `deleteInitializedPerpMarket` for the on-chain preconditions.
|
|
934
|
+
* @param marketIndex - Index of the perp market to delete.
|
|
935
|
+
* @returns The unsigned `deleteInitializedPerpMarket` instruction.
|
|
936
|
+
*/
|
|
712
937
|
public async getDeleteInitializedPerpMarketIx(
|
|
713
938
|
marketIndex: number
|
|
714
939
|
): Promise<TransactionInstruction> {
|
|
@@ -731,6 +956,19 @@ export class AdminClient extends VelocityClient {
|
|
|
731
956
|
);
|
|
732
957
|
}
|
|
733
958
|
|
|
959
|
+
/**
|
|
960
|
+
* Directly overwrites the AMM's base/quote reserves and `sqrtK` for a perp market — an
|
|
961
|
+
* admin escape hatch to force the AMM mark price (`quoteAssetReserve / baseAssetReserve *
|
|
962
|
+
* pegMultiplier`) without going through a repeg. Requires warm admin (`check_warm`).
|
|
963
|
+
* Re-derives min/max base reserve bounds from the new `sqrtK` and re-validates the market
|
|
964
|
+
* (`validate_perp_market`) before committing, so an inconsistent reserve/peg combination
|
|
965
|
+
* fails the transaction.
|
|
966
|
+
* @param perpMarketIndex - Perp market to move.
|
|
967
|
+
* @param baseAssetReserve - New AMM base reserve, BASE_PRECISION (1e9).
|
|
968
|
+
* @param quoteAssetReserve - New AMM quote reserve, BASE_PRECISION (1e9, AMM-internal units).
|
|
969
|
+
* @param sqrtK - New invariant `sqrt(baseAssetReserve * quoteAssetReserve)`, BASE_PRECISION (1e9). Defaults to the exact square root of `baseAssetReserve * quoteAssetReserve` when omitted.
|
|
970
|
+
* @returns Transaction signature.
|
|
971
|
+
*/
|
|
734
972
|
public async moveAmmPrice(
|
|
735
973
|
perpMarketIndex: number,
|
|
736
974
|
baseAssetReserve: BN,
|
|
@@ -751,6 +989,11 @@ export class AdminClient extends VelocityClient {
|
|
|
751
989
|
return txSig;
|
|
752
990
|
}
|
|
753
991
|
|
|
992
|
+
/**
|
|
993
|
+
* Builds the `moveAmmPrice` instruction without sending it. See `moveAmmPrice` for units
|
|
994
|
+
* and the `sqrtK` default.
|
|
995
|
+
* @returns The unsigned `moveAmmPrice` instruction.
|
|
996
|
+
*/
|
|
754
997
|
public async getMoveAmmPriceIx(
|
|
755
998
|
perpMarketIndex: number,
|
|
756
999
|
baseAssetReserve: BN,
|
|
@@ -782,6 +1025,18 @@ export class AdminClient extends VelocityClient {
|
|
|
782
1025
|
);
|
|
783
1026
|
}
|
|
784
1027
|
|
|
1028
|
+
/**
|
|
1029
|
+
* Rescales a perp market's AMM invariant (`sqrtK`) while holding the mark price
|
|
1030
|
+
* approximately constant, widening or tightening depth around the current peg. Requires
|
|
1031
|
+
* warm admin (`check_warm`). On-chain, increasing `sqrtK` must cost the AMM's fee reserve
|
|
1032
|
+
* a non-negative amount (charged against `totalFeeMinusDistributions`, capped at that
|
|
1033
|
+
* balance) and decreasing it must yield a non-positive cost; the resulting price move must
|
|
1034
|
+
* stay within `MAX_UPDATE_K_PRICE_CHANGE` and `sqrtK` may not increase past `MAX_SQRT_K` —
|
|
1035
|
+
* violating any of these throws `InvalidUpdateK`.
|
|
1036
|
+
* @param perpMarketIndex - Perp market to rescale.
|
|
1037
|
+
* @param sqrtK - New invariant, BASE_PRECISION (1e9).
|
|
1038
|
+
* @returns Transaction signature.
|
|
1039
|
+
*/
|
|
785
1040
|
public async updateK(
|
|
786
1041
|
perpMarketIndex: number,
|
|
787
1042
|
sqrtK: BN
|
|
@@ -795,6 +1050,11 @@ export class AdminClient extends VelocityClient {
|
|
|
795
1050
|
return txSig;
|
|
796
1051
|
}
|
|
797
1052
|
|
|
1053
|
+
/**
|
|
1054
|
+
* Builds the `updateK` instruction without sending it. See `updateK` for units and the
|
|
1055
|
+
* on-chain cost/price-change constraints.
|
|
1056
|
+
* @returns The unsigned `updateK` instruction.
|
|
1057
|
+
*/
|
|
798
1058
|
public async getUpdateKIx(
|
|
799
1059
|
perpMarketIndex: number,
|
|
800
1060
|
sqrtK: BN
|
|
@@ -815,6 +1075,17 @@ export class AdminClient extends VelocityClient {
|
|
|
815
1075
|
});
|
|
816
1076
|
}
|
|
817
1077
|
|
|
1078
|
+
/**
|
|
1079
|
+
* Re-centers a perp market's AMM around a new peg and invariant while keeping the AMM's
|
|
1080
|
+
* net position unchanged (`amm.recenter`) — the admin-driven counterpart of an automatic
|
|
1081
|
+
* repeg, typically used to realign the AMM to the oracle after a large price move.
|
|
1082
|
+
* Requires warm admin (`check_warm`). Re-derives min/max base reserve bounds and
|
|
1083
|
+
* re-validates the market before committing.
|
|
1084
|
+
* @param perpMarketIndex - Perp market to recenter.
|
|
1085
|
+
* @param pegMultiplier - New AMM peg, PEG_PRECISION (1e6).
|
|
1086
|
+
* @param sqrtK - New invariant, BASE_PRECISION (1e9).
|
|
1087
|
+
* @returns Transaction signature.
|
|
1088
|
+
*/
|
|
818
1089
|
public async recenterPerpMarketAmm(
|
|
819
1090
|
perpMarketIndex: number,
|
|
820
1091
|
pegMultiplier: BN,
|
|
@@ -833,6 +1104,11 @@ export class AdminClient extends VelocityClient {
|
|
|
833
1104
|
return txSig;
|
|
834
1105
|
}
|
|
835
1106
|
|
|
1107
|
+
/**
|
|
1108
|
+
* Builds the `recenterPerpMarketAmm` instruction without sending it. See
|
|
1109
|
+
* `recenterPerpMarketAmm` for units.
|
|
1110
|
+
* @returns The unsigned `recenterPerpMarketAmm` instruction.
|
|
1111
|
+
*/
|
|
836
1112
|
public async getRecenterPerpMarketAmmIx(
|
|
837
1113
|
perpMarketIndex: number,
|
|
838
1114
|
pegMultiplier: BN,
|
|
@@ -858,6 +1134,14 @@ export class AdminClient extends VelocityClient {
|
|
|
858
1134
|
);
|
|
859
1135
|
}
|
|
860
1136
|
|
|
1137
|
+
/**
|
|
1138
|
+
* Keeper-cranked variant of `recenterPerpMarketAmm`: derives the target peg/invariant from
|
|
1139
|
+
* the current oracle price (and an optional target depth) instead of taking them as
|
|
1140
|
+
* explicit params. Requires the `AmmCrank` hot key (or warm/cold).
|
|
1141
|
+
* @param perpMarketIndex - Perp market to recenter.
|
|
1142
|
+
* @param depth - Optional target liquidity depth to recenter around, BASE_PRECISION (1e9). Omit to use the market's existing depth.
|
|
1143
|
+
* @returns Transaction signature.
|
|
1144
|
+
*/
|
|
861
1145
|
public async recenterPerpMarketAmmCrank(
|
|
862
1146
|
perpMarketIndex: number,
|
|
863
1147
|
depth?: BN
|
|
@@ -874,6 +1158,11 @@ export class AdminClient extends VelocityClient {
|
|
|
874
1158
|
return txSig;
|
|
875
1159
|
}
|
|
876
1160
|
|
|
1161
|
+
/**
|
|
1162
|
+
* Builds the `recenterPerpMarketAmmCrank` instruction without sending it. See
|
|
1163
|
+
* `recenterPerpMarketAmmCrank`.
|
|
1164
|
+
* @returns The unsigned `recenterPerpMarketAmmCrank` instruction.
|
|
1165
|
+
*/
|
|
877
1166
|
public async getRecenterPerpMarketAmmCrankIx(
|
|
878
1167
|
perpMarketIndex: number,
|
|
879
1168
|
depth?: BN
|
|
@@ -901,6 +1190,14 @@ export class AdminClient extends VelocityClient {
|
|
|
901
1190
|
);
|
|
902
1191
|
}
|
|
903
1192
|
|
|
1193
|
+
/**
|
|
1194
|
+
* Updates a perp market's AMM concentration coefficient, changing how tightly liquidity
|
|
1195
|
+
* is concentrated around the peg (calls the on-chain `updatePerpMarketConcentrationCoef`
|
|
1196
|
+
* instruction). Requires warm admin (`check_warm`).
|
|
1197
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1198
|
+
* @param concentrationScale - Unitless divisor, must be > 0 (`concentrationCoef = CONCENTRATION_PRECISION + (MAX_CONCENTRATION_COEFFICIENT - CONCENTRATION_PRECISION) / concentrationScale`). Larger scale narrows the depth band; `1` yields the widest allowed concentration.
|
|
1199
|
+
* @returns Transaction signature.
|
|
1200
|
+
*/
|
|
904
1201
|
public async updatePerpMarketConcentrationScale(
|
|
905
1202
|
perpMarketIndex: number,
|
|
906
1203
|
concentrationScale: BN
|
|
@@ -918,6 +1215,11 @@ export class AdminClient extends VelocityClient {
|
|
|
918
1215
|
return txSig;
|
|
919
1216
|
}
|
|
920
1217
|
|
|
1218
|
+
/**
|
|
1219
|
+
* Builds the `updatePerpMarketConcentrationCoef` instruction without sending it. See
|
|
1220
|
+
* `updatePerpMarketConcentrationScale`.
|
|
1221
|
+
* @returns The unsigned `updatePerpMarketConcentrationCoef` instruction.
|
|
1222
|
+
*/
|
|
921
1223
|
public async getUpdatePerpMarketConcentrationScaleIx(
|
|
922
1224
|
perpMarketIndex: number,
|
|
923
1225
|
concentrationScale: BN
|
|
@@ -939,6 +1241,13 @@ export class AdminClient extends VelocityClient {
|
|
|
939
1241
|
);
|
|
940
1242
|
}
|
|
941
1243
|
|
|
1244
|
+
/**
|
|
1245
|
+
* Sets which LP pool a perp market's hedge exposure (`hedgeConfig.poolId`) is routed to.
|
|
1246
|
+
* Requires warm admin (`check_warm`).
|
|
1247
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1248
|
+
* @param lpPoolId - Target LP pool id; 0 means unassigned.
|
|
1249
|
+
* @returns Transaction signature.
|
|
1250
|
+
*/
|
|
942
1251
|
public async updatePerpMarketLpPoolId(
|
|
943
1252
|
perpMarketIndex: number,
|
|
944
1253
|
lpPoolId: number
|
|
@@ -955,6 +1264,11 @@ export class AdminClient extends VelocityClient {
|
|
|
955
1264
|
return txSig;
|
|
956
1265
|
}
|
|
957
1266
|
|
|
1267
|
+
/**
|
|
1268
|
+
* Builds the `updatePerpMarketLpPoolId` instruction without sending it. See
|
|
1269
|
+
* `updatePerpMarketLpPoolId`.
|
|
1270
|
+
* @returns The unsigned `updatePerpMarketLpPoolId` instruction.
|
|
1271
|
+
*/
|
|
958
1272
|
public async getUpdatePerpMarketLpPoolIdIx(
|
|
959
1273
|
perpMarketIndex: number,
|
|
960
1274
|
lpPoolId: number
|
|
@@ -973,6 +1287,14 @@ export class AdminClient extends VelocityClient {
|
|
|
973
1287
|
});
|
|
974
1288
|
}
|
|
975
1289
|
|
|
1290
|
+
/**
|
|
1291
|
+
* Sets a perp market's LP-pool hedge status (`hedgeConfig.status`) and immediately
|
|
1292
|
+
* refreshes its `AmmCache` entry from the new market state. Requires warm admin
|
|
1293
|
+
* (`check_warm`).
|
|
1294
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1295
|
+
* @param lpStatus - New hedge status bitmask/value for `hedgeConfig.status`.
|
|
1296
|
+
* @returns Transaction signature.
|
|
1297
|
+
*/
|
|
976
1298
|
public async updatePerpMarketLpPoolStatus(
|
|
977
1299
|
perpMarketIndex: number,
|
|
978
1300
|
lpStatus: number
|
|
@@ -987,6 +1309,11 @@ export class AdminClient extends VelocityClient {
|
|
|
987
1309
|
return txSig;
|
|
988
1310
|
}
|
|
989
1311
|
|
|
1312
|
+
/**
|
|
1313
|
+
* Builds the `updatePerpMarketLpPoolStatus` instruction without sending it. See
|
|
1314
|
+
* `updatePerpMarketLpPoolStatus`.
|
|
1315
|
+
* @returns The unsigned `updatePerpMarketLpPoolStatus` instruction.
|
|
1316
|
+
*/
|
|
990
1317
|
public async getUpdatePerpMarketLpPoolStatusIx(
|
|
991
1318
|
perpMarketIndex: number,
|
|
992
1319
|
lpStatus: number
|
|
@@ -1009,6 +1336,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1009
1336
|
);
|
|
1010
1337
|
}
|
|
1011
1338
|
|
|
1339
|
+
/**
|
|
1340
|
+
* Convenience wrapper around `moveAmmPrice`: computes, from the locally cached
|
|
1341
|
+
* `PerpMarket` account, the base/quote reserves that move the AMM's mark price to
|
|
1342
|
+
* `targetPrice` (holding `sqrtK` fixed at its current value) and sends that instruction.
|
|
1343
|
+
* Requires warm admin (`check_warm`, same as `moveAmmPrice`). Throws if the market isn't
|
|
1344
|
+
* tracked by the local account subscriber.
|
|
1345
|
+
* @param perpMarketIndex - Perp market to move.
|
|
1346
|
+
* @param targetPrice - Desired AMM mark price, PRICE_PRECISION (1e6).
|
|
1347
|
+
* @returns Transaction signature.
|
|
1348
|
+
*/
|
|
1012
1349
|
public async moveAmmToPrice(
|
|
1013
1350
|
perpMarketIndex: number,
|
|
1014
1351
|
targetPrice: BN
|
|
@@ -1025,6 +1362,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1025
1362
|
return txSig;
|
|
1026
1363
|
}
|
|
1027
1364
|
|
|
1365
|
+
/**
|
|
1366
|
+
* Builds the underlying `moveAmmPrice` instruction that moves the AMM to `targetPrice`.
|
|
1367
|
+
* See `moveAmmToPrice`.
|
|
1368
|
+
* @returns The unsigned `moveAmmPrice` instruction.
|
|
1369
|
+
*/
|
|
1028
1370
|
public async getMoveAmmToPriceIx(
|
|
1029
1371
|
perpMarketIndex: number,
|
|
1030
1372
|
targetPrice: BN
|
|
@@ -1068,6 +1410,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1068
1410
|
);
|
|
1069
1411
|
}
|
|
1070
1412
|
|
|
1413
|
+
/**
|
|
1414
|
+
* Repegs a perp market's AMM toward `newPeg`, adjusting reserves to keep the invariant
|
|
1415
|
+
* (`sqrtK`) fixed while moving the mark price. Requires warm admin (`check_warm`). The
|
|
1416
|
+
* on-chain `repeg` routine validates the oracle (per `state.oracleGuardRails`) and charges
|
|
1417
|
+
* the reserve/fee-pool the resulting `adjustment_cost`; emits `AmmCurveChanged`.
|
|
1418
|
+
* @param newPeg - Candidate new AMM peg, PEG_PRECISION (1e6).
|
|
1419
|
+
* @param perpMarketIndex - Perp market to repeg.
|
|
1420
|
+
* @returns Transaction signature.
|
|
1421
|
+
*/
|
|
1071
1422
|
public async repegAmmCurve(
|
|
1072
1423
|
newPeg: BN,
|
|
1073
1424
|
perpMarketIndex: number
|
|
@@ -1084,6 +1435,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1084
1435
|
return txSig;
|
|
1085
1436
|
}
|
|
1086
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* Builds the `repegAmmCurve` instruction without sending it. See `repegAmmCurve`. Throws
|
|
1440
|
+
* if `perpMarketIndex` isn't tracked by the local account subscriber (needed to resolve
|
|
1441
|
+
* the market's oracle account).
|
|
1442
|
+
* @returns The unsigned `repegAmmCurve` instruction.
|
|
1443
|
+
*/
|
|
1087
1444
|
public async getRepegAmmCurveIx(
|
|
1088
1445
|
newPeg: BN,
|
|
1089
1446
|
perpMarketIndex: number
|
|
@@ -1106,6 +1463,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1106
1463
|
});
|
|
1107
1464
|
}
|
|
1108
1465
|
|
|
1466
|
+
/**
|
|
1467
|
+
* Nudges a perp market's cached oracle TWAP (`marketStats.historicalOracleData.lastOraclePriceTwap`,
|
|
1468
|
+
* PRICE_PRECISION 1e6) toward the freshly-sampled oracle TWAP, but only accepts the move
|
|
1469
|
+
* if it narrows the mark/oracle TWAP gap or flips its sign (otherwise clamps the cached
|
|
1470
|
+
* TWAP to the mark TWAP). Requires warm admin (`check_warm`); throws `PriceBandsBreached`
|
|
1471
|
+
* on-chain if the new gap would be strictly larger with the same sign, and `InvalidOracle`
|
|
1472
|
+
* if the oracle can't be read.
|
|
1473
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1474
|
+
* @returns Transaction signature.
|
|
1475
|
+
*/
|
|
1109
1476
|
public async updatePerpMarketAmmOracleTwap(
|
|
1110
1477
|
perpMarketIndex: number
|
|
1111
1478
|
): Promise<TransactionSignature> {
|
|
@@ -1119,6 +1486,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1119
1486
|
return txSig;
|
|
1120
1487
|
}
|
|
1121
1488
|
|
|
1489
|
+
/**
|
|
1490
|
+
* Builds the `updatePerpMarketAmmOracleTwap` instruction without sending it. See
|
|
1491
|
+
* `updatePerpMarketAmmOracleTwap`.
|
|
1492
|
+
* @returns The unsigned `updatePerpMarketAmmOracleTwap` instruction.
|
|
1493
|
+
*/
|
|
1122
1494
|
public async getUpdatePerpMarketAmmOracleTwapIx(
|
|
1123
1495
|
perpMarketIndex: number
|
|
1124
1496
|
): Promise<TransactionInstruction> {
|
|
@@ -1140,6 +1512,14 @@ export class AdminClient extends VelocityClient {
|
|
|
1140
1512
|
});
|
|
1141
1513
|
}
|
|
1142
1514
|
|
|
1515
|
+
/**
|
|
1516
|
+
* Admin failsafe that force-resets a perp market's cached oracle TWAP to the current mark
|
|
1517
|
+
* TWAP (unconditionally, unlike `updatePerpMarketAmmOracleTwap`'s gap-narrowing check).
|
|
1518
|
+
* Requires warm admin (`check_warm`). Use when the oracle TWAP has drifted badly (e.g.
|
|
1519
|
+
* after an oracle outage) and funding needs to be re-anchored immediately.
|
|
1520
|
+
* @param perpMarketIndex - Perp market to reset.
|
|
1521
|
+
* @returns Transaction signature.
|
|
1522
|
+
*/
|
|
1143
1523
|
public async resetPerpMarketAmmOracleTwap(
|
|
1144
1524
|
perpMarketIndex: number
|
|
1145
1525
|
): Promise<TransactionSignature> {
|
|
@@ -1153,6 +1533,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1153
1533
|
return txSig;
|
|
1154
1534
|
}
|
|
1155
1535
|
|
|
1536
|
+
/**
|
|
1537
|
+
* Builds the `resetPerpMarketAmmOracleTwap` instruction without sending it. See
|
|
1538
|
+
* `resetPerpMarketAmmOracleTwap`.
|
|
1539
|
+
* @returns The unsigned `resetPerpMarketAmmOracleTwap` instruction.
|
|
1540
|
+
*/
|
|
1156
1541
|
public async getResetPerpMarketAmmOracleTwapIx(
|
|
1157
1542
|
perpMarketIndex: number
|
|
1158
1543
|
): Promise<TransactionInstruction> {
|
|
@@ -1174,6 +1559,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1174
1559
|
});
|
|
1175
1560
|
}
|
|
1176
1561
|
|
|
1562
|
+
/**
|
|
1563
|
+
* Tops up a perp market's AMM fee pool: transfers `amount` from `sourceVault` (a token
|
|
1564
|
+
* account the caller controls) into the quote spot market's vault via CPI, and credits
|
|
1565
|
+
* the same amount to `perpMarket.amm.totalFeeMinusDistributions` / `amm.feePool`. Requires
|
|
1566
|
+
* the `VaultDeposit` hot key (or warm/cold).
|
|
1567
|
+
* @param perpMarketIndex - Perp market whose fee pool to credit.
|
|
1568
|
+
* @param amount - Amount to deposit, quote spot market's native decimals (QUOTE_PRECISION, 1e6, for the standard USDC quote market).
|
|
1569
|
+
* @param sourceVault - Token account to transfer `amount` from; `admin` must be its authority.
|
|
1570
|
+
* @returns Transaction signature.
|
|
1571
|
+
*/
|
|
1177
1572
|
public async depositIntoPerpMarketFeePool(
|
|
1178
1573
|
perpMarketIndex: number,
|
|
1179
1574
|
amount: BN,
|
|
@@ -1193,6 +1588,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1193
1588
|
return txSig;
|
|
1194
1589
|
}
|
|
1195
1590
|
|
|
1591
|
+
/**
|
|
1592
|
+
* Builds the `depositIntoPerpMarketFeePool` instruction without sending it. See
|
|
1593
|
+
* `depositIntoPerpMarketFeePool`.
|
|
1594
|
+
* @returns The unsigned `depositIntoPerpMarketFeePool` instruction.
|
|
1595
|
+
*/
|
|
1196
1596
|
public async getDepositIntoPerpMarketFeePoolIx(
|
|
1197
1597
|
perpMarketIndex: number,
|
|
1198
1598
|
amount: BN,
|
|
@@ -1227,6 +1627,17 @@ export class AdminClient extends VelocityClient {
|
|
|
1227
1627
|
});
|
|
1228
1628
|
}
|
|
1229
1629
|
|
|
1630
|
+
/**
|
|
1631
|
+
* Credits `amount` to a perp market's PnL pool balance as pure internal accounting — it
|
|
1632
|
+
* does **not** move any tokens. On-chain the handler only validates that the quote spot
|
|
1633
|
+
* market's actual vault balance still covers the resulting internal balances
|
|
1634
|
+
* (`validate_spot_market_vault_amount`); it does not itself deposit the backing tokens, so
|
|
1635
|
+
* call this only after (or together with) a real deposit that gets the tokens into the
|
|
1636
|
+
* vault. Requires warm admin (`check_warm`).
|
|
1637
|
+
* @param perpMarketIndex - Perp market whose PnL pool to credit.
|
|
1638
|
+
* @param amount - Amount to credit, quote spot market's native decimals (QUOTE_PRECISION, 1e6, for the standard USDC quote market).
|
|
1639
|
+
* @returns Transaction signature.
|
|
1640
|
+
*/
|
|
1230
1641
|
public async updatePerpMarketPnlPool(
|
|
1231
1642
|
perpMarketIndex: number,
|
|
1232
1643
|
amount: BN
|
|
@@ -1243,6 +1654,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1243
1654
|
return txSig;
|
|
1244
1655
|
}
|
|
1245
1656
|
|
|
1657
|
+
/**
|
|
1658
|
+
* Builds the `updatePerpMarketPnlPool` instruction without sending it. See
|
|
1659
|
+
* `updatePerpMarketPnlPool` — no tokens are moved by this instruction.
|
|
1660
|
+
* @returns The unsigned `updatePerpMarketPnlPool` instruction.
|
|
1661
|
+
*/
|
|
1246
1662
|
public async getUpdatePerpMarketPnlPoolIx(
|
|
1247
1663
|
perpMarketIndex: number,
|
|
1248
1664
|
amount: BN
|
|
@@ -1263,6 +1679,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1263
1679
|
});
|
|
1264
1680
|
}
|
|
1265
1681
|
|
|
1682
|
+
/**
|
|
1683
|
+
* Deposits `amount` from `sourceVault` (a token account the caller controls) directly into
|
|
1684
|
+
* a spot market's vault via CPI and credits the market's deposit balance accordingly.
|
|
1685
|
+
* Requires the `VaultDeposit` hot key (or warm/cold). Throws on-chain if the spot market
|
|
1686
|
+
* has deposits paused (`SpotOperation::Deposit`).
|
|
1687
|
+
* @param spotMarketIndex - Spot market whose vault to deposit into.
|
|
1688
|
+
* @param amount - Amount to deposit, the spot market's native token decimals.
|
|
1689
|
+
* @param sourceVault - Token account to transfer `amount` from; `admin` must be its authority.
|
|
1690
|
+
* @returns Transaction signature.
|
|
1691
|
+
*/
|
|
1266
1692
|
public async depositIntoSpotMarketVault(
|
|
1267
1693
|
spotMarketIndex: number,
|
|
1268
1694
|
amount: BN,
|
|
@@ -1282,6 +1708,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1282
1708
|
return txSig;
|
|
1283
1709
|
}
|
|
1284
1710
|
|
|
1711
|
+
/**
|
|
1712
|
+
* Builds the `depositIntoSpotMarketVault` instruction without sending it. See
|
|
1713
|
+
* `depositIntoSpotMarketVault`. Automatically appends transfer-hook extra account metas
|
|
1714
|
+
* when the mint requires them.
|
|
1715
|
+
* @returns The unsigned `depositIntoSpotMarketVault` instruction.
|
|
1716
|
+
*/
|
|
1285
1717
|
public async getDepositIntoSpotMarketVaultIx(
|
|
1286
1718
|
spotMarketIndex: number,
|
|
1287
1719
|
amount: BN,
|
|
@@ -1314,6 +1746,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1314
1746
|
});
|
|
1315
1747
|
}
|
|
1316
1748
|
|
|
1749
|
+
/**
|
|
1750
|
+
* Rotates the root (`state.coldAdmin`) authority — the top of the cold ⊇ warm ⊇
|
|
1751
|
+
* hot(role) tier hierarchy. Cold-only: the `ColdAdminUpdateState` context requires
|
|
1752
|
+
* the current signer to equal `state.coldAdmin`. This is the one-time-per-rotation
|
|
1753
|
+
* root key change; `warmAdmin` and `pauseAdmin` are rotated separately via
|
|
1754
|
+
* `updateWarmAdmin`/`updatePauseAdmin` (also cold-only).
|
|
1755
|
+
* @param admin - New cold admin pubkey.
|
|
1756
|
+
* @returns Transaction signature.
|
|
1757
|
+
*/
|
|
1317
1758
|
public async updateAdmin(admin: PublicKey): Promise<TransactionSignature> {
|
|
1318
1759
|
const updateAdminIx = await this.getUpdateAdminIx(admin);
|
|
1319
1760
|
|
|
@@ -1324,6 +1765,10 @@ export class AdminClient extends VelocityClient {
|
|
|
1324
1765
|
return txSig;
|
|
1325
1766
|
}
|
|
1326
1767
|
|
|
1768
|
+
/**
|
|
1769
|
+
* Builds the `updateAdmin` instruction without sending it. See `updateAdmin`.
|
|
1770
|
+
* @returns The unsigned `updateAdmin` instruction.
|
|
1771
|
+
*/
|
|
1327
1772
|
public async getUpdateAdminIx(
|
|
1328
1773
|
admin: PublicKey
|
|
1329
1774
|
): Promise<TransactionInstruction> {
|
|
@@ -1337,6 +1782,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1337
1782
|
});
|
|
1338
1783
|
}
|
|
1339
1784
|
|
|
1785
|
+
/**
|
|
1786
|
+
* Sets how aggressively a perp market's AMM curve auto-adjusts. Requires the market's
|
|
1787
|
+
* `HotAdminUpdatePerpMarket` gate — the `check_warm` constraint on that context currently
|
|
1788
|
+
* accepts cold or warm admin only (no dedicated hot role is wired to it). On-chain, values
|
|
1789
|
+
* `0..=100` control repeg/formulaic-k intensity and `101..=200` additionally enable
|
|
1790
|
+
* reference-price-offset intensity; values above 200 throw `DefaultError`.
|
|
1791
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1792
|
+
* @param curveUpdateIntensity - 0-200 intensity knob (see above for the two sub-ranges).
|
|
1793
|
+
* @returns Transaction signature.
|
|
1794
|
+
*/
|
|
1340
1795
|
public async updatePerpMarketCurveUpdateIntensity(
|
|
1341
1796
|
perpMarketIndex: number,
|
|
1342
1797
|
curveUpdateIntensity: number
|
|
@@ -1356,6 +1811,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1356
1811
|
return txSig;
|
|
1357
1812
|
}
|
|
1358
1813
|
|
|
1814
|
+
/**
|
|
1815
|
+
* Builds the `updatePerpMarketCurveUpdateIntensity` instruction without sending it. See
|
|
1816
|
+
* `updatePerpMarketCurveUpdateIntensity`.
|
|
1817
|
+
* @returns The unsigned `updatePerpMarketCurveUpdateIntensity` instruction.
|
|
1818
|
+
*/
|
|
1359
1819
|
public async getUpdatePerpMarketCurveUpdateIntensityIx(
|
|
1360
1820
|
perpMarketIndex: number,
|
|
1361
1821
|
curveUpdateIntensity: number
|
|
@@ -1377,6 +1837,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1377
1837
|
);
|
|
1378
1838
|
}
|
|
1379
1839
|
|
|
1840
|
+
/**
|
|
1841
|
+
* Sets the dead-band, as a percent of price, within which the AMM's reference-price offset
|
|
1842
|
+
* (used to bias the AMM's quoted price away from the raw oracle/mark price) is suppressed.
|
|
1843
|
+
* Gated the same as `updatePerpMarketCurveUpdateIntensity` (warm admin via
|
|
1844
|
+
* `HotAdminUpdatePerpMarket`'s `check_warm` constraint). Throws `DefaultError` on-chain if
|
|
1845
|
+
* `referencePriceOffsetDeadbandPct > 100`.
|
|
1846
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1847
|
+
* @param referencePriceOffsetDeadbandPct - 0-100 percent dead-band.
|
|
1848
|
+
* @returns Transaction signature.
|
|
1849
|
+
*/
|
|
1380
1850
|
public async updatePerpMarketReferencePriceOffsetDeadbandPct(
|
|
1381
1851
|
perpMarketIndex: number,
|
|
1382
1852
|
referencePriceOffsetDeadbandPct: number
|
|
@@ -1396,6 +1866,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1396
1866
|
return txSig;
|
|
1397
1867
|
}
|
|
1398
1868
|
|
|
1869
|
+
/**
|
|
1870
|
+
* Builds the `updatePerpMarketReferencePriceOffsetDeadbandPct` instruction without sending
|
|
1871
|
+
* it. See `updatePerpMarketReferencePriceOffsetDeadbandPct`.
|
|
1872
|
+
* @returns The unsigned `updatePerpMarketReferencePriceOffsetDeadbandPct` instruction.
|
|
1873
|
+
*/
|
|
1399
1874
|
public async getUpdatePerpMarketReferencePriceOffsetDeadbandPctIx(
|
|
1400
1875
|
perpMarketIndex: number,
|
|
1401
1876
|
referencePriceOffsetDeadbandPct: number
|
|
@@ -1417,6 +1892,17 @@ export class AdminClient extends VelocityClient {
|
|
|
1417
1892
|
);
|
|
1418
1893
|
}
|
|
1419
1894
|
|
|
1895
|
+
/**
|
|
1896
|
+
* **Currently non-functional**: the program does not expose an
|
|
1897
|
+
* `update_perp_market_target_base_asset_amount_per_lp` instruction (no such handler is
|
|
1898
|
+
* wired into `lib.rs`, and it's absent from the generated IDL). `getUpdatePerpMarketTargetBaseAssetAmountPerLpIx`
|
|
1899
|
+
* casts `this.program.instruction` to `any` to bypass the missing type, but the call
|
|
1900
|
+
* throws at runtime. `targetBaseAssetAmountPerLp` exists only as a legacy field in
|
|
1901
|
+
* `test_utils/legacy_snapshot.rs`, not on the live `PerpMarket`/`AMM` struct.
|
|
1902
|
+
* @param perpMarketIndex - Perp market that would be updated.
|
|
1903
|
+
* @param targetBaseAssetAmountPerLP - Intended target base-asset-amount-per-LP value.
|
|
1904
|
+
* @returns Transaction signature (in practice: throws before a transaction is built).
|
|
1905
|
+
*/
|
|
1420
1906
|
public async updatePerpMarketTargetBaseAssetAmountPerLp(
|
|
1421
1907
|
perpMarketIndex: number,
|
|
1422
1908
|
targetBaseAssetAmountPerLP: number
|
|
@@ -1436,6 +1922,18 @@ export class AdminClient extends VelocityClient {
|
|
|
1436
1922
|
return txSig;
|
|
1437
1923
|
}
|
|
1438
1924
|
|
|
1925
|
+
/**
|
|
1926
|
+
* Admin recalibration of a perp market's AMM fee-accounting summary stats. Requires the
|
|
1927
|
+
* `AmmCrank` hot key (or warm/cold). If `netUnsettledFundingPnl` is provided it directly
|
|
1928
|
+
* overwrites `perpMarket.netUnsettledFundingPnl`. If `updateAmmSummaryStats` is `true`,
|
|
1929
|
+
* recomputes `amm.totalFeeMinusDistributions` from current market/spot-market/oracle state
|
|
1930
|
+
* and applies the resulting delta to `amm.totalFee` and `amm.totalMmFee`; omitted or
|
|
1931
|
+
* `false` leaves fee accounting untouched. Re-validates the market before committing.
|
|
1932
|
+
* @param perpMarketIndex - Perp market to recalibrate.
|
|
1933
|
+
* @param updateAmmSummaryStats - If `true`, recompute and correct AMM fee-accounting totals. Default: unset (no correction).
|
|
1934
|
+
* @param netUnsettledFundingPnl - Overwrite for `perpMarket.netUnsettledFundingPnl`, QUOTE_PRECISION (1e6), signed. Default: unset (unchanged).
|
|
1935
|
+
* @returns Transaction signature.
|
|
1936
|
+
*/
|
|
1439
1937
|
public async updatePerpMarketAmmSummaryStats(
|
|
1440
1938
|
perpMarketIndex: number,
|
|
1441
1939
|
updateAmmSummaryStats?: boolean,
|
|
@@ -1455,6 +1953,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1455
1953
|
return txSig;
|
|
1456
1954
|
}
|
|
1457
1955
|
|
|
1956
|
+
/**
|
|
1957
|
+
* Builds the `updatePerpMarketAmmSummaryStats` instruction without sending it. See
|
|
1958
|
+
* `updatePerpMarketAmmSummaryStats`. Throws if `perpMarketIndex` isn't tracked by the
|
|
1959
|
+
* local account subscriber (needed to resolve the market's oracle account).
|
|
1960
|
+
* @returns The unsigned `updatePerpMarketAmmSummaryStats` instruction.
|
|
1961
|
+
*/
|
|
1458
1962
|
public async getUpdatePerpMarketAmmSummaryStatsIx(
|
|
1459
1963
|
perpMarketIndex: number,
|
|
1460
1964
|
updateAmmSummaryStats?: boolean,
|
|
@@ -1486,6 +1990,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1486
1990
|
);
|
|
1487
1991
|
}
|
|
1488
1992
|
|
|
1993
|
+
/**
|
|
1994
|
+
* Builds the (currently non-existent) `updatePerpMarketTargetBaseAssetAmountPerLp`
|
|
1995
|
+
* instruction. See `updatePerpMarketTargetBaseAssetAmountPerLp` — this throws because the
|
|
1996
|
+
* program does not expose that instruction.
|
|
1997
|
+
* @returns Never resolves successfully; throws when the missing instruction is invoked.
|
|
1998
|
+
*/
|
|
1489
1999
|
public async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(
|
|
1490
2000
|
perpMarketIndex: number,
|
|
1491
2001
|
targetBaseAssetAmountPerLP: number
|
|
@@ -1506,6 +2016,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1506
2016
|
});
|
|
1507
2017
|
}
|
|
1508
2018
|
|
|
2019
|
+
/**
|
|
2020
|
+
* Sets a perp market's initial and maintenance margin ratios (max leverage and
|
|
2021
|
+
* liquidation threshold). Requires warm admin (`check_warm`). On-chain, validates the pair
|
|
2022
|
+
* is internally consistent and compatible with the market's current `liquidatorFee`
|
|
2023
|
+
* (`amm.validate_compatible_with_margin_ratio`) before committing.
|
|
2024
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2025
|
+
* @param marginRatioInitial - Initial margin ratio, MARGIN_PRECISION (1e4, e.g. 2000 = 20% = 5x max leverage). Must be >= `marginRatioMaintenance`.
|
|
2026
|
+
* @param marginRatioMaintenance - Maintenance margin ratio, MARGIN_PRECISION (1e4).
|
|
2027
|
+
* @returns Transaction signature.
|
|
2028
|
+
*/
|
|
1509
2029
|
public async updatePerpMarketMarginRatio(
|
|
1510
2030
|
perpMarketIndex: number,
|
|
1511
2031
|
marginRatioInitial: number,
|
|
@@ -1525,6 +2045,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1525
2045
|
return txSig;
|
|
1526
2046
|
}
|
|
1527
2047
|
|
|
2048
|
+
/**
|
|
2049
|
+
* Builds the `updatePerpMarketMarginRatio` instruction without sending it. See
|
|
2050
|
+
* `updatePerpMarketMarginRatio`.
|
|
2051
|
+
* @returns The unsigned `updatePerpMarketMarginRatio` instruction.
|
|
2052
|
+
*/
|
|
1528
2053
|
public async getUpdatePerpMarketMarginRatioIx(
|
|
1529
2054
|
perpMarketIndex: number,
|
|
1530
2055
|
marginRatioInitial: number,
|
|
@@ -1548,6 +2073,19 @@ export class AdminClient extends VelocityClient {
|
|
|
1548
2073
|
);
|
|
1549
2074
|
}
|
|
1550
2075
|
|
|
2076
|
+
/**
|
|
2077
|
+
* Sets a perp market's funding dead-zone: the band around the oracle TWAP within which no
|
|
2078
|
+
* funding premium accrues, and the ramp applied to the premium beyond that band. Requires
|
|
2079
|
+
* warm admin (`check_warm`). Unlike `initializePerpMarket` (where `0` silently falls back
|
|
2080
|
+
* to defaults), the update handler validates its inputs directly and throws `DefaultError`
|
|
2081
|
+
* if `fundingClampThreshold >= BPS_PRECISION` (i.e. must be < 100%) or if
|
|
2082
|
+
* `fundingRampSlope === 0` (a zero slope would flatten every premium past the band to the
|
|
2083
|
+
* funding-rate offset).
|
|
2084
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2085
|
+
* @param fundingClampThreshold - Dead-zone half-width, basis points (BPS_PRECISION, 1e4). Must be < 10000.
|
|
2086
|
+
* @param fundingRampSlope - Slope applied beyond the dead zone, PERCENTAGE_PRECISION (1e6, 1e6 = 1.0x). Must be > 0.
|
|
2087
|
+
* @returns Transaction signature.
|
|
2088
|
+
*/
|
|
1551
2089
|
public async updatePerpMarketFundingDeadZone(
|
|
1552
2090
|
perpMarketIndex: number,
|
|
1553
2091
|
fundingClampThreshold: number,
|
|
@@ -1567,6 +2105,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1567
2105
|
return txSig;
|
|
1568
2106
|
}
|
|
1569
2107
|
|
|
2108
|
+
/**
|
|
2109
|
+
* Builds the `updatePerpMarketFundingDeadZone` instruction without sending it. See
|
|
2110
|
+
* `updatePerpMarketFundingDeadZone` for units and validation.
|
|
2111
|
+
* @returns The unsigned `updatePerpMarketFundingDeadZone` instruction.
|
|
2112
|
+
*/
|
|
1570
2113
|
public async getUpdatePerpMarketFundingDeadZoneIx(
|
|
1571
2114
|
perpMarketIndex: number,
|
|
1572
2115
|
fundingClampThreshold: number,
|
|
@@ -1590,6 +2133,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1590
2133
|
);
|
|
1591
2134
|
}
|
|
1592
2135
|
|
|
2136
|
+
/**
|
|
2137
|
+
* Sets a perp market's IMF factors, which increase the effective margin requirement (and
|
|
2138
|
+
* shrink unrealized-PnL asset weight) as position size grows. Requires warm admin
|
|
2139
|
+
* (`check_warm`). Throws `DefaultError` on-chain if either value exceeds `SPOT_IMF_PRECISION` (1e6).
|
|
2140
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2141
|
+
* @param imfFactor - Position-size margin penalty factor, SPOT_IMF_PRECISION (1e6). Must be <= 1e6.
|
|
2142
|
+
* @param unrealizedPnlImfFactor - Position-size penalty factor applied to unrealized-PnL asset weight, SPOT_IMF_PRECISION (1e6). Must be <= 1e6.
|
|
2143
|
+
* @returns Transaction signature.
|
|
2144
|
+
*/
|
|
1593
2145
|
public async updatePerpMarketImfFactor(
|
|
1594
2146
|
perpMarketIndex: number,
|
|
1595
2147
|
imfFactor: number,
|
|
@@ -1609,6 +2161,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1609
2161
|
return txSig;
|
|
1610
2162
|
}
|
|
1611
2163
|
|
|
2164
|
+
/**
|
|
2165
|
+
* Builds the `updatePerpMarketImfFactor` instruction without sending it. See
|
|
2166
|
+
* `updatePerpMarketImfFactor`.
|
|
2167
|
+
* @returns The unsigned `updatePerpMarketImfFactor` instruction.
|
|
2168
|
+
*/
|
|
1612
2169
|
public async getUpdatePerpMarketImfFactorIx(
|
|
1613
2170
|
perpMarketIndex: number,
|
|
1614
2171
|
imfFactor: number,
|
|
@@ -1632,6 +2189,14 @@ export class AdminClient extends VelocityClient {
|
|
|
1632
2189
|
);
|
|
1633
2190
|
}
|
|
1634
2191
|
|
|
2192
|
+
/**
|
|
2193
|
+
* Sets a perp market's base bid/ask spread around the AMM reserve price. Requires warm
|
|
2194
|
+
* admin (`check_warm`). The AMM's cached `longSpread`/`shortSpread` are refreshed from
|
|
2195
|
+
* this value on the next quote/fill rather than immediately.
|
|
2196
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2197
|
+
* @param baseSpread - New base spread, BID_ASK_SPREAD_PRECISION (1e6).
|
|
2198
|
+
* @returns Transaction signature.
|
|
2199
|
+
*/
|
|
1635
2200
|
public async updatePerpMarketBaseSpread(
|
|
1636
2201
|
perpMarketIndex: number,
|
|
1637
2202
|
baseSpread: number
|
|
@@ -1646,6 +2211,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1646
2211
|
return txSig;
|
|
1647
2212
|
}
|
|
1648
2213
|
|
|
2214
|
+
/**
|
|
2215
|
+
* Builds the `updatePerpMarketBaseSpread` instruction without sending it. See
|
|
2216
|
+
* `updatePerpMarketBaseSpread`.
|
|
2217
|
+
* @returns The unsigned `updatePerpMarketBaseSpread` instruction.
|
|
2218
|
+
*/
|
|
1649
2219
|
public async getUpdatePerpMarketBaseSpreadIx(
|
|
1650
2220
|
perpMarketIndex: number,
|
|
1651
2221
|
baseSpread: number
|
|
@@ -1667,6 +2237,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1667
2237
|
);
|
|
1668
2238
|
}
|
|
1669
2239
|
|
|
2240
|
+
/**
|
|
2241
|
+
* Sets how aggressively the AMM just-in-time-fills incoming taker orders against its own
|
|
2242
|
+
* inventory before routing to the DLOB. Gated the same as `updatePerpMarketCurveUpdateIntensity`
|
|
2243
|
+
* (warm admin via `HotAdminUpdatePerpMarket`'s `check_warm` constraint). Throws
|
|
2244
|
+
* `DefaultError` on-chain if outside `0..=100`.
|
|
2245
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2246
|
+
* @param ammJitIntensity - 0-100 intensity; 0 disables AMM JIT fills.
|
|
2247
|
+
* @returns Transaction signature.
|
|
2248
|
+
*/
|
|
1670
2249
|
public async updateAmmJitIntensity(
|
|
1671
2250
|
perpMarketIndex: number,
|
|
1672
2251
|
ammJitIntensity: number
|
|
@@ -1683,6 +2262,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1683
2262
|
return txSig;
|
|
1684
2263
|
}
|
|
1685
2264
|
|
|
2265
|
+
/**
|
|
2266
|
+
* Builds the `updateAmmJitIntensity` instruction without sending it. See
|
|
2267
|
+
* `updateAmmJitIntensity`.
|
|
2268
|
+
* @returns The unsigned `updateAmmJitIntensity` instruction.
|
|
2269
|
+
*/
|
|
1686
2270
|
public async getUpdateAmmJitIntensityIx(
|
|
1687
2271
|
perpMarketIndex: number,
|
|
1688
2272
|
ammJitIntensity: number
|
|
@@ -1704,6 +2288,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1704
2288
|
);
|
|
1705
2289
|
}
|
|
1706
2290
|
|
|
2291
|
+
/**
|
|
2292
|
+
* Sets a perp market's display name. Requires warm admin (`check_warm`).
|
|
2293
|
+
* @param perpMarketIndex - Perp market to rename.
|
|
2294
|
+
* @param name - New display name, UTF-8 encoded and padded/truncated to 32 bytes.
|
|
2295
|
+
* @returns Transaction signature.
|
|
2296
|
+
*/
|
|
1707
2297
|
public async updatePerpMarketName(
|
|
1708
2298
|
perpMarketIndex: number,
|
|
1709
2299
|
name: string
|
|
@@ -1720,6 +2310,10 @@ export class AdminClient extends VelocityClient {
|
|
|
1720
2310
|
return txSig;
|
|
1721
2311
|
}
|
|
1722
2312
|
|
|
2313
|
+
/**
|
|
2314
|
+
* Builds the `updatePerpMarketName` instruction without sending it. See `updatePerpMarketName`.
|
|
2315
|
+
* @returns The unsigned `updatePerpMarketName` instruction.
|
|
2316
|
+
*/
|
|
1723
2317
|
public async getUpdatePerpMarketNameIx(
|
|
1724
2318
|
perpMarketIndex: number,
|
|
1725
2319
|
name: string
|
|
@@ -1739,6 +2333,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1739
2333
|
});
|
|
1740
2334
|
}
|
|
1741
2335
|
|
|
2336
|
+
/**
|
|
2337
|
+
* Sets a spot market's display name. Requires warm admin (`check_warm`).
|
|
2338
|
+
* @param spotMarketIndex - Spot market to rename.
|
|
2339
|
+
* @param name - New display name, UTF-8 encoded and padded/truncated to 32 bytes.
|
|
2340
|
+
* @returns Transaction signature.
|
|
2341
|
+
*/
|
|
1742
2342
|
public async updateSpotMarketName(
|
|
1743
2343
|
spotMarketIndex: number,
|
|
1744
2344
|
name: string
|
|
@@ -1755,6 +2355,10 @@ export class AdminClient extends VelocityClient {
|
|
|
1755
2355
|
return txSig;
|
|
1756
2356
|
}
|
|
1757
2357
|
|
|
2358
|
+
/**
|
|
2359
|
+
* Builds the `updateSpotMarketName` instruction without sending it. See `updateSpotMarketName`.
|
|
2360
|
+
* @returns The unsigned `updateSpotMarketName` instruction.
|
|
2361
|
+
*/
|
|
1758
2362
|
public async getUpdateSpotMarketNameIx(
|
|
1759
2363
|
spotMarketIndex: number,
|
|
1760
2364
|
name: string
|
|
@@ -1774,6 +2378,13 @@ export class AdminClient extends VelocityClient {
|
|
|
1774
2378
|
});
|
|
1775
2379
|
}
|
|
1776
2380
|
|
|
2381
|
+
/**
|
|
2382
|
+
* Sets which pool a spot market belongs to (used to segment markets, e.g. for LP-pool
|
|
2383
|
+
* constituent grouping). Requires warm admin (`check_warm`).
|
|
2384
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2385
|
+
* @param poolId - Target pool id.
|
|
2386
|
+
* @returns Transaction signature.
|
|
2387
|
+
*/
|
|
1777
2388
|
public async updateSpotMarketPoolId(
|
|
1778
2389
|
spotMarketIndex: number,
|
|
1779
2390
|
poolId: number
|
|
@@ -1790,6 +2401,10 @@ export class AdminClient extends VelocityClient {
|
|
|
1790
2401
|
return txSig;
|
|
1791
2402
|
}
|
|
1792
2403
|
|
|
2404
|
+
/**
|
|
2405
|
+
* Builds the `updateSpotMarketPoolId` instruction without sending it. See `updateSpotMarketPoolId`.
|
|
2406
|
+
* @returns The unsigned `updateSpotMarketPoolId` instruction.
|
|
2407
|
+
*/
|
|
1793
2408
|
public async getUpdateSpotMarketPoolIdIx(
|
|
1794
2409
|
spotMarketIndex: number,
|
|
1795
2410
|
poolId: number
|
|
@@ -1808,6 +2423,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1808
2423
|
});
|
|
1809
2424
|
}
|
|
1810
2425
|
|
|
2426
|
+
/**
|
|
2427
|
+
* Sets a perp market's maximum allowed total bid/ask spread. Gated the same as
|
|
2428
|
+
* `updatePerpMarketCurveUpdateIntensity` (warm admin via `HotAdminUpdatePerpMarket`'s
|
|
2429
|
+
* `check_warm` constraint). Throws `DefaultError` on-chain if `maxSpread` is below the
|
|
2430
|
+
* market's current `baseSpread` or exceeds `marginRatioInitial * 100`.
|
|
2431
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2432
|
+
* @param maxSpread - New max spread, BID_ASK_SPREAD_PRECISION (1e6). Must be >= `baseSpread` and <= `marginRatioInitial * 100`.
|
|
2433
|
+
* @returns Transaction signature.
|
|
2434
|
+
*/
|
|
1811
2435
|
public async updatePerpMarketMaxSpread(
|
|
1812
2436
|
perpMarketIndex: number,
|
|
1813
2437
|
maxSpread: number
|
|
@@ -1822,6 +2446,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1822
2446
|
return txSig;
|
|
1823
2447
|
}
|
|
1824
2448
|
|
|
2449
|
+
/**
|
|
2450
|
+
* Builds the `updatePerpMarketMaxSpread` instruction without sending it. See
|
|
2451
|
+
* `updatePerpMarketMaxSpread` for units and validation.
|
|
2452
|
+
* @returns The unsigned `updatePerpMarketMaxSpread` instruction.
|
|
2453
|
+
*/
|
|
1825
2454
|
public async getUpdatePerpMarketMaxSpreadIx(
|
|
1826
2455
|
perpMarketIndex: number,
|
|
1827
2456
|
maxSpread: number
|
|
@@ -1842,6 +2471,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1842
2471
|
});
|
|
1843
2472
|
}
|
|
1844
2473
|
|
|
2474
|
+
/**
|
|
2475
|
+
* Replaces the protocol-wide perp `FeeStructure` (fee tiers, filler reward, AMM/IF
|
|
2476
|
+
* fee split) wholesale. Requires warm admin (`check_warm`). On-chain,
|
|
2477
|
+
* `validate_fee_structure` rejects a structure whose `amm_fee_numerator +
|
|
2478
|
+
* if_fee_numerator` (both FEE_PERCENTAGE_DENOMINATOR-scaled) exceeds 100% of the
|
|
2479
|
+
* trade-fee remainder, among other tier sanity checks.
|
|
2480
|
+
* @param feeStructure - Full replacement fee structure (not a partial patch).
|
|
2481
|
+
* @returns Transaction signature.
|
|
2482
|
+
*/
|
|
1845
2483
|
public async updatePerpFeeStructure(
|
|
1846
2484
|
feeStructure: FeeStructure
|
|
1847
2485
|
): Promise<TransactionSignature> {
|
|
@@ -1856,6 +2494,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1856
2494
|
return txSig;
|
|
1857
2495
|
}
|
|
1858
2496
|
|
|
2497
|
+
/**
|
|
2498
|
+
* Builds the `updatePerpFeeStructure` instruction without sending it. See
|
|
2499
|
+
* `updatePerpFeeStructure`.
|
|
2500
|
+
* @returns The unsigned `updatePerpFeeStructure` instruction.
|
|
2501
|
+
*/
|
|
1859
2502
|
public async getUpdatePerpFeeStructureIx(
|
|
1860
2503
|
feeStructure: FeeStructure
|
|
1861
2504
|
): Promise<TransactionInstruction> {
|
|
@@ -1869,6 +2512,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1869
2512
|
});
|
|
1870
2513
|
}
|
|
1871
2514
|
|
|
2515
|
+
/**
|
|
2516
|
+
* Replaces the protocol-wide spot `FeeStructure` wholesale. Requires warm admin
|
|
2517
|
+
* (`check_warm`); see `updatePerpFeeStructure` for validation.
|
|
2518
|
+
* @param feeStructure - Full replacement fee structure (not a partial patch).
|
|
2519
|
+
* @returns Transaction signature.
|
|
2520
|
+
*/
|
|
1872
2521
|
public async updateSpotFeeStructure(
|
|
1873
2522
|
feeStructure: FeeStructure
|
|
1874
2523
|
): Promise<TransactionSignature> {
|
|
@@ -1883,6 +2532,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1883
2532
|
return txSig;
|
|
1884
2533
|
}
|
|
1885
2534
|
|
|
2535
|
+
/**
|
|
2536
|
+
* Builds the `updateSpotFeeStructure` instruction without sending it. See
|
|
2537
|
+
* `updateSpotFeeStructure`.
|
|
2538
|
+
* @returns The unsigned `updateSpotFeeStructure` instruction.
|
|
2539
|
+
*/
|
|
1886
2540
|
public async getUpdateSpotFeeStructureIx(
|
|
1887
2541
|
feeStructure: FeeStructure
|
|
1888
2542
|
): Promise<TransactionInstruction> {
|
|
@@ -1896,6 +2550,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1896
2550
|
});
|
|
1897
2551
|
}
|
|
1898
2552
|
|
|
2553
|
+
/**
|
|
2554
|
+
* Sets the fraction of a liquidatable position that may be closed immediately
|
|
2555
|
+
* (before the `updateLiquidationDuration` ramp phases in the rest). Requires warm
|
|
2556
|
+
* admin (`check_warm`). On-chain the liquidatable fraction ramps linearly from this
|
|
2557
|
+
* floor up to 100% over `liquidationDuration` slots since the user's last active
|
|
2558
|
+
* slot (see `calculate_max_pct_to_liquidate`); shortages under 50 QUOTE_PRECISION
|
|
2559
|
+
* always liquidate in full regardless of this setting.
|
|
2560
|
+
* @param initialPctToLiquidate - Initial liquidatable fraction, LIQUIDATION_PCT_PRECISION (1e4, e.g. 2500 = 25%).
|
|
2561
|
+
* @returns Transaction signature.
|
|
2562
|
+
*/
|
|
1899
2563
|
public async updateInitialPctToLiquidate(
|
|
1900
2564
|
initialPctToLiquidate: number
|
|
1901
2565
|
): Promise<TransactionSignature> {
|
|
@@ -1909,6 +2573,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1909
2573
|
return txSig;
|
|
1910
2574
|
}
|
|
1911
2575
|
|
|
2576
|
+
/**
|
|
2577
|
+
* Builds the `updateInitialPctToLiquidate` instruction without sending it. See
|
|
2578
|
+
* `updateInitialPctToLiquidate`.
|
|
2579
|
+
* @returns The unsigned `updateInitialPctToLiquidate` instruction.
|
|
2580
|
+
*/
|
|
1912
2581
|
public async getUpdateInitialPctToLiquidateIx(
|
|
1913
2582
|
initialPctToLiquidate: number
|
|
1914
2583
|
): Promise<TransactionInstruction> {
|
|
@@ -1925,6 +2594,13 @@ export class AdminClient extends VelocityClient {
|
|
|
1925
2594
|
);
|
|
1926
2595
|
}
|
|
1927
2596
|
|
|
2597
|
+
/**
|
|
2598
|
+
* Sets how many slots it takes for a liquidation's max-closeable fraction to ramp
|
|
2599
|
+
* from `initialPctToLiquidate` up to 100% (see `updateInitialPctToLiquidate`).
|
|
2600
|
+
* Requires warm admin (`check_warm`).
|
|
2601
|
+
* @param liquidationDuration - Ramp duration, slots (comment in `calculate_max_pct_to_liquidate` notes ~150 slots ≈ 1 minute at 400ms/slot).
|
|
2602
|
+
* @returns Transaction signature.
|
|
2603
|
+
*/
|
|
1928
2604
|
public async updateLiquidationDuration(
|
|
1929
2605
|
liquidationDuration: number
|
|
1930
2606
|
): Promise<TransactionSignature> {
|
|
@@ -1938,6 +2614,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1938
2614
|
return txSig;
|
|
1939
2615
|
}
|
|
1940
2616
|
|
|
2617
|
+
/**
|
|
2618
|
+
* Builds the `updateLiquidationDuration` instruction without sending it. See
|
|
2619
|
+
* `updateLiquidationDuration`.
|
|
2620
|
+
* @returns The unsigned `updateLiquidationDuration` instruction.
|
|
2621
|
+
*/
|
|
1941
2622
|
public async getUpdateLiquidationDurationIx(
|
|
1942
2623
|
liquidationDuration: number
|
|
1943
2624
|
): Promise<TransactionInstruction> {
|
|
@@ -1954,6 +2635,14 @@ export class AdminClient extends VelocityClient {
|
|
|
1954
2635
|
);
|
|
1955
2636
|
}
|
|
1956
2637
|
|
|
2638
|
+
/**
|
|
2639
|
+
* Sets the extra maintenance-margin buffer applied when deciding whether a user is
|
|
2640
|
+
* liquidatable, on top of the market's own maintenance margin ratio — a safety
|
|
2641
|
+
* margin so liquidation triggers before a user is fully underwater. Requires warm
|
|
2642
|
+
* admin (`check_warm`).
|
|
2643
|
+
* @param updateLiquidationMarginBufferRatio - Extra margin buffer, MARGIN_PRECISION (1e4).
|
|
2644
|
+
* @returns Transaction signature.
|
|
2645
|
+
*/
|
|
1957
2646
|
public async updateLiquidationMarginBufferRatio(
|
|
1958
2647
|
updateLiquidationMarginBufferRatio: number
|
|
1959
2648
|
): Promise<TransactionSignature> {
|
|
@@ -1971,6 +2660,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1971
2660
|
return txSig;
|
|
1972
2661
|
}
|
|
1973
2662
|
|
|
2663
|
+
/**
|
|
2664
|
+
* Builds the `updateLiquidationMarginBufferRatio` instruction without sending it.
|
|
2665
|
+
* See `updateLiquidationMarginBufferRatio`.
|
|
2666
|
+
* @returns The unsigned `updateLiquidationMarginBufferRatio` instruction.
|
|
2667
|
+
*/
|
|
1974
2668
|
public async getUpdateLiquidationMarginBufferRatioIx(
|
|
1975
2669
|
updateLiquidationMarginBufferRatio: number
|
|
1976
2670
|
): Promise<TransactionInstruction> {
|
|
@@ -1987,6 +2681,13 @@ export class AdminClient extends VelocityClient {
|
|
|
1987
2681
|
);
|
|
1988
2682
|
}
|
|
1989
2683
|
|
|
2684
|
+
/**
|
|
2685
|
+
* Replaces the protocol-wide `OracleGuardRails` (validity/confidence/divergence
|
|
2686
|
+
* thresholds used to gate oracle-price-driven actions across every market).
|
|
2687
|
+
* Requires warm admin (`check_warm`).
|
|
2688
|
+
* @param oracleGuardRails - Full replacement guard-rail config (not a partial patch).
|
|
2689
|
+
* @returns Transaction signature.
|
|
2690
|
+
*/
|
|
1990
2691
|
public async updateOracleGuardRails(
|
|
1991
2692
|
oracleGuardRails: OracleGuardRails
|
|
1992
2693
|
): Promise<TransactionSignature> {
|
|
@@ -2001,6 +2702,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2001
2702
|
return txSig;
|
|
2002
2703
|
}
|
|
2003
2704
|
|
|
2705
|
+
/**
|
|
2706
|
+
* Builds the `updateOracleGuardRails` instruction without sending it. See
|
|
2707
|
+
* `updateOracleGuardRails`.
|
|
2708
|
+
* @returns The unsigned `updateOracleGuardRails` instruction.
|
|
2709
|
+
*/
|
|
2004
2710
|
public async getUpdateOracleGuardRailsIx(
|
|
2005
2711
|
oracleGuardRails: OracleGuardRails
|
|
2006
2712
|
): Promise<TransactionInstruction> {
|
|
@@ -2017,6 +2723,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2017
2723
|
);
|
|
2018
2724
|
}
|
|
2019
2725
|
|
|
2726
|
+
/**
|
|
2727
|
+
* Sets the buffer (past a perp market's `expiry_ts`) that must elapse before user
|
|
2728
|
+
* positions in a `Settlement`-status market can be settled at the expiry price.
|
|
2729
|
+
* Requires warm admin (`check_warm`).
|
|
2730
|
+
* @param settlementDuration - Post-expiry settlement buffer, seconds.
|
|
2731
|
+
* @returns Transaction signature.
|
|
2732
|
+
*/
|
|
2020
2733
|
public async updateStateSettlementDuration(
|
|
2021
2734
|
settlementDuration: number
|
|
2022
2735
|
): Promise<TransactionSignature> {
|
|
@@ -2030,6 +2743,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2030
2743
|
return txSig;
|
|
2031
2744
|
}
|
|
2032
2745
|
|
|
2746
|
+
/**
|
|
2747
|
+
* Builds the `updateStateSettlementDuration` instruction without sending it. See
|
|
2748
|
+
* `updateStateSettlementDuration`.
|
|
2749
|
+
* @returns The unsigned `updateStateSettlementDuration` instruction.
|
|
2750
|
+
*/
|
|
2033
2751
|
public async getUpdateStateSettlementDurationIx(
|
|
2034
2752
|
settlementDuration: number
|
|
2035
2753
|
): Promise<TransactionInstruction> {
|
|
@@ -2046,6 +2764,15 @@ export class AdminClient extends VelocityClient {
|
|
|
2046
2764
|
);
|
|
2047
2765
|
}
|
|
2048
2766
|
|
|
2767
|
+
/**
|
|
2768
|
+
* Sets the protocol-wide cap on sub-accounts per authority
|
|
2769
|
+
* (`state.maxNumberOfSubAccounts`) and, via `get_init_user_fee`, the denominator
|
|
2770
|
+
* against which `state.numberOfSubAccounts` utilization phases in the
|
|
2771
|
+
* `initializeUser` anti-spam fee (see `updateStateMaxInitializeUserFee`). Requires
|
|
2772
|
+
* warm admin (`check_warm`).
|
|
2773
|
+
* @param maxNumberOfSubAccounts - New protocol-wide sub-account cap.
|
|
2774
|
+
* @returns Transaction signature.
|
|
2775
|
+
*/
|
|
2049
2776
|
public async updateStateMaxNumberOfSubAccounts(
|
|
2050
2777
|
maxNumberOfSubAccounts: number
|
|
2051
2778
|
): Promise<TransactionSignature> {
|
|
@@ -2059,6 +2786,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2059
2786
|
return txSig;
|
|
2060
2787
|
}
|
|
2061
2788
|
|
|
2789
|
+
/**
|
|
2790
|
+
* Builds the `updateStateMaxNumberOfSubAccounts` instruction without sending it.
|
|
2791
|
+
* See `updateStateMaxNumberOfSubAccounts`.
|
|
2792
|
+
* @returns The unsigned `updateStateMaxNumberOfSubAccounts` instruction.
|
|
2793
|
+
*/
|
|
2062
2794
|
public async getUpdateStateMaxNumberOfSubAccountsIx(
|
|
2063
2795
|
maxNumberOfSubAccounts: number
|
|
2064
2796
|
): Promise<TransactionInstruction> {
|
|
@@ -2075,6 +2807,15 @@ export class AdminClient extends VelocityClient {
|
|
|
2075
2807
|
);
|
|
2076
2808
|
}
|
|
2077
2809
|
|
|
2810
|
+
/**
|
|
2811
|
+
* Sets the cap on the anti-spam fee `initializeUser` may charge as
|
|
2812
|
+
* `state.numberOfSubAccounts` approaches `state.maxNumberOfSubAccounts`. On-chain
|
|
2813
|
+
* (`State::get_init_user_fee`) the fee is 0 below ~80% utilization and then scales
|
|
2814
|
+
* up to this cap by the time the cap is reached; `0` disables the fee entirely.
|
|
2815
|
+
* Requires warm admin (`check_warm`).
|
|
2816
|
+
* @param maxInitializeUserFee - Fee cap, hundredths of a SOL (e.g. `100` = 1 SOL, `1` = 0.01 SOL).
|
|
2817
|
+
* @returns Transaction signature.
|
|
2818
|
+
*/
|
|
2078
2819
|
public async updateStateMaxInitializeUserFee(
|
|
2079
2820
|
maxInitializeUserFee: number
|
|
2080
2821
|
): Promise<TransactionSignature> {
|
|
@@ -2088,6 +2829,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2088
2829
|
return txSig;
|
|
2089
2830
|
}
|
|
2090
2831
|
|
|
2832
|
+
/**
|
|
2833
|
+
* Builds the `updateStateMaxInitializeUserFee` instruction without sending it. See
|
|
2834
|
+
* `updateStateMaxInitializeUserFee`.
|
|
2835
|
+
* @returns The unsigned `updateStateMaxInitializeUserFee` instruction.
|
|
2836
|
+
*/
|
|
2091
2837
|
public async getUpdateStateMaxInitializeUserFeeIx(
|
|
2092
2838
|
maxInitializeUserFee: number
|
|
2093
2839
|
): Promise<TransactionInstruction> {
|
|
@@ -2104,6 +2850,23 @@ export class AdminClient extends VelocityClient {
|
|
|
2104
2850
|
);
|
|
2105
2851
|
}
|
|
2106
2852
|
|
|
2853
|
+
/**
|
|
2854
|
+
* Sets a spot market's withdraw guard threshold — the token-amount cap above which a
|
|
2855
|
+
* single withdraw/borrow is blocked. Requires warm admin (`check_warm`, on the
|
|
2856
|
+
* `AdminUpdateSpotMarketWithdrawGuardThreshold` context). On-chain the notional is priced
|
|
2857
|
+
* with the max of the live oracle price and the 5-minute oracle TWAP (`StrictOraclePrice`),
|
|
2858
|
+
* so a momentarily-manipulated-down oracle can't let an oversized threshold through;
|
|
2859
|
+
* `validate_withdraw_guard_threshold` then re-derives the implied cap and rejects an
|
|
2860
|
+
* inconsistent value.
|
|
2861
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2862
|
+
* @param withdrawGuardThreshold - New threshold, the market's native token decimals.
|
|
2863
|
+
* @param oracle - Must equal `spotMarket.oracle` — the account struct's `has_one = oracle`
|
|
2864
|
+
* constraint (`ErrorCode::InvalidOracle`) enforces this on-chain, so it is not a way to
|
|
2865
|
+
* point at a different price feed. When omitted, this is resolved automatically from the
|
|
2866
|
+
* local account cache (or, if not subscribed, by fetching and decoding the `SpotMarket`
|
|
2867
|
+
* account directly) — pass it explicitly only to avoid that extra lookup.
|
|
2868
|
+
* @returns Transaction signature.
|
|
2869
|
+
*/
|
|
2107
2870
|
public async updateWithdrawGuardThreshold(
|
|
2108
2871
|
spotMarketIndex: number,
|
|
2109
2872
|
withdrawGuardThreshold: BN,
|
|
@@ -2123,6 +2886,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2123
2886
|
return txSig;
|
|
2124
2887
|
}
|
|
2125
2888
|
|
|
2889
|
+
/**
|
|
2890
|
+
* Builds the `updateWithdrawGuardThreshold` instruction without sending it. See
|
|
2891
|
+
* `updateWithdrawGuardThreshold` — in particular, the `oracle` param must equal
|
|
2892
|
+
* `spotMarket.oracle` (enforced by the `has_one` constraint) and is auto-resolved when
|
|
2893
|
+
* omitted. Throws if the spot market account can't be found when not subscribed.
|
|
2894
|
+
* @returns The unsigned `updateWithdrawGuardThreshold` instruction.
|
|
2895
|
+
*/
|
|
2126
2896
|
public async getUpdateWithdrawGuardThresholdIx(
|
|
2127
2897
|
spotMarketIndex: number,
|
|
2128
2898
|
withdrawGuardThreshold: BN,
|
|
@@ -2173,6 +2943,18 @@ export class AdminClient extends VelocityClient {
|
|
|
2173
2943
|
);
|
|
2174
2944
|
}
|
|
2175
2945
|
|
|
2946
|
+
/**
|
|
2947
|
+
* Sets a spot market's lending-gain carveouts: the share of deposit interest routed to the
|
|
2948
|
+
* insurance fund (`ifFeeFactor`) and to the withdrawable protocol fee pool
|
|
2949
|
+
* (`protocolFeeFactor`); lenders keep the remainder. Requires warm admin (`check_warm`).
|
|
2950
|
+
* Throws `DefaultError` on-chain if the two factors don't sum to strictly less than 100%
|
|
2951
|
+
* (a full 100% carveout would zero out lender interest and freeze the entire accrual path,
|
|
2952
|
+
* including the IF/protocol credits themselves).
|
|
2953
|
+
* @param spotMarketIndex - Spot market to update; must match the market account passed.
|
|
2954
|
+
* @param ifFeeFactor - Insurance-fund carveout, IF_FACTOR_PRECISION (1e6).
|
|
2955
|
+
* @param protocolFeeFactor - Protocol-fee-pool carveout, IF_FACTOR_PRECISION (1e6). `ifFeeFactor + protocolFeeFactor` must be < 1e6.
|
|
2956
|
+
* @returns Transaction signature.
|
|
2957
|
+
*/
|
|
2176
2958
|
public async updateSpotMarketIfFactor(
|
|
2177
2959
|
spotMarketIndex: number,
|
|
2178
2960
|
ifFeeFactor: number,
|
|
@@ -2191,6 +2973,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2191
2973
|
return txSig;
|
|
2192
2974
|
}
|
|
2193
2975
|
|
|
2976
|
+
/**
|
|
2977
|
+
* Builds the `updateSpotMarketIfFactor` instruction without sending it. See
|
|
2978
|
+
* `updateSpotMarketIfFactor` for units and validation.
|
|
2979
|
+
* @returns The unsigned `updateSpotMarketIfFactor` instruction.
|
|
2980
|
+
*/
|
|
2194
2981
|
public async getUpdateSpotMarketIfFactorIx(
|
|
2195
2982
|
spotMarketIndex: number,
|
|
2196
2983
|
ifFeeFactor: number,
|
|
@@ -2215,6 +3002,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2215
3002
|
);
|
|
2216
3003
|
}
|
|
2217
3004
|
|
|
3005
|
+
/**
|
|
3006
|
+
* Sets how often a spot market's revenue pool may be settled to the insurance fund.
|
|
3007
|
+
* Requires warm admin (`check_warm`).
|
|
3008
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3009
|
+
* @param revenueSettlePeriod - Minimum interval between revenue settlements, seconds.
|
|
3010
|
+
* @returns Transaction signature.
|
|
3011
|
+
*/
|
|
2218
3012
|
public async updateSpotMarketRevenueSettlePeriod(
|
|
2219
3013
|
spotMarketIndex: number,
|
|
2220
3014
|
revenueSettlePeriod: BN
|
|
@@ -2234,6 +3028,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2234
3028
|
return txSig;
|
|
2235
3029
|
}
|
|
2236
3030
|
|
|
3031
|
+
/**
|
|
3032
|
+
* Builds the `updateSpotMarketRevenueSettlePeriod` instruction without sending it. See
|
|
3033
|
+
* `updateSpotMarketRevenueSettlePeriod`.
|
|
3034
|
+
* @returns The unsigned `updateSpotMarketRevenueSettlePeriod` instruction.
|
|
3035
|
+
*/
|
|
2237
3036
|
public async getUpdateSpotMarketRevenueSettlePeriodIx(
|
|
2238
3037
|
spotMarketIndex: number,
|
|
2239
3038
|
revenueSettlePeriod: BN
|
|
@@ -2255,6 +3054,12 @@ export class AdminClient extends VelocityClient {
|
|
|
2255
3054
|
);
|
|
2256
3055
|
}
|
|
2257
3056
|
|
|
3057
|
+
/**
|
|
3058
|
+
* Sets a spot market's maximum total deposit balance. Requires warm admin (`check_warm`).
|
|
3059
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3060
|
+
* @param maxTokenDeposits - New deposit cap, the market's native token decimals. `0` disables the cap.
|
|
3061
|
+
* @returns Transaction signature.
|
|
3062
|
+
*/
|
|
2258
3063
|
public async updateSpotMarketMaxTokenDeposits(
|
|
2259
3064
|
spotMarketIndex: number,
|
|
2260
3065
|
maxTokenDeposits: BN
|
|
@@ -2272,6 +3077,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2272
3077
|
return txSig;
|
|
2273
3078
|
}
|
|
2274
3079
|
|
|
3080
|
+
/**
|
|
3081
|
+
* Builds the `updateSpotMarketMaxTokenDeposits` instruction without sending it. See
|
|
3082
|
+
* `updateSpotMarketMaxTokenDeposits`.
|
|
3083
|
+
* @returns The unsigned `updateSpotMarketMaxTokenDeposits` instruction.
|
|
3084
|
+
*/
|
|
2275
3085
|
public async getUpdateSpotMarketMaxTokenDepositsIx(
|
|
2276
3086
|
spotMarketIndex: number,
|
|
2277
3087
|
maxTokenDeposits: BN
|
|
@@ -2293,6 +3103,15 @@ export class AdminClient extends VelocityClient {
|
|
|
2293
3103
|
);
|
|
2294
3104
|
}
|
|
2295
3105
|
|
|
3106
|
+
/**
|
|
3107
|
+
* Caps a spot market's total borrows as a fraction of its `maxTokenDeposits`, rather than
|
|
3108
|
+
* an absolute token amount. Requires warm admin (`check_warm`). On-chain, the effective cap
|
|
3109
|
+
* is `maxTokenDeposits * maxTokenBorrowsFraction / 10000`; the handler throws
|
|
3110
|
+
* `InvalidSpotMarketInitialization` if current borrows already exceed the new cap.
|
|
3111
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3112
|
+
* @param maxTokenBorrowsFraction - Fraction of `maxTokenDeposits` borrowable, in hundredths of a percent (10000 = 100%).
|
|
3113
|
+
* @returns Transaction signature.
|
|
3114
|
+
*/
|
|
2296
3115
|
public async updateSpotMarketMaxTokenBorrows(
|
|
2297
3116
|
spotMarketIndex: number,
|
|
2298
3117
|
maxTokenBorrowsFraction: number
|
|
@@ -2310,6 +3129,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2310
3129
|
return txSig;
|
|
2311
3130
|
}
|
|
2312
3131
|
|
|
3132
|
+
/**
|
|
3133
|
+
* Builds the `updateSpotMarketMaxTokenBorrows` instruction without sending it. See
|
|
3134
|
+
* `updateSpotMarketMaxTokenBorrows`.
|
|
3135
|
+
* @returns The unsigned `updateSpotMarketMaxTokenBorrows` instruction.
|
|
3136
|
+
*/
|
|
2313
3137
|
public async getUpdateSpotMarketMaxTokenBorrowsIx(
|
|
2314
3138
|
spotMarketIndex: number,
|
|
2315
3139
|
maxTokenBorrowsFraction: number
|
|
@@ -2331,6 +3155,14 @@ export class AdminClient extends VelocityClient {
|
|
|
2331
3155
|
);
|
|
2332
3156
|
}
|
|
2333
3157
|
|
|
3158
|
+
/**
|
|
3159
|
+
* Sets the deposit-notional threshold above which a spot market's `initialAssetWeight`
|
|
3160
|
+
* scales down (see `initializeSpotMarket`'s `scaleInitialAssetWeightStart`). Requires warm
|
|
3161
|
+
* admin (`check_warm`). `0` disables scaling.
|
|
3162
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3163
|
+
* @param scaleInitialAssetWeightStart - Deposit-notional threshold, QUOTE_PRECISION (1e6). `0` disables scaling.
|
|
3164
|
+
* @returns Transaction signature.
|
|
3165
|
+
*/
|
|
2334
3166
|
public async updateSpotMarketScaleInitialAssetWeightStart(
|
|
2335
3167
|
spotMarketIndex: number,
|
|
2336
3168
|
scaleInitialAssetWeightStart: BN
|
|
@@ -2350,6 +3182,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2350
3182
|
return txSig;
|
|
2351
3183
|
}
|
|
2352
3184
|
|
|
3185
|
+
/**
|
|
3186
|
+
* Builds the `updateSpotMarketScaleInitialAssetWeightStart` instruction without sending it.
|
|
3187
|
+
* See `updateSpotMarketScaleInitialAssetWeightStart`.
|
|
3188
|
+
* @returns The unsigned `updateSpotMarketScaleInitialAssetWeightStart` instruction.
|
|
3189
|
+
*/
|
|
2353
3190
|
public async getUpdateSpotMarketScaleInitialAssetWeightStartIx(
|
|
2354
3191
|
spotMarketIndex: number,
|
|
2355
3192
|
scaleInitialAssetWeightStart: BN
|
|
@@ -2371,6 +3208,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2371
3208
|
);
|
|
2372
3209
|
}
|
|
2373
3210
|
|
|
3211
|
+
/**
|
|
3212
|
+
* Sets how long an insurance-fund staker's unstake request must sit in escrow before it can
|
|
3213
|
+
* be completed for a given spot market. Requires warm admin (`check_warm`).
|
|
3214
|
+
* @param spotMarketIndex - Spot market whose insurance fund to update.
|
|
3215
|
+
* @param insuranceWithdrawEscrowPeriod - Unstaking escrow duration, seconds.
|
|
3216
|
+
* @returns Transaction signature.
|
|
3217
|
+
*/
|
|
2374
3218
|
public async updateInsuranceFundUnstakingPeriod(
|
|
2375
3219
|
spotMarketIndex: number,
|
|
2376
3220
|
insuranceWithdrawEscrowPeriod: BN
|
|
@@ -2390,6 +3234,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2390
3234
|
return txSig;
|
|
2391
3235
|
}
|
|
2392
3236
|
|
|
3237
|
+
/**
|
|
3238
|
+
* Builds the `updateInsuranceFundUnstakingPeriod` instruction without sending it. See
|
|
3239
|
+
* `updateInsuranceFundUnstakingPeriod`.
|
|
3240
|
+
* @returns The unsigned `updateInsuranceFundUnstakingPeriod` instruction.
|
|
3241
|
+
*/
|
|
2393
3242
|
public async getUpdateInsuranceFundUnstakingPeriodIx(
|
|
2394
3243
|
spotMarketIndex: number,
|
|
2395
3244
|
insuranceWithdrawEscrowPeriod: BN
|
|
@@ -2411,6 +3260,20 @@ export class AdminClient extends VelocityClient {
|
|
|
2411
3260
|
);
|
|
2412
3261
|
}
|
|
2413
3262
|
|
|
3263
|
+
/**
|
|
3264
|
+
* Swaps a perp market's oracle account/source. Requires **cold** admin
|
|
3265
|
+
* (`AdminUpdatePerpMarketOracle`'s `check_cold` constraint) — a lesser admin swapping the
|
|
3266
|
+
* oracle could re-price margin/liquidation math and any `AmmCache`-derived value at will.
|
|
3267
|
+
* On-chain the handler reads both the new and current (`oldOracle`) oracle prices and,
|
|
3268
|
+
* unless `skipInvaraintCheck` is `true`, throws `DefaultError` if the new price is
|
|
3269
|
+
* non-positive or diverges more than 10% from the old one. If the market is present in the
|
|
3270
|
+
* `AmmCache`, its cached fields are refreshed from the new oracle in the same instruction.
|
|
3271
|
+
* @param perpMarketIndex - Perp market to update.
|
|
3272
|
+
* @param oracle - New oracle account.
|
|
3273
|
+
* @param oracleSource - Oracle provider/format for `oracle`.
|
|
3274
|
+
* @param skipInvaraintCheck - If `true`, skips the on-chain non-positive/10%-divergence sanity check against the current oracle price. Default `false`.
|
|
3275
|
+
* @returns Transaction signature.
|
|
3276
|
+
*/
|
|
2414
3277
|
public async updatePerpMarketOracle(
|
|
2415
3278
|
perpMarketIndex: number,
|
|
2416
3279
|
oracle: PublicKey,
|
|
@@ -2431,6 +3294,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2431
3294
|
return txSig;
|
|
2432
3295
|
}
|
|
2433
3296
|
|
|
3297
|
+
/**
|
|
3298
|
+
* Builds the `updatePerpMarketOracle` instruction without sending it. See
|
|
3299
|
+
* `updatePerpMarketOracle`. Resolves `oldOracle` from the locally-cached perp market account
|
|
3300
|
+
* (throws if `perpMarketIndex` isn't tracked by the account subscriber) and passes the
|
|
3301
|
+
* program's singleton `AmmCache` PDA.
|
|
3302
|
+
* @returns The unsigned `updatePerpMarketOracle` instruction.
|
|
3303
|
+
*/
|
|
2434
3304
|
public async getUpdatePerpMarketOracleIx(
|
|
2435
3305
|
perpMarketIndex: number,
|
|
2436
3306
|
oracle: PublicKey,
|
|
@@ -2460,6 +3330,16 @@ export class AdminClient extends VelocityClient {
|
|
|
2460
3330
|
);
|
|
2461
3331
|
}
|
|
2462
3332
|
|
|
3333
|
+
/**
|
|
3334
|
+
* Sets a perp market's minimum base-size increment and minimum price increment for orders.
|
|
3335
|
+
* Requires warm admin (`check_warm`). On-chain, throws `DefaultError` unless both are > 0
|
|
3336
|
+
* and `stepSize <= 2_000_000_000` (kept below `i32::MAX` for the LP's remainder-base-asset
|
|
3337
|
+
* accounting).
|
|
3338
|
+
* @param perpMarketIndex - Perp market to update.
|
|
3339
|
+
* @param stepSize - Minimum base-size increment, BASE_PRECISION (1e9).
|
|
3340
|
+
* @param tickSize - Minimum price increment, PRICE_PRECISION (1e6).
|
|
3341
|
+
* @returns Transaction signature.
|
|
3342
|
+
*/
|
|
2463
3343
|
public async updatePerpMarketStepSizeAndTickSize(
|
|
2464
3344
|
perpMarketIndex: number,
|
|
2465
3345
|
stepSize: BN,
|
|
@@ -2481,6 +3361,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2481
3361
|
return txSig;
|
|
2482
3362
|
}
|
|
2483
3363
|
|
|
3364
|
+
/**
|
|
3365
|
+
* Builds the `updatePerpMarketStepSizeAndTickSize` instruction without sending it. See
|
|
3366
|
+
* `updatePerpMarketStepSizeAndTickSize`.
|
|
3367
|
+
* @returns The unsigned `updatePerpMarketStepSizeAndTickSize` instruction.
|
|
3368
|
+
*/
|
|
2484
3369
|
public async getUpdatePerpMarketStepSizeAndTickSizeIx(
|
|
2485
3370
|
perpMarketIndex: number,
|
|
2486
3371
|
stepSize: BN,
|
|
@@ -2504,6 +3389,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2504
3389
|
);
|
|
2505
3390
|
}
|
|
2506
3391
|
|
|
3392
|
+
/**
|
|
3393
|
+
* Sets a perp market's minimum order base size (`market.marketStats.minOrderSize`). Requires
|
|
3394
|
+
* warm admin (`check_warm`). On-chain, throws `DefaultError` unless `orderSize > 0`.
|
|
3395
|
+
* @param perpMarketIndex - Perp market to update.
|
|
3396
|
+
* @param orderSize - Minimum base order size, BASE_PRECISION (1e9).
|
|
3397
|
+
* @returns Transaction signature.
|
|
3398
|
+
*/
|
|
2507
3399
|
public async updatePerpMarketMinOrderSize(
|
|
2508
3400
|
perpMarketIndex: number,
|
|
2509
3401
|
orderSize: BN
|
|
@@ -2518,6 +3410,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2518
3410
|
return txSig;
|
|
2519
3411
|
}
|
|
2520
3412
|
|
|
3413
|
+
/**
|
|
3414
|
+
* Builds the `updatePerpMarketMinOrderSize` instruction without sending it. See
|
|
3415
|
+
* `updatePerpMarketMinOrderSize`.
|
|
3416
|
+
* @returns The unsigned `updatePerpMarketMinOrderSize` instruction.
|
|
3417
|
+
*/
|
|
2521
3418
|
public async getUpdatePerpMarketMinOrderSizeIx(
|
|
2522
3419
|
perpMarketIndex: number,
|
|
2523
3420
|
orderSize: BN
|
|
@@ -2539,6 +3436,15 @@ export class AdminClient extends VelocityClient {
|
|
|
2539
3436
|
);
|
|
2540
3437
|
}
|
|
2541
3438
|
|
|
3439
|
+
/**
|
|
3440
|
+
* Sets a spot market's minimum base-size increment and minimum price increment for orders.
|
|
3441
|
+
* Requires warm admin (`check_warm`). On-chain, the quote/index-0 market (`marketIndex ===
|
|
3442
|
+
* 0`) is exempt from the `> 0` check other spot markets must satisfy.
|
|
3443
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3444
|
+
* @param stepSize - Minimum base-size increment, market's native token decimals.
|
|
3445
|
+
* @param tickSize - Minimum price increment, PRICE_PRECISION (1e6).
|
|
3446
|
+
* @returns Transaction signature.
|
|
3447
|
+
*/
|
|
2542
3448
|
public async updateSpotMarketStepSizeAndTickSize(
|
|
2543
3449
|
spotMarketIndex: number,
|
|
2544
3450
|
stepSize: BN,
|
|
@@ -2560,6 +3466,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2560
3466
|
return txSig;
|
|
2561
3467
|
}
|
|
2562
3468
|
|
|
3469
|
+
/**
|
|
3470
|
+
* Builds the `updateSpotMarketStepSizeAndTickSize` instruction without sending it. See
|
|
3471
|
+
* `updateSpotMarketStepSizeAndTickSize`.
|
|
3472
|
+
* @returns The unsigned `updateSpotMarketStepSizeAndTickSize` instruction.
|
|
3473
|
+
*/
|
|
2563
3474
|
public async getUpdateSpotMarketStepSizeAndTickSizeIx(
|
|
2564
3475
|
spotMarketIndex: number,
|
|
2565
3476
|
stepSize: BN,
|
|
@@ -2583,6 +3494,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2583
3494
|
);
|
|
2584
3495
|
}
|
|
2585
3496
|
|
|
3497
|
+
/**
|
|
3498
|
+
* Sets a spot market's minimum order base size. Requires warm admin (`check_warm`). On-chain,
|
|
3499
|
+
* the quote/index-0 market is exempt from the `> 0` check other spot markets must satisfy.
|
|
3500
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3501
|
+
* @param orderSize - Minimum base order size, market's native token decimals.
|
|
3502
|
+
* @returns Transaction signature.
|
|
3503
|
+
*/
|
|
2586
3504
|
public async updateSpotMarketMinOrderSize(
|
|
2587
3505
|
spotMarketIndex: number,
|
|
2588
3506
|
orderSize: BN
|
|
@@ -2608,6 +3526,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2608
3526
|
return txSig;
|
|
2609
3527
|
}
|
|
2610
3528
|
|
|
3529
|
+
/**
|
|
3530
|
+
* Builds the `updateSpotMarketMinOrderSize` instruction without sending it. See
|
|
3531
|
+
* `updateSpotMarketMinOrderSize`.
|
|
3532
|
+
* @returns The unsigned `updateSpotMarketMinOrderSize` instruction.
|
|
3533
|
+
*/
|
|
2611
3534
|
public async getUpdateSpotMarketMinOrderSizeIx(
|
|
2612
3535
|
spotMarketIndex: number,
|
|
2613
3536
|
orderSize: BN
|
|
@@ -2629,6 +3552,16 @@ export class AdminClient extends VelocityClient {
|
|
|
2629
3552
|
);
|
|
2630
3553
|
}
|
|
2631
3554
|
|
|
3555
|
+
/**
|
|
3556
|
+
* Schedules a perp market for expiry: sets `expiryTs` and immediately flips the market to
|
|
3557
|
+
* `MarketStatus.ReduceOnly` (existing positions can only be reduced from this point).
|
|
3558
|
+
* Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if `expiryTs` is not
|
|
3559
|
+
* strictly after the current on-chain clock timestamp. This does not settle or delist the
|
|
3560
|
+
* market — see `settleExpiredMarketPoolsToRevenuePool` for the later teardown step.
|
|
3561
|
+
* @param perpMarketIndex - Perp market to schedule for expiry.
|
|
3562
|
+
* @param expiryTs - Unix timestamp (seconds) after which the market is expired; must be in the future.
|
|
3563
|
+
* @returns Transaction signature.
|
|
3564
|
+
*/
|
|
2632
3565
|
public async updatePerpMarketExpiry(
|
|
2633
3566
|
perpMarketIndex: number,
|
|
2634
3567
|
expiryTs: BN
|
|
@@ -2644,6 +3577,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2644
3577
|
return txSig;
|
|
2645
3578
|
}
|
|
2646
3579
|
|
|
3580
|
+
/**
|
|
3581
|
+
* Builds the `updatePerpMarketExpiry` instruction without sending it. See
|
|
3582
|
+
* `updatePerpMarketExpiry`.
|
|
3583
|
+
* @returns The unsigned `updatePerpMarketExpiry` instruction.
|
|
3584
|
+
*/
|
|
2647
3585
|
public async getUpdatePerpMarketExpiryIx(
|
|
2648
3586
|
perpMarketIndex: number,
|
|
2649
3587
|
expiryTs: BN
|
|
@@ -2662,6 +3600,19 @@ export class AdminClient extends VelocityClient {
|
|
|
2662
3600
|
});
|
|
2663
3601
|
}
|
|
2664
3602
|
|
|
3603
|
+
/**
|
|
3604
|
+
* Swaps a spot market's oracle account/source. Requires **cold** admin
|
|
3605
|
+
* (`AdminUpdateSpotMarketOracle`'s `check_cold` constraint) — a lesser admin swapping the
|
|
3606
|
+
* oracle could re-price the withdraw guard threshold notional cap and all margin math at
|
|
3607
|
+
* will. On-chain the handler reads both the new and current (`oldOracle`) oracle prices and,
|
|
3608
|
+
* unless `skipInvaraintCheck` is `true`, throws `DefaultError` if the new price is
|
|
3609
|
+
* non-positive or diverges more than 10% from the old one.
|
|
3610
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3611
|
+
* @param oracle - New oracle account.
|
|
3612
|
+
* @param oracleSource - Oracle provider/format for `oracle`.
|
|
3613
|
+
* @param skipInvaraintCheck - If `true`, skips the on-chain non-positive/10%-divergence sanity check against the current oracle price. Default `false`.
|
|
3614
|
+
* @returns Transaction signature.
|
|
3615
|
+
*/
|
|
2665
3616
|
public async updateSpotMarketOracle(
|
|
2666
3617
|
spotMarketIndex: number,
|
|
2667
3618
|
oracle: PublicKey,
|
|
@@ -2682,6 +3633,12 @@ export class AdminClient extends VelocityClient {
|
|
|
2682
3633
|
return txSig;
|
|
2683
3634
|
}
|
|
2684
3635
|
|
|
3636
|
+
/**
|
|
3637
|
+
* Builds the `updateSpotMarketOracle` instruction without sending it. See
|
|
3638
|
+
* `updateSpotMarketOracle`. Resolves `oldOracle` from the locally-cached spot market account
|
|
3639
|
+
* (throws if `spotMarketIndex` isn't tracked by the account subscriber).
|
|
3640
|
+
* @returns The unsigned `updateSpotMarketOracle` instruction.
|
|
3641
|
+
*/
|
|
2685
3642
|
public async getUpdateSpotMarketOracleIx(
|
|
2686
3643
|
spotMarketIndex: number,
|
|
2687
3644
|
oracle: PublicKey,
|
|
@@ -2710,6 +3667,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2710
3667
|
);
|
|
2711
3668
|
}
|
|
2712
3669
|
|
|
3670
|
+
/**
|
|
3671
|
+
* Enables or disables limit-order placement/fills on a spot market (`spotMarket.ordersEnabled`).
|
|
3672
|
+
* Requires warm admin (`check_warm`).
|
|
3673
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3674
|
+
* @param ordersEnabled - Whether spot orders are enabled for this market.
|
|
3675
|
+
* @returns Transaction signature.
|
|
3676
|
+
*/
|
|
2713
3677
|
public async updateSpotMarketOrdersEnabled(
|
|
2714
3678
|
spotMarketIndex: number,
|
|
2715
3679
|
ordersEnabled: boolean
|
|
@@ -2727,6 +3691,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2727
3691
|
return txSig;
|
|
2728
3692
|
}
|
|
2729
3693
|
|
|
3694
|
+
/**
|
|
3695
|
+
* Builds the `updateSpotMarketOrdersEnabled` instruction without sending it. See
|
|
3696
|
+
* `updateSpotMarketOrdersEnabled`.
|
|
3697
|
+
* @returns The unsigned `updateSpotMarketOrdersEnabled` instruction.
|
|
3698
|
+
*/
|
|
2730
3699
|
public async getUpdateSpotMarketOrdersEnabledIx(
|
|
2731
3700
|
spotMarketIndex: number,
|
|
2732
3701
|
ordersEnabled: boolean
|
|
@@ -2748,6 +3717,16 @@ export class AdminClient extends VelocityClient {
|
|
|
2748
3717
|
);
|
|
2749
3718
|
}
|
|
2750
3719
|
|
|
3720
|
+
/**
|
|
3721
|
+
* Sets a spot market's insurance-fund operation pause bitmask (`InsuranceFundOperation`:
|
|
3722
|
+
* `Init` 0b0001, `Add` 0b0010, `RequestRemove` 0b0100, `Remove` 0b1000). Gated by
|
|
3723
|
+
* `PauseAdminUpdateSpotMarket` — callable by cold, warm, or the dedicated `pause_admin`; a
|
|
3724
|
+
* caller authorized only via `pause_admin` (not warm/cold) may only *add* pause bits, never
|
|
3725
|
+
* clear existing ones (`require_pause_only_added`).
|
|
3726
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3727
|
+
* @param pausedOperations - New `InsuranceFundOperation` bitmask.
|
|
3728
|
+
* @returns Transaction signature.
|
|
3729
|
+
*/
|
|
2751
3730
|
public async updateSpotMarketIfPausedOperations(
|
|
2752
3731
|
spotMarketIndex: number,
|
|
2753
3732
|
pausedOperations: number
|
|
@@ -2765,6 +3744,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2765
3744
|
return txSig;
|
|
2766
3745
|
}
|
|
2767
3746
|
|
|
3747
|
+
/**
|
|
3748
|
+
* Builds the `updateSpotMarketIfPausedOperations` instruction without sending it. See
|
|
3749
|
+
* `updateSpotMarketIfPausedOperations`.
|
|
3750
|
+
* @returns The unsigned `updateSpotMarketIfPausedOperations` instruction.
|
|
3751
|
+
*/
|
|
2768
3752
|
public async getUpdateSpotMarketIfPausedOperationsIx(
|
|
2769
3753
|
spotMarketIndex: number,
|
|
2770
3754
|
pausedOperations: number
|
|
@@ -2786,6 +3770,14 @@ export class AdminClient extends VelocityClient {
|
|
|
2786
3770
|
);
|
|
2787
3771
|
}
|
|
2788
3772
|
|
|
3773
|
+
/**
|
|
3774
|
+
* Schedules a spot market for expiry: sets `expiryTs` and immediately flips the market to
|
|
3775
|
+
* `MarketStatus.ReduceOnly`. Requires warm admin (`check_warm`). Throws `DefaultError`
|
|
3776
|
+
* on-chain if `expiryTs` is not strictly after the current on-chain clock timestamp.
|
|
3777
|
+
* @param spotMarketIndex - Spot market to schedule for expiry.
|
|
3778
|
+
* @param expiryTs - Unix timestamp (seconds) after which the market is expired; must be in the future.
|
|
3779
|
+
* @returns Transaction signature.
|
|
3780
|
+
*/
|
|
2789
3781
|
public async updateSpotMarketExpiry(
|
|
2790
3782
|
spotMarketIndex: number,
|
|
2791
3783
|
expiryTs: BN
|
|
@@ -2802,6 +3794,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2802
3794
|
return txSig;
|
|
2803
3795
|
}
|
|
2804
3796
|
|
|
3797
|
+
/**
|
|
3798
|
+
* Builds the `updateSpotMarketExpiry` instruction without sending it. See
|
|
3799
|
+
* `updateSpotMarketExpiry`.
|
|
3800
|
+
* @returns The unsigned `updateSpotMarketExpiry` instruction.
|
|
3801
|
+
*/
|
|
2805
3802
|
public async getUpdateSpotMarketExpiryIx(
|
|
2806
3803
|
spotMarketIndex: number,
|
|
2807
3804
|
expiryTs: BN
|
|
@@ -2820,6 +3817,17 @@ export class AdminClient extends VelocityClient {
|
|
|
2820
3817
|
});
|
|
2821
3818
|
}
|
|
2822
3819
|
|
|
3820
|
+
/**
|
|
3821
|
+
* @deprecated The `update_whitelist_mint` instruction handler exists in the Rust
|
|
3822
|
+
* program (`handle_update_whitelist_mint`) but its `#[program]` entry point is
|
|
3823
|
+
* currently commented out in `lib.rs`, so it is absent from the deployed program
|
|
3824
|
+
* and from the generated IDL. Calling this (or `getUpdateWhitelistMintIx`) throws
|
|
3825
|
+
* at runtime — `this.program.instruction` has no `updateWhitelistMint` member —
|
|
3826
|
+
* regardless of the `as any` cast used to bypass the TS type check. Do not call
|
|
3827
|
+
* until the on-chain entry point is re-enabled.
|
|
3828
|
+
* @param whitelistMint - Intended new `state.whitelistMint` (unused while dead).
|
|
3829
|
+
* @returns Transaction signature (never reached).
|
|
3830
|
+
*/
|
|
2823
3831
|
public async updateWhitelistMint(
|
|
2824
3832
|
whitelistMint?: PublicKey
|
|
2825
3833
|
): Promise<TransactionSignature> {
|
|
@@ -2834,6 +3842,12 @@ export class AdminClient extends VelocityClient {
|
|
|
2834
3842
|
return txSig;
|
|
2835
3843
|
}
|
|
2836
3844
|
|
|
3845
|
+
/**
|
|
3846
|
+
* @deprecated See `updateWhitelistMint` — the underlying `update_whitelist_mint`
|
|
3847
|
+
* instruction is not wired up on-chain and is missing from the IDL; this throws
|
|
3848
|
+
* at runtime.
|
|
3849
|
+
* @returns Never resolves successfully.
|
|
3850
|
+
*/
|
|
2837
3851
|
public async getUpdateWhitelistMintIx(
|
|
2838
3852
|
whitelistMint?: PublicKey
|
|
2839
3853
|
): Promise<TransactionInstruction> {
|
|
@@ -2850,6 +3864,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2850
3864
|
);
|
|
2851
3865
|
}
|
|
2852
3866
|
|
|
3867
|
+
/**
|
|
3868
|
+
* Sets `state.discountMint` — a token that grants trade-fee discounts to holders
|
|
3869
|
+
* (checked against the `FeeTier` discount rules at fill time). Requires warm admin
|
|
3870
|
+
* (`check_warm`).
|
|
3871
|
+
* @param discountMint - New discount-token mint.
|
|
3872
|
+
* @returns Transaction signature.
|
|
3873
|
+
*/
|
|
2853
3874
|
public async updateDiscountMint(
|
|
2854
3875
|
discountMint: PublicKey
|
|
2855
3876
|
): Promise<TransactionSignature> {
|
|
@@ -2864,6 +3885,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2864
3885
|
return txSig;
|
|
2865
3886
|
}
|
|
2866
3887
|
|
|
3888
|
+
/**
|
|
3889
|
+
* Builds the `updateDiscountMint` instruction without sending it. See
|
|
3890
|
+
* `updateDiscountMint`.
|
|
3891
|
+
* @returns The unsigned `updateDiscountMint` instruction.
|
|
3892
|
+
*/
|
|
2867
3893
|
public async getUpdateDiscountMintIx(
|
|
2868
3894
|
discountMint: PublicKey
|
|
2869
3895
|
): Promise<TransactionInstruction> {
|
|
@@ -2877,6 +3903,19 @@ export class AdminClient extends VelocityClient {
|
|
|
2877
3903
|
});
|
|
2878
3904
|
}
|
|
2879
3905
|
|
|
3906
|
+
/**
|
|
3907
|
+
* Sets a spot market's deposit/borrow margin weights and IMF factor. Requires warm admin
|
|
3908
|
+
* (`check_warm`). On-chain, `validate_margin_weights` enforces the standard invariants
|
|
3909
|
+
* (asset weights <= SPOT_WEIGHT_PRECISION, liability weights >= SPOT_WEIGHT_PRECISION,
|
|
3910
|
+
* initial at least as conservative as maintenance, and consistency with `imfFactor`).
|
|
3911
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3912
|
+
* @param initialAssetWeight - Initial (deposit) asset weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
3913
|
+
* @param maintenanceAssetWeight - Maintenance asset weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
3914
|
+
* @param initialLiabilityWeight - Initial (borrow) liability weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
3915
|
+
* @param maintenanceLiabilityWeight - Maintenance liability weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
3916
|
+
* @param imfFactor - Increases weight penalty as position size grows, SPOT_IMF_PRECISION (1e6). Default 0.
|
|
3917
|
+
* @returns Transaction signature.
|
|
3918
|
+
*/
|
|
2880
3919
|
public async updateSpotMarketMarginWeights(
|
|
2881
3920
|
spotMarketIndex: number,
|
|
2882
3921
|
initialAssetWeight: number,
|
|
@@ -2902,6 +3941,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2902
3941
|
return txSig;
|
|
2903
3942
|
}
|
|
2904
3943
|
|
|
3944
|
+
/**
|
|
3945
|
+
* Builds the `updateSpotMarketMarginWeights` instruction without sending it. See
|
|
3946
|
+
* `updateSpotMarketMarginWeights`.
|
|
3947
|
+
* @returns The unsigned `updateSpotMarketMarginWeights` instruction.
|
|
3948
|
+
*/
|
|
2905
3949
|
public async getUpdateSpotMarketMarginWeightsIx(
|
|
2906
3950
|
spotMarketIndex: number,
|
|
2907
3951
|
initialAssetWeight: number,
|
|
@@ -2931,6 +3975,18 @@ export class AdminClient extends VelocityClient {
|
|
|
2931
3975
|
);
|
|
2932
3976
|
}
|
|
2933
3977
|
|
|
3978
|
+
/**
|
|
3979
|
+
* Sets a spot market's interest-rate curve: the utilization/rate kink plus the max rate at
|
|
3980
|
+
* 100% utilization. Requires warm admin (`check_warm`). On-chain, `validate_borrow_rate`
|
|
3981
|
+
* checks the curve is well-formed (kink within bounds, rates monotonically increasing,
|
|
3982
|
+
* `min_borrow_rate` at or below `optimal_borrow_rate`).
|
|
3983
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3984
|
+
* @param optimalUtilization - Utilization at the borrow-rate kink, SPOT_UTILIZATION_PRECISION (1e6, 100% = 1e6).
|
|
3985
|
+
* @param optimalBorrowRate - Borrow rate at `optimalUtilization`, SPOT_RATE_PRECISION (1e6, 100% APR = 1e6).
|
|
3986
|
+
* @param optimalMaxRate - Borrow rate at 100% utilization, SPOT_RATE_PRECISION (1e6).
|
|
3987
|
+
* @param minBorrowRate - Floor borrow rate at 0% utilization, in units of 0.5% (i.e. `SPOT_RATE_PRECISION / 200` per unit); omit to leave `spotMarket.minBorrowRate` unchanged.
|
|
3988
|
+
* @returns Transaction signature.
|
|
3989
|
+
*/
|
|
2934
3990
|
public async updateSpotMarketBorrowRate(
|
|
2935
3991
|
spotMarketIndex: number,
|
|
2936
3992
|
optimalUtilization: number,
|
|
@@ -2954,6 +4010,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2954
4010
|
return txSig;
|
|
2955
4011
|
}
|
|
2956
4012
|
|
|
4013
|
+
/**
|
|
4014
|
+
* Builds the `updateSpotMarketBorrowRate` instruction without sending it. See
|
|
4015
|
+
* `updateSpotMarketBorrowRate`.
|
|
4016
|
+
* @returns The unsigned `updateSpotMarketBorrowRate` instruction.
|
|
4017
|
+
*/
|
|
2957
4018
|
public async getUpdateSpotMarketBorrowRateIx(
|
|
2958
4019
|
spotMarketIndex: number,
|
|
2959
4020
|
optimalUtilization: number,
|
|
@@ -2981,6 +4042,16 @@ export class AdminClient extends VelocityClient {
|
|
|
2981
4042
|
);
|
|
2982
4043
|
}
|
|
2983
4044
|
|
|
4045
|
+
/**
|
|
4046
|
+
* Sets a spot market's `AssetTier` (collateral-usability gate for cross-margin). Requires
|
|
4047
|
+
* warm admin (`check_warm`). On-chain, if `spotMarket.initialAssetWeight > 0` (the market is
|
|
4048
|
+
* currently usable as collateral), the new tier must be `AssetTier.COLLATERAL` or
|
|
4049
|
+
* `AssetTier.PROTECTED` — otherwise it throws `DefaultError`; zero the initial asset weight
|
|
4050
|
+
* first to move a market to a lesser tier.
|
|
4051
|
+
* @param spotMarketIndex - Spot market to update.
|
|
4052
|
+
* @param assetTier - New asset tier.
|
|
4053
|
+
* @returns Transaction signature.
|
|
4054
|
+
*/
|
|
2984
4055
|
public async updateSpotMarketAssetTier(
|
|
2985
4056
|
spotMarketIndex: number,
|
|
2986
4057
|
assetTier: AssetTier
|
|
@@ -2995,6 +4066,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2995
4066
|
return txSig;
|
|
2996
4067
|
}
|
|
2997
4068
|
|
|
4069
|
+
/**
|
|
4070
|
+
* Builds the `updateSpotMarketAssetTier` instruction without sending it. See
|
|
4071
|
+
* `updateSpotMarketAssetTier`.
|
|
4072
|
+
* @returns The unsigned `updateSpotMarketAssetTier` instruction.
|
|
4073
|
+
*/
|
|
2998
4074
|
public async getUpdateSpotMarketAssetTierIx(
|
|
2999
4075
|
spotMarketIndex: number,
|
|
3000
4076
|
assetTier: AssetTier
|
|
@@ -3013,6 +4089,15 @@ export class AdminClient extends VelocityClient {
|
|
|
3013
4089
|
});
|
|
3014
4090
|
}
|
|
3015
4091
|
|
|
4092
|
+
/**
|
|
4093
|
+
* Sets a spot market's `MarketStatus` directly. Requires warm admin (`check_warm`). Unlike
|
|
4094
|
+
* `updatePerpMarketStatus`, the spot handler applies no restriction on the target status —
|
|
4095
|
+
* `Delisted`/`Settlement` can be set here directly (there is no separate spot
|
|
4096
|
+
* settlement-teardown instruction).
|
|
4097
|
+
* @param spotMarketIndex - Spot market to update.
|
|
4098
|
+
* @param marketStatus - New market status.
|
|
4099
|
+
* @returns Transaction signature.
|
|
4100
|
+
*/
|
|
3016
4101
|
public async updateSpotMarketStatus(
|
|
3017
4102
|
spotMarketIndex: number,
|
|
3018
4103
|
marketStatus: MarketStatus
|
|
@@ -3029,6 +4114,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3029
4114
|
return txSig;
|
|
3030
4115
|
}
|
|
3031
4116
|
|
|
4117
|
+
/**
|
|
4118
|
+
* Builds the `updateSpotMarketStatus` instruction without sending it. See
|
|
4119
|
+
* `updateSpotMarketStatus`.
|
|
4120
|
+
* @returns The unsigned `updateSpotMarketStatus` instruction.
|
|
4121
|
+
*/
|
|
3032
4122
|
public async getUpdateSpotMarketStatusIx(
|
|
3033
4123
|
spotMarketIndex: number,
|
|
3034
4124
|
marketStatus: MarketStatus
|
|
@@ -3047,6 +4137,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3047
4137
|
});
|
|
3048
4138
|
}
|
|
3049
4139
|
|
|
4140
|
+
/**
|
|
4141
|
+
* Sets a spot market's operation pause bitmask (`SpotOperation`: `UpdateCumulativeInterest`
|
|
4142
|
+
* 0b00001, `Fill` 0b00010, `Deposit` 0b00100, `Withdraw` 0b01000, `Liquidation` 0b10000).
|
|
4143
|
+
* Gated by `PauseAdminUpdateSpotMarket` — callable by cold, warm, or the dedicated
|
|
4144
|
+
* `pause_admin`; a caller authorized only via `pause_admin` may only *add* pause bits, never
|
|
4145
|
+
* clear existing ones (`require_pause_only_added`).
|
|
4146
|
+
* @param spotMarketIndex - Spot market to update.
|
|
4147
|
+
* @param pausedOperations - New `SpotOperation` bitmask.
|
|
4148
|
+
* @returns Transaction signature.
|
|
4149
|
+
*/
|
|
3050
4150
|
public async updateSpotMarketPausedOperations(
|
|
3051
4151
|
spotMarketIndex: number,
|
|
3052
4152
|
pausedOperations: number
|
|
@@ -3064,6 +4164,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3064
4164
|
return txSig;
|
|
3065
4165
|
}
|
|
3066
4166
|
|
|
4167
|
+
/**
|
|
4168
|
+
* Builds the `updateSpotMarketPausedOperations` instruction without sending it. See
|
|
4169
|
+
* `updateSpotMarketPausedOperations`.
|
|
4170
|
+
* @returns The unsigned `updateSpotMarketPausedOperations` instruction.
|
|
4171
|
+
*/
|
|
3067
4172
|
public async getUpdateSpotMarketPausedOperationsIx(
|
|
3068
4173
|
spotMarketIndex: number,
|
|
3069
4174
|
pausedOperations: number
|
|
@@ -3085,6 +4190,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3085
4190
|
);
|
|
3086
4191
|
}
|
|
3087
4192
|
|
|
4193
|
+
/**
|
|
4194
|
+
* Sets a perp market's `MarketStatus` directly. Requires warm admin (`check_warm`). On-chain,
|
|
4195
|
+
* throws `DefaultError` if the target status is `Delisted` or `Settlement` — those are only
|
|
4196
|
+
* reached through the market-expiry lifecycle (`updatePerpMarketExpiry` -> `ReduceOnly`,
|
|
4197
|
+
* then the keeper's `settleExpiredMarket` -> `Settlement`, then
|
|
4198
|
+
* `settleExpiredMarketPoolsToRevenuePool` -> `Delisted`), never set directly here.
|
|
4199
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4200
|
+
* @param marketStatus - New market status; must not be `Delisted` or `Settlement`.
|
|
4201
|
+
* @returns Transaction signature.
|
|
4202
|
+
*/
|
|
3088
4203
|
public async updatePerpMarketStatus(
|
|
3089
4204
|
perpMarketIndex: number,
|
|
3090
4205
|
marketStatus: MarketStatus
|
|
@@ -3101,6 +4216,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3101
4216
|
return txSig;
|
|
3102
4217
|
}
|
|
3103
4218
|
|
|
4219
|
+
/**
|
|
4220
|
+
* Builds the `updatePerpMarketStatus` instruction without sending it. See
|
|
4221
|
+
* `updatePerpMarketStatus`.
|
|
4222
|
+
* @returns The unsigned `updatePerpMarketStatus` instruction.
|
|
4223
|
+
*/
|
|
3104
4224
|
public async getUpdatePerpMarketStatusIx(
|
|
3105
4225
|
perpMarketIndex: number,
|
|
3106
4226
|
marketStatus: MarketStatus
|
|
@@ -3119,6 +4239,19 @@ export class AdminClient extends VelocityClient {
|
|
|
3119
4239
|
});
|
|
3120
4240
|
}
|
|
3121
4241
|
|
|
4242
|
+
/**
|
|
4243
|
+
* Sets a perp market's operation pause bitmask (`PerpOperation`: `UpdateFunding` 0b00000001,
|
|
4244
|
+
* `AmmFill` 0b00000010, `Fill` 0b00000100, `SettlePnl` 0b00001000, `SettlePnlWithPosition`
|
|
4245
|
+
* 0b00010000, `Liquidation` 0b00100000, `AmmImmediateFill` 0b01000000, `SettleRevPool`
|
|
4246
|
+
* 0b10000000). Gated by `PauseAdminUpdatePerpMarket` — callable by cold, warm, or the
|
|
4247
|
+
* dedicated `pause_admin`. Authority matrix on-chain: **cold** may set any value; **warm**
|
|
4248
|
+
* may only flip the `UpdateFunding` / `SettleRevPool` bits, all others must be preserved
|
|
4249
|
+
* (throws `DefaultError` otherwise); **pause_admin** may set any bit but only *add* pause
|
|
4250
|
+
* bits, never clear them (`require_pause_only_added`).
|
|
4251
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4252
|
+
* @param pausedOperations - New `PerpOperation` bitmask.
|
|
4253
|
+
* @returns Transaction signature.
|
|
4254
|
+
*/
|
|
3122
4255
|
public async updatePerpMarketPausedOperations(
|
|
3123
4256
|
perpMarketIndex: number,
|
|
3124
4257
|
pausedOperations: number
|
|
@@ -3136,6 +4269,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3136
4269
|
return txSig;
|
|
3137
4270
|
}
|
|
3138
4271
|
|
|
4272
|
+
/**
|
|
4273
|
+
* Builds the `updatePerpMarketPausedOperations` instruction without sending it. See
|
|
4274
|
+
* `updatePerpMarketPausedOperations`.
|
|
4275
|
+
* @returns The unsigned `updatePerpMarketPausedOperations` instruction.
|
|
4276
|
+
*/
|
|
3139
4277
|
public async getUpdatePerpMarketPausedOperationsIx(
|
|
3140
4278
|
perpMarketIndex: number,
|
|
3141
4279
|
pausedOperations: number
|
|
@@ -3157,6 +4295,13 @@ export class AdminClient extends VelocityClient {
|
|
|
3157
4295
|
);
|
|
3158
4296
|
}
|
|
3159
4297
|
|
|
4298
|
+
/**
|
|
4299
|
+
* Sets a perp market's `ContractTier` (risk/collateral classification). Requires warm admin
|
|
4300
|
+
* (`check_warm`).
|
|
4301
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4302
|
+
* @param contractTier - New contract tier.
|
|
4303
|
+
* @returns Transaction signature.
|
|
4304
|
+
*/
|
|
3160
4305
|
public async updatePerpMarketContractTier(
|
|
3161
4306
|
perpMarketIndex: number,
|
|
3162
4307
|
contractTier: ContractTier
|
|
@@ -3174,6 +4319,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3174
4319
|
return txSig;
|
|
3175
4320
|
}
|
|
3176
4321
|
|
|
4322
|
+
/**
|
|
4323
|
+
* Builds the `updatePerpMarketContractTier` instruction without sending it. See
|
|
4324
|
+
* `updatePerpMarketContractTier`.
|
|
4325
|
+
* @returns The unsigned `updatePerpMarketContractTier` instruction.
|
|
4326
|
+
*/
|
|
3177
4327
|
public async getUpdatePerpMarketContractTierIx(
|
|
3178
4328
|
perpMarketIndex: number,
|
|
3179
4329
|
contractTier: ContractTier
|
|
@@ -3196,6 +4346,17 @@ export class AdminClient extends VelocityClient {
|
|
|
3196
4346
|
);
|
|
3197
4347
|
}
|
|
3198
4348
|
|
|
4349
|
+
/**
|
|
4350
|
+
* Sets `state.exchangeStatus`, the protocol-wide pause bitmask (`ExchangeStatus`).
|
|
4351
|
+
* Reachable by cold, warm, or `pauseAdmin` (`PauseAdminUpdateState`'s
|
|
4352
|
+
* `check_pause`), but the handler enforces `require_pause_only_added`: a caller
|
|
4353
|
+
* authorised only via `pauseAdmin` (not warm/cold) may add pause bits but never
|
|
4354
|
+
* clear one — cold/warm can set any value, including unpausing. The `admin`
|
|
4355
|
+
* account below defaults to `coldAdmin`; a pause-admin-only caller must override it
|
|
4356
|
+
* with their own pubkey.
|
|
4357
|
+
* @param exchangeStatus - New pause bitmask, `ExchangeStatus` (bit values; `PAUSED` = 255 pauses everything).
|
|
4358
|
+
* @returns Transaction signature.
|
|
4359
|
+
*/
|
|
3199
4360
|
public async updateExchangeStatus(
|
|
3200
4361
|
exchangeStatus: ExchangeStatus
|
|
3201
4362
|
): Promise<TransactionSignature> {
|
|
@@ -3210,6 +4371,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3210
4371
|
return txSig;
|
|
3211
4372
|
}
|
|
3212
4373
|
|
|
4374
|
+
/**
|
|
4375
|
+
* Builds the `updateExchangeStatus` instruction without sending it. See
|
|
4376
|
+
* `updateExchangeStatus`.
|
|
4377
|
+
* @returns The unsigned `updateExchangeStatus` instruction.
|
|
4378
|
+
*/
|
|
3213
4379
|
public async getUpdateExchangeStatusIx(
|
|
3214
4380
|
exchangeStatus: ExchangeStatus
|
|
3215
4381
|
): Promise<TransactionInstruction> {
|
|
@@ -3223,6 +4389,54 @@ export class AdminClient extends VelocityClient {
|
|
|
3223
4389
|
});
|
|
3224
4390
|
}
|
|
3225
4391
|
|
|
4392
|
+
/**
|
|
4393
|
+
* Sets `state.solvencyStatus` (`SolvencyStatus`), gating internal solvency-repair
|
|
4394
|
+
* flows (bankruptcy / pnl-deficit resolution) independently of
|
|
4395
|
+
* `ExchangeStatus.WITHDRAW_PAUSED`. Cold-only — unlike `updateExchangeStatus`, the
|
|
4396
|
+
* `ColdAdminUpdateState` context accepts only `state.coldAdmin`; there is no
|
|
4397
|
+
* pause-admin or warm-admin path and no bit-add-only restriction.
|
|
4398
|
+
* @param solvencyStatus - New bitmask, `SolvencyStatus` (currently one bit: `SOLVENCY_REPAIR_PAUSED`).
|
|
4399
|
+
* @returns Transaction signature.
|
|
4400
|
+
*/
|
|
4401
|
+
public async updateSolvencyStatus(
|
|
4402
|
+
solvencyStatus: SolvencyStatus
|
|
4403
|
+
): Promise<TransactionSignature> {
|
|
4404
|
+
const updateSolvencyStatusIx = await this.getUpdateSolvencyStatusIx(
|
|
4405
|
+
solvencyStatus
|
|
4406
|
+
);
|
|
4407
|
+
|
|
4408
|
+
const tx = await this.buildTransaction(updateSolvencyStatusIx);
|
|
4409
|
+
|
|
4410
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4411
|
+
|
|
4412
|
+
return txSig;
|
|
4413
|
+
}
|
|
4414
|
+
|
|
4415
|
+
/**
|
|
4416
|
+
* Builds the `updateSolvencyStatus` instruction without sending it. See
|
|
4417
|
+
* `updateSolvencyStatus`.
|
|
4418
|
+
* @returns The unsigned `updateSolvencyStatus` instruction.
|
|
4419
|
+
*/
|
|
4420
|
+
public async getUpdateSolvencyStatusIx(
|
|
4421
|
+
solvencyStatus: SolvencyStatus
|
|
4422
|
+
): Promise<TransactionInstruction> {
|
|
4423
|
+
return await this.program.instruction.updateSolvencyStatus(solvencyStatus, {
|
|
4424
|
+
accounts: {
|
|
4425
|
+
admin: this.isSubscribed
|
|
4426
|
+
? this.getStateAccount().coldAdmin
|
|
4427
|
+
: this.wallet.publicKey,
|
|
4428
|
+
state: await this.getStatePublicKey(),
|
|
4429
|
+
},
|
|
4430
|
+
});
|
|
4431
|
+
}
|
|
4432
|
+
|
|
4433
|
+
/**
|
|
4434
|
+
* Sets the protocol-wide default minimum perp-order auction duration
|
|
4435
|
+
* (`state.minPerpAuctionDuration`) — orders placed without an explicit longer
|
|
4436
|
+
* auction fall back to this floor. Requires warm admin (`check_warm`).
|
|
4437
|
+
* @param minDuration - Minimum auction duration, slots.
|
|
4438
|
+
* @returns Transaction signature.
|
|
4439
|
+
*/
|
|
3226
4440
|
public async updatePerpAuctionDuration(
|
|
3227
4441
|
minDuration: BN | number
|
|
3228
4442
|
): Promise<TransactionSignature> {
|
|
@@ -3236,6 +4450,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3236
4450
|
return txSig;
|
|
3237
4451
|
}
|
|
3238
4452
|
|
|
4453
|
+
/**
|
|
4454
|
+
* Builds the `updatePerpAuctionDuration` instruction without sending it. See
|
|
4455
|
+
* `updatePerpAuctionDuration`.
|
|
4456
|
+
* @returns The unsigned `updatePerpAuctionDuration` instruction.
|
|
4457
|
+
*/
|
|
3239
4458
|
public async getUpdatePerpAuctionDurationIx(
|
|
3240
4459
|
minDuration: BN | number
|
|
3241
4460
|
): Promise<TransactionInstruction> {
|
|
@@ -3252,6 +4471,12 @@ export class AdminClient extends VelocityClient {
|
|
|
3252
4471
|
);
|
|
3253
4472
|
}
|
|
3254
4473
|
|
|
4474
|
+
/**
|
|
4475
|
+
* Sets the protocol-wide default spot-order auction duration
|
|
4476
|
+
* (`state.defaultSpotAuctionDuration`). Requires warm admin (`check_warm`).
|
|
4477
|
+
* @param defaultAuctionDuration - Default auction duration, slots.
|
|
4478
|
+
* @returns Transaction signature.
|
|
4479
|
+
*/
|
|
3255
4480
|
public async updateSpotAuctionDuration(
|
|
3256
4481
|
defaultAuctionDuration: number
|
|
3257
4482
|
): Promise<TransactionSignature> {
|
|
@@ -3265,6 +4490,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3265
4490
|
return txSig;
|
|
3266
4491
|
}
|
|
3267
4492
|
|
|
4493
|
+
/**
|
|
4494
|
+
* Builds the `updateSpotAuctionDuration` instruction without sending it. See
|
|
4495
|
+
* `updateSpotAuctionDuration`.
|
|
4496
|
+
* @returns The unsigned `updateSpotAuctionDuration` instruction.
|
|
4497
|
+
*/
|
|
3268
4498
|
public async getUpdateSpotAuctionDurationIx(
|
|
3269
4499
|
defaultAuctionDuration: number
|
|
3270
4500
|
): Promise<TransactionInstruction> {
|
|
@@ -3281,6 +4511,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3281
4511
|
);
|
|
3282
4512
|
}
|
|
3283
4513
|
|
|
4514
|
+
/**
|
|
4515
|
+
* Sets the fraction of a perp market's AMM base reserve a single fill may consume
|
|
4516
|
+
* (`amm.maxFillReserveFraction`; a single fill is capped at
|
|
4517
|
+
* `baseAssetReserve / maxFillReserveFraction`, further bounded by half the AMM's
|
|
4518
|
+
* per-side available liquidity). Requires warm admin (`check_warm`). Throws `DefaultError`
|
|
4519
|
+
* on-chain if `maxBaseAssetAmountRatio` is 0. Smaller values allow larger single fills.
|
|
4520
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4521
|
+
* @param maxBaseAssetAmountRatio - Divisor applied to `baseAssetReserve` to cap a single fill's size; must be > 0.
|
|
4522
|
+
* @returns Transaction signature.
|
|
4523
|
+
*/
|
|
3284
4524
|
public async updatePerpMarketMaxFillReserveFraction(
|
|
3285
4525
|
perpMarketIndex: number,
|
|
3286
4526
|
maxBaseAssetAmountRatio: number
|
|
@@ -3300,6 +4540,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3300
4540
|
return txSig;
|
|
3301
4541
|
}
|
|
3302
4542
|
|
|
4543
|
+
/**
|
|
4544
|
+
* Builds the `updatePerpMarketMaxFillReserveFraction` instruction without sending it. See
|
|
4545
|
+
* `updatePerpMarketMaxFillReserveFraction`.
|
|
4546
|
+
* @returns The unsigned `updatePerpMarketMaxFillReserveFraction` instruction.
|
|
4547
|
+
*/
|
|
3303
4548
|
public async getUpdatePerpMarketMaxFillReserveFractionIx(
|
|
3304
4549
|
perpMarketIndex: number,
|
|
3305
4550
|
maxBaseAssetAmountRatio: number
|
|
@@ -3321,6 +4566,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3321
4566
|
);
|
|
3322
4567
|
}
|
|
3323
4568
|
|
|
4569
|
+
/**
|
|
4570
|
+
* **Currently broken and a dead config knob even if fixed.** Intended to set a perp market's
|
|
4571
|
+
* `amm.maxSlippageRatio` (on-chain default 50, i.e. ~2% per the seed comment in
|
|
4572
|
+
* `initializePerpMarket`'s default config) — but `getUpdateMaxSlippageRatioIx` calls
|
|
4573
|
+
* `this.program.instruction.updateMaxSlippageRatio` (cast to `any` to bypass the missing
|
|
4574
|
+
* type); the actual on-chain/IDL instruction is named `updatePerpMarketMaxSlippageRatio`, so
|
|
4575
|
+
* this throws at runtime (`... is not a function`). Separately, even the correctly-named
|
|
4576
|
+
* instruction's target field, `amm.maxSlippageRatio`, is not read by any fill/slippage-check
|
|
4577
|
+
* path in the program — it is write-only. Requires warm admin (`check_warm`) on the
|
|
4578
|
+
* `update_perp_market_max_slippage_ratio` handler.
|
|
4579
|
+
* @param perpMarketIndex - Perp market that would be updated.
|
|
4580
|
+
* @param maxSlippageRatio - Intended `amm.maxSlippageRatio` value, unitless (would validate `> 0`).
|
|
4581
|
+
* @returns Transaction signature (in practice: throws before a transaction is built).
|
|
4582
|
+
*/
|
|
3324
4583
|
public async updateMaxSlippageRatio(
|
|
3325
4584
|
perpMarketIndex: number,
|
|
3326
4585
|
maxSlippageRatio: number
|
|
@@ -3337,6 +4596,14 @@ export class AdminClient extends VelocityClient {
|
|
|
3337
4596
|
return txSig;
|
|
3338
4597
|
}
|
|
3339
4598
|
|
|
4599
|
+
/**
|
|
4600
|
+
* Builds the (currently broken) `updateMaxSlippageRatio` instruction. See
|
|
4601
|
+
* `updateMaxSlippageRatio` — this throws because the program has no `updateMaxSlippageRatio`
|
|
4602
|
+
* instruction (the real name is `updatePerpMarketMaxSlippageRatio`). Throws if
|
|
4603
|
+
* `perpMarketIndex` isn't tracked by the local account subscriber, before it even reaches
|
|
4604
|
+
* the bad instruction-name call.
|
|
4605
|
+
* @returns Never resolves successfully; throws when the missing instruction is invoked.
|
|
4606
|
+
*/
|
|
3340
4607
|
public async getUpdateMaxSlippageRatioIx(
|
|
3341
4608
|
perpMarketIndex: number,
|
|
3342
4609
|
maxSlippageRatio: number
|
|
@@ -3356,6 +4623,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3356
4623
|
);
|
|
3357
4624
|
}
|
|
3358
4625
|
|
|
4626
|
+
/**
|
|
4627
|
+
* Sets the asset weights applied to a user's unrealized (unsettled) perp PnL when it counts
|
|
4628
|
+
* toward free collateral. Requires warm admin (`check_warm`). On-chain, both weights must be
|
|
4629
|
+
* <= SPOT_WEIGHT_PRECISION and `unrealizedInitialAssetWeight <= unrealizedMaintenanceAssetWeight`,
|
|
4630
|
+
* or the handler throws `DefaultError`.
|
|
4631
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4632
|
+
* @param unrealizedInitialAssetWeight - Initial-margin weight on unrealized PnL, SPOT_WEIGHT_PRECISION (1e4).
|
|
4633
|
+
* @param unrealizedMaintenanceAssetWeight - Maintenance-margin weight on unrealized PnL, SPOT_WEIGHT_PRECISION (1e4). Must be >= the initial weight.
|
|
4634
|
+
* @returns Transaction signature.
|
|
4635
|
+
*/
|
|
3359
4636
|
public async updatePerpMarketUnrealizedAssetWeight(
|
|
3360
4637
|
perpMarketIndex: number,
|
|
3361
4638
|
unrealizedInitialAssetWeight: number,
|
|
@@ -3377,6 +4654,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3377
4654
|
return txSig;
|
|
3378
4655
|
}
|
|
3379
4656
|
|
|
4657
|
+
/**
|
|
4658
|
+
* Builds the `updatePerpMarketUnrealizedAssetWeight` instruction without sending it. See
|
|
4659
|
+
* `updatePerpMarketUnrealizedAssetWeight`.
|
|
4660
|
+
* @returns The unsigned `updatePerpMarketUnrealizedAssetWeight` instruction.
|
|
4661
|
+
*/
|
|
3380
4662
|
public async getUpdatePerpMarketUnrealizedAssetWeightIx(
|
|
3381
4663
|
perpMarketIndex: number,
|
|
3382
4664
|
unrealizedInitialAssetWeight: number,
|
|
@@ -3400,6 +4682,19 @@ export class AdminClient extends VelocityClient {
|
|
|
3400
4682
|
);
|
|
3401
4683
|
}
|
|
3402
4684
|
|
|
4685
|
+
/**
|
|
4686
|
+
* Sets a perp market's insurance/revenue-pool caps. Requires warm admin (`check_warm`).
|
|
4687
|
+
* On-chain, all three are bounded by the tier-specific `INSURANCE_{A,B,C,SPECULATIVE}_MAX`
|
|
4688
|
+
* constant for the market's current `contractTier` (`maxRevenueWithdrawPerPeriod` may
|
|
4689
|
+
* alternatively be as large as `FEE_POOL_TO_REVENUE_POOL_THRESHOLD` if that's bigger than
|
|
4690
|
+
* the tier max), and `quoteMaxInsurance` must be >= the market's already-settled insurance
|
|
4691
|
+
* claim — violating either throws `DefaultError`.
|
|
4692
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4693
|
+
* @param unrealizedMaxImbalance - Cap on unrealized-PnL imbalance eligible for insurance backing, QUOTE_PRECISION (1e6).
|
|
4694
|
+
* @param maxRevenueWithdrawPerPeriod - Cap on revenue-pool withdrawals per settlement period, QUOTE_PRECISION (1e6).
|
|
4695
|
+
* @param quoteMaxInsurance - Lifetime cap on insurance draws for this market, QUOTE_PRECISION (1e6). Must be >= the market's already-settled insurance claim.
|
|
4696
|
+
* @returns Transaction signature.
|
|
4697
|
+
*/
|
|
3403
4698
|
public async updatePerpMarketMaxImbalances(
|
|
3404
4699
|
perpMarketIndex: number,
|
|
3405
4700
|
unrealizedMaxImbalance: BN,
|
|
@@ -3421,6 +4716,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3421
4716
|
return txSig;
|
|
3422
4717
|
}
|
|
3423
4718
|
|
|
4719
|
+
/**
|
|
4720
|
+
* Builds the `updatePerpMarketMaxImbalances` instruction without sending it. See
|
|
4721
|
+
* `updatePerpMarketMaxImbalances`.
|
|
4722
|
+
* @returns The unsigned `updatePerpMarketMaxImbalances` instruction.
|
|
4723
|
+
*/
|
|
3424
4724
|
public async getUpdatePerpMarketMaxImbalancesIx(
|
|
3425
4725
|
perpMarketIndex: number,
|
|
3426
4726
|
unrealizedMaxImbalance: BN,
|
|
@@ -3446,6 +4746,14 @@ export class AdminClient extends VelocityClient {
|
|
|
3446
4746
|
);
|
|
3447
4747
|
}
|
|
3448
4748
|
|
|
4749
|
+
/**
|
|
4750
|
+
* Sets a perp market's open-interest cap. Requires warm admin (`check_warm`). Throws
|
|
4751
|
+
* `DefaultError` on-chain unless `maxOpenInterest` is an exact multiple of the market's
|
|
4752
|
+
* `orderStepSize`.
|
|
4753
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4754
|
+
* @param maxOpenInterest - Cap on base-asset open interest, BASE_PRECISION (1e9). Must be a multiple of `orderStepSize`.
|
|
4755
|
+
* @returns Transaction signature.
|
|
4756
|
+
*/
|
|
3449
4757
|
public async updatePerpMarketMaxOpenInterest(
|
|
3450
4758
|
perpMarketIndex: number,
|
|
3451
4759
|
maxOpenInterest: BN
|
|
@@ -3463,6 +4771,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3463
4771
|
return txSig;
|
|
3464
4772
|
}
|
|
3465
4773
|
|
|
4774
|
+
/**
|
|
4775
|
+
* Builds the `updatePerpMarketMaxOpenInterest` instruction without sending it. See
|
|
4776
|
+
* `updatePerpMarketMaxOpenInterest`.
|
|
4777
|
+
* @returns The unsigned `updatePerpMarketMaxOpenInterest` instruction.
|
|
4778
|
+
*/
|
|
3466
4779
|
public async getUpdatePerpMarketMaxOpenInterestIx(
|
|
3467
4780
|
perpMarketIndex: number,
|
|
3468
4781
|
maxOpenInterest: BN
|
|
@@ -3484,6 +4797,17 @@ export class AdminClient extends VelocityClient {
|
|
|
3484
4797
|
);
|
|
3485
4798
|
}
|
|
3486
4799
|
|
|
4800
|
+
/**
|
|
4801
|
+
* Directly overwrites a perp market's user-count counters (`numberOfUsers` /
|
|
4802
|
+
* `numberOfUsersWithBase`), used to correct drift from the incrementally-maintained
|
|
4803
|
+
* counters. Requires warm admin (`check_warm`). Either counter can be omitted to leave it
|
|
4804
|
+
* unchanged. On-chain, throws `DefaultError` if the resulting `numberOfUsers <
|
|
4805
|
+
* numberOfUsersWithBase`.
|
|
4806
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4807
|
+
* @param numberOfUsers - New total open-position-or-order user count. Omit to leave unchanged.
|
|
4808
|
+
* @param numberOfUsersWithBase - New count of users with a nonzero base position. Omit to leave unchanged. Must not exceed `numberOfUsers`.
|
|
4809
|
+
* @returns Transaction signature.
|
|
4810
|
+
*/
|
|
3487
4811
|
public async updatePerpMarketNumberOfUser(
|
|
3488
4812
|
perpMarketIndex: number,
|
|
3489
4813
|
numberOfUsers?: number,
|
|
@@ -3503,6 +4827,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3503
4827
|
return txSig;
|
|
3504
4828
|
}
|
|
3505
4829
|
|
|
4830
|
+
/**
|
|
4831
|
+
* Builds the `updatePerpMarketNumberOfUsers` instruction without sending it. See
|
|
4832
|
+
* `updatePerpMarketNumberOfUser`.
|
|
4833
|
+
* @returns The unsigned `updatePerpMarketNumberOfUsers` instruction.
|
|
4834
|
+
*/
|
|
3506
4835
|
public async getUpdatePerpMarketNumberOfUsersIx(
|
|
3507
4836
|
perpMarketIndex: number,
|
|
3508
4837
|
numberOfUsers?: number,
|
|
@@ -3526,6 +4855,14 @@ export class AdminClient extends VelocityClient {
|
|
|
3526
4855
|
);
|
|
3527
4856
|
}
|
|
3528
4857
|
|
|
4858
|
+
/**
|
|
4859
|
+
* Scales a perp market's taker fee and maker rebate up or down by a percentage of the base
|
|
4860
|
+
* fee tier. Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if
|
|
4861
|
+
* `abs(feeAdjustment) > FEE_ADJUSTMENT_MAX` (100).
|
|
4862
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4863
|
+
* @param feeAdjustment - Percent adjustment applied to the base taker fee / maker rebate, -100..100 (negative reduces, positive increases; 0 = no adjustment).
|
|
4864
|
+
* @returns Transaction signature.
|
|
4865
|
+
*/
|
|
3529
4866
|
public async updatePerpMarketFeeAdjustment(
|
|
3530
4867
|
perpMarketIndex: number,
|
|
3531
4868
|
feeAdjustment: number
|
|
@@ -3543,6 +4880,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3543
4880
|
return txSig;
|
|
3544
4881
|
}
|
|
3545
4882
|
|
|
4883
|
+
/**
|
|
4884
|
+
* Builds the `updatePerpMarketFeeAdjustment` instruction without sending it. See
|
|
4885
|
+
* `updatePerpMarketFeeAdjustment`.
|
|
4886
|
+
* @returns The unsigned `updatePerpMarketFeeAdjustment` instruction.
|
|
4887
|
+
*/
|
|
3546
4888
|
public async getUpdatePerpMarketFeeAdjustmentIx(
|
|
3547
4889
|
perpMarketIndex: number,
|
|
3548
4890
|
feeAdjustment: number
|
|
@@ -3564,6 +4906,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3564
4906
|
);
|
|
3565
4907
|
}
|
|
3566
4908
|
|
|
4909
|
+
/**
|
|
4910
|
+
* Sets the retention buffer the streaming fee sweep leaves in a perp market's pnl pool on top
|
|
4911
|
+
* of `max(netUserPnl, 0)` before the IF/AMM-provision drains take their cut (the protocol
|
|
4912
|
+
* drain is exempt and always runs). Requires warm admin (`check_warm`). See
|
|
4913
|
+
* `perp_market.fee_pool_buffer_target`'s doc comment for why the buffer exists (a swept pool
|
|
4914
|
+
* is short on the next adverse oracle tick, and sweeps are a one-way valve).
|
|
4915
|
+
* @param perpMarketIndex - Perp market to update.
|
|
4916
|
+
* @param feePoolBufferTarget - Pnl-pool retention buffer, QUOTE_PRECISION (1e6).
|
|
4917
|
+
* @returns Transaction signature.
|
|
4918
|
+
*/
|
|
3567
4919
|
public async updatePerpMarketFeePoolBufferTarget(
|
|
3568
4920
|
perpMarketIndex: number,
|
|
3569
4921
|
feePoolBufferTarget: BN
|
|
@@ -3583,6 +4935,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3583
4935
|
return txSig;
|
|
3584
4936
|
}
|
|
3585
4937
|
|
|
4938
|
+
/**
|
|
4939
|
+
* Builds the `updatePerpMarketFeePoolBufferTarget` instruction without sending it. See
|
|
4940
|
+
* `updatePerpMarketFeePoolBufferTarget`.
|
|
4941
|
+
* @returns The unsigned `updatePerpMarketFeePoolBufferTarget` instruction.
|
|
4942
|
+
*/
|
|
3586
4943
|
public async getUpdatePerpMarketFeePoolBufferTargetIx(
|
|
3587
4944
|
perpMarketIndex: number,
|
|
3588
4945
|
feePoolBufferTarget: BN
|
|
@@ -3604,6 +4961,15 @@ export class AdminClient extends VelocityClient {
|
|
|
3604
4961
|
);
|
|
3605
4962
|
}
|
|
3606
4963
|
|
|
4964
|
+
/**
|
|
4965
|
+
* Scales a spot market's taker fee and maker rebate up or down by a percentage of the base
|
|
4966
|
+
* fee tier. Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if
|
|
4967
|
+
* `abs(feeAdjustment) > FEE_ADJUSTMENT_MAX` (100). Note: the first parameter is a **spot**
|
|
4968
|
+
* market index despite being named `perpMarketIndex` here.
|
|
4969
|
+
* @param perpMarketIndex - Spot market index to update (misnamed; not a perp market index).
|
|
4970
|
+
* @param feeAdjustment - Percent adjustment applied to the base taker fee / maker rebate, -100..100 (negative reduces, positive increases; 0 = no adjustment).
|
|
4971
|
+
* @returns Transaction signature.
|
|
4972
|
+
*/
|
|
3607
4973
|
public async updateSpotMarketFeeAdjustment(
|
|
3608
4974
|
perpMarketIndex: number,
|
|
3609
4975
|
feeAdjustment: number
|
|
@@ -3621,6 +4987,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3621
4987
|
return txSig;
|
|
3622
4988
|
}
|
|
3623
4989
|
|
|
4990
|
+
/**
|
|
4991
|
+
* Builds the `updateSpotMarketFeeAdjustment` instruction without sending it. See
|
|
4992
|
+
* `updateSpotMarketFeeAdjustment`.
|
|
4993
|
+
* @returns The unsigned `updateSpotMarketFeeAdjustment` instruction.
|
|
4994
|
+
*/
|
|
3624
4995
|
public async getUpdateSpotMarketFeeAdjustmentIx(
|
|
3625
4996
|
spotMarketIndex: number,
|
|
3626
4997
|
feeAdjustment: number
|
|
@@ -3642,6 +5013,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3642
5013
|
);
|
|
3643
5014
|
}
|
|
3644
5015
|
|
|
5016
|
+
/**
|
|
5017
|
+
* Sets the three-way split of a perp market's liquidation fee: the cut paid to the
|
|
5018
|
+
* liquidator, the cut routed to the insurance fund, and the cut kept by the protocol.
|
|
5019
|
+
* Requires warm admin (`check_warm`). On-chain, throws `DefaultError` unless
|
|
5020
|
+
* `liquidatorFee + ifLiquidationFee + protocolLiquidationFee < LIQUIDATION_FEE_PRECISION`,
|
|
5021
|
+
* `ifLiquidationFee < LIQUIDATION_FEE_PRECISION`, and `protocolLiquidationFee <=
|
|
5022
|
+
* LIQUIDATION_FEE_PRECISION / 10` (10%); also re-validates `liquidatorFee` against the
|
|
5023
|
+
* market's current margin ratios (`amm.validate_compatible_with_liquidation_fee`).
|
|
5024
|
+
* @param perpMarketIndex - Perp market to update.
|
|
5025
|
+
* @param liquidatorFee - Fee paid to the liquidator, LIQUIDATION_FEE_PRECISION (1e6).
|
|
5026
|
+
* @param ifLiquidationFee - Portion routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6).
|
|
5027
|
+
* @param protocolLiquidationFee - Portion kept by the protocol, LIQUIDATION_FEE_PRECISION (1e6). Max 10% of precision. Default 0.
|
|
5028
|
+
* @returns Transaction signature.
|
|
5029
|
+
*/
|
|
3645
5030
|
public async updatePerpMarketLiquidationFee(
|
|
3646
5031
|
perpMarketIndex: number,
|
|
3647
5032
|
liquidatorFee: number,
|
|
@@ -3663,6 +5048,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3663
5048
|
return txSig;
|
|
3664
5049
|
}
|
|
3665
5050
|
|
|
5051
|
+
/**
|
|
5052
|
+
* Builds the `updatePerpMarketLiquidationFee` instruction without sending it. See
|
|
5053
|
+
* `updatePerpMarketLiquidationFee`.
|
|
5054
|
+
* @returns The unsigned `updatePerpMarketLiquidationFee` instruction.
|
|
5055
|
+
*/
|
|
3666
5056
|
public async getUpdatePerpMarketLiquidationFeeIx(
|
|
3667
5057
|
perpMarketIndex: number,
|
|
3668
5058
|
liquidatorFee: number,
|
|
@@ -3688,6 +5078,19 @@ export class AdminClient extends VelocityClient {
|
|
|
3688
5078
|
);
|
|
3689
5079
|
}
|
|
3690
5080
|
|
|
5081
|
+
/**
|
|
5082
|
+
* Sets the three-way split of a spot market's liquidation fee: the cut paid to the
|
|
5083
|
+
* liquidator, the cut routed to the insurance fund, and the cut kept by the protocol.
|
|
5084
|
+
* Requires warm admin (`check_warm`). On-chain, throws `DefaultError` unless
|
|
5085
|
+
* `liquidatorFee + ifLiquidationFee + protocolLiquidationFee < LIQUIDATION_FEE_PRECISION`,
|
|
5086
|
+
* and both `ifLiquidationFee` and `protocolLiquidationFee` are each
|
|
5087
|
+
* <= `LIQUIDATION_FEE_PRECISION / 10` (10%).
|
|
5088
|
+
* @param spotMarketIndex - Spot market to update.
|
|
5089
|
+
* @param liquidatorFee - Fee paid to the liquidator, LIQUIDATION_FEE_PRECISION (1e6).
|
|
5090
|
+
* @param ifLiquidationFee - Portion routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6). Max 10% of precision.
|
|
5091
|
+
* @param protocolLiquidationFee - Portion kept by the protocol, LIQUIDATION_FEE_PRECISION (1e6). Max 10% of precision. Default 0.
|
|
5092
|
+
* @returns Transaction signature.
|
|
5093
|
+
*/
|
|
3691
5094
|
public async updateSpotMarketLiquidationFee(
|
|
3692
5095
|
spotMarketIndex: number,
|
|
3693
5096
|
liquidatorFee: number,
|
|
@@ -3709,6 +5112,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3709
5112
|
return txSig;
|
|
3710
5113
|
}
|
|
3711
5114
|
|
|
5115
|
+
/**
|
|
5116
|
+
* Builds the `updateSpotMarketLiquidationFee` instruction without sending it. See
|
|
5117
|
+
* `updateSpotMarketLiquidationFee`.
|
|
5118
|
+
* @returns The unsigned `updateSpotMarketLiquidationFee` instruction.
|
|
5119
|
+
*/
|
|
3712
5120
|
public async getUpdateSpotMarketLiquidationFeeIx(
|
|
3713
5121
|
spotMarketIndex: number,
|
|
3714
5122
|
liquidatorFee: number,
|
|
@@ -3734,6 +5142,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3734
5142
|
);
|
|
3735
5143
|
}
|
|
3736
5144
|
|
|
5145
|
+
/**
|
|
5146
|
+
* Cold-only. Sets the treasury pubkey that `withdrawProtocolFeesPerp` /
|
|
5147
|
+
* `withdrawProtocolFeesSpot` pay out to. Perp (quote-denominated) and spot
|
|
5148
|
+
* (per-market-token) recipients are independent — `marketType` selects which one
|
|
5149
|
+
* this call updates. Withdrawals for a market type are inert (the fee-withdraw ix
|
|
5150
|
+
* always fails) until its recipient is set to a non-default pubkey.
|
|
5151
|
+
* @param protocolFeeRecipient - New recipient wallet; its ATA (per mint) receives future withdrawals.
|
|
5152
|
+
* @param marketType - Which recipient slot to update, `MarketType.PERP` or `MarketType.SPOT`.
|
|
5153
|
+
* @returns Transaction signature.
|
|
5154
|
+
*/
|
|
3737
5155
|
public async updateProtocolFeeRecipient(
|
|
3738
5156
|
protocolFeeRecipient: PublicKey,
|
|
3739
5157
|
marketType: MarketType
|
|
@@ -3747,6 +5165,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3747
5165
|
return txSig;
|
|
3748
5166
|
}
|
|
3749
5167
|
|
|
5168
|
+
/**
|
|
5169
|
+
* Builds the `updateProtocolFeeRecipient` instruction without sending it. See
|
|
5170
|
+
* `updateProtocolFeeRecipient`.
|
|
5171
|
+
* @returns The unsigned `updateProtocolFeeRecipient` instruction.
|
|
5172
|
+
*/
|
|
3750
5173
|
public async getUpdateProtocolFeeRecipientIx(
|
|
3751
5174
|
protocolFeeRecipient: PublicKey,
|
|
3752
5175
|
marketType: MarketType
|
|
@@ -3765,6 +5188,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3765
5188
|
);
|
|
3766
5189
|
}
|
|
3767
5190
|
|
|
5191
|
+
/**
|
|
5192
|
+
* Withdraws a spot market's accrued protocol fees (lending-interest + spot-liquidation
|
|
5193
|
+
* carveouts, tracked in `spotMarket.protocolFeePool`) from its vault to
|
|
5194
|
+
* `state.protocolFeeRecipientSpot`'s ATA. Requires `HotRole.FeeWithdraw` (cold, warm,
|
|
5195
|
+
* or the configured fee-withdraw hot key) — `this.wallet` must hold that role, since
|
|
5196
|
+
* `getWithdrawProtocolFeesSpotIx` signs as `this.wallet.publicKey` for both `payer`
|
|
5197
|
+
* and `authority`. The recipient ATA is created (`init_if_needed`) if missing. The
|
|
5198
|
+
* withdrawn amount is capped at whatever is actually available, and the vault must
|
|
5199
|
+
* still fully cover depositor backing afterward or the instruction fails.
|
|
5200
|
+
* @param marketIndex - Spot market to withdraw protocol fees from.
|
|
5201
|
+
* @param amount - Requested amount, the market's native token decimals (clamped down to the available balance on-chain).
|
|
5202
|
+
* @param txParams - Optional transaction-building overrides.
|
|
5203
|
+
* @returns Transaction signature.
|
|
5204
|
+
*/
|
|
3768
5205
|
public async withdrawProtocolFeesSpot(
|
|
3769
5206
|
marketIndex: number,
|
|
3770
5207
|
amount: BN,
|
|
@@ -3776,6 +5213,12 @@ export class AdminClient extends VelocityClient {
|
|
|
3776
5213
|
return txSig;
|
|
3777
5214
|
}
|
|
3778
5215
|
|
|
5216
|
+
/**
|
|
5217
|
+
* Builds the `withdrawProtocolFeesSpot` instruction without sending it. Also wires
|
|
5218
|
+
* up transfer-hook remaining accounts if the market's mint requires them. See
|
|
5219
|
+
* `withdrawProtocolFeesSpot`.
|
|
5220
|
+
* @returns The unsigned `withdrawProtocolFeesSpot` instruction.
|
|
5221
|
+
*/
|
|
3779
5222
|
public async getWithdrawProtocolFeesSpotIx(
|
|
3780
5223
|
marketIndex: number,
|
|
3781
5224
|
amount: BN
|
|
@@ -3825,6 +5268,18 @@ export class AdminClient extends VelocityClient {
|
|
|
3825
5268
|
);
|
|
3826
5269
|
}
|
|
3827
5270
|
|
|
5271
|
+
/**
|
|
5272
|
+
* Withdraws a perp market's accrued protocol fees (quote-denominated, tracked in
|
|
5273
|
+
* `perpMarket.protocolFeePool`) from the quote spot market's vault to
|
|
5274
|
+
* `state.protocolFeeRecipientPerp`'s ATA. Requires `HotRole.FeeWithdraw` — see
|
|
5275
|
+
* `withdrawProtocolFeesSpot` for the same signer/ATA/clamping/vault-invariant
|
|
5276
|
+
* behavior (this mirrors it against the perp market's quote-denominated pool
|
|
5277
|
+
* instead of a spot market's own token).
|
|
5278
|
+
* @param marketIndex - Perp market to withdraw protocol fees from.
|
|
5279
|
+
* @param amount - Requested amount, QUOTE_PRECISION (1e6) (clamped down to the available balance on-chain).
|
|
5280
|
+
* @param txParams - Optional transaction-building overrides.
|
|
5281
|
+
* @returns Transaction signature.
|
|
5282
|
+
*/
|
|
3828
5283
|
public async withdrawProtocolFeesPerp(
|
|
3829
5284
|
marketIndex: number,
|
|
3830
5285
|
amount: BN,
|
|
@@ -3836,6 +5291,12 @@ export class AdminClient extends VelocityClient {
|
|
|
3836
5291
|
return txSig;
|
|
3837
5292
|
}
|
|
3838
5293
|
|
|
5294
|
+
/**
|
|
5295
|
+
* Builds the `withdrawProtocolFeesPerp` instruction without sending it. Also wires
|
|
5296
|
+
* up transfer-hook remaining accounts if the quote market's mint requires them. See
|
|
5297
|
+
* `withdrawProtocolFeesPerp`.
|
|
5298
|
+
* @returns The unsigned `withdrawProtocolFeesPerp` instruction.
|
|
5299
|
+
*/
|
|
3839
5300
|
public async getWithdrawProtocolFeesPerpIx(
|
|
3840
5301
|
marketIndex: number,
|
|
3841
5302
|
amount: BN
|
|
@@ -3889,6 +5350,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3889
5350
|
);
|
|
3890
5351
|
}
|
|
3891
5352
|
|
|
5353
|
+
/**
|
|
5354
|
+
* Creates a market-local synthetic "oracle" account (`PrelaunchOracle`) for a perp market
|
|
5355
|
+
* that has no real price feed yet (e.g. a pre-launch/pre-listing market), seeded with an
|
|
5356
|
+
* admin-supplied price. Requires warm admin (`check_warm`). Set the market's `oracle` to
|
|
5357
|
+
* this account's address (via `updatePerpMarketOracle`, with a matching `OracleSource`) to
|
|
5358
|
+
* use it. `PrelaunchOracle::validate` runs at the end of the handler and throws
|
|
5359
|
+
* `InvalidOracle` if `price` or `maxPrice` end up `0` (both are zero-initialized and only
|
|
5360
|
+
* set when the corresponding argument is provided) or if `price > maxPrice` — in practice
|
|
5361
|
+
* both must be supplied and satisfy `price <= maxPrice`.
|
|
5362
|
+
* @param perpMarketIndex - Perp market this oracle backs; fixes the PDA seed.
|
|
5363
|
+
* @param price - Initial synthetic price, PRICE_PRECISION (1e6). Must be nonzero and <= `maxPrice`.
|
|
5364
|
+
* @param maxPrice - Ceiling the price is allowed to move to, PRICE_PRECISION (1e6). Must be nonzero and >= `price`.
|
|
5365
|
+
* @returns Transaction signature.
|
|
5366
|
+
*/
|
|
3892
5367
|
public async initializePrelaunchOracle(
|
|
3893
5368
|
perpMarketIndex: number,
|
|
3894
5369
|
price?: BN,
|
|
@@ -3908,6 +5383,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3908
5383
|
return txSig;
|
|
3909
5384
|
}
|
|
3910
5385
|
|
|
5386
|
+
/**
|
|
5387
|
+
* Builds the `initializePrelaunchOracle` instruction without sending it. See
|
|
5388
|
+
* `initializePrelaunchOracle`.
|
|
5389
|
+
* @returns The unsigned `initializePrelaunchOracle` instruction.
|
|
5390
|
+
*/
|
|
3911
5391
|
public async getInitializePrelaunchOracleIx(
|
|
3912
5392
|
perpMarketIndex: number,
|
|
3913
5393
|
price?: BN,
|
|
@@ -3935,6 +5415,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3935
5415
|
});
|
|
3936
5416
|
}
|
|
3937
5417
|
|
|
5418
|
+
/**
|
|
5419
|
+
* Updates a perp market's `PrelaunchOracle` price and/or ceiling. Requires warm admin
|
|
5420
|
+
* (`check_warm`). If `price` is provided, this **also directly overwrites the perp market's
|
|
5421
|
+
* mark-price TWAPs** (`lastMarkPriceTwap`, `lastMarkPriceTwap5min`, and clamps
|
|
5422
|
+
* `lastBidPriceTwap`/`lastAskPriceTwap` toward the new price) and their timestamp — a much
|
|
5423
|
+
* broader side effect than the field name suggests. `PrelaunchOracle::validate` re-runs at
|
|
5424
|
+
* the end and throws `InvalidOracle` if the resulting `price`/`maxPrice` are `0` or
|
|
5425
|
+
* `price > maxPrice`. Either argument omitted leaves that field (and, for `price`, the TWAPs)
|
|
5426
|
+
* unchanged.
|
|
5427
|
+
* @param perpMarketIndex - Perp market whose prelaunch oracle to update.
|
|
5428
|
+
* @param price - New synthetic price, PRICE_PRECISION (1e6). Also overwrites the market's mark-price TWAPs when provided. Omit to leave unchanged.
|
|
5429
|
+
* @param maxPrice - New price ceiling, PRICE_PRECISION (1e6). Omit to leave unchanged.
|
|
5430
|
+
* @returns Transaction signature.
|
|
5431
|
+
*/
|
|
3938
5432
|
public async updatePrelaunchOracleParams(
|
|
3939
5433
|
perpMarketIndex: number,
|
|
3940
5434
|
price?: BN,
|
|
@@ -3954,6 +5448,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3954
5448
|
return txSig;
|
|
3955
5449
|
}
|
|
3956
5450
|
|
|
5451
|
+
/**
|
|
5452
|
+
* Builds the `updatePrelaunchOracleParams` instruction without sending it. See
|
|
5453
|
+
* `updatePrelaunchOracleParams`.
|
|
5454
|
+
* @returns The unsigned `updatePrelaunchOracleParams` instruction.
|
|
5455
|
+
*/
|
|
3957
5456
|
public async getUpdatePrelaunchOracleParamsIx(
|
|
3958
5457
|
perpMarketIndex: number,
|
|
3959
5458
|
price?: BN,
|
|
@@ -3985,6 +5484,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3985
5484
|
});
|
|
3986
5485
|
}
|
|
3987
5486
|
|
|
5487
|
+
/**
|
|
5488
|
+
* Closes a perp market's `PrelaunchOracle` account and refunds rent to the admin. Requires
|
|
5489
|
+
* warm admin (`check_warm`). On-chain, throws `DefaultError` if the oracle is still the
|
|
5490
|
+
* market's active `oracle` — repoint the market to a different oracle first (via
|
|
5491
|
+
* `updatePerpMarketOracle`).
|
|
5492
|
+
*
|
|
5493
|
+
* **Currently broken**: `getDeletePrelaunchOracleIx` builds a `PrelaunchOracleParams`-shaped
|
|
5494
|
+
* object (`{ perpMarketIndex, price, maxPrice }`) as the instruction argument, but the
|
|
5495
|
+
* on-chain `deletePrelaunchOracle` instruction (and its IDL) takes a single `u16`
|
|
5496
|
+
* `perpMarketIndex` scalar, not that object — this throws when the Borsh encoder tries to
|
|
5497
|
+
* serialize an object where a `u16` is expected.
|
|
5498
|
+
* @param perpMarketIndex - Perp market whose prelaunch oracle to delete; must not be the market's current oracle.
|
|
5499
|
+
* @returns Transaction signature (in practice: throws before a transaction is built).
|
|
5500
|
+
*/
|
|
3988
5501
|
public async deletePrelaunchOracle(
|
|
3989
5502
|
perpMarketIndex: number
|
|
3990
5503
|
): Promise<TransactionSignature> {
|
|
@@ -3999,6 +5512,12 @@ export class AdminClient extends VelocityClient {
|
|
|
3999
5512
|
return txSig;
|
|
4000
5513
|
}
|
|
4001
5514
|
|
|
5515
|
+
/**
|
|
5516
|
+
* Builds the (currently broken) `deletePrelaunchOracle` instruction. See
|
|
5517
|
+
* `deletePrelaunchOracle` — throws because the argument shape doesn't match the IDL's `u16`.
|
|
5518
|
+
* `price`/`maxPrice` are accepted but unused; the underlying call never reads them.
|
|
5519
|
+
* @returns Never resolves successfully; throws when the malformed instruction args are encoded.
|
|
5520
|
+
*/
|
|
4002
5521
|
public async getDeletePrelaunchOracleIx(
|
|
4003
5522
|
perpMarketIndex: number,
|
|
4004
5523
|
price?: BN,
|
|
@@ -4030,6 +5549,19 @@ export class AdminClient extends VelocityClient {
|
|
|
4030
5549
|
});
|
|
4031
5550
|
}
|
|
4032
5551
|
|
|
5552
|
+
/**
|
|
5553
|
+
* Overrides how many slots of oracle delay a perp market tolerates before its "low-risk"
|
|
5554
|
+
* oracle-staleness check (`OracleValidity`'s `is_stale_for_amm_low_risk`, consumed by margin
|
|
5555
|
+
* calculations, order fills, AMM repeg/refresh, and the AMM cache) trips. Gated on
|
|
5556
|
+
* `HotAdminUpdatePerpMarket`, whose account constraint is actually `check_warm` — this
|
|
5557
|
+
* requires **warm** admin (or cold), not a dedicated hot key, despite the struct's name.
|
|
5558
|
+
* `0` (the default) means no override — the market falls back to the global
|
|
5559
|
+
* `state.oracleGuardRails.validity.slotsBeforeStaleForAmm`; a nonzero value is clamped to
|
|
5560
|
+
* `>= 0` and used as the slot threshold directly.
|
|
5561
|
+
* @param perpMarketIndex - Perp market to update.
|
|
5562
|
+
* @param oracleLowRiskSlotDelayOverride - Slots of oracle delay tolerated for low-risk AMM actions before staleness trips. `0` = use the global default; negative values are treated as `0`.
|
|
5563
|
+
* @returns Transaction signature.
|
|
5564
|
+
*/
|
|
4033
5565
|
public async updatePerpMarketOracleLowRiskSlotDelayOverride(
|
|
4034
5566
|
perpMarketIndex: number,
|
|
4035
5567
|
oracleLowRiskSlotDelayOverride: number
|
|
@@ -4047,6 +5579,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4047
5579
|
return txSig;
|
|
4048
5580
|
}
|
|
4049
5581
|
|
|
5582
|
+
/**
|
|
5583
|
+
* Builds the `updatePerpMarketOracleLowRiskSlotDelayOverride` instruction without sending it.
|
|
5584
|
+
* See `updatePerpMarketOracleLowRiskSlotDelayOverride`.
|
|
5585
|
+
* @returns The unsigned `updatePerpMarketOracleLowRiskSlotDelayOverride` instruction.
|
|
5586
|
+
*/
|
|
4050
5587
|
public async getUpdatePerpMarketOracleLowRiskSlotDelayOverrideIx(
|
|
4051
5588
|
perpMarketIndex: number,
|
|
4052
5589
|
oracleLowRiskSlotDelayOverride: number
|
|
@@ -4070,6 +5607,18 @@ export class AdminClient extends VelocityClient {
|
|
|
4070
5607
|
);
|
|
4071
5608
|
}
|
|
4072
5609
|
|
|
5610
|
+
/**
|
|
5611
|
+
* Overrides how many slots of oracle delay a perp market tolerates before its "immediate"
|
|
5612
|
+
* per-fill staleness check trips (used for AMM-immediate fills; the on-chain field is
|
|
5613
|
+
* `perpMarket.oracleSlotDelayOverride`, default `-1`). Gated on `HotAdminUpdatePerpMarket`,
|
|
5614
|
+
* whose account constraint is actually `check_warm` — this requires **warm** admin (or
|
|
5615
|
+
* cold), not a dedicated hot key. `0` means the market is always treated as stale for
|
|
5616
|
+
* immediate AMM actions; any other value is clamped to `>= 0` and used as the slot threshold
|
|
5617
|
+
* (delay > threshold is stale).
|
|
5618
|
+
* @param perpMarketIndex - Perp market to update.
|
|
5619
|
+
* @param oracleSlotDelay - Slots of oracle delay tolerated before the immediate-fill staleness check trips. `0` = always stale; negative input is clamped to `0` on-chain.
|
|
5620
|
+
* @returns Transaction signature.
|
|
5621
|
+
*/
|
|
4073
5622
|
public async updatePerpMarketOracleSlotDelayOverride(
|
|
4074
5623
|
perpMarketIndex: number,
|
|
4075
5624
|
oracleSlotDelay: number
|
|
@@ -4087,6 +5636,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4087
5636
|
return txSig;
|
|
4088
5637
|
}
|
|
4089
5638
|
|
|
5639
|
+
/**
|
|
5640
|
+
* Builds the `updatePerpMarketOracleSlotDelayOverride` instruction without sending it. See
|
|
5641
|
+
* `updatePerpMarketOracleSlotDelayOverride`.
|
|
5642
|
+
* @returns The unsigned `updatePerpMarketOracleSlotDelayOverride` instruction.
|
|
5643
|
+
*/
|
|
4090
5644
|
public async getUpdatePerpMarketOracleSlotDelayOverrideIx(
|
|
4091
5645
|
perpMarketIndex: number,
|
|
4092
5646
|
oracleSlotDelay: number
|
|
@@ -4110,6 +5664,20 @@ export class AdminClient extends VelocityClient {
|
|
|
4110
5664
|
);
|
|
4111
5665
|
}
|
|
4112
5666
|
|
|
5667
|
+
/**
|
|
5668
|
+
* Sets a perp market's manual spread-widening scalars. Gated on `HotAdminUpdatePerpMarket`,
|
|
5669
|
+
* whose account constraint is actually `check_warm` — this requires **warm** admin (or
|
|
5670
|
+
* cold), not a dedicated hot key. **`referencePriceOffset` is accepted for wire/IDL
|
|
5671
|
+
* compatibility but ignored on-chain** — `amm.referencePriceOffset` is a per-crank output
|
|
5672
|
+
* recomputed from inventory and market stats by
|
|
5673
|
+
* `crate::vlp::amm::math::spread::update_amm_quote_state`, not an admin-settable value; pass
|
|
5674
|
+
* any value.
|
|
5675
|
+
* @param perpMarketIndex - Perp market to update.
|
|
5676
|
+
* @param ammSpreadAdjustment - Signed scalar on the AMM's base spread, same convention as `fee_adjustment` (-100 = spread scaled to 0, 100 = spread doubled, 0 = no adjustment).
|
|
5677
|
+
* @param ammInventorySpreadAdjustment - Signed scalar on the inventory-skew component of the spread, same -100..100 convention.
|
|
5678
|
+
* @param referencePriceOffset - Ignored on-chain; retained only for instruction-argument compatibility.
|
|
5679
|
+
* @returns Transaction signature.
|
|
5680
|
+
*/
|
|
4113
5681
|
public async updatePerpMarketAmmSpreadAdjustment(
|
|
4114
5682
|
perpMarketIndex: number,
|
|
4115
5683
|
ammSpreadAdjustment: number,
|
|
@@ -4131,6 +5699,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4131
5699
|
return txSig;
|
|
4132
5700
|
}
|
|
4133
5701
|
|
|
5702
|
+
/**
|
|
5703
|
+
* Builds the `updatePerpMarketAmmSpreadAdjustment` instruction without sending it. See
|
|
5704
|
+
* `updatePerpMarketAmmSpreadAdjustment`.
|
|
5705
|
+
* @returns The unsigned `updatePerpMarketAmmSpreadAdjustment` instruction.
|
|
5706
|
+
*/
|
|
4134
5707
|
public async getUpdatePerpMarketAmmSpreadAdjustmentIx(
|
|
4135
5708
|
perpMarketIndex: number,
|
|
4136
5709
|
ammSpreadAdjustment: number,
|
|
@@ -4158,6 +5731,16 @@ export class AdminClient extends VelocityClient {
|
|
|
4158
5731
|
);
|
|
4159
5732
|
}
|
|
4160
5733
|
|
|
5734
|
+
/**
|
|
5735
|
+
* Sets how much a perp market's paying-side spread widens while the vAMM's inventory is
|
|
5736
|
+
* paying funding: `amm.fundingBiasSensitivity = s` gives multiplier `β(f) = 1 + s/100 * ρ(f)`
|
|
5737
|
+
* (at full ramp, `ρ = 1`: 50 -> 1.5x, 100 -> 2x). Gated on `HotAdminUpdatePerpMarket`, whose
|
|
5738
|
+
* account constraint is actually `check_warm` — this requires **warm** admin (or cold), not
|
|
5739
|
+
* a dedicated hot key.
|
|
5740
|
+
* @param perpMarketIndex - Perp market to update.
|
|
5741
|
+
* @param fundingBiasSensitivity - Sensitivity `s`, in hundredths (value/100 is the multiplier slope); `0` disables the bias. `u8` range caps `s` at 2.55.
|
|
5742
|
+
* @returns Transaction signature.
|
|
5743
|
+
*/
|
|
4161
5744
|
public async updatePerpMarketFundingBiasSensitivity(
|
|
4162
5745
|
perpMarketIndex: number,
|
|
4163
5746
|
fundingBiasSensitivity: number
|
|
@@ -4175,6 +5758,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4175
5758
|
return txSig;
|
|
4176
5759
|
}
|
|
4177
5760
|
|
|
5761
|
+
/**
|
|
5762
|
+
* Builds the `updatePerpMarketFundingBiasSensitivity` instruction without sending it. See
|
|
5763
|
+
* `updatePerpMarketFundingBiasSensitivity`.
|
|
5764
|
+
* @returns The unsigned `updatePerpMarketFundingBiasSensitivity` instruction.
|
|
5765
|
+
*/
|
|
4178
5766
|
public async getUpdatePerpMarketFundingBiasSensitivityIx(
|
|
4179
5767
|
perpMarketIndex: number,
|
|
4180
5768
|
fundingBiasSensitivity: number
|
|
@@ -4198,6 +5786,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4198
5786
|
);
|
|
4199
5787
|
}
|
|
4200
5788
|
|
|
5789
|
+
/**
|
|
5790
|
+
* Creates the zero'd `PythLazerOracle` PDA for a Pyth Lazer feed id (one-time setup
|
|
5791
|
+
* before that feed can be pushed to via `updatePythLazerOracle`/keeper cranks).
|
|
5792
|
+
* Requires warm admin (`check_warm`, `InitPythLazerOracle` context). Idempotent per
|
|
5793
|
+
* `feedId` — a second call for the same id fails (`init` on an existing PDA).
|
|
5794
|
+
* @param feedId - Pyth Lazer feed id; seeds the `PythLazerOracle` PDA (`getPythLazerOraclePublicKey`).
|
|
5795
|
+
* @returns Transaction signature.
|
|
5796
|
+
*/
|
|
4201
5797
|
public async initializePythLazerOracle(
|
|
4202
5798
|
feedId: number
|
|
4203
5799
|
): Promise<TransactionSignature> {
|
|
@@ -4209,6 +5805,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4209
5805
|
return txSig;
|
|
4210
5806
|
}
|
|
4211
5807
|
|
|
5808
|
+
/**
|
|
5809
|
+
* Builds the `initializePythLazerOracle` instruction without sending it. See
|
|
5810
|
+
* `initializePythLazerOracle`.
|
|
5811
|
+
* @returns The unsigned `initializePythLazerOracle` instruction.
|
|
5812
|
+
*/
|
|
4212
5813
|
public async getInitializePythLazerOracleIx(
|
|
4213
5814
|
feedId: number
|
|
4214
5815
|
): Promise<TransactionInstruction> {
|
|
@@ -4228,6 +5829,18 @@ export class AdminClient extends VelocityClient {
|
|
|
4228
5829
|
});
|
|
4229
5830
|
}
|
|
4230
5831
|
|
|
5832
|
+
/**
|
|
5833
|
+
* Deposits tokens from an admin-controlled token account directly into a user's
|
|
5834
|
+
* spot balance, recorded as a `DepositExplanation.Reward` deposit (e.g. crediting a
|
|
5835
|
+
* promotional/reward balance without the user signing). Requires
|
|
5836
|
+
* `HotRole.VaultDeposit` (cold, warm, or the configured vault-deposit hot key) —
|
|
5837
|
+
* `this.wallet` signs as `admin` and must hold that role.
|
|
5838
|
+
* @param marketIndex - Spot market to deposit into.
|
|
5839
|
+
* @param amount - Deposit amount, the market's native token decimals.
|
|
5840
|
+
* @param depositUserAccount - User account (`User` PDA pubkey) to credit.
|
|
5841
|
+
* @param adminTokenAccount - Source token account (must belong to `this.wallet`). Defaults to `this.wallet`'s associated token account for the market's mint.
|
|
5842
|
+
* @returns Transaction signature.
|
|
5843
|
+
*/
|
|
4231
5844
|
public async adminDeposit(
|
|
4232
5845
|
marketIndex: number,
|
|
4233
5846
|
amount: BN,
|
|
@@ -4245,6 +5858,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4245
5858
|
return txSig;
|
|
4246
5859
|
}
|
|
4247
5860
|
|
|
5861
|
+
/**
|
|
5862
|
+
* Builds the `adminDeposit` instruction without sending it. Also wires up the
|
|
5863
|
+
* mint and transfer-hook remaining accounts the deposit needs. See `adminDeposit`.
|
|
5864
|
+
* @returns The unsigned `adminDeposit` instruction.
|
|
5865
|
+
*/
|
|
4248
5866
|
public async getAdminDepositIx(
|
|
4249
5867
|
marketIndex: number,
|
|
4250
5868
|
amount: BN,
|
|
@@ -4281,6 +5899,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4281
5899
|
});
|
|
4282
5900
|
}
|
|
4283
5901
|
|
|
5902
|
+
/**
|
|
5903
|
+
* Resets a perp market's push-oracle ("MM oracle") state — `marketStats.mmOraclePrice`,
|
|
5904
|
+
* `mmOracleSequenceId`, and `mmOracleSlot` — all to `0`. Requires warm admin (the
|
|
5905
|
+
* `HotAdminUpdatePerpMarket` context's `check_warm` constraint — despite the name,
|
|
5906
|
+
* no dedicated hot role is wired to it; see `updatePerpMarketCurveUpdateIntensity`
|
|
5907
|
+
* for the same gate). Use to force the next `updateMmOracleNative` push to be
|
|
5908
|
+
* treated as a fresh bootstrap (its step-size cap is skipped when the previous
|
|
5909
|
+
* price is `0`).
|
|
5910
|
+
* @param marketIndex - Perp market whose MM oracle fields to zero.
|
|
5911
|
+
* @returns Transaction signature.
|
|
5912
|
+
*/
|
|
4284
5913
|
public async zeroMMOracleFields(
|
|
4285
5914
|
marketIndex: number
|
|
4286
5915
|
): Promise<TransactionSignature> {
|
|
@@ -4294,6 +5923,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4294
5923
|
return txSig;
|
|
4295
5924
|
}
|
|
4296
5925
|
|
|
5926
|
+
/**
|
|
5927
|
+
* Builds the `zeroMMOracleFields` instruction without sending it. See
|
|
5928
|
+
* `zeroMMOracleFields`.
|
|
5929
|
+
* @returns The unsigned `zeroMmOracleFields` instruction.
|
|
5930
|
+
*/
|
|
4297
5931
|
public async getZeroMMOracleFieldsIx(
|
|
4298
5932
|
marketIndex: number
|
|
4299
5933
|
): Promise<TransactionInstruction> {
|
|
@@ -4311,6 +5945,18 @@ export class AdminClient extends VelocityClient {
|
|
|
4311
5945
|
});
|
|
4312
5946
|
}
|
|
4313
5947
|
|
|
5948
|
+
/**
|
|
5949
|
+
* Toggles the `FeatureBitFlags.MM_ORACLE_UPDATE` bit on `state.featureBitFlags`,
|
|
5950
|
+
* which gates the native (non-Anchor) `updateMmOracleNative` push-oracle
|
|
5951
|
+
* dispatch — the on-chain handler asserts this bit before accepting a push.
|
|
5952
|
+
* Requires `HotRole.FeatureFlag` (`HotAdminUpdateState`'s `check_hot`) to disable,
|
|
5953
|
+
* but **enabling requires `state.coldAdmin` specifically** — the handler rejects
|
|
5954
|
+
* `enable: true` from any other signer, even one otherwise authorised for the
|
|
5955
|
+
* `FeatureFlag` role, so a compromised feature-flag hot key can only trip this
|
|
5956
|
+
* kill switch, never clear it.
|
|
5957
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
5958
|
+
* @returns Transaction signature.
|
|
5959
|
+
*/
|
|
4314
5960
|
public async updateFeatureBitFlagsMMOracle(
|
|
4315
5961
|
enable: boolean
|
|
4316
5962
|
): Promise<TransactionSignature> {
|
|
@@ -4323,6 +5969,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4323
5969
|
return txSig;
|
|
4324
5970
|
}
|
|
4325
5971
|
|
|
5972
|
+
/**
|
|
5973
|
+
* Builds the `updateFeatureBitFlagsMMOracle` instruction without sending it. See
|
|
5974
|
+
* `updateFeatureBitFlagsMMOracle`.
|
|
5975
|
+
* @returns The unsigned `updateFeatureBitFlagsMmOracle` instruction.
|
|
5976
|
+
*/
|
|
4326
5977
|
public async getUpdateFeatureBitFlagsMMOracleIx(
|
|
4327
5978
|
enable: boolean
|
|
4328
5979
|
): Promise<TransactionInstruction> {
|
|
@@ -4339,6 +5990,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4339
5990
|
);
|
|
4340
5991
|
}
|
|
4341
5992
|
|
|
5993
|
+
/**
|
|
5994
|
+
* Toggles the `FeatureBitFlags.BUILDER_CODES` bit on `state.featureBitFlags`
|
|
5995
|
+
* (gates builder-code fee-attribution instructions protocol-wide). Same
|
|
5996
|
+
* kill-switch gating as `updateFeatureBitFlagsMMOracle`: `HotRole.FeatureFlag` may
|
|
5997
|
+
* disable, only `coldAdmin` may enable.
|
|
5998
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
5999
|
+
* @returns Transaction signature.
|
|
6000
|
+
*/
|
|
4342
6001
|
public async updateFeatureBitFlagsBuilderCodes(
|
|
4343
6002
|
enable: boolean
|
|
4344
6003
|
): Promise<TransactionSignature> {
|
|
@@ -4351,6 +6010,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4351
6010
|
return txSig;
|
|
4352
6011
|
}
|
|
4353
6012
|
|
|
6013
|
+
/**
|
|
6014
|
+
* Builds the `updateFeatureBitFlagsBuilderCodes` instruction without sending it.
|
|
6015
|
+
* See `updateFeatureBitFlagsBuilderCodes`.
|
|
6016
|
+
* @returns The unsigned `updateFeatureBitFlagsBuilderCodes` instruction.
|
|
6017
|
+
*/
|
|
4354
6018
|
public async getUpdateFeatureBitFlagsBuilderCodesIx(
|
|
4355
6019
|
enable: boolean
|
|
4356
6020
|
): Promise<TransactionInstruction> {
|
|
@@ -4364,6 +6028,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4364
6028
|
});
|
|
4365
6029
|
}
|
|
4366
6030
|
|
|
6031
|
+
/**
|
|
6032
|
+
* @deprecated There is no `BuilderReferral` bit in the on-chain `FeatureBitFlags`
|
|
6033
|
+
* enum (only `MmOracleUpdate`, `MedianTriggerPrice`, `BuilderCodes` exist) and no
|
|
6034
|
+
* `update_feature_bit_flags_builder_referral` instruction is defined in the
|
|
6035
|
+
* program or present in the IDL. Calling this (or
|
|
6036
|
+
* `getUpdateFeatureBitFlagsBuilderReferralIx`) throws at runtime — hence the
|
|
6037
|
+
* `as any` cast on `this.program.instruction` used to bypass the TS type check.
|
|
6038
|
+
* Do not call until (and unless) a matching on-chain instruction ships.
|
|
6039
|
+
* @param enable - Intended flag state (unused while dead).
|
|
6040
|
+
* @returns Transaction signature (never reached).
|
|
6041
|
+
*/
|
|
4367
6042
|
public async updateFeatureBitFlagsBuilderReferral(
|
|
4368
6043
|
enable: boolean
|
|
4369
6044
|
): Promise<TransactionSignature> {
|
|
@@ -4378,6 +6053,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4378
6053
|
return txSig;
|
|
4379
6054
|
}
|
|
4380
6055
|
|
|
6056
|
+
/**
|
|
6057
|
+
* @deprecated See `updateFeatureBitFlagsBuilderReferral` — no matching instruction
|
|
6058
|
+
* exists on-chain or in the IDL; this throws at runtime.
|
|
6059
|
+
* @returns Never resolves successfully.
|
|
6060
|
+
*/
|
|
4381
6061
|
public async getUpdateFeatureBitFlagsBuilderReferralIx(
|
|
4382
6062
|
enable: boolean
|
|
4383
6063
|
): Promise<TransactionInstruction> {
|
|
@@ -4393,6 +6073,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4393
6073
|
});
|
|
4394
6074
|
}
|
|
4395
6075
|
|
|
6076
|
+
/**
|
|
6077
|
+
* Toggles the `FeatureBitFlags.MEDIAN_TRIGGER_PRICE` bit on
|
|
6078
|
+
* `state.featureBitFlags` (gates using a median of price sources for trigger-order
|
|
6079
|
+
* evaluation). Same kill-switch gating as `updateFeatureBitFlagsMMOracle`:
|
|
6080
|
+
* `HotRole.FeatureFlag` may disable, only `coldAdmin` may enable.
|
|
6081
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
6082
|
+
* @returns Transaction signature.
|
|
6083
|
+
*/
|
|
4396
6084
|
public async updateFeatureBitFlagsMedianTriggerPrice(
|
|
4397
6085
|
enable: boolean
|
|
4398
6086
|
): Promise<TransactionSignature> {
|
|
@@ -4406,6 +6094,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4406
6094
|
return txSig;
|
|
4407
6095
|
}
|
|
4408
6096
|
|
|
6097
|
+
/**
|
|
6098
|
+
* Builds the `updateFeatureBitFlagsMedianTriggerPrice` instruction without sending
|
|
6099
|
+
* it. See `updateFeatureBitFlagsMedianTriggerPrice`.
|
|
6100
|
+
* @returns The unsigned `updateFeatureBitFlagsMedianTriggerPrice` instruction.
|
|
6101
|
+
*/
|
|
4409
6102
|
public async getUpdateFeatureBitFlagsMedianTriggerPriceIx(
|
|
4410
6103
|
enable: boolean
|
|
4411
6104
|
): Promise<TransactionInstruction> {
|
|
@@ -4422,6 +6115,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4422
6115
|
);
|
|
4423
6116
|
}
|
|
4424
6117
|
|
|
6118
|
+
/**
|
|
6119
|
+
* Toggles the `LpPoolFeatureBitFlags.SettleLpPool`-equivalent bit on
|
|
6120
|
+
* `state.lpPoolFeatureBitFlags` (gates `settlePerpToLpPool`/LP-pool settlement
|
|
6121
|
+
* protocol-wide). Same kill-switch gating as `updateFeatureBitFlagsMMOracle`:
|
|
6122
|
+
* `HotRole.FeatureFlag` may disable, only `coldAdmin` may enable.
|
|
6123
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
6124
|
+
* @returns Transaction signature.
|
|
6125
|
+
*/
|
|
4425
6126
|
public async updateFeatureBitFlagsSettleLpPool(
|
|
4426
6127
|
enable: boolean
|
|
4427
6128
|
): Promise<TransactionSignature> {
|
|
@@ -4434,6 +6135,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4434
6135
|
return txSig;
|
|
4435
6136
|
}
|
|
4436
6137
|
|
|
6138
|
+
/**
|
|
6139
|
+
* Builds the `updateFeatureBitFlagsSettleLpPool` instruction without sending it.
|
|
6140
|
+
* See `updateFeatureBitFlagsSettleLpPool`.
|
|
6141
|
+
* @returns The unsigned `updateFeatureBitFlagsSettleLpPool` instruction.
|
|
6142
|
+
*/
|
|
4437
6143
|
public async getUpdateFeatureBitFlagsSettleLpPoolIx(
|
|
4438
6144
|
enable: boolean
|
|
4439
6145
|
): Promise<TransactionInstruction> {
|
|
@@ -4450,6 +6156,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4450
6156
|
);
|
|
4451
6157
|
}
|
|
4452
6158
|
|
|
6159
|
+
/**
|
|
6160
|
+
* Toggles the LP-pool swap-enabled bit on `state.lpPoolFeatureBitFlags` (gates
|
|
6161
|
+
* `lpPoolSwap`/begin-end swap flows protocol-wide). Same kill-switch gating as
|
|
6162
|
+
* `updateFeatureBitFlagsMMOracle`: `HotRole.FeatureFlag` may disable, only
|
|
6163
|
+
* `coldAdmin` may enable.
|
|
6164
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
6165
|
+
* @returns Transaction signature.
|
|
6166
|
+
*/
|
|
4453
6167
|
public async updateFeatureBitFlagsSwapLpPool(
|
|
4454
6168
|
enable: boolean
|
|
4455
6169
|
): Promise<TransactionSignature> {
|
|
@@ -4462,6 +6176,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4462
6176
|
return txSig;
|
|
4463
6177
|
}
|
|
4464
6178
|
|
|
6179
|
+
/**
|
|
6180
|
+
* Builds the `updateFeatureBitFlagsSwapLpPool` instruction without sending it. See
|
|
6181
|
+
* `updateFeatureBitFlagsSwapLpPool`.
|
|
6182
|
+
* @returns The unsigned `updateFeatureBitFlagsSwapLpPool` instruction.
|
|
6183
|
+
*/
|
|
4465
6184
|
public async getUpdateFeatureBitFlagsSwapLpPoolIx(
|
|
4466
6185
|
enable: boolean
|
|
4467
6186
|
): Promise<TransactionInstruction> {
|
|
@@ -4478,6 +6197,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4478
6197
|
);
|
|
4479
6198
|
}
|
|
4480
6199
|
|
|
6200
|
+
/**
|
|
6201
|
+
* Toggles the LP-pool mint/redeem-enabled bit on `state.lpPoolFeatureBitFlags`
|
|
6202
|
+
* (gates `lpPoolAddLiquidity`/`lpPoolRemoveLiquidity` protocol-wide). Same
|
|
6203
|
+
* kill-switch gating as `updateFeatureBitFlagsMMOracle`: `HotRole.FeatureFlag` may
|
|
6204
|
+
* disable, only `coldAdmin` may enable.
|
|
6205
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
6206
|
+
* @returns Transaction signature.
|
|
6207
|
+
*/
|
|
4481
6208
|
public async updateFeatureBitFlagsMintRedeemLpPool(
|
|
4482
6209
|
enable: boolean
|
|
4483
6210
|
): Promise<TransactionSignature> {
|
|
@@ -4490,6 +6217,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4490
6217
|
return txSig;
|
|
4491
6218
|
}
|
|
4492
6219
|
|
|
6220
|
+
/**
|
|
6221
|
+
* Builds the `updateFeatureBitFlagsMintRedeemLpPool` instruction without sending
|
|
6222
|
+
* it. See `updateFeatureBitFlagsMintRedeemLpPool`.
|
|
6223
|
+
* @returns The unsigned `updateFeatureBitFlagsMintRedeemLpPool` instruction.
|
|
6224
|
+
*/
|
|
4493
6225
|
public async getUpdateFeatureBitFlagsMintRedeemLpPoolIx(
|
|
4494
6226
|
enable: boolean
|
|
4495
6227
|
): Promise<TransactionInstruction> {
|
|
@@ -4506,6 +6238,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4506
6238
|
);
|
|
4507
6239
|
}
|
|
4508
6240
|
|
|
6241
|
+
/**
|
|
6242
|
+
* Sets a user's `UserStats.pausedOperations` bitmask. Reachable by cold, warm,
|
|
6243
|
+
* `HotRole.UserFlag`, or `pauseAdmin` (`PauseAdminUpdateUserStats`'s constraint
|
|
6244
|
+
* ORs `check_pause` with `check_hot(.., UserFlag)`). A caller authorised only via
|
|
6245
|
+
* `pauseAdmin` (i.e. not cold/warm/`UserFlag`) may add pause bits but never clear
|
|
6246
|
+
* one; cold/warm/`UserFlag` may set any value. The `admin` account below defaults
|
|
6247
|
+
* to `coldAdmin`; other roles must override it with their own pubkey.
|
|
6248
|
+
* @param authority - Wallet authority whose `UserStats` PDA to update (derives the PDA).
|
|
6249
|
+
* @param pausedOperations - New pause bitmask for the user's stats account.
|
|
6250
|
+
* @returns Transaction signature.
|
|
6251
|
+
*/
|
|
4509
6252
|
public async adminUpdateUserStatsPausedOperations(
|
|
4510
6253
|
authority: PublicKey,
|
|
4511
6254
|
pausedOperations: number
|
|
@@ -4522,6 +6265,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4522
6265
|
return txSig;
|
|
4523
6266
|
}
|
|
4524
6267
|
|
|
6268
|
+
/**
|
|
6269
|
+
* Builds the `adminUpdateUserStatsPausedOperations` instruction without sending
|
|
6270
|
+
* it. See `adminUpdateUserStatsPausedOperations`.
|
|
6271
|
+
* @returns The unsigned `adminUpdateUserStatsPausedOperations` instruction.
|
|
6272
|
+
*/
|
|
4525
6273
|
public async getAdminUpdateUserStatsPausedOperationsIx(
|
|
4526
6274
|
authority: PublicKey,
|
|
4527
6275
|
pausedOperations: number
|
|
@@ -4543,6 +6291,21 @@ export class AdminClient extends VelocityClient {
|
|
|
4543
6291
|
);
|
|
4544
6292
|
}
|
|
4545
6293
|
|
|
6294
|
+
/**
|
|
6295
|
+
* Creates a new LP pool: mints its 6-decimal LP-token mint (fresh `mint` keypair,
|
|
6296
|
+
* mint authority set to the `lpPool` PDA), then initializes the `LPPool` account
|
|
6297
|
+
* plus its (initially empty) `AmmConstituentMapping`, `ConstituentTargetBase`, and
|
|
6298
|
+
* `ConstituentCorrelations` side accounts. Requires warm admin (`check_warm`).
|
|
6299
|
+
* Constituents (backing spot-market assets) are added afterward via
|
|
6300
|
+
* `initializeConstituent`.
|
|
6301
|
+
* @param lpPoolId - New pool's id byte; seeds the `LPPool` PDA (`getLpPoolPublicKey`).
|
|
6302
|
+
* @param minMintFee - Minimum fee floor charged on mint, signed, PERCENTAGE_PRECISION (1e6).
|
|
6303
|
+
* @param maxAum - AUM cap above which minting new LP tokens is rejected, QUOTE_PRECISION (1e6).
|
|
6304
|
+
* @param maxSettleQuoteAmountPerMarket - Per-perp-market cap on quote settled into/out of the pool per settlement, QUOTE_PRECISION (1e6).
|
|
6305
|
+
* @param mint - Fresh keypair for the pool's LP-token mint; funded and initialized by this call, and must co-sign.
|
|
6306
|
+
* @param whitelistMint - Optional token that gates who may mint/redeem this pool's LP token (see `updateLpPoolParams`). Defaults to `PublicKey.default` (no gating).
|
|
6307
|
+
* @returns Transaction signature.
|
|
6308
|
+
*/
|
|
4546
6309
|
public async initializeLpPool(
|
|
4547
6310
|
lpPoolId: number,
|
|
4548
6311
|
minMintFee: BN,
|
|
@@ -4564,6 +6327,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4564
6327
|
return txSig;
|
|
4565
6328
|
}
|
|
4566
6329
|
|
|
6330
|
+
/**
|
|
6331
|
+
* Builds the `createAccount` + `initializeMint2` + `initializeLpPool` instructions
|
|
6332
|
+
* without sending them. See `initializeLpPool`.
|
|
6333
|
+
* @returns The unsigned instructions (mint account creation, mint init, pool init) in order; `mint` must also sign the transaction.
|
|
6334
|
+
*/
|
|
4567
6335
|
public async getInitializeLpPoolIx(
|
|
4568
6336
|
lpPoolId: number,
|
|
4569
6337
|
minMintFee: BN,
|
|
@@ -4636,6 +6404,18 @@ export class AdminClient extends VelocityClient {
|
|
|
4636
6404
|
];
|
|
4637
6405
|
}
|
|
4638
6406
|
|
|
6407
|
+
/**
|
|
6408
|
+
* Adds a new constituent (backing spot-market asset) to an existing LP pool:
|
|
6409
|
+
* creates its `Constituent` PDA + token vault, appends a slot to
|
|
6410
|
+
* `ConstituentTargetBase`, and records its correlation row in
|
|
6411
|
+
* `ConstituentCorrelations`. Requires warm admin (`check_warm`). On-chain,
|
|
6412
|
+
* `newConstituentCorrelations`'s length must equal the pool's current constituent
|
|
6413
|
+
* count *before* this call (one correlation entry per existing constituent); the
|
|
6414
|
+
* new constituent's `constituentIndex` is assigned as the next sequential index.
|
|
6415
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
6416
|
+
* @param initializeConstituentParams - Constituent configuration; see `InitializeConstituentParams` for per-field precision.
|
|
6417
|
+
* @returns Transaction signature.
|
|
6418
|
+
*/
|
|
4639
6419
|
public async initializeConstituent(
|
|
4640
6420
|
lpPoolId: number,
|
|
4641
6421
|
initializeConstituentParams: InitializeConstituentParams
|
|
@@ -4649,6 +6429,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4649
6429
|
return txSig;
|
|
4650
6430
|
}
|
|
4651
6431
|
|
|
6432
|
+
/**
|
|
6433
|
+
* Builds the `initializeConstituent` instruction without sending it. See
|
|
6434
|
+
* `initializeConstituent`.
|
|
6435
|
+
* @returns The unsigned `initializeConstituent` instruction, as a single-element array.
|
|
6436
|
+
*/
|
|
4652
6437
|
public async getInitializeConstituentIx(
|
|
4653
6438
|
lpPoolId: number,
|
|
4654
6439
|
initializeConstituentParams: InitializeConstituentParams
|
|
@@ -4726,6 +6511,15 @@ export class AdminClient extends VelocityClient {
|
|
|
4726
6511
|
];
|
|
4727
6512
|
}
|
|
4728
6513
|
|
|
6514
|
+
/**
|
|
6515
|
+
* Sets an LP-pool constituent's lifecycle `status` (`ConstituentStatus`: `ACTIVE`,
|
|
6516
|
+
* `REDUCE_ONLY`, or `DECOMMISSIONED`). Requires warm admin (`check_warm`).
|
|
6517
|
+
* `REDUCE_ONLY` restricts flows to only shrink the constituent toward its target
|
|
6518
|
+
* weight; `DECOMMISSIONED` marks it as having no remaining participants.
|
|
6519
|
+
* @param constituent - Constituent PDA to update.
|
|
6520
|
+
* @param constituentStatus - New status.
|
|
6521
|
+
* @returns Transaction signature.
|
|
6522
|
+
*/
|
|
4729
6523
|
public async updateConstituentStatus(
|
|
4730
6524
|
constituent: PublicKey,
|
|
4731
6525
|
constituentStatus: ConstituentStatus
|
|
@@ -4742,6 +6536,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4742
6536
|
return txSig;
|
|
4743
6537
|
}
|
|
4744
6538
|
|
|
6539
|
+
/**
|
|
6540
|
+
* Builds the `updateConstituentStatus` instruction without sending it. See
|
|
6541
|
+
* `updateConstituentStatus`.
|
|
6542
|
+
* @returns The unsigned `updateConstituentStatus` instruction.
|
|
6543
|
+
*/
|
|
4745
6544
|
public async getUpdateConstituentStatusIx(
|
|
4746
6545
|
constituent: PublicKey,
|
|
4747
6546
|
constituentStatus: ConstituentStatus
|
|
@@ -4760,6 +6559,15 @@ export class AdminClient extends VelocityClient {
|
|
|
4760
6559
|
);
|
|
4761
6560
|
}
|
|
4762
6561
|
|
|
6562
|
+
/**
|
|
6563
|
+
* Sets an LP-pool constituent's `pausedOperations` bitmask (`ConstituentLpOperation`:
|
|
6564
|
+
* `Swap`/`Deposit`/`Withdraw`). Requires warm admin (`check_warm`) — despite the
|
|
6565
|
+
* `useHotWalletAdmin` flag name used for the default `admin` account below, no
|
|
6566
|
+
* dedicated hot role exists for this ix; the signer must be cold or warm.
|
|
6567
|
+
* @param constituent - Constituent PDA to update.
|
|
6568
|
+
* @param pausedOperations - New pause bitmask, `ConstituentLpOperation` bit values.
|
|
6569
|
+
* @returns Transaction signature.
|
|
6570
|
+
*/
|
|
4763
6571
|
public async updateConstituentPausedOperations(
|
|
4764
6572
|
constituent: PublicKey,
|
|
4765
6573
|
pausedOperations: number
|
|
@@ -4777,6 +6585,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4777
6585
|
return txSig;
|
|
4778
6586
|
}
|
|
4779
6587
|
|
|
6588
|
+
/**
|
|
6589
|
+
* Builds the `updateConstituentPausedOperations` instruction without sending it.
|
|
6590
|
+
* See `updateConstituentPausedOperations`.
|
|
6591
|
+
* @returns The unsigned `updateConstituentPausedOperations` instruction.
|
|
6592
|
+
*/
|
|
4780
6593
|
public async getUpdateConstituentPausedOperationsIx(
|
|
4781
6594
|
constituent: PublicKey,
|
|
4782
6595
|
pausedOperations: number
|
|
@@ -4795,6 +6608,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4795
6608
|
);
|
|
4796
6609
|
}
|
|
4797
6610
|
|
|
6611
|
+
/**
|
|
6612
|
+
* Patches an LP-pool constituent's tunable params — each field is optional and
|
|
6613
|
+
* only the ones provided overwrite the on-chain value (see `ConstituentAccount`
|
|
6614
|
+
* for per-field precision, which matches these params 1:1). Requires warm admin
|
|
6615
|
+
* (`check_warm`); the underlying ix builder resolves `admin` as `this.wallet`
|
|
6616
|
+
* directly (no cold/warm fallback), so `this.wallet` must itself hold that role.
|
|
6617
|
+
* @param lpPoolId - Constituent's parent LP pool id byte.
|
|
6618
|
+
* @param constituentPublicKey - Constituent PDA to patch.
|
|
6619
|
+
* @param updateConstituentParams - Partial param patch; unset fields are left unchanged. `costToTradeBps` is bps and lives on the pool's `ConstituentTargetBase`, not the `Constituent` account itself.
|
|
6620
|
+
* @returns Transaction signature.
|
|
6621
|
+
*/
|
|
4798
6622
|
public async updateConstituentParams(
|
|
4799
6623
|
lpPoolId: number,
|
|
4800
6624
|
constituentPublicKey: PublicKey,
|
|
@@ -4823,6 +6647,15 @@ export class AdminClient extends VelocityClient {
|
|
|
4823
6647
|
return txSig;
|
|
4824
6648
|
}
|
|
4825
6649
|
|
|
6650
|
+
/**
|
|
6651
|
+
* Builds the `updateConstituentParams` instruction without sending it. Note this
|
|
6652
|
+
* method's parameter type omits `costToTradeBps` even though the public
|
|
6653
|
+
* `updateConstituentParams` wrapper's type includes it and forwards it through
|
|
6654
|
+
* unchanged at runtime — call via `updateConstituentParams` (or add the field
|
|
6655
|
+
* manually) if you need to set it while calling this builder directly. See
|
|
6656
|
+
* `updateConstituentParams`.
|
|
6657
|
+
* @returns The unsigned `updateConstituentParams` instruction, as a single-element array.
|
|
6658
|
+
*/
|
|
4826
6659
|
public async getUpdateConstituentParamsIx(
|
|
4827
6660
|
lpPoolId: number,
|
|
4828
6661
|
constituentPublicKey: PublicKey,
|
|
@@ -4878,6 +6711,15 @@ export class AdminClient extends VelocityClient {
|
|
|
4878
6711
|
];
|
|
4879
6712
|
}
|
|
4880
6713
|
|
|
6714
|
+
/**
|
|
6715
|
+
* Patches an LP pool's tunable params — each field is optional and only the ones
|
|
6716
|
+
* provided overwrite the on-chain value. Requires warm admin (`check_warm`). If
|
|
6717
|
+
* `maxAum` is provided, on-chain validation rejects lowering it below the pool's
|
|
6718
|
+
* current `maxAum` (the cap may only be raised via this ix).
|
|
6719
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
6720
|
+
* @param updateLpPoolParams - Partial param patch; unset fields are left unchanged. `maxSettleQuoteAmount` and `maxAum` are QUOTE_PRECISION (1e6); `volatility` is PERCENTAGE_PRECISION (1e6); `whitelistMint` gates who may mint/redeem the pool's LP token.
|
|
6721
|
+
* @returns Transaction signature.
|
|
6722
|
+
*/
|
|
4881
6723
|
public async updateLpPoolParams(
|
|
4882
6724
|
lpPoolId: number,
|
|
4883
6725
|
updateLpPoolParams: {
|
|
@@ -4898,6 +6740,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4898
6740
|
return txSig;
|
|
4899
6741
|
}
|
|
4900
6742
|
|
|
6743
|
+
/**
|
|
6744
|
+
* Builds the `updateLpPoolParams` instruction without sending it. See
|
|
6745
|
+
* `updateLpPoolParams`.
|
|
6746
|
+
* @returns The unsigned `updateLpPoolParams` instruction, as a single-element array.
|
|
6747
|
+
*/
|
|
4901
6748
|
public async getUpdateLpPoolParamsIx(
|
|
4902
6749
|
lpPoolId: number,
|
|
4903
6750
|
updateLpPoolParams: {
|
|
@@ -4935,6 +6782,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4935
6782
|
];
|
|
4936
6783
|
}
|
|
4937
6784
|
|
|
6785
|
+
/**
|
|
6786
|
+
* Adds new (perp market, constituent) weight entries to an LP pool's
|
|
6787
|
+
* `AmmConstituentMapping` — routing that fraction of the perp market's hedge flow
|
|
6788
|
+
* into the given constituent. Requires warm admin (`check_warm`). On-chain,
|
|
6789
|
+
* inserting a `(perpMarketIndex, constituentIndex)` pair that already exists fails
|
|
6790
|
+
* (`InvalidAmmConstituentMappingArgument`) — use `updateAmmConstituentMappingData`
|
|
6791
|
+
* to change an existing entry's weight instead.
|
|
6792
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
6793
|
+
* @param addAmmConstituentMappingData - New entries to add; see `AddAmmConstituentMappingDatum` (`weight` is PERCENTAGE_PRECISION, 1e6).
|
|
6794
|
+
* @returns Transaction signature.
|
|
6795
|
+
*/
|
|
4938
6796
|
public async addAmmConstituentMappingData(
|
|
4939
6797
|
lpPoolId: number,
|
|
4940
6798
|
addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]
|
|
@@ -4948,6 +6806,13 @@ export class AdminClient extends VelocityClient {
|
|
|
4948
6806
|
return txSig;
|
|
4949
6807
|
}
|
|
4950
6808
|
|
|
6809
|
+
/**
|
|
6810
|
+
* Builds the `addAmmConstituentMappingData` instruction without sending it (the
|
|
6811
|
+
* `as any` cast works around a generated-type mismatch, not a missing on-chain
|
|
6812
|
+
* instruction — `add_amm_constituent_mapping_data` is present in the IDL). See
|
|
6813
|
+
* `addAmmConstituentMappingData`.
|
|
6814
|
+
* @returns The unsigned `addAmmConstituentMappingData` instruction, as a single-element array.
|
|
6815
|
+
*/
|
|
4951
6816
|
public async getAddAmmConstituentMappingDataIx(
|
|
4952
6817
|
lpPoolId: number,
|
|
4953
6818
|
addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]
|
|
@@ -4979,6 +6844,16 @@ export class AdminClient extends VelocityClient {
|
|
|
4979
6844
|
];
|
|
4980
6845
|
}
|
|
4981
6846
|
|
|
6847
|
+
/**
|
|
6848
|
+
* Updates the weight (and refreshes `lastSlot`) of existing entries in an LP
|
|
6849
|
+
* pool's `AmmConstituentMapping`. Requires warm admin (`check_warm`). On-chain,
|
|
6850
|
+
* every `(perpMarketIndex, constituentIndex)` pair must already exist — an unknown
|
|
6851
|
+
* pair fails with `InvalidAmmConstituentMappingArgument` (use
|
|
6852
|
+
* `addAmmConstituentMappingData` to create new entries).
|
|
6853
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
6854
|
+
* @param addAmmConstituentMappingData - Entries to update in place; see `AddAmmConstituentMappingDatum` (`weight` is PERCENTAGE_PRECISION, 1e6).
|
|
6855
|
+
* @returns Transaction signature.
|
|
6856
|
+
*/
|
|
4982
6857
|
public async updateAmmConstituentMappingData(
|
|
4983
6858
|
lpPoolId: number,
|
|
4984
6859
|
addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]
|
|
@@ -4992,6 +6867,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4992
6867
|
return txSig;
|
|
4993
6868
|
}
|
|
4994
6869
|
|
|
6870
|
+
/**
|
|
6871
|
+
* Builds the `updateAmmConstituentMappingData` instruction without sending it. See
|
|
6872
|
+
* `updateAmmConstituentMappingData`.
|
|
6873
|
+
* @returns The unsigned `updateAmmConstituentMappingData` instruction, as a single-element array.
|
|
6874
|
+
*/
|
|
4995
6875
|
public async getUpdateAmmConstituentMappingDataIx(
|
|
4996
6876
|
lpPoolId: number,
|
|
4997
6877
|
addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]
|
|
@@ -5017,6 +6897,15 @@ export class AdminClient extends VelocityClient {
|
|
|
5017
6897
|
];
|
|
5018
6898
|
}
|
|
5019
6899
|
|
|
6900
|
+
/**
|
|
6901
|
+
* Removes a single `(perpMarketIndex, constituentIndex)` entry from an LP pool's
|
|
6902
|
+
* `AmmConstituentMapping`. Requires warm admin (`check_warm`). Fails
|
|
6903
|
+
* (`InvalidAmmConstituentMappingArgument`) if no matching entry exists.
|
|
6904
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
6905
|
+
* @param perpMarketIndex - Perp market side of the entry to remove.
|
|
6906
|
+
* @param constituentIndex - Constituent side of the entry to remove.
|
|
6907
|
+
* @returns Transaction signature.
|
|
6908
|
+
*/
|
|
5020
6909
|
public async removeAmmConstituentMappingData(
|
|
5021
6910
|
lpPoolId: number,
|
|
5022
6911
|
perpMarketIndex: number,
|
|
@@ -5032,6 +6921,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5032
6921
|
return txSig;
|
|
5033
6922
|
}
|
|
5034
6923
|
|
|
6924
|
+
/**
|
|
6925
|
+
* Builds the `removeAmmConstituentMappingData` instruction without sending it. See
|
|
6926
|
+
* `removeAmmConstituentMappingData`.
|
|
6927
|
+
* @returns The unsigned `removeAmmConstituentMappingData` instruction, as a single-element array.
|
|
6928
|
+
*/
|
|
5035
6929
|
public async getRemoveAmmConstituentMappingDataIx(
|
|
5036
6930
|
lpPoolId: number,
|
|
5037
6931
|
perpMarketIndex: number,
|
|
@@ -5060,6 +6954,16 @@ export class AdminClient extends VelocityClient {
|
|
|
5060
6954
|
];
|
|
5061
6955
|
}
|
|
5062
6956
|
|
|
6957
|
+
/**
|
|
6958
|
+
* Sets the correlation between two constituents in an LP pool's
|
|
6959
|
+
* `ConstituentCorrelations` matrix (symmetric — updates both `(index1, index2)`
|
|
6960
|
+
* and `(index2, index1)`). Requires warm admin (`check_warm`).
|
|
6961
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
6962
|
+
* @param index1 - First constituent's index.
|
|
6963
|
+
* @param index2 - Second constituent's index.
|
|
6964
|
+
* @param correlation - New correlation, PERCENTAGE_PRECISION (1e6), signed.
|
|
6965
|
+
* @returns Transaction signature.
|
|
6966
|
+
*/
|
|
5063
6967
|
public async updateConstituentCorrelationData(
|
|
5064
6968
|
lpPoolId: number,
|
|
5065
6969
|
index1: number,
|
|
@@ -5077,6 +6981,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5077
6981
|
return txSig;
|
|
5078
6982
|
}
|
|
5079
6983
|
|
|
6984
|
+
/**
|
|
6985
|
+
* Builds the `updateConstituentCorrelationData` instruction without sending it.
|
|
6986
|
+
* See `updateConstituentCorrelationData`.
|
|
6987
|
+
* @returns The unsigned `updateConstituentCorrelationData` instruction, as a single-element array.
|
|
6988
|
+
*/
|
|
5080
6989
|
public async getUpdateConstituentCorrelationDataIx(
|
|
5081
6990
|
lpPoolId: number,
|
|
5082
6991
|
index1: number,
|
|
@@ -5236,6 +7145,24 @@ export class AdminClient extends VelocityClient {
|
|
|
5236
7145
|
return { beginSwapIx, endSwapIx };
|
|
5237
7146
|
}
|
|
5238
7147
|
|
|
7148
|
+
/**
|
|
7149
|
+
* Builds a flash-loan-style LP-pool swap that routes the actual trade through
|
|
7150
|
+
* Jupiter: wraps a Jupiter swap quote/instruction set between the same
|
|
7151
|
+
* `beginLpSwap`/`endLpSwap` instruction pair `getSwapIx` uses, so the LP pool's
|
|
7152
|
+
* constituent vaults temporarily fund the swap and are repaid by the end of the
|
|
7153
|
+
* transaction (`endLpSwap` fails if the constituents aren't made whole). Fetches
|
|
7154
|
+
* a quote from `jupiterClient` if one isn't passed in.
|
|
7155
|
+
* @param jupiterClient - Jupiter client used to fetch the quote/swap transaction and lookup tables.
|
|
7156
|
+
* @param outMarketIndex - Spot market of the token being bought.
|
|
7157
|
+
* @param inMarketIndex - Spot market of the token being sold.
|
|
7158
|
+
* @param amount - Swap amount, in-market's native decimals (interpreted as exact-in or exact-out per `swapMode`).
|
|
7159
|
+
* @param slippageBps - Optional slippage tolerance passed to Jupiter, basis points.
|
|
7160
|
+
* @param swapMode - Optional `'ExactIn'` / `'ExactOut'`; also inferred from `quote.swapMode` if a quote is supplied.
|
|
7161
|
+
* @param onlyDirectRoutes - Optional, restricts the Jupiter quote to single-hop routes.
|
|
7162
|
+
* @param quote - Optional pre-fetched Jupiter quote; skips the internal fetch if provided.
|
|
7163
|
+
* @param lpPoolId - LP pool id byte the swap routes through.
|
|
7164
|
+
* @returns The unsigned instruction sequence (begin-swap, Jupiter swap instructions, end-swap) and any address lookup tables the Jupiter instructions require.
|
|
7165
|
+
*/
|
|
5239
7166
|
public async getLpJupiterSwapIxV6({
|
|
5240
7167
|
jupiterClient,
|
|
5241
7168
|
outMarketIndex,
|
|
@@ -5370,6 +7297,22 @@ export class AdminClient extends VelocityClient {
|
|
|
5370
7297
|
return { ixs, lookupTables };
|
|
5371
7298
|
}
|
|
5372
7299
|
|
|
7300
|
+
/**
|
|
7301
|
+
* Devnet/test-only helper: builds a plain SPL-token transfer pair simulating an
|
|
7302
|
+
* external counterparty swapping against `this.wallet`'s own token accounts (not
|
|
7303
|
+
* an atomic on-chain program instruction, and not gated by any admin tier — it's
|
|
7304
|
+
* ordinary token transfers assembled for local test flows, typically alongside
|
|
7305
|
+
* `getSwapIx`'s begin/end pair as in `getAllDevnetLpSwapIxs`). Also idempotently
|
|
7306
|
+
* creates the external user's in/out ATAs.
|
|
7307
|
+
* @param amountIn - Amount `this.wallet` sends of the in-market token, that market's native decimals.
|
|
7308
|
+
* @param amountOut - Amount `this.wallet` receives of the out-market token, that market's native decimals.
|
|
7309
|
+
* @param externalUserAuthority - The simulated counterparty's wallet authority.
|
|
7310
|
+
* @param externalUserInTokenAccount - Counterparty's ATA that receives the in-market token.
|
|
7311
|
+
* @param externalUserOutTokenAccount - Counterparty's ATA that sends the out-market token.
|
|
7312
|
+
* @param inSpotMarketIndex - Spot market of the token `this.wallet` sends.
|
|
7313
|
+
* @param outSpotMarketIndex - Spot market of the token `this.wallet` receives.
|
|
7314
|
+
* @returns Unsigned instructions: create both ATAs, then the two transfers.
|
|
7315
|
+
*/
|
|
5373
7316
|
public async getDevnetLpSwapIxs(
|
|
5374
7317
|
amountIn: BN,
|
|
5375
7318
|
amountOut: BN,
|
|
@@ -5442,6 +7385,18 @@ export class AdminClient extends VelocityClient {
|
|
|
5442
7385
|
return ixs;
|
|
5443
7386
|
}
|
|
5444
7387
|
|
|
7388
|
+
/**
|
|
7389
|
+
* Devnet/test-only helper: wraps `getSwapIx`'s begin/end LP-pool swap pair around
|
|
7390
|
+
* `getDevnetLpSwapIxs`'s simulated-counterparty transfers, producing the full
|
|
7391
|
+
* instruction sequence for an end-to-end devnet LP-pool swap test.
|
|
7392
|
+
* @param lpPoolId - LP pool id byte the swap routes through.
|
|
7393
|
+
* @param inMarketIndex - Spot market of the token going in.
|
|
7394
|
+
* @param outMarketIndex - Spot market of the token coming out.
|
|
7395
|
+
* @param inAmount - Amount going in, in-market's native decimals.
|
|
7396
|
+
* @param minOutAmount - Minimum acceptable amount out, out-market's native decimals (also used as the simulated counterparty's exact transfer amount).
|
|
7397
|
+
* @param externalUserAuthority - The simulated counterparty's wallet authority.
|
|
7398
|
+
* @returns Unsigned instructions: begin-swap, the simulated transfer pair, end-swap, in order.
|
|
7399
|
+
*/
|
|
5445
7400
|
public async getAllDevnetLpSwapIxs(
|
|
5446
7401
|
lpPoolId: number,
|
|
5447
7402
|
inMarketIndex: number,
|
|
@@ -5497,6 +7452,22 @@ export class AdminClient extends VelocityClient {
|
|
|
5497
7452
|
] as TransactionInstruction[];
|
|
5498
7453
|
}
|
|
5499
7454
|
|
|
7455
|
+
/**
|
|
7456
|
+
* Atomically moves an LP-pool constituent's idle tokens into a spot market's
|
|
7457
|
+
* lending vault (earning yield) and borrows another constituent's tokens back out
|
|
7458
|
+
* of a (possibly different) spot market's vault, in one transaction. Requires
|
|
7459
|
+
* `HotRole.LpSwap` on both legs (`DepositProgramVault`/`WithdrawProgramVault`
|
|
7460
|
+
* contexts) — `this.wallet` signs as `admin` directly and must hold that role.
|
|
7461
|
+
* Each leg re-validates the constituent's borrow/token-amount invariants
|
|
7462
|
+
* on-chain; the withdraw leg additionally caps the transfer at
|
|
7463
|
+
* `constituent.maxBorrowTokenAmount` (+5% buffer).
|
|
7464
|
+
* @param lpPoolId - LP pool whose constituents to move tokens for.
|
|
7465
|
+
* @param depositMarketIndex - Spot market (and matching constituent) to deposit into.
|
|
7466
|
+
* @param borrowMarketIndex - Spot market (and matching constituent) to borrow/withdraw from.
|
|
7467
|
+
* @param amountToDeposit - Deposit amount, the deposit market's native decimals.
|
|
7468
|
+
* @param amountToBorrow - Withdraw amount, the borrow market's native decimals.
|
|
7469
|
+
* @returns Transaction signature.
|
|
7470
|
+
*/
|
|
5500
7471
|
public async depositWithdrawToProgramVault(
|
|
5501
7472
|
lpPoolId: number,
|
|
5502
7473
|
depositMarketIndex: number,
|
|
@@ -5518,6 +7489,13 @@ export class AdminClient extends VelocityClient {
|
|
|
5518
7489
|
return txSig;
|
|
5519
7490
|
}
|
|
5520
7491
|
|
|
7492
|
+
/**
|
|
7493
|
+
* Builds the `depositToProgramVault` and `withdrawFromProgramVault` instructions
|
|
7494
|
+
* without sending them. See `depositWithdrawToProgramVault`; also the building
|
|
7495
|
+
* block for `getDepositToProgramVaultIx`/`getWithdrawFromProgramVaultIx`
|
|
7496
|
+
* (each of which calls this with the unused leg's amount set to `0`).
|
|
7497
|
+
* @returns The unsigned `{ depositIx, withdrawIx }` pair.
|
|
7498
|
+
*/
|
|
5521
7499
|
public async getDepositWithdrawToProgramVaultIxs(
|
|
5522
7500
|
lpPoolId: number,
|
|
5523
7501
|
depositMarketIndex: number,
|
|
@@ -5599,6 +7577,15 @@ export class AdminClient extends VelocityClient {
|
|
|
5599
7577
|
return { depositIx, withdrawIx };
|
|
5600
7578
|
}
|
|
5601
7579
|
|
|
7580
|
+
/**
|
|
7581
|
+
* Deposits an LP-pool constituent's idle tokens into its spot market's lending
|
|
7582
|
+
* vault, on its own (single-leg version of `depositWithdrawToProgramVault`).
|
|
7583
|
+
* Requires `HotRole.LpSwap`; `this.wallet` must hold that role.
|
|
7584
|
+
* @param lpPoolId - LP pool whose constituent to deposit from.
|
|
7585
|
+
* @param depositMarketIndex - Spot market (and matching constituent) to deposit into.
|
|
7586
|
+
* @param amountToDeposit - Deposit amount, the market's native decimals.
|
|
7587
|
+
* @returns Transaction signature.
|
|
7588
|
+
*/
|
|
5602
7589
|
public async depositToProgramVault(
|
|
5603
7590
|
lpPoolId: number,
|
|
5604
7591
|
depositMarketIndex: number,
|
|
@@ -5615,6 +7602,16 @@ export class AdminClient extends VelocityClient {
|
|
|
5615
7602
|
return txSig;
|
|
5616
7603
|
}
|
|
5617
7604
|
|
|
7605
|
+
/**
|
|
7606
|
+
* Borrows tokens from a spot market's lending vault back into an LP-pool
|
|
7607
|
+
* constituent, on its own (single-leg version of `depositWithdrawToProgramVault`).
|
|
7608
|
+
* Requires `HotRole.LpSwap`; `this.wallet` must hold that role. On-chain, capped
|
|
7609
|
+
* at `constituent.maxBorrowTokenAmount` (+5% buffer).
|
|
7610
|
+
* @param lpPoolId - LP pool whose constituent to borrow into.
|
|
7611
|
+
* @param borrowMarketIndex - Spot market (and matching constituent) to borrow from.
|
|
7612
|
+
* @param amountToWithdraw - Withdraw amount, the market's native decimals.
|
|
7613
|
+
* @returns Transaction signature.
|
|
7614
|
+
*/
|
|
5618
7615
|
public async withdrawFromProgramVault(
|
|
5619
7616
|
lpPoolId: number,
|
|
5620
7617
|
borrowMarketIndex: number,
|
|
@@ -5630,6 +7627,13 @@ export class AdminClient extends VelocityClient {
|
|
|
5630
7627
|
return txSig;
|
|
5631
7628
|
}
|
|
5632
7629
|
|
|
7630
|
+
/**
|
|
7631
|
+
* Builds the `depositToProgramVault` instruction without sending it, via
|
|
7632
|
+
* `getDepositWithdrawToProgramVaultIxs` with a `0` withdraw amount (the
|
|
7633
|
+
* accompanying zero-amount withdraw instruction is discarded, not sent). See
|
|
7634
|
+
* `depositToProgramVault`.
|
|
7635
|
+
* @returns The unsigned `depositToProgramVault` instruction.
|
|
7636
|
+
*/
|
|
5633
7637
|
public async getDepositToProgramVaultIx(
|
|
5634
7638
|
lpPoolId: number,
|
|
5635
7639
|
depositMarketIndex: number,
|
|
@@ -5645,6 +7649,13 @@ export class AdminClient extends VelocityClient {
|
|
|
5645
7649
|
return depositIx;
|
|
5646
7650
|
}
|
|
5647
7651
|
|
|
7652
|
+
/**
|
|
7653
|
+
* Builds the `withdrawFromProgramVault` instruction without sending it, via
|
|
7654
|
+
* `getDepositWithdrawToProgramVaultIxs` with a `0` deposit amount (the
|
|
7655
|
+
* accompanying zero-amount deposit instruction is discarded, not sent). See
|
|
7656
|
+
* `withdrawFromProgramVault`.
|
|
7657
|
+
* @returns The unsigned `withdrawFromProgramVault` instruction.
|
|
7658
|
+
*/
|
|
5648
7659
|
public async getWithdrawFromProgramVaultIx(
|
|
5649
7660
|
lpPoolId: number,
|
|
5650
7661
|
borrowMarketIndex: number,
|
|
@@ -5660,6 +7671,16 @@ export class AdminClient extends VelocityClient {
|
|
|
5660
7671
|
return withdrawIx;
|
|
5661
7672
|
}
|
|
5662
7673
|
|
|
7674
|
+
/**
|
|
7675
|
+
* Patches a perp market's `hedgeConfig` fee-routing scalars that control how much
|
|
7676
|
+
* of the AMM's fee growth is swept to its LP pool (see `sweepPerpMarketFees`).
|
|
7677
|
+
* Requires warm admin (the `HotAdminUpdatePerpMarketDlp` context's `check_warm`
|
|
7678
|
+
* constraint). Both params are optional; only the ones provided are updated.
|
|
7679
|
+
* @param marketIndex - Perp market to update.
|
|
7680
|
+
* @param lpFeeTransferScalar - `hedgeConfig.feeTransferScalar`, percent 0-100 (divided by 100 on-chain) of AMM fee-pool growth routed to the LP pool.
|
|
7681
|
+
* @param lpExchangeFeeExcluscionScalar - `hedgeConfig.exchangeFeeExclusionScalar`, percent 0-100 of the period's exchange-fee growth excluded from that sweep.
|
|
7682
|
+
* @returns Transaction signature.
|
|
7683
|
+
*/
|
|
5663
7684
|
public async updatePerpMarketLpPoolFeeTransferScalar(
|
|
5664
7685
|
marketIndex: number,
|
|
5665
7686
|
lpFeeTransferScalar?: number,
|
|
@@ -5675,6 +7696,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5675
7696
|
return txSig;
|
|
5676
7697
|
}
|
|
5677
7698
|
|
|
7699
|
+
/**
|
|
7700
|
+
* Builds the `updatePerpMarketLpPoolFeeTransferScalar` instruction without
|
|
7701
|
+
* sending it. See `updatePerpMarketLpPoolFeeTransferScalar`.
|
|
7702
|
+
* @returns The unsigned `updatePerpMarketLpPoolFeeTransferScalar` instruction.
|
|
7703
|
+
*/
|
|
5678
7704
|
public async getUpdatePerpMarketLpPoolFeeTransferScalarIx(
|
|
5679
7705
|
marketIndex: number,
|
|
5680
7706
|
lpFeeTransferScalar?: number,
|
|
@@ -5696,6 +7722,17 @@ export class AdminClient extends VelocityClient {
|
|
|
5696
7722
|
);
|
|
5697
7723
|
}
|
|
5698
7724
|
|
|
7725
|
+
/**
|
|
7726
|
+
* Sets a perp market's `hedgeConfig.pausedOperations` bitmask
|
|
7727
|
+
* (`ConstituentLpOperation`: `Swap`/`Deposit`/`Withdraw`), pausing that market's
|
|
7728
|
+
* side of LP-pool hedge flow. Reachable by cold, warm, or `pauseAdmin`
|
|
7729
|
+
* (`PauseAdminUpdatePerpMarket`'s `check_pause`), with the same bit-add-only
|
|
7730
|
+
* restriction for a pause-admin-only caller as `updateExchangeStatus`. The
|
|
7731
|
+
* `admin` account below defaults to `coldAdmin`; other roles must override it.
|
|
7732
|
+
* @param marketIndex - Perp market to update.
|
|
7733
|
+
* @param pausedOperations - New pause bitmask, `ConstituentLpOperation` bit values.
|
|
7734
|
+
* @returns Transaction signature.
|
|
7735
|
+
*/
|
|
5699
7736
|
public async updatePerpMarketLpPoolPausedOperations(
|
|
5700
7737
|
marketIndex: number,
|
|
5701
7738
|
pausedOperations: number
|
|
@@ -5709,6 +7746,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5709
7746
|
return txSig;
|
|
5710
7747
|
}
|
|
5711
7748
|
|
|
7749
|
+
/**
|
|
7750
|
+
* Builds the `updatePerpMarketLpPoolPausedOperations` instruction without
|
|
7751
|
+
* sending it. See `updatePerpMarketLpPoolPausedOperations`.
|
|
7752
|
+
* @returns The unsigned `updatePerpMarketLpPoolPausedOperations` instruction.
|
|
7753
|
+
*/
|
|
5712
7754
|
public async getUpdatePerpMarketLpPoolPausedOperationsIx(
|
|
5713
7755
|
marketIndex: number,
|
|
5714
7756
|
pausedOperations: number
|
|
@@ -5728,6 +7770,19 @@ export class AdminClient extends VelocityClient {
|
|
|
5728
7770
|
);
|
|
5729
7771
|
}
|
|
5730
7772
|
|
|
7773
|
+
/**
|
|
7774
|
+
* Mints `1000` units of an LP pool's `whitelistMint` to `authority`'s associated
|
|
7775
|
+
* token account, creating the ATA if needed. This is a plain SPL-token mint, not
|
|
7776
|
+
* a velocity program instruction — no `HotRole`/tier gate applies; instead the
|
|
7777
|
+
* token program itself requires `this.wallet` to be the mint's authority (set
|
|
7778
|
+
* whenever the whitelist mint was created — typically the same admin that called
|
|
7779
|
+
* `initializeLpPool`/`updateLpPoolParams` to configure it). Holding units of the
|
|
7780
|
+
* whitelist mint is what gates `authority`'s ability to mint/redeem this pool's LP
|
|
7781
|
+
* token, if `lpPool.whitelistMint` is set to a non-default pubkey.
|
|
7782
|
+
* @param lpPool - LP pool whose `whitelistMint` to mint from.
|
|
7783
|
+
* @param authority - Wallet to receive the whitelist tokens.
|
|
7784
|
+
* @returns Transaction signature.
|
|
7785
|
+
*/
|
|
5731
7786
|
public async mintLpWhitelistToken(
|
|
5732
7787
|
lpPool: LPPoolAccount,
|
|
5733
7788
|
authority: PublicKey
|
|
@@ -5738,6 +7793,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5738
7793
|
return txSig;
|
|
5739
7794
|
}
|
|
5740
7795
|
|
|
7796
|
+
/**
|
|
7797
|
+
* Builds the ATA-creation and `mintTo` instructions without sending them. See
|
|
7798
|
+
* `mintLpWhitelistToken`.
|
|
7799
|
+
* @returns The unsigned instructions: idempotent ATA creation, then mint-to, in order.
|
|
7800
|
+
*/
|
|
5741
7801
|
public async getMintLpWhitelistTokenIx(
|
|
5742
7802
|
lpPool: LPPoolAccount,
|
|
5743
7803
|
authority: PublicKey
|
|
@@ -5770,6 +7830,17 @@ export class AdminClient extends VelocityClient {
|
|
|
5770
7830
|
return ixs;
|
|
5771
7831
|
}
|
|
5772
7832
|
|
|
7833
|
+
/**
|
|
7834
|
+
* Sets a perp market's `marketConfig` bitmask (currently one bit:
|
|
7835
|
+
* `MarketConfigFlag.DisableFormulaicKUpdate`, which turns off the AMM's automatic
|
|
7836
|
+
* k-adjustment for the market). Requires warm admin (the `HotAdminUpdatePerpMarket`
|
|
7837
|
+
* context's `check_warm` constraint), but **setting any bit (a non-zero value)
|
|
7838
|
+
* requires `state.coldAdmin` specifically** — a warm-only signer may only pass `0`
|
|
7839
|
+
* (clear all bits). Unknown bits are rejected (`InvalidPerpMarketConfig`).
|
|
7840
|
+
* @param marketIndex - Perp market to update.
|
|
7841
|
+
* @param marketConfig - New bitmask; non-zero values require cold admin.
|
|
7842
|
+
* @returns Transaction signature.
|
|
7843
|
+
*/
|
|
5773
7844
|
public async updatePerpMarketConfig(
|
|
5774
7845
|
marketIndex: number,
|
|
5775
7846
|
marketConfig: number
|
|
@@ -5783,6 +7854,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5783
7854
|
return txSig;
|
|
5784
7855
|
}
|
|
5785
7856
|
|
|
7857
|
+
/**
|
|
7858
|
+
* Builds the `updatePerpMarketConfig` instruction without sending it. See
|
|
7859
|
+
* `updatePerpMarketConfig`.
|
|
7860
|
+
* @returns The unsigned `updatePerpMarketConfig` instruction.
|
|
7861
|
+
*/
|
|
5786
7862
|
public async getUpdatePerpMarketConfigIx(
|
|
5787
7863
|
marketIndex: number,
|
|
5788
7864
|
marketConfig: number
|
|
@@ -5799,6 +7875,22 @@ export class AdminClient extends VelocityClient {
|
|
|
5799
7875
|
});
|
|
5800
7876
|
}
|
|
5801
7877
|
|
|
7878
|
+
/**
|
|
7879
|
+
* Moves quote value between one perp market's protocol fee pool and another (or
|
|
7880
|
+
* the same) perp market's pnl pool — a pure internal ledger transfer against the
|
|
7881
|
+
* shared quote spot market's scaled balances, no tokens actually move. Requires
|
|
7882
|
+
* warm admin (`check_warm`). On-chain, the transfer is capped at the source
|
|
7883
|
+
* pool's available token amount. For a same-market move the AMM's
|
|
7884
|
+
* `totalFeeMinusDistributions` ledger is left untouched (equity-neutral within
|
|
7885
|
+
* one market's perimeter); for a cross-market move, the fee-pool market's ledger
|
|
7886
|
+
* is adjusted to reflect quote leaving/entering its perimeter (reconciled later
|
|
7887
|
+
* by the summary-stats recompute ix).
|
|
7888
|
+
* @param perpMarketIndexWithFeePool - Perp market whose fee pool is the transfer source/destination.
|
|
7889
|
+
* @param perpMarketIndexWithPnlPool - Perp market whose pnl pool is the transfer destination/source.
|
|
7890
|
+
* @param amount - Amount to move, QUOTE_PRECISION (1e6) (clamped down to the source pool's available balance on-chain).
|
|
7891
|
+
* @param direction - `TransferFeeAndPnlPoolDirection.FEE_TO_PNL_POOL` or `.PNL_TO_FEE_POOL`.
|
|
7892
|
+
* @returns Transaction signature.
|
|
7893
|
+
*/
|
|
5802
7894
|
public async transferFeeAndPnlPool(
|
|
5803
7895
|
perpMarketIndexWithFeePool: number,
|
|
5804
7896
|
perpMarketIndexWithPnlPool: number,
|
|
@@ -5816,6 +7908,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5816
7908
|
return txSig;
|
|
5817
7909
|
}
|
|
5818
7910
|
|
|
7911
|
+
/**
|
|
7912
|
+
* Builds the `transferFeeAndPnlPool` instruction without sending it. See
|
|
7913
|
+
* `transferFeeAndPnlPool`.
|
|
7914
|
+
* @returns The unsigned `transferFeeAndPnlPool` instruction.
|
|
7915
|
+
*/
|
|
5819
7916
|
public async getTransferFeeAndPnlPoolIx(
|
|
5820
7917
|
perpMarketIndexWithFeePool: number,
|
|
5821
7918
|
perpMarketIndexWithPnlPool: number,
|
|
@@ -5846,6 +7943,18 @@ export class AdminClient extends VelocityClient {
|
|
|
5846
7943
|
);
|
|
5847
7944
|
}
|
|
5848
7945
|
|
|
7946
|
+
/**
|
|
7947
|
+
* Sets a `User` account's `specialUserStatus` bitmask (`SpecialUserStatus`;
|
|
7948
|
+
* currently one bit, `VAMM_HEDGER`, marking the account the protocol's own
|
|
7949
|
+
* vAMM-hedging bot trades from). Requires `HotRole.UserFlag` (cold, warm, or the
|
|
7950
|
+
* configured user-flag hot key), but **setting any bit (a non-zero value)
|
|
7951
|
+
* requires `state.coldAdmin` specifically** — a `UserFlag`-hot-only signer may
|
|
7952
|
+
* only pass `0` (clear all bits). Unknown bits are rejected (`DefaultError`).
|
|
7953
|
+
* @param userAccountPublicKey - `User` PDA to update.
|
|
7954
|
+
* @param status - New bitmask; non-zero values require cold admin.
|
|
7955
|
+
* @param txParams - Optional transaction-building overrides.
|
|
7956
|
+
* @returns Transaction signature.
|
|
7957
|
+
*/
|
|
5849
7958
|
public async updateSpecialUserStatus(
|
|
5850
7959
|
userAccountPublicKey: PublicKey,
|
|
5851
7960
|
status: number,
|
|
@@ -5860,6 +7969,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5860
7969
|
return txSig;
|
|
5861
7970
|
}
|
|
5862
7971
|
|
|
7972
|
+
/**
|
|
7973
|
+
* Builds the `updateSpecialUserStatus` instruction without sending it. See
|
|
7974
|
+
* `updateSpecialUserStatus`.
|
|
7975
|
+
* @returns The unsigned `updateSpecialUserStatus` instruction.
|
|
7976
|
+
*/
|
|
5863
7977
|
public async getUpdateSpecialUserStatusIx(
|
|
5864
7978
|
userAccountPublicKey: PublicKey,
|
|
5865
7979
|
status: number
|
|
@@ -5882,6 +7996,13 @@ export class AdminClient extends VelocityClient {
|
|
|
5882
7996
|
// `handleInitialize` seeds `coldAdmin = warmAdmin = signer`; there is no
|
|
5883
7997
|
// separate "initialize admin authority config" ix.
|
|
5884
7998
|
|
|
7999
|
+
/**
|
|
8000
|
+
* Rotates `state.warmAdmin`, the operational (multisig+timelock) tier that can
|
|
8001
|
+
* rotate every hot-role key (`updateHotAdmin`). Cold-only: the `UpdateWarmAdmin`
|
|
8002
|
+
* context requires `state.coldAdmin == admin.key()`.
|
|
8003
|
+
* @param newWarmAdmin - New warm admin pubkey. `PublicKey.default()` unsets the role — only `coldAdmin` can then act where warm was accepted.
|
|
8004
|
+
* @returns Transaction signature.
|
|
8005
|
+
*/
|
|
5885
8006
|
public async updateWarmAdmin(
|
|
5886
8007
|
newWarmAdmin: PublicKey
|
|
5887
8008
|
): Promise<TransactionSignature> {
|
|
@@ -5891,6 +8012,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5891
8012
|
return txSig;
|
|
5892
8013
|
}
|
|
5893
8014
|
|
|
8015
|
+
/**
|
|
8016
|
+
* Builds the `updateWarmAdmin` instruction without sending it. See
|
|
8017
|
+
* `updateWarmAdmin`.
|
|
8018
|
+
* @returns The unsigned `updateWarmAdmin` instruction.
|
|
8019
|
+
*/
|
|
5894
8020
|
public async getUpdateWarmAdminIx(
|
|
5895
8021
|
newWarmAdmin: PublicKey
|
|
5896
8022
|
): Promise<TransactionInstruction> {
|
|
@@ -5904,6 +8030,53 @@ export class AdminClient extends VelocityClient {
|
|
|
5904
8030
|
});
|
|
5905
8031
|
}
|
|
5906
8032
|
|
|
8033
|
+
/**
|
|
8034
|
+
* Rotates `state.pauseAdmin`, the no-timelock emergency-pause key authorised (in
|
|
8035
|
+
* addition to cold/warm) for handlers that flip pause bitmasks
|
|
8036
|
+
* (`updateExchangeStatus`, per-market/per-user paused-operations updates) —
|
|
8037
|
+
* restricted at the handler level to *adding* pause bits, never clearing them.
|
|
8038
|
+
* Cold-only: the `UpdatePauseAdmin` context requires `state.coldAdmin ==
|
|
8039
|
+
* admin.key()`.
|
|
8040
|
+
* @param newPauseAdmin - New pause admin pubkey. `PublicKey.default()` unsets the role — only cold/warm can then pause.
|
|
8041
|
+
* @returns Transaction signature.
|
|
8042
|
+
*/
|
|
8043
|
+
public async updatePauseAdmin(
|
|
8044
|
+
newPauseAdmin: PublicKey
|
|
8045
|
+
): Promise<TransactionSignature> {
|
|
8046
|
+
const ix = await this.getUpdatePauseAdminIx(newPauseAdmin);
|
|
8047
|
+
const tx = await this.buildTransaction(ix);
|
|
8048
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
8049
|
+
return txSig;
|
|
8050
|
+
}
|
|
8051
|
+
|
|
8052
|
+
/**
|
|
8053
|
+
* Builds the `updatePauseAdmin` instruction without sending it. See
|
|
8054
|
+
* `updatePauseAdmin`.
|
|
8055
|
+
* @returns The unsigned `updatePauseAdmin` instruction.
|
|
8056
|
+
*/
|
|
8057
|
+
public async getUpdatePauseAdminIx(
|
|
8058
|
+
newPauseAdmin: PublicKey
|
|
8059
|
+
): Promise<TransactionInstruction> {
|
|
8060
|
+
return this.program.instruction.updatePauseAdmin(newPauseAdmin, {
|
|
8061
|
+
accounts: {
|
|
8062
|
+
state: await this.getStatePublicKey(),
|
|
8063
|
+
admin: this.isSubscribed
|
|
8064
|
+
? this.getStateAccount().coldAdmin
|
|
8065
|
+
: this.wallet.publicKey,
|
|
8066
|
+
},
|
|
8067
|
+
});
|
|
8068
|
+
}
|
|
8069
|
+
|
|
8070
|
+
/**
|
|
8071
|
+
* Rotates one purpose-specific hot-role key on `state` (e.g. `hotFeeWithdraw`,
|
|
8072
|
+
* `hotVaultDeposit`). Warm-or-cold: the `UpdateHotAdmin` context requires
|
|
8073
|
+
* `state.isWarm(admin.key())`. Compromise of one hot key only exposes the
|
|
8074
|
+
* instructions gated on that specific `HotRole` — rotating it here fully revokes
|
|
8075
|
+
* the old key for that role.
|
|
8076
|
+
* @param role - Which hot role's key to rotate.
|
|
8077
|
+
* @param newPubkey - New key for that role. `PublicKey.default()` unsets it — only warm/cold can then call handlers gated on that role.
|
|
8078
|
+
* @returns Transaction signature.
|
|
8079
|
+
*/
|
|
5907
8080
|
public async updateHotAdmin(
|
|
5908
8081
|
role: HotRole,
|
|
5909
8082
|
newPubkey: PublicKey
|
|
@@ -5914,6 +8087,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5914
8087
|
return txSig;
|
|
5915
8088
|
}
|
|
5916
8089
|
|
|
8090
|
+
/**
|
|
8091
|
+
* Builds the `updateHotAdmin` instruction without sending it. See
|
|
8092
|
+
* `updateHotAdmin`.
|
|
8093
|
+
* @returns The unsigned `updateHotAdmin` instruction.
|
|
8094
|
+
*/
|
|
5917
8095
|
public async getUpdateHotAdminIx(
|
|
5918
8096
|
role: HotRole,
|
|
5919
8097
|
newPubkey: PublicKey
|
|
@@ -5933,8 +8111,10 @@ export class AdminClient extends VelocityClient {
|
|
|
5933
8111
|
|
|
5934
8112
|
/**
|
|
5935
8113
|
* Hot-admin role identifier. Each role is a separate purpose-specific signer key
|
|
5936
|
-
* stored on the `
|
|
5937
|
-
*
|
|
8114
|
+
* stored directly on the `State` account (one `hot*` pubkey field per role, e.g.
|
|
8115
|
+
* `state.hotFeeWithdraw` for `FeeWithdraw`) — there is no separate
|
|
8116
|
+
* "AdminAuthorityConfig" account. Compromise of one role's key only enables that
|
|
8117
|
+
* role's instructions (see `updateHotAdmin` to rotate one).
|
|
5938
8118
|
*/
|
|
5939
8119
|
export enum HotRole {
|
|
5940
8120
|
AmmCrank = 'ammCrank',
|