@velocity-exchange/sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.js +18 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +18 -0
- package/lib/browser/accounts/bulkAccountLoader.d.ts +52 -0
- package/lib/browser/accounts/bulkAccountLoader.js +51 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +9 -2
- package/lib/browser/accounts/bulkUserStatsSubscription.js +9 -2
- package/lib/browser/accounts/bulkUserSubscription.d.ts +8 -2
- package/lib/browser/accounts/bulkUserSubscription.js +8 -2
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.js +37 -0
- package/lib/browser/accounts/fetch.d.ts +59 -2
- package/lib/browser/accounts/fetch.js +57 -2
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +30 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +30 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +118 -37
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +40 -12
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +33 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +15 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.js +15 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +15 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +34 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +34 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +19 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +21 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +22 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +32 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +22 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
- package/lib/browser/accounts/testBulkAccountLoader.d.ts +8 -0
- package/lib/browser/accounts/testBulkAccountLoader.js +8 -0
- package/lib/browser/accounts/types.d.ts +149 -0
- package/lib/browser/accounts/types.js +13 -0
- package/lib/browser/accounts/utils.d.ts +18 -0
- package/lib/browser/accounts/utils.js +32 -16
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +41 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.js +41 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +31 -23
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +36 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +26 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +33 -0
- package/lib/browser/addresses/marketAddresses.d.ts +10 -0
- package/lib/browser/addresses/marketAddresses.js +10 -0
- package/lib/browser/addresses/pda.d.ts +214 -2
- package/lib/browser/addresses/pda.js +217 -5
- package/lib/browser/adminClient.d.ts +2136 -4
- package/lib/browser/adminClient.js +2150 -4
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
- package/lib/browser/auctionSubscriber/index.d.ts +6 -0
- package/lib/browser/auctionSubscriber/index.js +6 -0
- package/lib/browser/auctionSubscriber/types.d.ts +7 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +33 -0
- package/lib/browser/blockhashSubscriber/index.d.ts +5 -0
- package/lib/browser/blockhashSubscriber/index.js +5 -0
- package/lib/browser/blockhashSubscriber/types.d.ts +5 -0
- package/lib/browser/clock/clockSubscriber.d.ts +24 -0
- package/lib/browser/clock/clockSubscriber.js +22 -0
- package/lib/browser/config.d.ts +58 -4
- package/lib/browser/config.js +88 -21
- package/lib/browser/constants/numericConstants.d.ts +67 -0
- package/lib/browser/constants/numericConstants.js +68 -1
- package/lib/browser/constants/perpMarkets.d.ts +10 -0
- package/lib/browser/constants/perpMarkets.js +40 -908
- package/lib/browser/constants/spotMarkets.d.ts +13 -0
- package/lib/browser/constants/spotMarkets.js +16 -742
- package/lib/browser/constants/txConstants.d.ts +1 -0
- package/lib/browser/constants/txConstants.js +1 -0
- package/lib/browser/core/VelocityCore.d.ts +285 -8
- package/lib/browser/core/VelocityCore.js +281 -8
- package/lib/browser/core/instructions/deposit.d.ts +22 -0
- package/lib/browser/core/instructions/deposit.js +22 -0
- package/lib/browser/core/instructions/fill.d.ts +17 -0
- package/lib/browser/core/instructions/fill.js +17 -0
- package/lib/browser/core/instructions/funding.d.ts +12 -0
- package/lib/browser/core/instructions/funding.js +12 -0
- package/lib/browser/core/instructions/liquidation.d.ts +18 -0
- package/lib/browser/core/instructions/liquidation.js +18 -0
- package/lib/browser/core/instructions/orders.d.ts +28 -0
- package/lib/browser/core/instructions/orders.js +28 -0
- package/lib/browser/core/instructions/perpOrders.d.ts +106 -0
- package/lib/browser/core/instructions/perpOrders.js +106 -0
- package/lib/browser/core/instructions/settlement.d.ts +14 -0
- package/lib/browser/core/instructions/settlement.js +14 -0
- package/lib/browser/core/instructions/trigger.d.ts +15 -0
- package/lib/browser/core/instructions/trigger.js +15 -0
- package/lib/browser/core/instructions/withdraw.d.ts +21 -0
- package/lib/browser/core/instructions/withdraw.js +21 -0
- package/lib/browser/core/remainingAccounts.d.ts +47 -3
- package/lib/browser/core/remainingAccounts.js +20 -0
- package/lib/browser/core/signedMsg.d.ts +38 -0
- package/lib/browser/core/signedMsg.js +33 -0
- package/lib/browser/decode/customCoder.d.ts +39 -3
- package/lib/browser/decode/customCoder.js +45 -3
- package/lib/browser/decode/user.d.ts +22 -0
- package/lib/browser/decode/user.js +22 -0
- package/lib/browser/dlob/DLOB.d.ts +502 -53
- package/lib/browser/dlob/DLOB.js +540 -98
- package/lib/browser/dlob/DLOBNode.d.ts +86 -4
- package/lib/browser/dlob/DLOBNode.js +37 -4
- package/lib/browser/dlob/DLOBSubscriber.d.ts +39 -12
- package/lib/browser/dlob/DLOBSubscriber.js +42 -12
- package/lib/browser/dlob/NodeList.d.ts +69 -0
- package/lib/browser/dlob/NodeList.js +66 -0
- package/lib/browser/dlob/orderBookLevels.d.ts +106 -13
- package/lib/browser/dlob/orderBookLevels.js +84 -14
- package/lib/browser/dlob/types.d.ts +15 -0
- package/lib/browser/events/eventList.d.ts +14 -0
- package/lib/browser/events/eventList.js +14 -0
- package/lib/browser/events/eventSubscriber.d.ts +87 -10
- package/lib/browser/events/eventSubscriber.js +93 -8
- package/lib/browser/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/browser/events/eventsServerLogProvider.js +27 -0
- package/lib/browser/events/fetchLogs.d.ts +31 -0
- package/lib/browser/events/fetchLogs.js +46 -1
- package/lib/browser/events/parse.d.ts +23 -0
- package/lib/browser/events/parse.js +23 -0
- package/lib/browser/events/pollingLogProvider.d.ts +24 -0
- package/lib/browser/events/pollingLogProvider.js +24 -0
- package/lib/browser/events/sort.d.ts +11 -0
- package/lib/browser/events/sort.js +12 -0
- package/lib/browser/events/txEventCache.d.ts +13 -3
- package/lib/browser/events/txEventCache.js +19 -7
- package/lib/browser/events/types.d.ts +118 -2
- package/lib/browser/events/types.js +11 -0
- package/lib/browser/events/webSocketLogProvider.d.ts +23 -0
- package/lib/browser/events/webSocketLogProvider.js +28 -0
- package/lib/browser/factory/oracleClient.js +2 -2
- package/lib/browser/idl/velocity.d.ts +4 -4
- package/lib/browser/idl/velocity.json +4 -4
- package/lib/browser/keypair.d.ts +8 -0
- package/lib/browser/keypair.js +8 -0
- package/lib/browser/marginCalculation.d.ts +134 -2
- package/lib/browser/marginCalculation.js +121 -0
- package/lib/browser/math/amm.d.ts +348 -29
- package/lib/browser/math/amm.js +310 -32
- package/lib/browser/math/auction.d.ts +95 -19
- package/lib/browser/math/auction.js +118 -28
- package/lib/browser/math/bankruptcy.d.ts +46 -0
- package/lib/browser/math/bankruptcy.js +89 -1
- package/lib/browser/math/builder.d.ts +64 -8
- package/lib/browser/math/builder.js +71 -9
- package/lib/browser/math/conversion.d.ts +21 -0
- package/lib/browser/math/conversion.js +21 -0
- package/lib/browser/math/exchangeStatus.d.ts +91 -0
- package/lib/browser/math/exchangeStatus.js +106 -3
- package/lib/browser/math/funding.d.ts +57 -20
- package/lib/browser/math/funding.js +63 -23
- package/lib/browser/math/insurance.d.ts +62 -0
- package/lib/browser/math/insurance.js +62 -0
- package/lib/browser/math/liquidation.d.ts +127 -11
- package/lib/browser/math/liquidation.js +182 -19
- package/lib/browser/math/margin.d.ts +79 -13
- package/lib/browser/math/margin.js +80 -14
- package/lib/browser/math/market.d.ts +135 -15
- package/lib/browser/math/market.js +145 -17
- package/lib/browser/math/oracles.d.ts +113 -0
- package/lib/browser/math/oracles.js +118 -1
- package/lib/browser/math/orders.d.ts +115 -10
- package/lib/browser/math/orders.js +130 -19
- package/lib/browser/math/position.d.ts +80 -33
- package/lib/browser/math/position.js +80 -33
- package/lib/browser/math/repeg.d.ts +48 -10
- package/lib/browser/math/repeg.js +48 -10
- package/lib/browser/math/spotBalance.d.ts +200 -5
- package/lib/browser/math/spotBalance.js +239 -10
- package/lib/browser/math/spotMarket.d.ts +36 -3
- package/lib/browser/math/spotMarket.js +36 -3
- package/lib/browser/math/spotPosition.d.ts +72 -0
- package/lib/browser/math/spotPosition.js +62 -0
- package/lib/browser/math/state.d.ts +31 -0
- package/lib/browser/math/state.js +31 -0
- package/lib/browser/math/superStake.d.ts +126 -2
- package/lib/browser/math/superStake.js +123 -3
- package/lib/browser/math/tiers.d.ts +29 -0
- package/lib/browser/math/tiers.js +29 -0
- package/lib/browser/math/trade.d.ts +102 -51
- package/lib/browser/math/trade.js +101 -55
- package/lib/browser/math/utils.d.ts +71 -9
- package/lib/browser/math/utils.js +71 -9
- package/lib/browser/memcmp.d.ts +94 -0
- package/lib/browser/memcmp.js +103 -2
- package/lib/browser/oracles/oracleClientCache.d.ts +16 -0
- package/lib/browser/oracles/oracleClientCache.js +16 -0
- package/lib/browser/oracles/oracleId.d.ts +31 -0
- package/lib/browser/oracles/oracleId.js +39 -8
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +20 -0
- package/lib/browser/oracles/prelaunchOracleClient.js +20 -0
- package/lib/browser/oracles/pythClient.d.ts +31 -0
- package/lib/browser/oracles/pythClient.js +32 -1
- package/lib/browser/oracles/pythLazerClient.d.ts +34 -0
- package/lib/browser/oracles/pythLazerClient.js +35 -1
- package/lib/browser/oracles/quoteAssetOracleClient.d.ts +18 -0
- package/lib/browser/oracles/quoteAssetOracleClient.js +18 -0
- package/lib/browser/oracles/strictOraclePrice.d.ts +21 -0
- package/lib/browser/oracles/strictOraclePrice.js +21 -0
- package/lib/browser/oracles/types.d.ts +45 -0
- package/lib/browser/oracles/utils.d.ts +20 -0
- package/lib/browser/oracles/utils.js +20 -0
- package/lib/browser/orderParams.d.ts +42 -4
- package/lib/browser/orderParams.js +42 -4
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +56 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.js +56 -0
- package/lib/browser/orderSubscriber/PollingSubscription.d.ts +11 -0
- package/lib/browser/orderSubscriber/PollingSubscription.js +11 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +18 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +18 -0
- package/lib/browser/orderSubscriber/grpcSubscription.d.ts +16 -0
- package/lib/browser/orderSubscriber/grpcSubscription.js +16 -0
- package/lib/browser/orderSubscriber/types.d.ts +9 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.js +1 -0
- package/lib/browser/priorityFee/averageStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/averageStrategy.js +1 -0
- package/lib/browser/priorityFee/ewmaStrategy.d.ts +10 -0
- package/lib/browser/priorityFee/ewmaStrategy.js +10 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +9 -2
- package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.js +1 -0
- package/lib/browser/priorityFee/maxStrategy.d.ts +1 -0
- package/lib/browser/priorityFee/maxStrategy.js +1 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +39 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +39 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +21 -2
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +10 -0
- package/lib/browser/priorityFee/types.d.ts +32 -0
- package/lib/browser/priorityFee/types.js +5 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +8 -0
- package/lib/browser/slot/SlotSubscriber.d.ts +18 -0
- package/lib/browser/slot/SlotSubscriber.js +16 -0
- package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/browser/slot/SlothashSubscriber.js +25 -1
- package/lib/browser/tx/baseTxSender.d.ts +163 -0
- package/lib/browser/tx/baseTxSender.js +174 -6
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
- package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/browser/tx/fastSingleTxSender.d.ts +47 -0
- package/lib/browser/tx/fastSingleTxSender.js +48 -1
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +48 -0
- package/lib/browser/tx/forwardOnlyTxSender.js +48 -0
- package/lib/browser/tx/reportTransactionError.d.ts +18 -6
- package/lib/browser/tx/reportTransactionError.js +18 -6
- package/lib/browser/tx/retryTxSender.d.ts +40 -0
- package/lib/browser/tx/retryTxSender.js +39 -0
- package/lib/browser/tx/txHandler.d.ts +146 -35
- package/lib/browser/tx/txHandler.js +132 -32
- package/lib/browser/tx/txParamProcessor.d.ts +47 -0
- package/lib/browser/tx/txParamProcessor.js +47 -0
- package/lib/browser/tx/types.d.ts +46 -0
- package/lib/browser/tx/types.js +5 -0
- package/lib/browser/tx/utils.d.ts +26 -0
- package/lib/browser/tx/utils.js +26 -0
- package/lib/browser/tx/whileValidTxSender.d.ts +82 -0
- package/lib/browser/tx/whileValidTxSender.js +81 -0
- package/lib/browser/types.d.ts +781 -13
- package/lib/browser/types.js +126 -9
- package/lib/browser/user.d.ts +645 -84
- package/lib/browser/user.js +779 -96
- package/lib/browser/userMap/PollingSubscription.d.ts +10 -0
- package/lib/browser/userMap/PollingSubscription.js +14 -2
- package/lib/browser/userMap/WebsocketSubscription.d.ts +9 -0
- package/lib/browser/userMap/WebsocketSubscription.js +9 -0
- package/lib/browser/userMap/grpcSubscription.d.ts +8 -0
- package/lib/browser/userMap/grpcSubscription.js +8 -0
- package/lib/browser/userMap/referrerMap.d.ts +72 -2
- package/lib/browser/userMap/referrerMap.js +84 -2
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +37 -10
- package/lib/browser/userMap/revenueShareEscrowMap.js +38 -11
- package/lib/browser/userMap/userMap.d.ts +81 -3
- package/lib/browser/userMap/userMap.js +81 -4
- package/lib/browser/userMap/userMapConfig.d.ts +23 -0
- package/lib/browser/userMap/userStatsMap.d.ts +22 -0
- package/lib/browser/userMap/userStatsMap.js +22 -0
- package/lib/browser/userName.d.ts +16 -0
- package/lib/browser/userName.js +16 -0
- package/lib/browser/userStats.d.ts +28 -1
- package/lib/browser/userStats.js +28 -1
- package/lib/browser/util/TransactionConfirmationManager.d.ts +33 -0
- package/lib/browser/util/TransactionConfirmationManager.js +33 -0
- package/lib/browser/util/chainClock.d.ts +24 -0
- package/lib/browser/util/chainClock.js +20 -0
- package/lib/browser/util/computeUnits.d.ts +32 -0
- package/lib/browser/util/computeUnits.js +32 -0
- package/lib/browser/util/digest.d.ts +17 -0
- package/lib/browser/util/digest.js +17 -0
- package/lib/browser/util/ed25519Utils.d.ts +12 -2
- package/lib/browser/util/ed25519Utils.js +12 -2
- package/lib/browser/util/promiseTimeout.d.ts +9 -0
- package/lib/browser/util/promiseTimeout.js +9 -0
- package/lib/browser/velocityClient.d.ts +3322 -215
- package/lib/browser/velocityClient.js +3412 -245
- package/lib/browser/wallet.d.ts +37 -0
- package/lib/browser/wallet.js +37 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserAccountSubscriber.js +18 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +18 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts +52 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/bulkAccountLoader.js +51 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts +9 -2
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts.map +1 -1
- package/lib/node/accounts/bulkUserStatsSubscription.js +9 -2
- package/lib/node/accounts/bulkUserSubscription.d.ts +8 -2
- package/lib/node/accounts/bulkUserSubscription.d.ts.map +1 -1
- package/lib/node/accounts/bulkUserSubscription.js +8 -2
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts +37 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.js +37 -0
- package/lib/node/accounts/fetch.d.ts +59 -2
- package/lib/node/accounts/fetch.d.ts.map +1 -1
- package/lib/node/accounts/fetch.js +57 -2
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcAccountSubscriber.js +30 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +16 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +16 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +60 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +118 -37
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +40 -12
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +33 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +33 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +15 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserAccountSubscriber.js +15 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +15 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +15 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +41 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +41 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +116 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +152 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +34 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.js +34 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +19 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +31 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +21 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +22 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +22 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +32 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +22 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +22 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +83 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +84 -1
- package/lib/node/accounts/testBulkAccountLoader.d.ts +8 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/testBulkAccountLoader.js +8 -0
- package/lib/node/accounts/types.d.ts +149 -0
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/types.js +13 -0
- package/lib/node/accounts/utils.d.ts +18 -0
- package/lib/node/accounts/utils.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +32 -16
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +41 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +41 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +31 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +31 -23
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +27 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +36 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +36 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +21 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +25 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +21 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +21 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +26 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +26 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +20 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +121 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +123 -2
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +96 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +108 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +33 -0
- package/lib/node/addresses/marketAddresses.d.ts +10 -0
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -1
- package/lib/node/addresses/marketAddresses.js +10 -0
- package/lib/node/addresses/pda.d.ts +214 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +217 -5
- package/lib/node/adminClient.d.ts +2136 -4
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +2150 -4
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +19 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +19 -0
- package/lib/node/auctionSubscriber/index.d.ts +6 -0
- package/lib/node/auctionSubscriber/index.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/index.js +6 -0
- package/lib/node/auctionSubscriber/types.d.ts +7 -0
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +33 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +33 -0
- package/lib/node/blockhashSubscriber/index.d.ts +5 -0
- package/lib/node/blockhashSubscriber/index.d.ts.map +1 -1
- package/lib/node/blockhashSubscriber/index.js +5 -0
- package/lib/node/blockhashSubscriber/types.d.ts +5 -0
- package/lib/node/blockhashSubscriber/types.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.d.ts +24 -0
- package/lib/node/clock/clockSubscriber.d.ts.map +1 -1
- package/lib/node/clock/clockSubscriber.js +22 -0
- package/lib/node/config.d.ts +58 -4
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +88 -21
- package/lib/node/constants/numericConstants.d.ts +67 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +68 -1
- package/lib/node/constants/perpMarkets.d.ts +10 -0
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +40 -908
- package/lib/node/constants/spotMarkets.d.ts +13 -0
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +16 -742
- package/lib/node/constants/txConstants.d.ts +1 -0
- package/lib/node/constants/txConstants.d.ts.map +1 -1
- package/lib/node/constants/txConstants.js +1 -0
- package/lib/node/core/VelocityCore.d.ts +285 -8
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +281 -8
- package/lib/node/core/instructions/deposit.d.ts +22 -0
- package/lib/node/core/instructions/deposit.d.ts.map +1 -1
- package/lib/node/core/instructions/deposit.js +22 -0
- package/lib/node/core/instructions/fill.d.ts +17 -0
- package/lib/node/core/instructions/fill.d.ts.map +1 -1
- package/lib/node/core/instructions/fill.js +17 -0
- package/lib/node/core/instructions/funding.d.ts +12 -0
- package/lib/node/core/instructions/funding.d.ts.map +1 -1
- package/lib/node/core/instructions/funding.js +12 -0
- package/lib/node/core/instructions/liquidation.d.ts +18 -0
- package/lib/node/core/instructions/liquidation.d.ts.map +1 -1
- package/lib/node/core/instructions/liquidation.js +18 -0
- package/lib/node/core/instructions/orders.d.ts +28 -0
- package/lib/node/core/instructions/orders.d.ts.map +1 -1
- package/lib/node/core/instructions/orders.js +28 -0
- package/lib/node/core/instructions/perpOrders.d.ts +106 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -1
- package/lib/node/core/instructions/perpOrders.js +106 -0
- package/lib/node/core/instructions/settlement.d.ts +14 -0
- package/lib/node/core/instructions/settlement.d.ts.map +1 -1
- package/lib/node/core/instructions/settlement.js +14 -0
- package/lib/node/core/instructions/trigger.d.ts +15 -0
- package/lib/node/core/instructions/trigger.d.ts.map +1 -1
- package/lib/node/core/instructions/trigger.js +15 -0
- package/lib/node/core/instructions/withdraw.d.ts +21 -0
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/core/instructions/withdraw.js +21 -0
- package/lib/node/core/remainingAccounts.d.ts +47 -3
- package/lib/node/core/remainingAccounts.d.ts.map +1 -1
- package/lib/node/core/remainingAccounts.js +20 -0
- package/lib/node/core/signedMsg.d.ts +38 -0
- package/lib/node/core/signedMsg.d.ts.map +1 -1
- package/lib/node/core/signedMsg.js +33 -0
- package/lib/node/decode/customCoder.d.ts +39 -3
- package/lib/node/decode/customCoder.d.ts.map +1 -1
- package/lib/node/decode/customCoder.js +45 -3
- package/lib/node/decode/user.d.ts +22 -0
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +22 -0
- package/lib/node/dlob/DLOB.d.ts +502 -53
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +540 -98
- package/lib/node/dlob/DLOBNode.d.ts +86 -4
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +37 -4
- package/lib/node/dlob/DLOBSubscriber.d.ts +39 -12
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +42 -12
- package/lib/node/dlob/NodeList.d.ts +69 -0
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.js +66 -0
- package/lib/node/dlob/orderBookLevels.d.ts +106 -13
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +84 -14
- package/lib/node/dlob/types.d.ts +15 -0
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/events/eventList.d.ts +14 -0
- package/lib/node/events/eventList.d.ts.map +1 -1
- package/lib/node/events/eventList.js +14 -0
- package/lib/node/events/eventSubscriber.d.ts +87 -10
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +93 -8
- package/lib/node/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -1
- package/lib/node/events/eventsServerLogProvider.js +27 -0
- package/lib/node/events/fetchLogs.d.ts +31 -0
- package/lib/node/events/fetchLogs.d.ts.map +1 -1
- package/lib/node/events/fetchLogs.js +46 -1
- package/lib/node/events/parse.d.ts +23 -0
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/events/parse.js +23 -0
- package/lib/node/events/pollingLogProvider.d.ts +24 -0
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -1
- package/lib/node/events/pollingLogProvider.js +24 -0
- package/lib/node/events/sort.d.ts +11 -0
- package/lib/node/events/sort.d.ts.map +1 -1
- package/lib/node/events/sort.js +12 -0
- package/lib/node/events/txEventCache.d.ts +13 -3
- package/lib/node/events/txEventCache.d.ts.map +1 -1
- package/lib/node/events/txEventCache.js +19 -7
- package/lib/node/events/types.d.ts +118 -2
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +11 -0
- package/lib/node/events/webSocketLogProvider.d.ts +23 -0
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -1
- package/lib/node/events/webSocketLogProvider.js +28 -0
- package/lib/node/factory/oracleClient.js +2 -2
- package/lib/node/idl/velocity.d.ts +4 -4
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +4 -4
- package/lib/node/keypair.d.ts +8 -0
- package/lib/node/keypair.d.ts.map +1 -1
- package/lib/node/keypair.js +8 -0
- package/lib/node/marginCalculation.d.ts +134 -2
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marginCalculation.js +121 -0
- package/lib/node/math/amm.d.ts +348 -29
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +310 -32
- package/lib/node/math/auction.d.ts +95 -19
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +118 -28
- package/lib/node/math/bankruptcy.d.ts +46 -0
- package/lib/node/math/bankruptcy.d.ts.map +1 -1
- package/lib/node/math/bankruptcy.js +89 -1
- package/lib/node/math/builder.d.ts +64 -8
- package/lib/node/math/builder.d.ts.map +1 -1
- package/lib/node/math/builder.js +71 -9
- package/lib/node/math/conversion.d.ts +21 -0
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/conversion.js +21 -0
- package/lib/node/math/exchangeStatus.d.ts +91 -0
- package/lib/node/math/exchangeStatus.d.ts.map +1 -1
- package/lib/node/math/exchangeStatus.js +106 -3
- package/lib/node/math/funding.d.ts +57 -20
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +63 -23
- package/lib/node/math/insurance.d.ts +62 -0
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/insurance.js +62 -0
- package/lib/node/math/liquidation.d.ts +127 -11
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/liquidation.js +182 -19
- package/lib/node/math/margin.d.ts +79 -13
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +80 -14
- package/lib/node/math/market.d.ts +135 -15
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +145 -17
- package/lib/node/math/oracles.d.ts +113 -0
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +118 -1
- package/lib/node/math/orders.d.ts +115 -10
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +130 -19
- package/lib/node/math/position.d.ts +80 -33
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +80 -33
- package/lib/node/math/repeg.d.ts +48 -10
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/repeg.js +48 -10
- package/lib/node/math/spotBalance.d.ts +200 -5
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotBalance.js +239 -10
- package/lib/node/math/spotMarket.d.ts +36 -3
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotMarket.js +36 -3
- package/lib/node/math/spotPosition.d.ts +72 -0
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/spotPosition.js +62 -0
- package/lib/node/math/state.d.ts +31 -0
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/state.js +31 -0
- package/lib/node/math/superStake.d.ts +126 -2
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +123 -3
- package/lib/node/math/tiers.d.ts +29 -0
- package/lib/node/math/tiers.d.ts.map +1 -1
- package/lib/node/math/tiers.js +29 -0
- package/lib/node/math/trade.d.ts +102 -51
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +101 -55
- package/lib/node/math/utils.d.ts +71 -9
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/math/utils.js +71 -9
- package/lib/node/memcmp.d.ts +94 -0
- package/lib/node/memcmp.d.ts.map +1 -1
- package/lib/node/memcmp.js +103 -2
- package/lib/node/oracles/oracleClientCache.d.ts +16 -0
- package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
- package/lib/node/oracles/oracleClientCache.js +16 -0
- package/lib/node/oracles/oracleId.d.ts +31 -0
- package/lib/node/oracles/oracleId.d.ts.map +1 -1
- package/lib/node/oracles/oracleId.js +39 -8
- package/lib/node/oracles/prelaunchOracleClient.d.ts +20 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +20 -0
- package/lib/node/oracles/pythClient.d.ts +31 -0
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.js +32 -1
- package/lib/node/oracles/pythLazerClient.d.ts +34 -0
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +35 -1
- package/lib/node/oracles/quoteAssetOracleClient.d.ts +18 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/quoteAssetOracleClient.js +18 -0
- package/lib/node/oracles/strictOraclePrice.d.ts +21 -0
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/strictOraclePrice.js +21 -0
- package/lib/node/oracles/types.d.ts +45 -0
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +20 -0
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/oracles/utils.js +20 -0
- package/lib/node/orderParams.d.ts +42 -4
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderParams.js +42 -4
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +56 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +56 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts +11 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/PollingSubscription.js +11 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +18 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/WebsocketSubscription.js +18 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts +16 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +16 -0
- package/lib/node/orderSubscriber/types.d.ts +9 -0
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +1 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/averageOverSlotsStrategy.js +1 -0
- package/lib/node/priorityFee/averageStrategy.d.ts +1 -0
- package/lib/node/priorityFee/averageStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/averageStrategy.js +1 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts +10 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/ewmaStrategy.js +10 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +13 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/heliusPriorityFeeMethod.js +9 -2
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +1 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/maxOverSlotsStrategy.js +1 -0
- package/lib/node/priorityFee/maxStrategy.d.ts +1 -0
- package/lib/node/priorityFee/maxStrategy.d.ts.map +1 -1
- package/lib/node/priorityFee/maxStrategy.js +1 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +39 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +39 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +20 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +21 -2
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +12 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/solanaPriorityFeeMethod.js +10 -0
- package/lib/node/priorityFee/types.d.ts +32 -0
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/types.js +5 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +11 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.js +8 -0
- package/lib/node/slot/SlotSubscriber.d.ts +18 -0
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlotSubscriber.js +16 -0
- package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -1
- package/lib/node/slot/SlothashSubscriber.js +25 -1
- package/lib/node/tx/baseTxSender.d.ts +163 -0
- package/lib/node/tx/baseTxSender.d.ts.map +1 -1
- package/lib/node/tx/baseTxSender.js +174 -6
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +12 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts.map +1 -1
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +12 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +15 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts.map +1 -1
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +15 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.d.ts +47 -0
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -1
- package/lib/node/tx/fastSingleTxSender.js +48 -1
- package/lib/node/tx/forwardOnlyTxSender.d.ts +48 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -1
- package/lib/node/tx/forwardOnlyTxSender.js +48 -0
- package/lib/node/tx/reportTransactionError.d.ts +18 -6
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -1
- package/lib/node/tx/reportTransactionError.js +18 -6
- package/lib/node/tx/retryTxSender.d.ts +40 -0
- package/lib/node/tx/retryTxSender.d.ts.map +1 -1
- package/lib/node/tx/retryTxSender.js +39 -0
- package/lib/node/tx/txHandler.d.ts +146 -35
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +132 -32
- package/lib/node/tx/txParamProcessor.d.ts +47 -0
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -1
- package/lib/node/tx/txParamProcessor.js +47 -0
- package/lib/node/tx/types.d.ts +46 -0
- package/lib/node/tx/types.d.ts.map +1 -1
- package/lib/node/tx/types.js +5 -0
- package/lib/node/tx/utils.d.ts +26 -0
- package/lib/node/tx/utils.d.ts.map +1 -1
- package/lib/node/tx/utils.js +26 -0
- package/lib/node/tx/whileValidTxSender.d.ts +82 -0
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -1
- package/lib/node/tx/whileValidTxSender.js +81 -0
- package/lib/node/types.d.ts +781 -13
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +126 -9
- package/lib/node/user.d.ts +645 -84
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +779 -96
- package/lib/node/userMap/PollingSubscription.d.ts +10 -0
- package/lib/node/userMap/PollingSubscription.d.ts.map +1 -1
- package/lib/node/userMap/PollingSubscription.js +14 -2
- package/lib/node/userMap/WebsocketSubscription.d.ts +9 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -1
- package/lib/node/userMap/WebsocketSubscription.js +9 -0
- package/lib/node/userMap/grpcSubscription.d.ts +8 -0
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -1
- package/lib/node/userMap/grpcSubscription.js +8 -0
- package/lib/node/userMap/referrerMap.d.ts +72 -2
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +84 -2
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +37 -10
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +38 -11
- package/lib/node/userMap/userMap.d.ts +81 -3
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +81 -4
- package/lib/node/userMap/userMapConfig.d.ts +23 -0
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +22 -0
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +22 -0
- package/lib/node/userName.d.ts +16 -0
- package/lib/node/userName.d.ts.map +1 -1
- package/lib/node/userName.js +16 -0
- package/lib/node/userStats.d.ts +28 -1
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +28 -1
- package/lib/node/util/TransactionConfirmationManager.d.ts +33 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -1
- package/lib/node/util/TransactionConfirmationManager.js +33 -0
- package/lib/node/util/chainClock.d.ts +24 -0
- package/lib/node/util/chainClock.d.ts.map +1 -1
- package/lib/node/util/chainClock.js +20 -0
- package/lib/node/util/computeUnits.d.ts +32 -0
- package/lib/node/util/computeUnits.d.ts.map +1 -1
- package/lib/node/util/computeUnits.js +32 -0
- package/lib/node/util/digest.d.ts +17 -0
- package/lib/node/util/digest.d.ts.map +1 -1
- package/lib/node/util/digest.js +17 -0
- package/lib/node/util/ed25519Utils.d.ts +12 -2
- package/lib/node/util/ed25519Utils.d.ts.map +1 -1
- package/lib/node/util/ed25519Utils.js +12 -2
- package/lib/node/util/promiseTimeout.d.ts +9 -0
- package/lib/node/util/promiseTimeout.d.ts.map +1 -1
- package/lib/node/util/promiseTimeout.js +9 -0
- package/lib/node/velocityClient.d.ts +3322 -215
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +3412 -245
- package/lib/node/wallet.d.ts +37 -0
- package/lib/node/wallet.d.ts.map +1 -1
- package/lib/node/wallet.js +37 -0
- package/package.json +2 -1
- package/src/accounts/basicUserAccountSubscriber.ts +18 -0
- package/src/accounts/basicUserStatsAccountSubscriber.ts +18 -0
- package/src/accounts/bulkAccountLoader.ts +52 -0
- package/src/accounts/bulkUserStatsSubscription.ts +9 -2
- package/src/accounts/bulkUserSubscription.ts +8 -2
- package/src/accounts/customizedCadenceBulkAccountLoader.ts +37 -0
- package/src/accounts/fetch.ts +59 -2
- package/src/accounts/grpcAccountSubscriber.ts +30 -0
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +16 -0
- package/src/accounts/grpcMultiAccountSubscriber.ts +121 -38
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +49 -11
- package/src/accounts/grpcProgramAccountSubscriber.ts +33 -0
- package/src/accounts/grpcUserAccountSubscriber.ts +15 -0
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +15 -0
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +41 -0
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +160 -1
- package/src/accounts/laserProgramAccountSubscriber.ts +34 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +19 -0
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +19 -0
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +31 -0
- package/src/accounts/pollingOracleAccountSubscriber.ts +21 -2
- package/src/accounts/pollingTokenAccountSubscriber.ts +22 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +32 -0
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +22 -0
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +84 -1
- package/src/accounts/testBulkAccountLoader.ts +8 -0
- package/src/accounts/types.ts +149 -0
- package/src/accounts/utils.ts +42 -24
- package/src/accounts/webSocketAccountSubscriber.ts +41 -0
- package/src/accounts/webSocketAccountSubscriberV2.ts +31 -23
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +27 -0
- package/src/accounts/webSocketProgramAccountSubscriber.ts +36 -0
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +26 -0
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +21 -0
- package/src/accounts/webSocketUserAccountSubscriber.ts +26 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +20 -0
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +127 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +110 -0
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +33 -0
- package/src/addresses/marketAddresses.ts +10 -0
- package/src/addresses/pda.ts +228 -12
- package/src/adminClient.ts +2156 -4
- package/src/auctionSubscriber/auctionSubscriber.ts +15 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +19 -0
- package/src/auctionSubscriber/index.ts +6 -0
- package/src/auctionSubscriber/types.ts +7 -0
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +33 -0
- package/src/blockhashSubscriber/index.ts +5 -0
- package/src/blockhashSubscriber/types.ts +5 -4
- package/src/clock/clockSubscriber.ts +24 -0
- package/src/config.ts +109 -22
- package/src/constants/numericConstants.ts +70 -0
- package/src/constants/perpMarkets.ts +45 -960
- package/src/constants/spotMarkets.ts +23 -793
- package/src/constants/txConstants.ts +1 -0
- package/src/core/VelocityCore.ts +286 -8
- package/src/core/instructions/deposit.ts +22 -0
- package/src/core/instructions/fill.ts +17 -0
- package/src/core/instructions/funding.ts +12 -0
- package/src/core/instructions/liquidation.ts +18 -0
- package/src/core/instructions/orders.ts +28 -0
- package/src/core/instructions/perpOrders.ts +106 -0
- package/src/core/instructions/settlement.ts +14 -0
- package/src/core/instructions/trigger.ts +15 -0
- package/src/core/instructions/withdraw.ts +21 -0
- package/src/core/remainingAccounts.ts +47 -3
- package/src/core/signedMsg.ts +38 -0
- package/src/decode/customCoder.ts +46 -3
- package/src/decode/user.ts +22 -0
- package/src/dlob/DLOB.ts +668 -97
- package/src/dlob/DLOBNode.ts +98 -6
- package/src/dlob/DLOBSubscriber.ts +49 -12
- package/src/dlob/NodeList.ts +69 -0
- package/src/dlob/orderBookLevels.ts +108 -14
- package/src/dlob/types.ts +15 -0
- package/src/events/eventList.ts +14 -0
- package/src/events/eventSubscriber.ts +100 -19
- package/src/events/eventsServerLogProvider.ts +28 -0
- package/src/events/fetchLogs.ts +52 -2
- package/src/events/parse.ts +23 -0
- package/src/events/pollingLogProvider.ts +24 -0
- package/src/events/sort.ts +12 -0
- package/src/events/txEventCache.ts +19 -7
- package/src/events/types.ts +131 -11
- package/src/events/webSocketLogProvider.ts +29 -0
- package/src/factory/oracleClient.ts +2 -2
- package/src/idl/velocity.json +4 -4
- package/src/idl/velocity.ts +4 -4
- package/src/keypair.ts +8 -0
- package/src/marginCalculation.ts +153 -2
- package/src/math/amm.ts +371 -36
- package/src/math/auction.ts +139 -30
- package/src/math/bankruptcy.ts +104 -1
- package/src/math/builder.ts +74 -8
- package/src/math/conversion.ts +21 -0
- package/src/math/exchangeStatus.ts +117 -2
- package/src/math/funding.ts +63 -23
- package/src/math/insurance.ts +62 -0
- package/src/math/liquidation.ts +227 -17
- package/src/math/margin.ts +80 -14
- package/src/math/market.ts +148 -17
- package/src/math/oracles.ts +124 -0
- package/src/math/orders.ts +141 -19
- package/src/math/position.ts +80 -33
- package/src/math/repeg.ts +48 -10
- package/src/math/spotBalance.ts +252 -12
- package/src/math/spotMarket.ts +36 -3
- package/src/math/spotPosition.ts +72 -0
- package/src/math/state.ts +31 -0
- package/src/math/superStake.ts +126 -3
- package/src/math/tiers.ts +29 -0
- package/src/math/trade.ts +125 -55
- package/src/math/utils.ts +71 -9
- package/src/memcmp.ts +104 -2
- package/src/oracles/oracleClientCache.ts +16 -0
- package/src/oracles/oracleId.ts +39 -6
- package/src/oracles/prelaunchOracleClient.ts +20 -0
- package/src/oracles/pythClient.ts +32 -1
- package/src/oracles/pythLazerClient.ts +35 -1
- package/src/oracles/quoteAssetOracleClient.ts +18 -0
- package/src/oracles/strictOraclePrice.ts +21 -0
- package/src/oracles/types.ts +45 -0
- package/src/oracles/utils.ts +20 -0
- package/src/orderParams.ts +42 -4
- package/src/orderSubscriber/OrderSubscriber.ts +56 -0
- package/src/orderSubscriber/PollingSubscription.ts +11 -0
- package/src/orderSubscriber/WebsocketSubscription.ts +18 -0
- package/src/orderSubscriber/grpcSubscription.ts +16 -0
- package/src/orderSubscriber/types.ts +9 -0
- package/src/priorityFee/averageOverSlotsStrategy.ts +1 -0
- package/src/priorityFee/averageStrategy.ts +1 -0
- package/src/priorityFee/ewmaStrategy.ts +10 -0
- package/src/priorityFee/heliusPriorityFeeMethod.ts +13 -2
- package/src/priorityFee/maxOverSlotsStrategy.ts +1 -0
- package/src/priorityFee/maxStrategy.ts +1 -0
- package/src/priorityFee/priorityFeeSubscriber.ts +39 -0
- package/src/priorityFee/priorityFeeSubscriberMap.ts +21 -2
- package/src/priorityFee/solanaPriorityFeeMethod.ts +12 -0
- package/src/priorityFee/types.ts +33 -15
- package/src/priorityFee/velocityPriorityFeeMethod.ts +11 -0
- package/src/slot/SlotSubscriber.ts +18 -0
- package/src/slot/SlothashSubscriber.ts +27 -1
- package/src/tx/baseTxSender.ts +185 -5
- package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +12 -0
- package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +15 -0
- package/src/tx/blockhashFetcher/types.ts +4 -0
- package/src/tx/fastSingleTxSender.ts +58 -4
- package/src/tx/forwardOnlyTxSender.ts +48 -0
- package/src/tx/reportTransactionError.ts +18 -6
- package/src/tx/retryTxSender.ts +40 -0
- package/src/tx/txHandler.ts +146 -35
- package/src/tx/txParamProcessor.ts +47 -0
- package/src/tx/types.ts +46 -0
- package/src/tx/utils.ts +26 -0
- package/src/tx/whileValidTxSender.ts +82 -0
- package/src/types.ts +777 -24
- package/src/user.ts +869 -110
- package/src/userMap/PollingSubscription.ts +16 -2
- package/src/userMap/WebsocketSubscription.ts +9 -0
- package/src/userMap/grpcSubscription.ts +8 -0
- package/src/userMap/referrerMap.ts +92 -3
- package/src/userMap/revenueShareEscrowMap.ts +38 -11
- package/src/userMap/userMap.ts +82 -4
- package/src/userMap/userMapConfig.ts +23 -10
- package/src/userMap/userStatsMap.ts +22 -0
- package/src/userName.ts +16 -0
- package/src/userStats.ts +28 -1
- package/src/util/TransactionConfirmationManager.ts +33 -0
- package/src/util/chainClock.ts +24 -0
- package/src/util/computeUnits.ts +32 -0
- package/src/util/digest.ts +17 -0
- package/src/util/ed25519Utils.ts +12 -2
- package/src/util/promiseTimeout.ts +9 -0
- package/src/velocityClient.ts +3439 -249
- package/src/wallet.ts +37 -0
- package/tests/VelocityCore/builder_escrow.test.ts +121 -0
- package/tests/amm/test.ts +102 -0
- package/tests/builder/builderFee.test.ts +42 -0
- package/tests/dlob/tickSizeStandardization.ts +545 -0
- package/tests/exchangeStatus/test.ts +45 -0
- package/tests/liquidation/test.ts +125 -0
- package/tests/oracles/mmOracleGate.test.ts +379 -0
- package/tests/oracles/pythPegSnap.test.ts +76 -0
- package/tests/sdkParity/enumParity.test.ts +84 -0
- package/tests/sdkParity/marginCategoryFill.test.ts +143 -0
- package/tests/sdkParity/memcmpOffsets.test.ts +139 -0
- package/tests/spot/test.ts +55 -0
- package/tests/user/bankruptcy.ts +165 -0
- package/tests/user/feeAndWithdrawLimits.ts +284 -0
- package/tests/user/getMarginCalculation.ts +226 -1
- package/tests/user/test.ts +8 -4
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,
|
|
@@ -84,6 +91,19 @@ import { JupiterClient, QuoteResponse } from './jupiter/jupiterClient';
|
|
|
84
91
|
import { SwapMode } from './swap/UnifiedSwapClient';
|
|
85
92
|
|
|
86
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
|
+
*/
|
|
87
107
|
public async initialize(
|
|
88
108
|
usdcMint: PublicKey,
|
|
89
109
|
_adminControlsPrices: boolean
|
|
@@ -119,6 +139,39 @@ export class AdminClient extends VelocityClient {
|
|
|
119
139
|
return [txSig];
|
|
120
140
|
}
|
|
121
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
|
+
*/
|
|
122
175
|
public async initializeSpotMarket(
|
|
123
176
|
mint: PublicKey,
|
|
124
177
|
optimalUtilization: number,
|
|
@@ -185,6 +238,14 @@ export class AdminClient extends VelocityClient {
|
|
|
185
238
|
return txSig;
|
|
186
239
|
}
|
|
187
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
|
+
*/
|
|
188
249
|
public async getInitializeSpotMarketIx(
|
|
189
250
|
mint: PublicKey,
|
|
190
251
|
optimalUtilization: number,
|
|
@@ -277,6 +338,15 @@ export class AdminClient extends VelocityClient {
|
|
|
277
338
|
return initializeIx;
|
|
278
339
|
}
|
|
279
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
|
+
*/
|
|
280
350
|
public async deleteInitializedSpotMarket(
|
|
281
351
|
marketIndex: number
|
|
282
352
|
): Promise<TransactionSignature> {
|
|
@@ -290,6 +360,12 @@ export class AdminClient extends VelocityClient {
|
|
|
290
360
|
return txSig;
|
|
291
361
|
}
|
|
292
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
|
+
*/
|
|
293
369
|
public async getDeleteInitializedSpotMarketIx(
|
|
294
370
|
marketIndex: number
|
|
295
371
|
): Promise<TransactionInstruction> {
|
|
@@ -326,6 +402,45 @@ export class AdminClient extends VelocityClient {
|
|
|
326
402
|
);
|
|
327
403
|
}
|
|
328
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
|
+
*/
|
|
329
444
|
public async initializePerpMarket(
|
|
330
445
|
marketIndex: number,
|
|
331
446
|
priceOracle: PublicKey,
|
|
@@ -408,6 +523,11 @@ export class AdminClient extends VelocityClient {
|
|
|
408
523
|
return txSig;
|
|
409
524
|
}
|
|
410
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
|
+
*/
|
|
411
531
|
public async getInitializePerpMarketIx(
|
|
412
532
|
marketIndex: number,
|
|
413
533
|
priceOracle: PublicKey,
|
|
@@ -495,6 +615,11 @@ export class AdminClient extends VelocityClient {
|
|
|
495
615
|
return ixs;
|
|
496
616
|
}
|
|
497
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
|
+
*/
|
|
498
623
|
public async initializeAmmCache(
|
|
499
624
|
txParams?: TxParams
|
|
500
625
|
): Promise<TransactionSignature> {
|
|
@@ -507,6 +632,10 @@ export class AdminClient extends VelocityClient {
|
|
|
507
632
|
return txSig;
|
|
508
633
|
}
|
|
509
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Builds the `initializeAmmCache` instruction without sending it. See `initializeAmmCache`.
|
|
637
|
+
* @returns The unsigned `initializeAmmCache` instruction.
|
|
638
|
+
*/
|
|
510
639
|
public async getInitializeAmmCacheIx(): Promise<TransactionInstruction> {
|
|
511
640
|
return await this.program.instruction.initializeAmmCache({
|
|
512
641
|
accounts: {
|
|
@@ -521,6 +650,14 @@ export class AdminClient extends VelocityClient {
|
|
|
521
650
|
});
|
|
522
651
|
}
|
|
523
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
|
+
*/
|
|
524
661
|
public async addMarketToAmmCache(
|
|
525
662
|
perpMarketIndex: number,
|
|
526
663
|
txParams?: TxParams
|
|
@@ -536,6 +673,12 @@ export class AdminClient extends VelocityClient {
|
|
|
536
673
|
return txSig;
|
|
537
674
|
}
|
|
538
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
|
+
*/
|
|
539
682
|
public async getAddMarketToAmmCacheIx(
|
|
540
683
|
perpMarketIndex: number
|
|
541
684
|
): Promise<TransactionInstruction> {
|
|
@@ -554,6 +697,12 @@ export class AdminClient extends VelocityClient {
|
|
|
554
697
|
});
|
|
555
698
|
}
|
|
556
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
|
+
*/
|
|
557
706
|
public async deleteAmmCache(
|
|
558
707
|
txParams?: TxParams
|
|
559
708
|
): Promise<TransactionSignature> {
|
|
@@ -566,6 +715,10 @@ export class AdminClient extends VelocityClient {
|
|
|
566
715
|
return txSig;
|
|
567
716
|
}
|
|
568
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Builds the `deleteAmmCache` instruction without sending it. See `deleteAmmCache`.
|
|
720
|
+
* @returns The unsigned `deleteAmmCache` instruction.
|
|
721
|
+
*/
|
|
569
722
|
public async getDeleteAmmCacheIx(): Promise<TransactionInstruction> {
|
|
570
723
|
return await this.program.instruction.deleteAmmCache({
|
|
571
724
|
accounts: {
|
|
@@ -578,6 +731,15 @@ export class AdminClient extends VelocityClient {
|
|
|
578
731
|
});
|
|
579
732
|
}
|
|
580
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
|
+
*/
|
|
581
743
|
public async updateInitialAmmCacheInfo(
|
|
582
744
|
perpMarketIndexes: number[],
|
|
583
745
|
txParams?: TxParams
|
|
@@ -593,6 +755,12 @@ export class AdminClient extends VelocityClient {
|
|
|
593
755
|
return txSig;
|
|
594
756
|
}
|
|
595
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
|
+
*/
|
|
596
764
|
public async getUpdateInitialAmmCacheInfoIx(
|
|
597
765
|
perpMarketIndexes: number[]
|
|
598
766
|
): Promise<TransactionInstruction> {
|
|
@@ -613,6 +781,26 @@ export class AdminClient extends VelocityClient {
|
|
|
613
781
|
});
|
|
614
782
|
}
|
|
615
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
|
+
*/
|
|
616
804
|
public async overrideAmmCacheInfo(
|
|
617
805
|
perpMarketIndex: number,
|
|
618
806
|
params: {
|
|
@@ -636,6 +824,12 @@ export class AdminClient extends VelocityClient {
|
|
|
636
824
|
return txSig;
|
|
637
825
|
}
|
|
638
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
|
+
*/
|
|
639
833
|
public async getOverrideAmmCacheInfoIx(
|
|
640
834
|
perpMarketIndex: number,
|
|
641
835
|
params: {
|
|
@@ -673,6 +867,17 @@ export class AdminClient extends VelocityClient {
|
|
|
673
867
|
);
|
|
674
868
|
}
|
|
675
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
|
+
*/
|
|
676
881
|
public async resetAmmCache(
|
|
677
882
|
txParams?: TxParams
|
|
678
883
|
): Promise<TransactionSignature> {
|
|
@@ -684,6 +889,11 @@ export class AdminClient extends VelocityClient {
|
|
|
684
889
|
return txSig;
|
|
685
890
|
}
|
|
686
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
|
+
*/
|
|
687
897
|
public async getResetAmmCacheIx(): Promise<TransactionInstruction> {
|
|
688
898
|
return (this.program.instruction as any).resetAmmCache({
|
|
689
899
|
accounts: {
|
|
@@ -697,6 +907,14 @@ export class AdminClient extends VelocityClient {
|
|
|
697
907
|
});
|
|
698
908
|
}
|
|
699
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
|
+
*/
|
|
700
918
|
public async deleteInitializedPerpMarket(
|
|
701
919
|
marketIndex: number
|
|
702
920
|
): Promise<TransactionSignature> {
|
|
@@ -710,6 +928,12 @@ export class AdminClient extends VelocityClient {
|
|
|
710
928
|
return txSig;
|
|
711
929
|
}
|
|
712
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
|
+
*/
|
|
713
937
|
public async getDeleteInitializedPerpMarketIx(
|
|
714
938
|
marketIndex: number
|
|
715
939
|
): Promise<TransactionInstruction> {
|
|
@@ -732,6 +956,19 @@ export class AdminClient extends VelocityClient {
|
|
|
732
956
|
);
|
|
733
957
|
}
|
|
734
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
|
+
*/
|
|
735
972
|
public async moveAmmPrice(
|
|
736
973
|
perpMarketIndex: number,
|
|
737
974
|
baseAssetReserve: BN,
|
|
@@ -752,6 +989,11 @@ export class AdminClient extends VelocityClient {
|
|
|
752
989
|
return txSig;
|
|
753
990
|
}
|
|
754
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
|
+
*/
|
|
755
997
|
public async getMoveAmmPriceIx(
|
|
756
998
|
perpMarketIndex: number,
|
|
757
999
|
baseAssetReserve: BN,
|
|
@@ -783,6 +1025,18 @@ export class AdminClient extends VelocityClient {
|
|
|
783
1025
|
);
|
|
784
1026
|
}
|
|
785
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
|
+
*/
|
|
786
1040
|
public async updateK(
|
|
787
1041
|
perpMarketIndex: number,
|
|
788
1042
|
sqrtK: BN
|
|
@@ -796,6 +1050,11 @@ export class AdminClient extends VelocityClient {
|
|
|
796
1050
|
return txSig;
|
|
797
1051
|
}
|
|
798
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
|
+
*/
|
|
799
1058
|
public async getUpdateKIx(
|
|
800
1059
|
perpMarketIndex: number,
|
|
801
1060
|
sqrtK: BN
|
|
@@ -816,6 +1075,17 @@ export class AdminClient extends VelocityClient {
|
|
|
816
1075
|
});
|
|
817
1076
|
}
|
|
818
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
|
+
*/
|
|
819
1089
|
public async recenterPerpMarketAmm(
|
|
820
1090
|
perpMarketIndex: number,
|
|
821
1091
|
pegMultiplier: BN,
|
|
@@ -834,6 +1104,11 @@ export class AdminClient extends VelocityClient {
|
|
|
834
1104
|
return txSig;
|
|
835
1105
|
}
|
|
836
1106
|
|
|
1107
|
+
/**
|
|
1108
|
+
* Builds the `recenterPerpMarketAmm` instruction without sending it. See
|
|
1109
|
+
* `recenterPerpMarketAmm` for units.
|
|
1110
|
+
* @returns The unsigned `recenterPerpMarketAmm` instruction.
|
|
1111
|
+
*/
|
|
837
1112
|
public async getRecenterPerpMarketAmmIx(
|
|
838
1113
|
perpMarketIndex: number,
|
|
839
1114
|
pegMultiplier: BN,
|
|
@@ -859,6 +1134,14 @@ export class AdminClient extends VelocityClient {
|
|
|
859
1134
|
);
|
|
860
1135
|
}
|
|
861
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
|
+
*/
|
|
862
1145
|
public async recenterPerpMarketAmmCrank(
|
|
863
1146
|
perpMarketIndex: number,
|
|
864
1147
|
depth?: BN
|
|
@@ -875,6 +1158,11 @@ export class AdminClient extends VelocityClient {
|
|
|
875
1158
|
return txSig;
|
|
876
1159
|
}
|
|
877
1160
|
|
|
1161
|
+
/**
|
|
1162
|
+
* Builds the `recenterPerpMarketAmmCrank` instruction without sending it. See
|
|
1163
|
+
* `recenterPerpMarketAmmCrank`.
|
|
1164
|
+
* @returns The unsigned `recenterPerpMarketAmmCrank` instruction.
|
|
1165
|
+
*/
|
|
878
1166
|
public async getRecenterPerpMarketAmmCrankIx(
|
|
879
1167
|
perpMarketIndex: number,
|
|
880
1168
|
depth?: BN
|
|
@@ -902,6 +1190,14 @@ export class AdminClient extends VelocityClient {
|
|
|
902
1190
|
);
|
|
903
1191
|
}
|
|
904
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
|
+
*/
|
|
905
1201
|
public async updatePerpMarketConcentrationScale(
|
|
906
1202
|
perpMarketIndex: number,
|
|
907
1203
|
concentrationScale: BN
|
|
@@ -919,6 +1215,11 @@ export class AdminClient extends VelocityClient {
|
|
|
919
1215
|
return txSig;
|
|
920
1216
|
}
|
|
921
1217
|
|
|
1218
|
+
/**
|
|
1219
|
+
* Builds the `updatePerpMarketConcentrationCoef` instruction without sending it. See
|
|
1220
|
+
* `updatePerpMarketConcentrationScale`.
|
|
1221
|
+
* @returns The unsigned `updatePerpMarketConcentrationCoef` instruction.
|
|
1222
|
+
*/
|
|
922
1223
|
public async getUpdatePerpMarketConcentrationScaleIx(
|
|
923
1224
|
perpMarketIndex: number,
|
|
924
1225
|
concentrationScale: BN
|
|
@@ -940,6 +1241,13 @@ export class AdminClient extends VelocityClient {
|
|
|
940
1241
|
);
|
|
941
1242
|
}
|
|
942
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
|
+
*/
|
|
943
1251
|
public async updatePerpMarketLpPoolId(
|
|
944
1252
|
perpMarketIndex: number,
|
|
945
1253
|
lpPoolId: number
|
|
@@ -956,6 +1264,11 @@ export class AdminClient extends VelocityClient {
|
|
|
956
1264
|
return txSig;
|
|
957
1265
|
}
|
|
958
1266
|
|
|
1267
|
+
/**
|
|
1268
|
+
* Builds the `updatePerpMarketLpPoolId` instruction without sending it. See
|
|
1269
|
+
* `updatePerpMarketLpPoolId`.
|
|
1270
|
+
* @returns The unsigned `updatePerpMarketLpPoolId` instruction.
|
|
1271
|
+
*/
|
|
959
1272
|
public async getUpdatePerpMarketLpPoolIdIx(
|
|
960
1273
|
perpMarketIndex: number,
|
|
961
1274
|
lpPoolId: number
|
|
@@ -974,6 +1287,14 @@ export class AdminClient extends VelocityClient {
|
|
|
974
1287
|
});
|
|
975
1288
|
}
|
|
976
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
|
+
*/
|
|
977
1298
|
public async updatePerpMarketLpPoolStatus(
|
|
978
1299
|
perpMarketIndex: number,
|
|
979
1300
|
lpStatus: number
|
|
@@ -988,6 +1309,11 @@ export class AdminClient extends VelocityClient {
|
|
|
988
1309
|
return txSig;
|
|
989
1310
|
}
|
|
990
1311
|
|
|
1312
|
+
/**
|
|
1313
|
+
* Builds the `updatePerpMarketLpPoolStatus` instruction without sending it. See
|
|
1314
|
+
* `updatePerpMarketLpPoolStatus`.
|
|
1315
|
+
* @returns The unsigned `updatePerpMarketLpPoolStatus` instruction.
|
|
1316
|
+
*/
|
|
991
1317
|
public async getUpdatePerpMarketLpPoolStatusIx(
|
|
992
1318
|
perpMarketIndex: number,
|
|
993
1319
|
lpStatus: number
|
|
@@ -1010,6 +1336,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1010
1336
|
);
|
|
1011
1337
|
}
|
|
1012
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
|
+
*/
|
|
1013
1349
|
public async moveAmmToPrice(
|
|
1014
1350
|
perpMarketIndex: number,
|
|
1015
1351
|
targetPrice: BN
|
|
@@ -1026,6 +1362,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1026
1362
|
return txSig;
|
|
1027
1363
|
}
|
|
1028
1364
|
|
|
1365
|
+
/**
|
|
1366
|
+
* Builds the underlying `moveAmmPrice` instruction that moves the AMM to `targetPrice`.
|
|
1367
|
+
* See `moveAmmToPrice`.
|
|
1368
|
+
* @returns The unsigned `moveAmmPrice` instruction.
|
|
1369
|
+
*/
|
|
1029
1370
|
public async getMoveAmmToPriceIx(
|
|
1030
1371
|
perpMarketIndex: number,
|
|
1031
1372
|
targetPrice: BN
|
|
@@ -1069,6 +1410,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1069
1410
|
);
|
|
1070
1411
|
}
|
|
1071
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
|
+
*/
|
|
1072
1422
|
public async repegAmmCurve(
|
|
1073
1423
|
newPeg: BN,
|
|
1074
1424
|
perpMarketIndex: number
|
|
@@ -1085,6 +1435,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1085
1435
|
return txSig;
|
|
1086
1436
|
}
|
|
1087
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
|
+
*/
|
|
1088
1444
|
public async getRepegAmmCurveIx(
|
|
1089
1445
|
newPeg: BN,
|
|
1090
1446
|
perpMarketIndex: number
|
|
@@ -1107,6 +1463,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1107
1463
|
});
|
|
1108
1464
|
}
|
|
1109
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
|
+
*/
|
|
1110
1476
|
public async updatePerpMarketAmmOracleTwap(
|
|
1111
1477
|
perpMarketIndex: number
|
|
1112
1478
|
): Promise<TransactionSignature> {
|
|
@@ -1120,6 +1486,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1120
1486
|
return txSig;
|
|
1121
1487
|
}
|
|
1122
1488
|
|
|
1489
|
+
/**
|
|
1490
|
+
* Builds the `updatePerpMarketAmmOracleTwap` instruction without sending it. See
|
|
1491
|
+
* `updatePerpMarketAmmOracleTwap`.
|
|
1492
|
+
* @returns The unsigned `updatePerpMarketAmmOracleTwap` instruction.
|
|
1493
|
+
*/
|
|
1123
1494
|
public async getUpdatePerpMarketAmmOracleTwapIx(
|
|
1124
1495
|
perpMarketIndex: number
|
|
1125
1496
|
): Promise<TransactionInstruction> {
|
|
@@ -1141,6 +1512,14 @@ export class AdminClient extends VelocityClient {
|
|
|
1141
1512
|
});
|
|
1142
1513
|
}
|
|
1143
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
|
+
*/
|
|
1144
1523
|
public async resetPerpMarketAmmOracleTwap(
|
|
1145
1524
|
perpMarketIndex: number
|
|
1146
1525
|
): Promise<TransactionSignature> {
|
|
@@ -1154,6 +1533,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1154
1533
|
return txSig;
|
|
1155
1534
|
}
|
|
1156
1535
|
|
|
1536
|
+
/**
|
|
1537
|
+
* Builds the `resetPerpMarketAmmOracleTwap` instruction without sending it. See
|
|
1538
|
+
* `resetPerpMarketAmmOracleTwap`.
|
|
1539
|
+
* @returns The unsigned `resetPerpMarketAmmOracleTwap` instruction.
|
|
1540
|
+
*/
|
|
1157
1541
|
public async getResetPerpMarketAmmOracleTwapIx(
|
|
1158
1542
|
perpMarketIndex: number
|
|
1159
1543
|
): Promise<TransactionInstruction> {
|
|
@@ -1175,6 +1559,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1175
1559
|
});
|
|
1176
1560
|
}
|
|
1177
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
|
+
*/
|
|
1178
1572
|
public async depositIntoPerpMarketFeePool(
|
|
1179
1573
|
perpMarketIndex: number,
|
|
1180
1574
|
amount: BN,
|
|
@@ -1194,6 +1588,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1194
1588
|
return txSig;
|
|
1195
1589
|
}
|
|
1196
1590
|
|
|
1591
|
+
/**
|
|
1592
|
+
* Builds the `depositIntoPerpMarketFeePool` instruction without sending it. See
|
|
1593
|
+
* `depositIntoPerpMarketFeePool`.
|
|
1594
|
+
* @returns The unsigned `depositIntoPerpMarketFeePool` instruction.
|
|
1595
|
+
*/
|
|
1197
1596
|
public async getDepositIntoPerpMarketFeePoolIx(
|
|
1198
1597
|
perpMarketIndex: number,
|
|
1199
1598
|
amount: BN,
|
|
@@ -1228,6 +1627,17 @@ export class AdminClient extends VelocityClient {
|
|
|
1228
1627
|
});
|
|
1229
1628
|
}
|
|
1230
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
|
+
*/
|
|
1231
1641
|
public async updatePerpMarketPnlPool(
|
|
1232
1642
|
perpMarketIndex: number,
|
|
1233
1643
|
amount: BN
|
|
@@ -1244,6 +1654,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1244
1654
|
return txSig;
|
|
1245
1655
|
}
|
|
1246
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
|
+
*/
|
|
1247
1662
|
public async getUpdatePerpMarketPnlPoolIx(
|
|
1248
1663
|
perpMarketIndex: number,
|
|
1249
1664
|
amount: BN
|
|
@@ -1264,6 +1679,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1264
1679
|
});
|
|
1265
1680
|
}
|
|
1266
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
|
+
*/
|
|
1267
1692
|
public async depositIntoSpotMarketVault(
|
|
1268
1693
|
spotMarketIndex: number,
|
|
1269
1694
|
amount: BN,
|
|
@@ -1283,6 +1708,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1283
1708
|
return txSig;
|
|
1284
1709
|
}
|
|
1285
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
|
+
*/
|
|
1286
1717
|
public async getDepositIntoSpotMarketVaultIx(
|
|
1287
1718
|
spotMarketIndex: number,
|
|
1288
1719
|
amount: BN,
|
|
@@ -1315,6 +1746,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1315
1746
|
});
|
|
1316
1747
|
}
|
|
1317
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
|
+
*/
|
|
1318
1758
|
public async updateAdmin(admin: PublicKey): Promise<TransactionSignature> {
|
|
1319
1759
|
const updateAdminIx = await this.getUpdateAdminIx(admin);
|
|
1320
1760
|
|
|
@@ -1325,6 +1765,10 @@ export class AdminClient extends VelocityClient {
|
|
|
1325
1765
|
return txSig;
|
|
1326
1766
|
}
|
|
1327
1767
|
|
|
1768
|
+
/**
|
|
1769
|
+
* Builds the `updateAdmin` instruction without sending it. See `updateAdmin`.
|
|
1770
|
+
* @returns The unsigned `updateAdmin` instruction.
|
|
1771
|
+
*/
|
|
1328
1772
|
public async getUpdateAdminIx(
|
|
1329
1773
|
admin: PublicKey
|
|
1330
1774
|
): Promise<TransactionInstruction> {
|
|
@@ -1338,6 +1782,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1338
1782
|
});
|
|
1339
1783
|
}
|
|
1340
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
|
+
*/
|
|
1341
1795
|
public async updatePerpMarketCurveUpdateIntensity(
|
|
1342
1796
|
perpMarketIndex: number,
|
|
1343
1797
|
curveUpdateIntensity: number
|
|
@@ -1357,6 +1811,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1357
1811
|
return txSig;
|
|
1358
1812
|
}
|
|
1359
1813
|
|
|
1814
|
+
/**
|
|
1815
|
+
* Builds the `updatePerpMarketCurveUpdateIntensity` instruction without sending it. See
|
|
1816
|
+
* `updatePerpMarketCurveUpdateIntensity`.
|
|
1817
|
+
* @returns The unsigned `updatePerpMarketCurveUpdateIntensity` instruction.
|
|
1818
|
+
*/
|
|
1360
1819
|
public async getUpdatePerpMarketCurveUpdateIntensityIx(
|
|
1361
1820
|
perpMarketIndex: number,
|
|
1362
1821
|
curveUpdateIntensity: number
|
|
@@ -1378,6 +1837,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1378
1837
|
);
|
|
1379
1838
|
}
|
|
1380
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
|
+
*/
|
|
1381
1850
|
public async updatePerpMarketReferencePriceOffsetDeadbandPct(
|
|
1382
1851
|
perpMarketIndex: number,
|
|
1383
1852
|
referencePriceOffsetDeadbandPct: number
|
|
@@ -1397,6 +1866,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1397
1866
|
return txSig;
|
|
1398
1867
|
}
|
|
1399
1868
|
|
|
1869
|
+
/**
|
|
1870
|
+
* Builds the `updatePerpMarketReferencePriceOffsetDeadbandPct` instruction without sending
|
|
1871
|
+
* it. See `updatePerpMarketReferencePriceOffsetDeadbandPct`.
|
|
1872
|
+
* @returns The unsigned `updatePerpMarketReferencePriceOffsetDeadbandPct` instruction.
|
|
1873
|
+
*/
|
|
1400
1874
|
public async getUpdatePerpMarketReferencePriceOffsetDeadbandPctIx(
|
|
1401
1875
|
perpMarketIndex: number,
|
|
1402
1876
|
referencePriceOffsetDeadbandPct: number
|
|
@@ -1418,6 +1892,17 @@ export class AdminClient extends VelocityClient {
|
|
|
1418
1892
|
);
|
|
1419
1893
|
}
|
|
1420
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
|
+
*/
|
|
1421
1906
|
public async updatePerpMarketTargetBaseAssetAmountPerLp(
|
|
1422
1907
|
perpMarketIndex: number,
|
|
1423
1908
|
targetBaseAssetAmountPerLP: number
|
|
@@ -1437,6 +1922,18 @@ export class AdminClient extends VelocityClient {
|
|
|
1437
1922
|
return txSig;
|
|
1438
1923
|
}
|
|
1439
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
|
+
*/
|
|
1440
1937
|
public async updatePerpMarketAmmSummaryStats(
|
|
1441
1938
|
perpMarketIndex: number,
|
|
1442
1939
|
updateAmmSummaryStats?: boolean,
|
|
@@ -1456,6 +1953,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1456
1953
|
return txSig;
|
|
1457
1954
|
}
|
|
1458
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
|
+
*/
|
|
1459
1962
|
public async getUpdatePerpMarketAmmSummaryStatsIx(
|
|
1460
1963
|
perpMarketIndex: number,
|
|
1461
1964
|
updateAmmSummaryStats?: boolean,
|
|
@@ -1487,6 +1990,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1487
1990
|
);
|
|
1488
1991
|
}
|
|
1489
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
|
+
*/
|
|
1490
1999
|
public async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(
|
|
1491
2000
|
perpMarketIndex: number,
|
|
1492
2001
|
targetBaseAssetAmountPerLP: number
|
|
@@ -1507,6 +2016,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1507
2016
|
});
|
|
1508
2017
|
}
|
|
1509
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
|
+
*/
|
|
1510
2029
|
public async updatePerpMarketMarginRatio(
|
|
1511
2030
|
perpMarketIndex: number,
|
|
1512
2031
|
marginRatioInitial: number,
|
|
@@ -1526,6 +2045,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1526
2045
|
return txSig;
|
|
1527
2046
|
}
|
|
1528
2047
|
|
|
2048
|
+
/**
|
|
2049
|
+
* Builds the `updatePerpMarketMarginRatio` instruction without sending it. See
|
|
2050
|
+
* `updatePerpMarketMarginRatio`.
|
|
2051
|
+
* @returns The unsigned `updatePerpMarketMarginRatio` instruction.
|
|
2052
|
+
*/
|
|
1529
2053
|
public async getUpdatePerpMarketMarginRatioIx(
|
|
1530
2054
|
perpMarketIndex: number,
|
|
1531
2055
|
marginRatioInitial: number,
|
|
@@ -1549,6 +2073,19 @@ export class AdminClient extends VelocityClient {
|
|
|
1549
2073
|
);
|
|
1550
2074
|
}
|
|
1551
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
|
+
*/
|
|
1552
2089
|
public async updatePerpMarketFundingDeadZone(
|
|
1553
2090
|
perpMarketIndex: number,
|
|
1554
2091
|
fundingClampThreshold: number,
|
|
@@ -1568,6 +2105,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1568
2105
|
return txSig;
|
|
1569
2106
|
}
|
|
1570
2107
|
|
|
2108
|
+
/**
|
|
2109
|
+
* Builds the `updatePerpMarketFundingDeadZone` instruction without sending it. See
|
|
2110
|
+
* `updatePerpMarketFundingDeadZone` for units and validation.
|
|
2111
|
+
* @returns The unsigned `updatePerpMarketFundingDeadZone` instruction.
|
|
2112
|
+
*/
|
|
1571
2113
|
public async getUpdatePerpMarketFundingDeadZoneIx(
|
|
1572
2114
|
perpMarketIndex: number,
|
|
1573
2115
|
fundingClampThreshold: number,
|
|
@@ -1591,6 +2133,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1591
2133
|
);
|
|
1592
2134
|
}
|
|
1593
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
|
+
*/
|
|
1594
2145
|
public async updatePerpMarketImfFactor(
|
|
1595
2146
|
perpMarketIndex: number,
|
|
1596
2147
|
imfFactor: number,
|
|
@@ -1610,6 +2161,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1610
2161
|
return txSig;
|
|
1611
2162
|
}
|
|
1612
2163
|
|
|
2164
|
+
/**
|
|
2165
|
+
* Builds the `updatePerpMarketImfFactor` instruction without sending it. See
|
|
2166
|
+
* `updatePerpMarketImfFactor`.
|
|
2167
|
+
* @returns The unsigned `updatePerpMarketImfFactor` instruction.
|
|
2168
|
+
*/
|
|
1613
2169
|
public async getUpdatePerpMarketImfFactorIx(
|
|
1614
2170
|
perpMarketIndex: number,
|
|
1615
2171
|
imfFactor: number,
|
|
@@ -1633,6 +2189,14 @@ export class AdminClient extends VelocityClient {
|
|
|
1633
2189
|
);
|
|
1634
2190
|
}
|
|
1635
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
|
+
*/
|
|
1636
2200
|
public async updatePerpMarketBaseSpread(
|
|
1637
2201
|
perpMarketIndex: number,
|
|
1638
2202
|
baseSpread: number
|
|
@@ -1647,6 +2211,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1647
2211
|
return txSig;
|
|
1648
2212
|
}
|
|
1649
2213
|
|
|
2214
|
+
/**
|
|
2215
|
+
* Builds the `updatePerpMarketBaseSpread` instruction without sending it. See
|
|
2216
|
+
* `updatePerpMarketBaseSpread`.
|
|
2217
|
+
* @returns The unsigned `updatePerpMarketBaseSpread` instruction.
|
|
2218
|
+
*/
|
|
1650
2219
|
public async getUpdatePerpMarketBaseSpreadIx(
|
|
1651
2220
|
perpMarketIndex: number,
|
|
1652
2221
|
baseSpread: number
|
|
@@ -1668,6 +2237,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1668
2237
|
);
|
|
1669
2238
|
}
|
|
1670
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
|
+
*/
|
|
1671
2249
|
public async updateAmmJitIntensity(
|
|
1672
2250
|
perpMarketIndex: number,
|
|
1673
2251
|
ammJitIntensity: number
|
|
@@ -1684,6 +2262,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1684
2262
|
return txSig;
|
|
1685
2263
|
}
|
|
1686
2264
|
|
|
2265
|
+
/**
|
|
2266
|
+
* Builds the `updateAmmJitIntensity` instruction without sending it. See
|
|
2267
|
+
* `updateAmmJitIntensity`.
|
|
2268
|
+
* @returns The unsigned `updateAmmJitIntensity` instruction.
|
|
2269
|
+
*/
|
|
1687
2270
|
public async getUpdateAmmJitIntensityIx(
|
|
1688
2271
|
perpMarketIndex: number,
|
|
1689
2272
|
ammJitIntensity: number
|
|
@@ -1705,6 +2288,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1705
2288
|
);
|
|
1706
2289
|
}
|
|
1707
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
|
+
*/
|
|
1708
2297
|
public async updatePerpMarketName(
|
|
1709
2298
|
perpMarketIndex: number,
|
|
1710
2299
|
name: string
|
|
@@ -1721,6 +2310,10 @@ export class AdminClient extends VelocityClient {
|
|
|
1721
2310
|
return txSig;
|
|
1722
2311
|
}
|
|
1723
2312
|
|
|
2313
|
+
/**
|
|
2314
|
+
* Builds the `updatePerpMarketName` instruction without sending it. See `updatePerpMarketName`.
|
|
2315
|
+
* @returns The unsigned `updatePerpMarketName` instruction.
|
|
2316
|
+
*/
|
|
1724
2317
|
public async getUpdatePerpMarketNameIx(
|
|
1725
2318
|
perpMarketIndex: number,
|
|
1726
2319
|
name: string
|
|
@@ -1740,6 +2333,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1740
2333
|
});
|
|
1741
2334
|
}
|
|
1742
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
|
+
*/
|
|
1743
2342
|
public async updateSpotMarketName(
|
|
1744
2343
|
spotMarketIndex: number,
|
|
1745
2344
|
name: string
|
|
@@ -1756,6 +2355,10 @@ export class AdminClient extends VelocityClient {
|
|
|
1756
2355
|
return txSig;
|
|
1757
2356
|
}
|
|
1758
2357
|
|
|
2358
|
+
/**
|
|
2359
|
+
* Builds the `updateSpotMarketName` instruction without sending it. See `updateSpotMarketName`.
|
|
2360
|
+
* @returns The unsigned `updateSpotMarketName` instruction.
|
|
2361
|
+
*/
|
|
1759
2362
|
public async getUpdateSpotMarketNameIx(
|
|
1760
2363
|
spotMarketIndex: number,
|
|
1761
2364
|
name: string
|
|
@@ -1775,6 +2378,13 @@ export class AdminClient extends VelocityClient {
|
|
|
1775
2378
|
});
|
|
1776
2379
|
}
|
|
1777
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
|
+
*/
|
|
1778
2388
|
public async updateSpotMarketPoolId(
|
|
1779
2389
|
spotMarketIndex: number,
|
|
1780
2390
|
poolId: number
|
|
@@ -1791,6 +2401,10 @@ export class AdminClient extends VelocityClient {
|
|
|
1791
2401
|
return txSig;
|
|
1792
2402
|
}
|
|
1793
2403
|
|
|
2404
|
+
/**
|
|
2405
|
+
* Builds the `updateSpotMarketPoolId` instruction without sending it. See `updateSpotMarketPoolId`.
|
|
2406
|
+
* @returns The unsigned `updateSpotMarketPoolId` instruction.
|
|
2407
|
+
*/
|
|
1794
2408
|
public async getUpdateSpotMarketPoolIdIx(
|
|
1795
2409
|
spotMarketIndex: number,
|
|
1796
2410
|
poolId: number
|
|
@@ -1809,6 +2423,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1809
2423
|
});
|
|
1810
2424
|
}
|
|
1811
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
|
+
*/
|
|
1812
2435
|
public async updatePerpMarketMaxSpread(
|
|
1813
2436
|
perpMarketIndex: number,
|
|
1814
2437
|
maxSpread: number
|
|
@@ -1823,6 +2446,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1823
2446
|
return txSig;
|
|
1824
2447
|
}
|
|
1825
2448
|
|
|
2449
|
+
/**
|
|
2450
|
+
* Builds the `updatePerpMarketMaxSpread` instruction without sending it. See
|
|
2451
|
+
* `updatePerpMarketMaxSpread` for units and validation.
|
|
2452
|
+
* @returns The unsigned `updatePerpMarketMaxSpread` instruction.
|
|
2453
|
+
*/
|
|
1826
2454
|
public async getUpdatePerpMarketMaxSpreadIx(
|
|
1827
2455
|
perpMarketIndex: number,
|
|
1828
2456
|
maxSpread: number
|
|
@@ -1843,6 +2471,15 @@ export class AdminClient extends VelocityClient {
|
|
|
1843
2471
|
});
|
|
1844
2472
|
}
|
|
1845
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
|
+
*/
|
|
1846
2483
|
public async updatePerpFeeStructure(
|
|
1847
2484
|
feeStructure: FeeStructure
|
|
1848
2485
|
): Promise<TransactionSignature> {
|
|
@@ -1857,6 +2494,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1857
2494
|
return txSig;
|
|
1858
2495
|
}
|
|
1859
2496
|
|
|
2497
|
+
/**
|
|
2498
|
+
* Builds the `updatePerpFeeStructure` instruction without sending it. See
|
|
2499
|
+
* `updatePerpFeeStructure`.
|
|
2500
|
+
* @returns The unsigned `updatePerpFeeStructure` instruction.
|
|
2501
|
+
*/
|
|
1860
2502
|
public async getUpdatePerpFeeStructureIx(
|
|
1861
2503
|
feeStructure: FeeStructure
|
|
1862
2504
|
): Promise<TransactionInstruction> {
|
|
@@ -1870,6 +2512,12 @@ export class AdminClient extends VelocityClient {
|
|
|
1870
2512
|
});
|
|
1871
2513
|
}
|
|
1872
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
|
+
*/
|
|
1873
2521
|
public async updateSpotFeeStructure(
|
|
1874
2522
|
feeStructure: FeeStructure
|
|
1875
2523
|
): Promise<TransactionSignature> {
|
|
@@ -1884,6 +2532,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1884
2532
|
return txSig;
|
|
1885
2533
|
}
|
|
1886
2534
|
|
|
2535
|
+
/**
|
|
2536
|
+
* Builds the `updateSpotFeeStructure` instruction without sending it. See
|
|
2537
|
+
* `updateSpotFeeStructure`.
|
|
2538
|
+
* @returns The unsigned `updateSpotFeeStructure` instruction.
|
|
2539
|
+
*/
|
|
1887
2540
|
public async getUpdateSpotFeeStructureIx(
|
|
1888
2541
|
feeStructure: FeeStructure
|
|
1889
2542
|
): Promise<TransactionInstruction> {
|
|
@@ -1897,6 +2550,16 @@ export class AdminClient extends VelocityClient {
|
|
|
1897
2550
|
});
|
|
1898
2551
|
}
|
|
1899
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
|
+
*/
|
|
1900
2563
|
public async updateInitialPctToLiquidate(
|
|
1901
2564
|
initialPctToLiquidate: number
|
|
1902
2565
|
): Promise<TransactionSignature> {
|
|
@@ -1910,6 +2573,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1910
2573
|
return txSig;
|
|
1911
2574
|
}
|
|
1912
2575
|
|
|
2576
|
+
/**
|
|
2577
|
+
* Builds the `updateInitialPctToLiquidate` instruction without sending it. See
|
|
2578
|
+
* `updateInitialPctToLiquidate`.
|
|
2579
|
+
* @returns The unsigned `updateInitialPctToLiquidate` instruction.
|
|
2580
|
+
*/
|
|
1913
2581
|
public async getUpdateInitialPctToLiquidateIx(
|
|
1914
2582
|
initialPctToLiquidate: number
|
|
1915
2583
|
): Promise<TransactionInstruction> {
|
|
@@ -1926,6 +2594,13 @@ export class AdminClient extends VelocityClient {
|
|
|
1926
2594
|
);
|
|
1927
2595
|
}
|
|
1928
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
|
+
*/
|
|
1929
2604
|
public async updateLiquidationDuration(
|
|
1930
2605
|
liquidationDuration: number
|
|
1931
2606
|
): Promise<TransactionSignature> {
|
|
@@ -1939,6 +2614,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1939
2614
|
return txSig;
|
|
1940
2615
|
}
|
|
1941
2616
|
|
|
2617
|
+
/**
|
|
2618
|
+
* Builds the `updateLiquidationDuration` instruction without sending it. See
|
|
2619
|
+
* `updateLiquidationDuration`.
|
|
2620
|
+
* @returns The unsigned `updateLiquidationDuration` instruction.
|
|
2621
|
+
*/
|
|
1942
2622
|
public async getUpdateLiquidationDurationIx(
|
|
1943
2623
|
liquidationDuration: number
|
|
1944
2624
|
): Promise<TransactionInstruction> {
|
|
@@ -1955,6 +2635,14 @@ export class AdminClient extends VelocityClient {
|
|
|
1955
2635
|
);
|
|
1956
2636
|
}
|
|
1957
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
|
+
*/
|
|
1958
2646
|
public async updateLiquidationMarginBufferRatio(
|
|
1959
2647
|
updateLiquidationMarginBufferRatio: number
|
|
1960
2648
|
): Promise<TransactionSignature> {
|
|
@@ -1972,6 +2660,11 @@ export class AdminClient extends VelocityClient {
|
|
|
1972
2660
|
return txSig;
|
|
1973
2661
|
}
|
|
1974
2662
|
|
|
2663
|
+
/**
|
|
2664
|
+
* Builds the `updateLiquidationMarginBufferRatio` instruction without sending it.
|
|
2665
|
+
* See `updateLiquidationMarginBufferRatio`.
|
|
2666
|
+
* @returns The unsigned `updateLiquidationMarginBufferRatio` instruction.
|
|
2667
|
+
*/
|
|
1975
2668
|
public async getUpdateLiquidationMarginBufferRatioIx(
|
|
1976
2669
|
updateLiquidationMarginBufferRatio: number
|
|
1977
2670
|
): Promise<TransactionInstruction> {
|
|
@@ -1988,6 +2681,13 @@ export class AdminClient extends VelocityClient {
|
|
|
1988
2681
|
);
|
|
1989
2682
|
}
|
|
1990
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
|
+
*/
|
|
1991
2691
|
public async updateOracleGuardRails(
|
|
1992
2692
|
oracleGuardRails: OracleGuardRails
|
|
1993
2693
|
): Promise<TransactionSignature> {
|
|
@@ -2002,6 +2702,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2002
2702
|
return txSig;
|
|
2003
2703
|
}
|
|
2004
2704
|
|
|
2705
|
+
/**
|
|
2706
|
+
* Builds the `updateOracleGuardRails` instruction without sending it. See
|
|
2707
|
+
* `updateOracleGuardRails`.
|
|
2708
|
+
* @returns The unsigned `updateOracleGuardRails` instruction.
|
|
2709
|
+
*/
|
|
2005
2710
|
public async getUpdateOracleGuardRailsIx(
|
|
2006
2711
|
oracleGuardRails: OracleGuardRails
|
|
2007
2712
|
): Promise<TransactionInstruction> {
|
|
@@ -2018,6 +2723,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2018
2723
|
);
|
|
2019
2724
|
}
|
|
2020
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
|
+
*/
|
|
2021
2733
|
public async updateStateSettlementDuration(
|
|
2022
2734
|
settlementDuration: number
|
|
2023
2735
|
): Promise<TransactionSignature> {
|
|
@@ -2031,6 +2743,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2031
2743
|
return txSig;
|
|
2032
2744
|
}
|
|
2033
2745
|
|
|
2746
|
+
/**
|
|
2747
|
+
* Builds the `updateStateSettlementDuration` instruction without sending it. See
|
|
2748
|
+
* `updateStateSettlementDuration`.
|
|
2749
|
+
* @returns The unsigned `updateStateSettlementDuration` instruction.
|
|
2750
|
+
*/
|
|
2034
2751
|
public async getUpdateStateSettlementDurationIx(
|
|
2035
2752
|
settlementDuration: number
|
|
2036
2753
|
): Promise<TransactionInstruction> {
|
|
@@ -2047,6 +2764,15 @@ export class AdminClient extends VelocityClient {
|
|
|
2047
2764
|
);
|
|
2048
2765
|
}
|
|
2049
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
|
+
*/
|
|
2050
2776
|
public async updateStateMaxNumberOfSubAccounts(
|
|
2051
2777
|
maxNumberOfSubAccounts: number
|
|
2052
2778
|
): Promise<TransactionSignature> {
|
|
@@ -2060,6 +2786,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2060
2786
|
return txSig;
|
|
2061
2787
|
}
|
|
2062
2788
|
|
|
2789
|
+
/**
|
|
2790
|
+
* Builds the `updateStateMaxNumberOfSubAccounts` instruction without sending it.
|
|
2791
|
+
* See `updateStateMaxNumberOfSubAccounts`.
|
|
2792
|
+
* @returns The unsigned `updateStateMaxNumberOfSubAccounts` instruction.
|
|
2793
|
+
*/
|
|
2063
2794
|
public async getUpdateStateMaxNumberOfSubAccountsIx(
|
|
2064
2795
|
maxNumberOfSubAccounts: number
|
|
2065
2796
|
): Promise<TransactionInstruction> {
|
|
@@ -2076,6 +2807,15 @@ export class AdminClient extends VelocityClient {
|
|
|
2076
2807
|
);
|
|
2077
2808
|
}
|
|
2078
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
|
+
*/
|
|
2079
2819
|
public async updateStateMaxInitializeUserFee(
|
|
2080
2820
|
maxInitializeUserFee: number
|
|
2081
2821
|
): Promise<TransactionSignature> {
|
|
@@ -2089,6 +2829,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2089
2829
|
return txSig;
|
|
2090
2830
|
}
|
|
2091
2831
|
|
|
2832
|
+
/**
|
|
2833
|
+
* Builds the `updateStateMaxInitializeUserFee` instruction without sending it. See
|
|
2834
|
+
* `updateStateMaxInitializeUserFee`.
|
|
2835
|
+
* @returns The unsigned `updateStateMaxInitializeUserFee` instruction.
|
|
2836
|
+
*/
|
|
2092
2837
|
public async getUpdateStateMaxInitializeUserFeeIx(
|
|
2093
2838
|
maxInitializeUserFee: number
|
|
2094
2839
|
): Promise<TransactionInstruction> {
|
|
@@ -2105,6 +2850,23 @@ export class AdminClient extends VelocityClient {
|
|
|
2105
2850
|
);
|
|
2106
2851
|
}
|
|
2107
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
|
+
*/
|
|
2108
2870
|
public async updateWithdrawGuardThreshold(
|
|
2109
2871
|
spotMarketIndex: number,
|
|
2110
2872
|
withdrawGuardThreshold: BN,
|
|
@@ -2124,6 +2886,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2124
2886
|
return txSig;
|
|
2125
2887
|
}
|
|
2126
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
|
+
*/
|
|
2127
2896
|
public async getUpdateWithdrawGuardThresholdIx(
|
|
2128
2897
|
spotMarketIndex: number,
|
|
2129
2898
|
withdrawGuardThreshold: BN,
|
|
@@ -2174,6 +2943,18 @@ export class AdminClient extends VelocityClient {
|
|
|
2174
2943
|
);
|
|
2175
2944
|
}
|
|
2176
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
|
+
*/
|
|
2177
2958
|
public async updateSpotMarketIfFactor(
|
|
2178
2959
|
spotMarketIndex: number,
|
|
2179
2960
|
ifFeeFactor: number,
|
|
@@ -2192,6 +2973,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2192
2973
|
return txSig;
|
|
2193
2974
|
}
|
|
2194
2975
|
|
|
2976
|
+
/**
|
|
2977
|
+
* Builds the `updateSpotMarketIfFactor` instruction without sending it. See
|
|
2978
|
+
* `updateSpotMarketIfFactor` for units and validation.
|
|
2979
|
+
* @returns The unsigned `updateSpotMarketIfFactor` instruction.
|
|
2980
|
+
*/
|
|
2195
2981
|
public async getUpdateSpotMarketIfFactorIx(
|
|
2196
2982
|
spotMarketIndex: number,
|
|
2197
2983
|
ifFeeFactor: number,
|
|
@@ -2216,6 +3002,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2216
3002
|
);
|
|
2217
3003
|
}
|
|
2218
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
|
+
*/
|
|
2219
3012
|
public async updateSpotMarketRevenueSettlePeriod(
|
|
2220
3013
|
spotMarketIndex: number,
|
|
2221
3014
|
revenueSettlePeriod: BN
|
|
@@ -2235,6 +3028,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2235
3028
|
return txSig;
|
|
2236
3029
|
}
|
|
2237
3030
|
|
|
3031
|
+
/**
|
|
3032
|
+
* Builds the `updateSpotMarketRevenueSettlePeriod` instruction without sending it. See
|
|
3033
|
+
* `updateSpotMarketRevenueSettlePeriod`.
|
|
3034
|
+
* @returns The unsigned `updateSpotMarketRevenueSettlePeriod` instruction.
|
|
3035
|
+
*/
|
|
2238
3036
|
public async getUpdateSpotMarketRevenueSettlePeriodIx(
|
|
2239
3037
|
spotMarketIndex: number,
|
|
2240
3038
|
revenueSettlePeriod: BN
|
|
@@ -2256,6 +3054,12 @@ export class AdminClient extends VelocityClient {
|
|
|
2256
3054
|
);
|
|
2257
3055
|
}
|
|
2258
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
|
+
*/
|
|
2259
3063
|
public async updateSpotMarketMaxTokenDeposits(
|
|
2260
3064
|
spotMarketIndex: number,
|
|
2261
3065
|
maxTokenDeposits: BN
|
|
@@ -2273,6 +3077,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2273
3077
|
return txSig;
|
|
2274
3078
|
}
|
|
2275
3079
|
|
|
3080
|
+
/**
|
|
3081
|
+
* Builds the `updateSpotMarketMaxTokenDeposits` instruction without sending it. See
|
|
3082
|
+
* `updateSpotMarketMaxTokenDeposits`.
|
|
3083
|
+
* @returns The unsigned `updateSpotMarketMaxTokenDeposits` instruction.
|
|
3084
|
+
*/
|
|
2276
3085
|
public async getUpdateSpotMarketMaxTokenDepositsIx(
|
|
2277
3086
|
spotMarketIndex: number,
|
|
2278
3087
|
maxTokenDeposits: BN
|
|
@@ -2294,6 +3103,15 @@ export class AdminClient extends VelocityClient {
|
|
|
2294
3103
|
);
|
|
2295
3104
|
}
|
|
2296
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
|
+
*/
|
|
2297
3115
|
public async updateSpotMarketMaxTokenBorrows(
|
|
2298
3116
|
spotMarketIndex: number,
|
|
2299
3117
|
maxTokenBorrowsFraction: number
|
|
@@ -2311,6 +3129,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2311
3129
|
return txSig;
|
|
2312
3130
|
}
|
|
2313
3131
|
|
|
3132
|
+
/**
|
|
3133
|
+
* Builds the `updateSpotMarketMaxTokenBorrows` instruction without sending it. See
|
|
3134
|
+
* `updateSpotMarketMaxTokenBorrows`.
|
|
3135
|
+
* @returns The unsigned `updateSpotMarketMaxTokenBorrows` instruction.
|
|
3136
|
+
*/
|
|
2314
3137
|
public async getUpdateSpotMarketMaxTokenBorrowsIx(
|
|
2315
3138
|
spotMarketIndex: number,
|
|
2316
3139
|
maxTokenBorrowsFraction: number
|
|
@@ -2332,6 +3155,14 @@ export class AdminClient extends VelocityClient {
|
|
|
2332
3155
|
);
|
|
2333
3156
|
}
|
|
2334
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
|
+
*/
|
|
2335
3166
|
public async updateSpotMarketScaleInitialAssetWeightStart(
|
|
2336
3167
|
spotMarketIndex: number,
|
|
2337
3168
|
scaleInitialAssetWeightStart: BN
|
|
@@ -2351,6 +3182,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2351
3182
|
return txSig;
|
|
2352
3183
|
}
|
|
2353
3184
|
|
|
3185
|
+
/**
|
|
3186
|
+
* Builds the `updateSpotMarketScaleInitialAssetWeightStart` instruction without sending it.
|
|
3187
|
+
* See `updateSpotMarketScaleInitialAssetWeightStart`.
|
|
3188
|
+
* @returns The unsigned `updateSpotMarketScaleInitialAssetWeightStart` instruction.
|
|
3189
|
+
*/
|
|
2354
3190
|
public async getUpdateSpotMarketScaleInitialAssetWeightStartIx(
|
|
2355
3191
|
spotMarketIndex: number,
|
|
2356
3192
|
scaleInitialAssetWeightStart: BN
|
|
@@ -2372,6 +3208,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2372
3208
|
);
|
|
2373
3209
|
}
|
|
2374
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
|
+
*/
|
|
2375
3218
|
public async updateInsuranceFundUnstakingPeriod(
|
|
2376
3219
|
spotMarketIndex: number,
|
|
2377
3220
|
insuranceWithdrawEscrowPeriod: BN
|
|
@@ -2391,6 +3234,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2391
3234
|
return txSig;
|
|
2392
3235
|
}
|
|
2393
3236
|
|
|
3237
|
+
/**
|
|
3238
|
+
* Builds the `updateInsuranceFundUnstakingPeriod` instruction without sending it. See
|
|
3239
|
+
* `updateInsuranceFundUnstakingPeriod`.
|
|
3240
|
+
* @returns The unsigned `updateInsuranceFundUnstakingPeriod` instruction.
|
|
3241
|
+
*/
|
|
2394
3242
|
public async getUpdateInsuranceFundUnstakingPeriodIx(
|
|
2395
3243
|
spotMarketIndex: number,
|
|
2396
3244
|
insuranceWithdrawEscrowPeriod: BN
|
|
@@ -2412,6 +3260,20 @@ export class AdminClient extends VelocityClient {
|
|
|
2412
3260
|
);
|
|
2413
3261
|
}
|
|
2414
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
|
+
*/
|
|
2415
3277
|
public async updatePerpMarketOracle(
|
|
2416
3278
|
perpMarketIndex: number,
|
|
2417
3279
|
oracle: PublicKey,
|
|
@@ -2432,6 +3294,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2432
3294
|
return txSig;
|
|
2433
3295
|
}
|
|
2434
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
|
+
*/
|
|
2435
3304
|
public async getUpdatePerpMarketOracleIx(
|
|
2436
3305
|
perpMarketIndex: number,
|
|
2437
3306
|
oracle: PublicKey,
|
|
@@ -2461,6 +3330,16 @@ export class AdminClient extends VelocityClient {
|
|
|
2461
3330
|
);
|
|
2462
3331
|
}
|
|
2463
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
|
+
*/
|
|
2464
3343
|
public async updatePerpMarketStepSizeAndTickSize(
|
|
2465
3344
|
perpMarketIndex: number,
|
|
2466
3345
|
stepSize: BN,
|
|
@@ -2482,6 +3361,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2482
3361
|
return txSig;
|
|
2483
3362
|
}
|
|
2484
3363
|
|
|
3364
|
+
/**
|
|
3365
|
+
* Builds the `updatePerpMarketStepSizeAndTickSize` instruction without sending it. See
|
|
3366
|
+
* `updatePerpMarketStepSizeAndTickSize`.
|
|
3367
|
+
* @returns The unsigned `updatePerpMarketStepSizeAndTickSize` instruction.
|
|
3368
|
+
*/
|
|
2485
3369
|
public async getUpdatePerpMarketStepSizeAndTickSizeIx(
|
|
2486
3370
|
perpMarketIndex: number,
|
|
2487
3371
|
stepSize: BN,
|
|
@@ -2505,6 +3389,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2505
3389
|
);
|
|
2506
3390
|
}
|
|
2507
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
|
+
*/
|
|
2508
3399
|
public async updatePerpMarketMinOrderSize(
|
|
2509
3400
|
perpMarketIndex: number,
|
|
2510
3401
|
orderSize: BN
|
|
@@ -2519,6 +3410,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2519
3410
|
return txSig;
|
|
2520
3411
|
}
|
|
2521
3412
|
|
|
3413
|
+
/**
|
|
3414
|
+
* Builds the `updatePerpMarketMinOrderSize` instruction without sending it. See
|
|
3415
|
+
* `updatePerpMarketMinOrderSize`.
|
|
3416
|
+
* @returns The unsigned `updatePerpMarketMinOrderSize` instruction.
|
|
3417
|
+
*/
|
|
2522
3418
|
public async getUpdatePerpMarketMinOrderSizeIx(
|
|
2523
3419
|
perpMarketIndex: number,
|
|
2524
3420
|
orderSize: BN
|
|
@@ -2540,6 +3436,15 @@ export class AdminClient extends VelocityClient {
|
|
|
2540
3436
|
);
|
|
2541
3437
|
}
|
|
2542
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
|
+
*/
|
|
2543
3448
|
public async updateSpotMarketStepSizeAndTickSize(
|
|
2544
3449
|
spotMarketIndex: number,
|
|
2545
3450
|
stepSize: BN,
|
|
@@ -2561,6 +3466,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2561
3466
|
return txSig;
|
|
2562
3467
|
}
|
|
2563
3468
|
|
|
3469
|
+
/**
|
|
3470
|
+
* Builds the `updateSpotMarketStepSizeAndTickSize` instruction without sending it. See
|
|
3471
|
+
* `updateSpotMarketStepSizeAndTickSize`.
|
|
3472
|
+
* @returns The unsigned `updateSpotMarketStepSizeAndTickSize` instruction.
|
|
3473
|
+
*/
|
|
2564
3474
|
public async getUpdateSpotMarketStepSizeAndTickSizeIx(
|
|
2565
3475
|
spotMarketIndex: number,
|
|
2566
3476
|
stepSize: BN,
|
|
@@ -2584,6 +3494,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2584
3494
|
);
|
|
2585
3495
|
}
|
|
2586
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
|
+
*/
|
|
2587
3504
|
public async updateSpotMarketMinOrderSize(
|
|
2588
3505
|
spotMarketIndex: number,
|
|
2589
3506
|
orderSize: BN
|
|
@@ -2609,6 +3526,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2609
3526
|
return txSig;
|
|
2610
3527
|
}
|
|
2611
3528
|
|
|
3529
|
+
/**
|
|
3530
|
+
* Builds the `updateSpotMarketMinOrderSize` instruction without sending it. See
|
|
3531
|
+
* `updateSpotMarketMinOrderSize`.
|
|
3532
|
+
* @returns The unsigned `updateSpotMarketMinOrderSize` instruction.
|
|
3533
|
+
*/
|
|
2612
3534
|
public async getUpdateSpotMarketMinOrderSizeIx(
|
|
2613
3535
|
spotMarketIndex: number,
|
|
2614
3536
|
orderSize: BN
|
|
@@ -2630,6 +3552,16 @@ export class AdminClient extends VelocityClient {
|
|
|
2630
3552
|
);
|
|
2631
3553
|
}
|
|
2632
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
|
+
*/
|
|
2633
3565
|
public async updatePerpMarketExpiry(
|
|
2634
3566
|
perpMarketIndex: number,
|
|
2635
3567
|
expiryTs: BN
|
|
@@ -2645,6 +3577,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2645
3577
|
return txSig;
|
|
2646
3578
|
}
|
|
2647
3579
|
|
|
3580
|
+
/**
|
|
3581
|
+
* Builds the `updatePerpMarketExpiry` instruction without sending it. See
|
|
3582
|
+
* `updatePerpMarketExpiry`.
|
|
3583
|
+
* @returns The unsigned `updatePerpMarketExpiry` instruction.
|
|
3584
|
+
*/
|
|
2648
3585
|
public async getUpdatePerpMarketExpiryIx(
|
|
2649
3586
|
perpMarketIndex: number,
|
|
2650
3587
|
expiryTs: BN
|
|
@@ -2663,6 +3600,19 @@ export class AdminClient extends VelocityClient {
|
|
|
2663
3600
|
});
|
|
2664
3601
|
}
|
|
2665
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
|
+
*/
|
|
2666
3616
|
public async updateSpotMarketOracle(
|
|
2667
3617
|
spotMarketIndex: number,
|
|
2668
3618
|
oracle: PublicKey,
|
|
@@ -2683,6 +3633,12 @@ export class AdminClient extends VelocityClient {
|
|
|
2683
3633
|
return txSig;
|
|
2684
3634
|
}
|
|
2685
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
|
+
*/
|
|
2686
3642
|
public async getUpdateSpotMarketOracleIx(
|
|
2687
3643
|
spotMarketIndex: number,
|
|
2688
3644
|
oracle: PublicKey,
|
|
@@ -2711,6 +3667,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2711
3667
|
);
|
|
2712
3668
|
}
|
|
2713
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
|
+
*/
|
|
2714
3677
|
public async updateSpotMarketOrdersEnabled(
|
|
2715
3678
|
spotMarketIndex: number,
|
|
2716
3679
|
ordersEnabled: boolean
|
|
@@ -2728,6 +3691,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2728
3691
|
return txSig;
|
|
2729
3692
|
}
|
|
2730
3693
|
|
|
3694
|
+
/**
|
|
3695
|
+
* Builds the `updateSpotMarketOrdersEnabled` instruction without sending it. See
|
|
3696
|
+
* `updateSpotMarketOrdersEnabled`.
|
|
3697
|
+
* @returns The unsigned `updateSpotMarketOrdersEnabled` instruction.
|
|
3698
|
+
*/
|
|
2731
3699
|
public async getUpdateSpotMarketOrdersEnabledIx(
|
|
2732
3700
|
spotMarketIndex: number,
|
|
2733
3701
|
ordersEnabled: boolean
|
|
@@ -2749,6 +3717,16 @@ export class AdminClient extends VelocityClient {
|
|
|
2749
3717
|
);
|
|
2750
3718
|
}
|
|
2751
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
|
+
*/
|
|
2752
3730
|
public async updateSpotMarketIfPausedOperations(
|
|
2753
3731
|
spotMarketIndex: number,
|
|
2754
3732
|
pausedOperations: number
|
|
@@ -2766,6 +3744,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2766
3744
|
return txSig;
|
|
2767
3745
|
}
|
|
2768
3746
|
|
|
3747
|
+
/**
|
|
3748
|
+
* Builds the `updateSpotMarketIfPausedOperations` instruction without sending it. See
|
|
3749
|
+
* `updateSpotMarketIfPausedOperations`.
|
|
3750
|
+
* @returns The unsigned `updateSpotMarketIfPausedOperations` instruction.
|
|
3751
|
+
*/
|
|
2769
3752
|
public async getUpdateSpotMarketIfPausedOperationsIx(
|
|
2770
3753
|
spotMarketIndex: number,
|
|
2771
3754
|
pausedOperations: number
|
|
@@ -2787,6 +3770,14 @@ export class AdminClient extends VelocityClient {
|
|
|
2787
3770
|
);
|
|
2788
3771
|
}
|
|
2789
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
|
+
*/
|
|
2790
3781
|
public async updateSpotMarketExpiry(
|
|
2791
3782
|
spotMarketIndex: number,
|
|
2792
3783
|
expiryTs: BN
|
|
@@ -2803,6 +3794,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2803
3794
|
return txSig;
|
|
2804
3795
|
}
|
|
2805
3796
|
|
|
3797
|
+
/**
|
|
3798
|
+
* Builds the `updateSpotMarketExpiry` instruction without sending it. See
|
|
3799
|
+
* `updateSpotMarketExpiry`.
|
|
3800
|
+
* @returns The unsigned `updateSpotMarketExpiry` instruction.
|
|
3801
|
+
*/
|
|
2806
3802
|
public async getUpdateSpotMarketExpiryIx(
|
|
2807
3803
|
spotMarketIndex: number,
|
|
2808
3804
|
expiryTs: BN
|
|
@@ -2821,6 +3817,17 @@ export class AdminClient extends VelocityClient {
|
|
|
2821
3817
|
});
|
|
2822
3818
|
}
|
|
2823
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
|
+
*/
|
|
2824
3831
|
public async updateWhitelistMint(
|
|
2825
3832
|
whitelistMint?: PublicKey
|
|
2826
3833
|
): Promise<TransactionSignature> {
|
|
@@ -2835,6 +3842,12 @@ export class AdminClient extends VelocityClient {
|
|
|
2835
3842
|
return txSig;
|
|
2836
3843
|
}
|
|
2837
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
|
+
*/
|
|
2838
3851
|
public async getUpdateWhitelistMintIx(
|
|
2839
3852
|
whitelistMint?: PublicKey
|
|
2840
3853
|
): Promise<TransactionInstruction> {
|
|
@@ -2851,6 +3864,13 @@ export class AdminClient extends VelocityClient {
|
|
|
2851
3864
|
);
|
|
2852
3865
|
}
|
|
2853
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
|
+
*/
|
|
2854
3874
|
public async updateDiscountMint(
|
|
2855
3875
|
discountMint: PublicKey
|
|
2856
3876
|
): Promise<TransactionSignature> {
|
|
@@ -2865,6 +3885,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2865
3885
|
return txSig;
|
|
2866
3886
|
}
|
|
2867
3887
|
|
|
3888
|
+
/**
|
|
3889
|
+
* Builds the `updateDiscountMint` instruction without sending it. See
|
|
3890
|
+
* `updateDiscountMint`.
|
|
3891
|
+
* @returns The unsigned `updateDiscountMint` instruction.
|
|
3892
|
+
*/
|
|
2868
3893
|
public async getUpdateDiscountMintIx(
|
|
2869
3894
|
discountMint: PublicKey
|
|
2870
3895
|
): Promise<TransactionInstruction> {
|
|
@@ -2878,6 +3903,19 @@ export class AdminClient extends VelocityClient {
|
|
|
2878
3903
|
});
|
|
2879
3904
|
}
|
|
2880
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
|
+
*/
|
|
2881
3919
|
public async updateSpotMarketMarginWeights(
|
|
2882
3920
|
spotMarketIndex: number,
|
|
2883
3921
|
initialAssetWeight: number,
|
|
@@ -2903,6 +3941,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2903
3941
|
return txSig;
|
|
2904
3942
|
}
|
|
2905
3943
|
|
|
3944
|
+
/**
|
|
3945
|
+
* Builds the `updateSpotMarketMarginWeights` instruction without sending it. See
|
|
3946
|
+
* `updateSpotMarketMarginWeights`.
|
|
3947
|
+
* @returns The unsigned `updateSpotMarketMarginWeights` instruction.
|
|
3948
|
+
*/
|
|
2906
3949
|
public async getUpdateSpotMarketMarginWeightsIx(
|
|
2907
3950
|
spotMarketIndex: number,
|
|
2908
3951
|
initialAssetWeight: number,
|
|
@@ -2932,6 +3975,18 @@ export class AdminClient extends VelocityClient {
|
|
|
2932
3975
|
);
|
|
2933
3976
|
}
|
|
2934
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
|
+
*/
|
|
2935
3990
|
public async updateSpotMarketBorrowRate(
|
|
2936
3991
|
spotMarketIndex: number,
|
|
2937
3992
|
optimalUtilization: number,
|
|
@@ -2955,6 +4010,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2955
4010
|
return txSig;
|
|
2956
4011
|
}
|
|
2957
4012
|
|
|
4013
|
+
/**
|
|
4014
|
+
* Builds the `updateSpotMarketBorrowRate` instruction without sending it. See
|
|
4015
|
+
* `updateSpotMarketBorrowRate`.
|
|
4016
|
+
* @returns The unsigned `updateSpotMarketBorrowRate` instruction.
|
|
4017
|
+
*/
|
|
2958
4018
|
public async getUpdateSpotMarketBorrowRateIx(
|
|
2959
4019
|
spotMarketIndex: number,
|
|
2960
4020
|
optimalUtilization: number,
|
|
@@ -2982,6 +4042,16 @@ export class AdminClient extends VelocityClient {
|
|
|
2982
4042
|
);
|
|
2983
4043
|
}
|
|
2984
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
|
+
*/
|
|
2985
4055
|
public async updateSpotMarketAssetTier(
|
|
2986
4056
|
spotMarketIndex: number,
|
|
2987
4057
|
assetTier: AssetTier
|
|
@@ -2996,6 +4066,11 @@ export class AdminClient extends VelocityClient {
|
|
|
2996
4066
|
return txSig;
|
|
2997
4067
|
}
|
|
2998
4068
|
|
|
4069
|
+
/**
|
|
4070
|
+
* Builds the `updateSpotMarketAssetTier` instruction without sending it. See
|
|
4071
|
+
* `updateSpotMarketAssetTier`.
|
|
4072
|
+
* @returns The unsigned `updateSpotMarketAssetTier` instruction.
|
|
4073
|
+
*/
|
|
2999
4074
|
public async getUpdateSpotMarketAssetTierIx(
|
|
3000
4075
|
spotMarketIndex: number,
|
|
3001
4076
|
assetTier: AssetTier
|
|
@@ -3014,6 +4089,15 @@ export class AdminClient extends VelocityClient {
|
|
|
3014
4089
|
});
|
|
3015
4090
|
}
|
|
3016
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
|
+
*/
|
|
3017
4101
|
public async updateSpotMarketStatus(
|
|
3018
4102
|
spotMarketIndex: number,
|
|
3019
4103
|
marketStatus: MarketStatus
|
|
@@ -3030,6 +4114,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3030
4114
|
return txSig;
|
|
3031
4115
|
}
|
|
3032
4116
|
|
|
4117
|
+
/**
|
|
4118
|
+
* Builds the `updateSpotMarketStatus` instruction without sending it. See
|
|
4119
|
+
* `updateSpotMarketStatus`.
|
|
4120
|
+
* @returns The unsigned `updateSpotMarketStatus` instruction.
|
|
4121
|
+
*/
|
|
3033
4122
|
public async getUpdateSpotMarketStatusIx(
|
|
3034
4123
|
spotMarketIndex: number,
|
|
3035
4124
|
marketStatus: MarketStatus
|
|
@@ -3048,6 +4137,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3048
4137
|
});
|
|
3049
4138
|
}
|
|
3050
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
|
+
*/
|
|
3051
4150
|
public async updateSpotMarketPausedOperations(
|
|
3052
4151
|
spotMarketIndex: number,
|
|
3053
4152
|
pausedOperations: number
|
|
@@ -3065,6 +4164,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3065
4164
|
return txSig;
|
|
3066
4165
|
}
|
|
3067
4166
|
|
|
4167
|
+
/**
|
|
4168
|
+
* Builds the `updateSpotMarketPausedOperations` instruction without sending it. See
|
|
4169
|
+
* `updateSpotMarketPausedOperations`.
|
|
4170
|
+
* @returns The unsigned `updateSpotMarketPausedOperations` instruction.
|
|
4171
|
+
*/
|
|
3068
4172
|
public async getUpdateSpotMarketPausedOperationsIx(
|
|
3069
4173
|
spotMarketIndex: number,
|
|
3070
4174
|
pausedOperations: number
|
|
@@ -3086,6 +4190,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3086
4190
|
);
|
|
3087
4191
|
}
|
|
3088
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
|
+
*/
|
|
3089
4203
|
public async updatePerpMarketStatus(
|
|
3090
4204
|
perpMarketIndex: number,
|
|
3091
4205
|
marketStatus: MarketStatus
|
|
@@ -3102,6 +4216,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3102
4216
|
return txSig;
|
|
3103
4217
|
}
|
|
3104
4218
|
|
|
4219
|
+
/**
|
|
4220
|
+
* Builds the `updatePerpMarketStatus` instruction without sending it. See
|
|
4221
|
+
* `updatePerpMarketStatus`.
|
|
4222
|
+
* @returns The unsigned `updatePerpMarketStatus` instruction.
|
|
4223
|
+
*/
|
|
3105
4224
|
public async getUpdatePerpMarketStatusIx(
|
|
3106
4225
|
perpMarketIndex: number,
|
|
3107
4226
|
marketStatus: MarketStatus
|
|
@@ -3120,6 +4239,19 @@ export class AdminClient extends VelocityClient {
|
|
|
3120
4239
|
});
|
|
3121
4240
|
}
|
|
3122
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
|
+
*/
|
|
3123
4255
|
public async updatePerpMarketPausedOperations(
|
|
3124
4256
|
perpMarketIndex: number,
|
|
3125
4257
|
pausedOperations: number
|
|
@@ -3137,6 +4269,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3137
4269
|
return txSig;
|
|
3138
4270
|
}
|
|
3139
4271
|
|
|
4272
|
+
/**
|
|
4273
|
+
* Builds the `updatePerpMarketPausedOperations` instruction without sending it. See
|
|
4274
|
+
* `updatePerpMarketPausedOperations`.
|
|
4275
|
+
* @returns The unsigned `updatePerpMarketPausedOperations` instruction.
|
|
4276
|
+
*/
|
|
3140
4277
|
public async getUpdatePerpMarketPausedOperationsIx(
|
|
3141
4278
|
perpMarketIndex: number,
|
|
3142
4279
|
pausedOperations: number
|
|
@@ -3158,6 +4295,13 @@ export class AdminClient extends VelocityClient {
|
|
|
3158
4295
|
);
|
|
3159
4296
|
}
|
|
3160
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
|
+
*/
|
|
3161
4305
|
public async updatePerpMarketContractTier(
|
|
3162
4306
|
perpMarketIndex: number,
|
|
3163
4307
|
contractTier: ContractTier
|
|
@@ -3175,6 +4319,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3175
4319
|
return txSig;
|
|
3176
4320
|
}
|
|
3177
4321
|
|
|
4322
|
+
/**
|
|
4323
|
+
* Builds the `updatePerpMarketContractTier` instruction without sending it. See
|
|
4324
|
+
* `updatePerpMarketContractTier`.
|
|
4325
|
+
* @returns The unsigned `updatePerpMarketContractTier` instruction.
|
|
4326
|
+
*/
|
|
3178
4327
|
public async getUpdatePerpMarketContractTierIx(
|
|
3179
4328
|
perpMarketIndex: number,
|
|
3180
4329
|
contractTier: ContractTier
|
|
@@ -3197,6 +4346,17 @@ export class AdminClient extends VelocityClient {
|
|
|
3197
4346
|
);
|
|
3198
4347
|
}
|
|
3199
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
|
+
*/
|
|
3200
4360
|
public async updateExchangeStatus(
|
|
3201
4361
|
exchangeStatus: ExchangeStatus
|
|
3202
4362
|
): Promise<TransactionSignature> {
|
|
@@ -3211,6 +4371,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3211
4371
|
return txSig;
|
|
3212
4372
|
}
|
|
3213
4373
|
|
|
4374
|
+
/**
|
|
4375
|
+
* Builds the `updateExchangeStatus` instruction without sending it. See
|
|
4376
|
+
* `updateExchangeStatus`.
|
|
4377
|
+
* @returns The unsigned `updateExchangeStatus` instruction.
|
|
4378
|
+
*/
|
|
3214
4379
|
public async getUpdateExchangeStatusIx(
|
|
3215
4380
|
exchangeStatus: ExchangeStatus
|
|
3216
4381
|
): Promise<TransactionInstruction> {
|
|
@@ -3224,6 +4389,15 @@ export class AdminClient extends VelocityClient {
|
|
|
3224
4389
|
});
|
|
3225
4390
|
}
|
|
3226
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
|
+
*/
|
|
3227
4401
|
public async updateSolvencyStatus(
|
|
3228
4402
|
solvencyStatus: SolvencyStatus
|
|
3229
4403
|
): Promise<TransactionSignature> {
|
|
@@ -3238,6 +4412,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3238
4412
|
return txSig;
|
|
3239
4413
|
}
|
|
3240
4414
|
|
|
4415
|
+
/**
|
|
4416
|
+
* Builds the `updateSolvencyStatus` instruction without sending it. See
|
|
4417
|
+
* `updateSolvencyStatus`.
|
|
4418
|
+
* @returns The unsigned `updateSolvencyStatus` instruction.
|
|
4419
|
+
*/
|
|
3241
4420
|
public async getUpdateSolvencyStatusIx(
|
|
3242
4421
|
solvencyStatus: SolvencyStatus
|
|
3243
4422
|
): Promise<TransactionInstruction> {
|
|
@@ -3251,6 +4430,13 @@ export class AdminClient extends VelocityClient {
|
|
|
3251
4430
|
});
|
|
3252
4431
|
}
|
|
3253
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
|
+
*/
|
|
3254
4440
|
public async updatePerpAuctionDuration(
|
|
3255
4441
|
minDuration: BN | number
|
|
3256
4442
|
): Promise<TransactionSignature> {
|
|
@@ -3264,6 +4450,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3264
4450
|
return txSig;
|
|
3265
4451
|
}
|
|
3266
4452
|
|
|
4453
|
+
/**
|
|
4454
|
+
* Builds the `updatePerpAuctionDuration` instruction without sending it. See
|
|
4455
|
+
* `updatePerpAuctionDuration`.
|
|
4456
|
+
* @returns The unsigned `updatePerpAuctionDuration` instruction.
|
|
4457
|
+
*/
|
|
3267
4458
|
public async getUpdatePerpAuctionDurationIx(
|
|
3268
4459
|
minDuration: BN | number
|
|
3269
4460
|
): Promise<TransactionInstruction> {
|
|
@@ -3280,6 +4471,12 @@ export class AdminClient extends VelocityClient {
|
|
|
3280
4471
|
);
|
|
3281
4472
|
}
|
|
3282
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
|
+
*/
|
|
3283
4480
|
public async updateSpotAuctionDuration(
|
|
3284
4481
|
defaultAuctionDuration: number
|
|
3285
4482
|
): Promise<TransactionSignature> {
|
|
@@ -3293,6 +4490,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3293
4490
|
return txSig;
|
|
3294
4491
|
}
|
|
3295
4492
|
|
|
4493
|
+
/**
|
|
4494
|
+
* Builds the `updateSpotAuctionDuration` instruction without sending it. See
|
|
4495
|
+
* `updateSpotAuctionDuration`.
|
|
4496
|
+
* @returns The unsigned `updateSpotAuctionDuration` instruction.
|
|
4497
|
+
*/
|
|
3296
4498
|
public async getUpdateSpotAuctionDurationIx(
|
|
3297
4499
|
defaultAuctionDuration: number
|
|
3298
4500
|
): Promise<TransactionInstruction> {
|
|
@@ -3309,6 +4511,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3309
4511
|
);
|
|
3310
4512
|
}
|
|
3311
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
|
+
*/
|
|
3312
4524
|
public async updatePerpMarketMaxFillReserveFraction(
|
|
3313
4525
|
perpMarketIndex: number,
|
|
3314
4526
|
maxBaseAssetAmountRatio: number
|
|
@@ -3328,6 +4540,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3328
4540
|
return txSig;
|
|
3329
4541
|
}
|
|
3330
4542
|
|
|
4543
|
+
/**
|
|
4544
|
+
* Builds the `updatePerpMarketMaxFillReserveFraction` instruction without sending it. See
|
|
4545
|
+
* `updatePerpMarketMaxFillReserveFraction`.
|
|
4546
|
+
* @returns The unsigned `updatePerpMarketMaxFillReserveFraction` instruction.
|
|
4547
|
+
*/
|
|
3331
4548
|
public async getUpdatePerpMarketMaxFillReserveFractionIx(
|
|
3332
4549
|
perpMarketIndex: number,
|
|
3333
4550
|
maxBaseAssetAmountRatio: number
|
|
@@ -3349,6 +4566,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3349
4566
|
);
|
|
3350
4567
|
}
|
|
3351
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
|
+
*/
|
|
3352
4583
|
public async updateMaxSlippageRatio(
|
|
3353
4584
|
perpMarketIndex: number,
|
|
3354
4585
|
maxSlippageRatio: number
|
|
@@ -3365,6 +4596,14 @@ export class AdminClient extends VelocityClient {
|
|
|
3365
4596
|
return txSig;
|
|
3366
4597
|
}
|
|
3367
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
|
+
*/
|
|
3368
4607
|
public async getUpdateMaxSlippageRatioIx(
|
|
3369
4608
|
perpMarketIndex: number,
|
|
3370
4609
|
maxSlippageRatio: number
|
|
@@ -3384,6 +4623,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3384
4623
|
);
|
|
3385
4624
|
}
|
|
3386
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
|
+
*/
|
|
3387
4636
|
public async updatePerpMarketUnrealizedAssetWeight(
|
|
3388
4637
|
perpMarketIndex: number,
|
|
3389
4638
|
unrealizedInitialAssetWeight: number,
|
|
@@ -3405,6 +4654,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3405
4654
|
return txSig;
|
|
3406
4655
|
}
|
|
3407
4656
|
|
|
4657
|
+
/**
|
|
4658
|
+
* Builds the `updatePerpMarketUnrealizedAssetWeight` instruction without sending it. See
|
|
4659
|
+
* `updatePerpMarketUnrealizedAssetWeight`.
|
|
4660
|
+
* @returns The unsigned `updatePerpMarketUnrealizedAssetWeight` instruction.
|
|
4661
|
+
*/
|
|
3408
4662
|
public async getUpdatePerpMarketUnrealizedAssetWeightIx(
|
|
3409
4663
|
perpMarketIndex: number,
|
|
3410
4664
|
unrealizedInitialAssetWeight: number,
|
|
@@ -3428,6 +4682,19 @@ export class AdminClient extends VelocityClient {
|
|
|
3428
4682
|
);
|
|
3429
4683
|
}
|
|
3430
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
|
+
*/
|
|
3431
4698
|
public async updatePerpMarketMaxImbalances(
|
|
3432
4699
|
perpMarketIndex: number,
|
|
3433
4700
|
unrealizedMaxImbalance: BN,
|
|
@@ -3449,6 +4716,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3449
4716
|
return txSig;
|
|
3450
4717
|
}
|
|
3451
4718
|
|
|
4719
|
+
/**
|
|
4720
|
+
* Builds the `updatePerpMarketMaxImbalances` instruction without sending it. See
|
|
4721
|
+
* `updatePerpMarketMaxImbalances`.
|
|
4722
|
+
* @returns The unsigned `updatePerpMarketMaxImbalances` instruction.
|
|
4723
|
+
*/
|
|
3452
4724
|
public async getUpdatePerpMarketMaxImbalancesIx(
|
|
3453
4725
|
perpMarketIndex: number,
|
|
3454
4726
|
unrealizedMaxImbalance: BN,
|
|
@@ -3474,6 +4746,14 @@ export class AdminClient extends VelocityClient {
|
|
|
3474
4746
|
);
|
|
3475
4747
|
}
|
|
3476
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
|
+
*/
|
|
3477
4757
|
public async updatePerpMarketMaxOpenInterest(
|
|
3478
4758
|
perpMarketIndex: number,
|
|
3479
4759
|
maxOpenInterest: BN
|
|
@@ -3491,6 +4771,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3491
4771
|
return txSig;
|
|
3492
4772
|
}
|
|
3493
4773
|
|
|
4774
|
+
/**
|
|
4775
|
+
* Builds the `updatePerpMarketMaxOpenInterest` instruction without sending it. See
|
|
4776
|
+
* `updatePerpMarketMaxOpenInterest`.
|
|
4777
|
+
* @returns The unsigned `updatePerpMarketMaxOpenInterest` instruction.
|
|
4778
|
+
*/
|
|
3494
4779
|
public async getUpdatePerpMarketMaxOpenInterestIx(
|
|
3495
4780
|
perpMarketIndex: number,
|
|
3496
4781
|
maxOpenInterest: BN
|
|
@@ -3512,6 +4797,17 @@ export class AdminClient extends VelocityClient {
|
|
|
3512
4797
|
);
|
|
3513
4798
|
}
|
|
3514
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
|
+
*/
|
|
3515
4811
|
public async updatePerpMarketNumberOfUser(
|
|
3516
4812
|
perpMarketIndex: number,
|
|
3517
4813
|
numberOfUsers?: number,
|
|
@@ -3531,6 +4827,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3531
4827
|
return txSig;
|
|
3532
4828
|
}
|
|
3533
4829
|
|
|
4830
|
+
/**
|
|
4831
|
+
* Builds the `updatePerpMarketNumberOfUsers` instruction without sending it. See
|
|
4832
|
+
* `updatePerpMarketNumberOfUser`.
|
|
4833
|
+
* @returns The unsigned `updatePerpMarketNumberOfUsers` instruction.
|
|
4834
|
+
*/
|
|
3534
4835
|
public async getUpdatePerpMarketNumberOfUsersIx(
|
|
3535
4836
|
perpMarketIndex: number,
|
|
3536
4837
|
numberOfUsers?: number,
|
|
@@ -3554,6 +4855,14 @@ export class AdminClient extends VelocityClient {
|
|
|
3554
4855
|
);
|
|
3555
4856
|
}
|
|
3556
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
|
+
*/
|
|
3557
4866
|
public async updatePerpMarketFeeAdjustment(
|
|
3558
4867
|
perpMarketIndex: number,
|
|
3559
4868
|
feeAdjustment: number
|
|
@@ -3571,6 +4880,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3571
4880
|
return txSig;
|
|
3572
4881
|
}
|
|
3573
4882
|
|
|
4883
|
+
/**
|
|
4884
|
+
* Builds the `updatePerpMarketFeeAdjustment` instruction without sending it. See
|
|
4885
|
+
* `updatePerpMarketFeeAdjustment`.
|
|
4886
|
+
* @returns The unsigned `updatePerpMarketFeeAdjustment` instruction.
|
|
4887
|
+
*/
|
|
3574
4888
|
public async getUpdatePerpMarketFeeAdjustmentIx(
|
|
3575
4889
|
perpMarketIndex: number,
|
|
3576
4890
|
feeAdjustment: number
|
|
@@ -3592,6 +4906,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3592
4906
|
);
|
|
3593
4907
|
}
|
|
3594
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
|
+
*/
|
|
3595
4919
|
public async updatePerpMarketFeePoolBufferTarget(
|
|
3596
4920
|
perpMarketIndex: number,
|
|
3597
4921
|
feePoolBufferTarget: BN
|
|
@@ -3611,6 +4935,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3611
4935
|
return txSig;
|
|
3612
4936
|
}
|
|
3613
4937
|
|
|
4938
|
+
/**
|
|
4939
|
+
* Builds the `updatePerpMarketFeePoolBufferTarget` instruction without sending it. See
|
|
4940
|
+
* `updatePerpMarketFeePoolBufferTarget`.
|
|
4941
|
+
* @returns The unsigned `updatePerpMarketFeePoolBufferTarget` instruction.
|
|
4942
|
+
*/
|
|
3614
4943
|
public async getUpdatePerpMarketFeePoolBufferTargetIx(
|
|
3615
4944
|
perpMarketIndex: number,
|
|
3616
4945
|
feePoolBufferTarget: BN
|
|
@@ -3632,6 +4961,15 @@ export class AdminClient extends VelocityClient {
|
|
|
3632
4961
|
);
|
|
3633
4962
|
}
|
|
3634
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
|
+
*/
|
|
3635
4973
|
public async updateSpotMarketFeeAdjustment(
|
|
3636
4974
|
perpMarketIndex: number,
|
|
3637
4975
|
feeAdjustment: number
|
|
@@ -3649,6 +4987,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3649
4987
|
return txSig;
|
|
3650
4988
|
}
|
|
3651
4989
|
|
|
4990
|
+
/**
|
|
4991
|
+
* Builds the `updateSpotMarketFeeAdjustment` instruction without sending it. See
|
|
4992
|
+
* `updateSpotMarketFeeAdjustment`.
|
|
4993
|
+
* @returns The unsigned `updateSpotMarketFeeAdjustment` instruction.
|
|
4994
|
+
*/
|
|
3652
4995
|
public async getUpdateSpotMarketFeeAdjustmentIx(
|
|
3653
4996
|
spotMarketIndex: number,
|
|
3654
4997
|
feeAdjustment: number
|
|
@@ -3670,6 +5013,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3670
5013
|
);
|
|
3671
5014
|
}
|
|
3672
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
|
+
*/
|
|
3673
5030
|
public async updatePerpMarketLiquidationFee(
|
|
3674
5031
|
perpMarketIndex: number,
|
|
3675
5032
|
liquidatorFee: number,
|
|
@@ -3691,6 +5048,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3691
5048
|
return txSig;
|
|
3692
5049
|
}
|
|
3693
5050
|
|
|
5051
|
+
/**
|
|
5052
|
+
* Builds the `updatePerpMarketLiquidationFee` instruction without sending it. See
|
|
5053
|
+
* `updatePerpMarketLiquidationFee`.
|
|
5054
|
+
* @returns The unsigned `updatePerpMarketLiquidationFee` instruction.
|
|
5055
|
+
*/
|
|
3694
5056
|
public async getUpdatePerpMarketLiquidationFeeIx(
|
|
3695
5057
|
perpMarketIndex: number,
|
|
3696
5058
|
liquidatorFee: number,
|
|
@@ -3716,6 +5078,19 @@ export class AdminClient extends VelocityClient {
|
|
|
3716
5078
|
);
|
|
3717
5079
|
}
|
|
3718
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
|
+
*/
|
|
3719
5094
|
public async updateSpotMarketLiquidationFee(
|
|
3720
5095
|
spotMarketIndex: number,
|
|
3721
5096
|
liquidatorFee: number,
|
|
@@ -3737,6 +5112,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3737
5112
|
return txSig;
|
|
3738
5113
|
}
|
|
3739
5114
|
|
|
5115
|
+
/**
|
|
5116
|
+
* Builds the `updateSpotMarketLiquidationFee` instruction without sending it. See
|
|
5117
|
+
* `updateSpotMarketLiquidationFee`.
|
|
5118
|
+
* @returns The unsigned `updateSpotMarketLiquidationFee` instruction.
|
|
5119
|
+
*/
|
|
3740
5120
|
public async getUpdateSpotMarketLiquidationFeeIx(
|
|
3741
5121
|
spotMarketIndex: number,
|
|
3742
5122
|
liquidatorFee: number,
|
|
@@ -3762,6 +5142,16 @@ export class AdminClient extends VelocityClient {
|
|
|
3762
5142
|
);
|
|
3763
5143
|
}
|
|
3764
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
|
+
*/
|
|
3765
5155
|
public async updateProtocolFeeRecipient(
|
|
3766
5156
|
protocolFeeRecipient: PublicKey,
|
|
3767
5157
|
marketType: MarketType
|
|
@@ -3775,6 +5165,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3775
5165
|
return txSig;
|
|
3776
5166
|
}
|
|
3777
5167
|
|
|
5168
|
+
/**
|
|
5169
|
+
* Builds the `updateProtocolFeeRecipient` instruction without sending it. See
|
|
5170
|
+
* `updateProtocolFeeRecipient`.
|
|
5171
|
+
* @returns The unsigned `updateProtocolFeeRecipient` instruction.
|
|
5172
|
+
*/
|
|
3778
5173
|
public async getUpdateProtocolFeeRecipientIx(
|
|
3779
5174
|
protocolFeeRecipient: PublicKey,
|
|
3780
5175
|
marketType: MarketType
|
|
@@ -3793,6 +5188,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3793
5188
|
);
|
|
3794
5189
|
}
|
|
3795
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
|
+
*/
|
|
3796
5205
|
public async withdrawProtocolFeesSpot(
|
|
3797
5206
|
marketIndex: number,
|
|
3798
5207
|
amount: BN,
|
|
@@ -3804,6 +5213,12 @@ export class AdminClient extends VelocityClient {
|
|
|
3804
5213
|
return txSig;
|
|
3805
5214
|
}
|
|
3806
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
|
+
*/
|
|
3807
5222
|
public async getWithdrawProtocolFeesSpotIx(
|
|
3808
5223
|
marketIndex: number,
|
|
3809
5224
|
amount: BN
|
|
@@ -3853,6 +5268,18 @@ export class AdminClient extends VelocityClient {
|
|
|
3853
5268
|
);
|
|
3854
5269
|
}
|
|
3855
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
|
+
*/
|
|
3856
5283
|
public async withdrawProtocolFeesPerp(
|
|
3857
5284
|
marketIndex: number,
|
|
3858
5285
|
amount: BN,
|
|
@@ -3864,6 +5291,12 @@ export class AdminClient extends VelocityClient {
|
|
|
3864
5291
|
return txSig;
|
|
3865
5292
|
}
|
|
3866
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
|
+
*/
|
|
3867
5300
|
public async getWithdrawProtocolFeesPerpIx(
|
|
3868
5301
|
marketIndex: number,
|
|
3869
5302
|
amount: BN
|
|
@@ -3917,6 +5350,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3917
5350
|
);
|
|
3918
5351
|
}
|
|
3919
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
|
+
*/
|
|
3920
5367
|
public async initializePrelaunchOracle(
|
|
3921
5368
|
perpMarketIndex: number,
|
|
3922
5369
|
price?: BN,
|
|
@@ -3936,6 +5383,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3936
5383
|
return txSig;
|
|
3937
5384
|
}
|
|
3938
5385
|
|
|
5386
|
+
/**
|
|
5387
|
+
* Builds the `initializePrelaunchOracle` instruction without sending it. See
|
|
5388
|
+
* `initializePrelaunchOracle`.
|
|
5389
|
+
* @returns The unsigned `initializePrelaunchOracle` instruction.
|
|
5390
|
+
*/
|
|
3939
5391
|
public async getInitializePrelaunchOracleIx(
|
|
3940
5392
|
perpMarketIndex: number,
|
|
3941
5393
|
price?: BN,
|
|
@@ -3963,6 +5415,20 @@ export class AdminClient extends VelocityClient {
|
|
|
3963
5415
|
});
|
|
3964
5416
|
}
|
|
3965
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
|
+
*/
|
|
3966
5432
|
public async updatePrelaunchOracleParams(
|
|
3967
5433
|
perpMarketIndex: number,
|
|
3968
5434
|
price?: BN,
|
|
@@ -3982,6 +5448,11 @@ export class AdminClient extends VelocityClient {
|
|
|
3982
5448
|
return txSig;
|
|
3983
5449
|
}
|
|
3984
5450
|
|
|
5451
|
+
/**
|
|
5452
|
+
* Builds the `updatePrelaunchOracleParams` instruction without sending it. See
|
|
5453
|
+
* `updatePrelaunchOracleParams`.
|
|
5454
|
+
* @returns The unsigned `updatePrelaunchOracleParams` instruction.
|
|
5455
|
+
*/
|
|
3985
5456
|
public async getUpdatePrelaunchOracleParamsIx(
|
|
3986
5457
|
perpMarketIndex: number,
|
|
3987
5458
|
price?: BN,
|
|
@@ -4013,6 +5484,20 @@ export class AdminClient extends VelocityClient {
|
|
|
4013
5484
|
});
|
|
4014
5485
|
}
|
|
4015
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
|
+
*/
|
|
4016
5501
|
public async deletePrelaunchOracle(
|
|
4017
5502
|
perpMarketIndex: number
|
|
4018
5503
|
): Promise<TransactionSignature> {
|
|
@@ -4027,6 +5512,12 @@ export class AdminClient extends VelocityClient {
|
|
|
4027
5512
|
return txSig;
|
|
4028
5513
|
}
|
|
4029
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
|
+
*/
|
|
4030
5521
|
public async getDeletePrelaunchOracleIx(
|
|
4031
5522
|
perpMarketIndex: number,
|
|
4032
5523
|
price?: BN,
|
|
@@ -4058,6 +5549,19 @@ export class AdminClient extends VelocityClient {
|
|
|
4058
5549
|
});
|
|
4059
5550
|
}
|
|
4060
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
|
+
*/
|
|
4061
5565
|
public async updatePerpMarketOracleLowRiskSlotDelayOverride(
|
|
4062
5566
|
perpMarketIndex: number,
|
|
4063
5567
|
oracleLowRiskSlotDelayOverride: number
|
|
@@ -4075,6 +5579,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4075
5579
|
return txSig;
|
|
4076
5580
|
}
|
|
4077
5581
|
|
|
5582
|
+
/**
|
|
5583
|
+
* Builds the `updatePerpMarketOracleLowRiskSlotDelayOverride` instruction without sending it.
|
|
5584
|
+
* See `updatePerpMarketOracleLowRiskSlotDelayOverride`.
|
|
5585
|
+
* @returns The unsigned `updatePerpMarketOracleLowRiskSlotDelayOverride` instruction.
|
|
5586
|
+
*/
|
|
4078
5587
|
public async getUpdatePerpMarketOracleLowRiskSlotDelayOverrideIx(
|
|
4079
5588
|
perpMarketIndex: number,
|
|
4080
5589
|
oracleLowRiskSlotDelayOverride: number
|
|
@@ -4098,6 +5607,18 @@ export class AdminClient extends VelocityClient {
|
|
|
4098
5607
|
);
|
|
4099
5608
|
}
|
|
4100
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
|
+
*/
|
|
4101
5622
|
public async updatePerpMarketOracleSlotDelayOverride(
|
|
4102
5623
|
perpMarketIndex: number,
|
|
4103
5624
|
oracleSlotDelay: number
|
|
@@ -4115,6 +5636,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4115
5636
|
return txSig;
|
|
4116
5637
|
}
|
|
4117
5638
|
|
|
5639
|
+
/**
|
|
5640
|
+
* Builds the `updatePerpMarketOracleSlotDelayOverride` instruction without sending it. See
|
|
5641
|
+
* `updatePerpMarketOracleSlotDelayOverride`.
|
|
5642
|
+
* @returns The unsigned `updatePerpMarketOracleSlotDelayOverride` instruction.
|
|
5643
|
+
*/
|
|
4118
5644
|
public async getUpdatePerpMarketOracleSlotDelayOverrideIx(
|
|
4119
5645
|
perpMarketIndex: number,
|
|
4120
5646
|
oracleSlotDelay: number
|
|
@@ -4138,6 +5664,20 @@ export class AdminClient extends VelocityClient {
|
|
|
4138
5664
|
);
|
|
4139
5665
|
}
|
|
4140
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
|
+
*/
|
|
4141
5681
|
public async updatePerpMarketAmmSpreadAdjustment(
|
|
4142
5682
|
perpMarketIndex: number,
|
|
4143
5683
|
ammSpreadAdjustment: number,
|
|
@@ -4159,6 +5699,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4159
5699
|
return txSig;
|
|
4160
5700
|
}
|
|
4161
5701
|
|
|
5702
|
+
/**
|
|
5703
|
+
* Builds the `updatePerpMarketAmmSpreadAdjustment` instruction without sending it. See
|
|
5704
|
+
* `updatePerpMarketAmmSpreadAdjustment`.
|
|
5705
|
+
* @returns The unsigned `updatePerpMarketAmmSpreadAdjustment` instruction.
|
|
5706
|
+
*/
|
|
4162
5707
|
public async getUpdatePerpMarketAmmSpreadAdjustmentIx(
|
|
4163
5708
|
perpMarketIndex: number,
|
|
4164
5709
|
ammSpreadAdjustment: number,
|
|
@@ -4186,6 +5731,16 @@ export class AdminClient extends VelocityClient {
|
|
|
4186
5731
|
);
|
|
4187
5732
|
}
|
|
4188
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
|
+
*/
|
|
4189
5744
|
public async updatePerpMarketFundingBiasSensitivity(
|
|
4190
5745
|
perpMarketIndex: number,
|
|
4191
5746
|
fundingBiasSensitivity: number
|
|
@@ -4203,6 +5758,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4203
5758
|
return txSig;
|
|
4204
5759
|
}
|
|
4205
5760
|
|
|
5761
|
+
/**
|
|
5762
|
+
* Builds the `updatePerpMarketFundingBiasSensitivity` instruction without sending it. See
|
|
5763
|
+
* `updatePerpMarketFundingBiasSensitivity`.
|
|
5764
|
+
* @returns The unsigned `updatePerpMarketFundingBiasSensitivity` instruction.
|
|
5765
|
+
*/
|
|
4206
5766
|
public async getUpdatePerpMarketFundingBiasSensitivityIx(
|
|
4207
5767
|
perpMarketIndex: number,
|
|
4208
5768
|
fundingBiasSensitivity: number
|
|
@@ -4226,6 +5786,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4226
5786
|
);
|
|
4227
5787
|
}
|
|
4228
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
|
+
*/
|
|
4229
5797
|
public async initializePythLazerOracle(
|
|
4230
5798
|
feedId: number
|
|
4231
5799
|
): Promise<TransactionSignature> {
|
|
@@ -4237,6 +5805,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4237
5805
|
return txSig;
|
|
4238
5806
|
}
|
|
4239
5807
|
|
|
5808
|
+
/**
|
|
5809
|
+
* Builds the `initializePythLazerOracle` instruction without sending it. See
|
|
5810
|
+
* `initializePythLazerOracle`.
|
|
5811
|
+
* @returns The unsigned `initializePythLazerOracle` instruction.
|
|
5812
|
+
*/
|
|
4240
5813
|
public async getInitializePythLazerOracleIx(
|
|
4241
5814
|
feedId: number
|
|
4242
5815
|
): Promise<TransactionInstruction> {
|
|
@@ -4256,6 +5829,18 @@ export class AdminClient extends VelocityClient {
|
|
|
4256
5829
|
});
|
|
4257
5830
|
}
|
|
4258
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
|
+
*/
|
|
4259
5844
|
public async adminDeposit(
|
|
4260
5845
|
marketIndex: number,
|
|
4261
5846
|
amount: BN,
|
|
@@ -4273,6 +5858,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4273
5858
|
return txSig;
|
|
4274
5859
|
}
|
|
4275
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
|
+
*/
|
|
4276
5866
|
public async getAdminDepositIx(
|
|
4277
5867
|
marketIndex: number,
|
|
4278
5868
|
amount: BN,
|
|
@@ -4309,6 +5899,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4309
5899
|
});
|
|
4310
5900
|
}
|
|
4311
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
|
+
*/
|
|
4312
5913
|
public async zeroMMOracleFields(
|
|
4313
5914
|
marketIndex: number
|
|
4314
5915
|
): Promise<TransactionSignature> {
|
|
@@ -4322,6 +5923,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4322
5923
|
return txSig;
|
|
4323
5924
|
}
|
|
4324
5925
|
|
|
5926
|
+
/**
|
|
5927
|
+
* Builds the `zeroMMOracleFields` instruction without sending it. See
|
|
5928
|
+
* `zeroMMOracleFields`.
|
|
5929
|
+
* @returns The unsigned `zeroMmOracleFields` instruction.
|
|
5930
|
+
*/
|
|
4325
5931
|
public async getZeroMMOracleFieldsIx(
|
|
4326
5932
|
marketIndex: number
|
|
4327
5933
|
): Promise<TransactionInstruction> {
|
|
@@ -4339,6 +5945,18 @@ export class AdminClient extends VelocityClient {
|
|
|
4339
5945
|
});
|
|
4340
5946
|
}
|
|
4341
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
|
+
*/
|
|
4342
5960
|
public async updateFeatureBitFlagsMMOracle(
|
|
4343
5961
|
enable: boolean
|
|
4344
5962
|
): Promise<TransactionSignature> {
|
|
@@ -4351,6 +5969,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4351
5969
|
return txSig;
|
|
4352
5970
|
}
|
|
4353
5971
|
|
|
5972
|
+
/**
|
|
5973
|
+
* Builds the `updateFeatureBitFlagsMMOracle` instruction without sending it. See
|
|
5974
|
+
* `updateFeatureBitFlagsMMOracle`.
|
|
5975
|
+
* @returns The unsigned `updateFeatureBitFlagsMmOracle` instruction.
|
|
5976
|
+
*/
|
|
4354
5977
|
public async getUpdateFeatureBitFlagsMMOracleIx(
|
|
4355
5978
|
enable: boolean
|
|
4356
5979
|
): Promise<TransactionInstruction> {
|
|
@@ -4367,6 +5990,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4367
5990
|
);
|
|
4368
5991
|
}
|
|
4369
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
|
+
*/
|
|
4370
6001
|
public async updateFeatureBitFlagsBuilderCodes(
|
|
4371
6002
|
enable: boolean
|
|
4372
6003
|
): Promise<TransactionSignature> {
|
|
@@ -4379,6 +6010,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4379
6010
|
return txSig;
|
|
4380
6011
|
}
|
|
4381
6012
|
|
|
6013
|
+
/**
|
|
6014
|
+
* Builds the `updateFeatureBitFlagsBuilderCodes` instruction without sending it.
|
|
6015
|
+
* See `updateFeatureBitFlagsBuilderCodes`.
|
|
6016
|
+
* @returns The unsigned `updateFeatureBitFlagsBuilderCodes` instruction.
|
|
6017
|
+
*/
|
|
4382
6018
|
public async getUpdateFeatureBitFlagsBuilderCodesIx(
|
|
4383
6019
|
enable: boolean
|
|
4384
6020
|
): Promise<TransactionInstruction> {
|
|
@@ -4392,6 +6028,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4392
6028
|
});
|
|
4393
6029
|
}
|
|
4394
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
|
+
*/
|
|
4395
6042
|
public async updateFeatureBitFlagsBuilderReferral(
|
|
4396
6043
|
enable: boolean
|
|
4397
6044
|
): Promise<TransactionSignature> {
|
|
@@ -4406,6 +6053,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4406
6053
|
return txSig;
|
|
4407
6054
|
}
|
|
4408
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
|
+
*/
|
|
4409
6061
|
public async getUpdateFeatureBitFlagsBuilderReferralIx(
|
|
4410
6062
|
enable: boolean
|
|
4411
6063
|
): Promise<TransactionInstruction> {
|
|
@@ -4421,6 +6073,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4421
6073
|
});
|
|
4422
6074
|
}
|
|
4423
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
|
+
*/
|
|
4424
6084
|
public async updateFeatureBitFlagsMedianTriggerPrice(
|
|
4425
6085
|
enable: boolean
|
|
4426
6086
|
): Promise<TransactionSignature> {
|
|
@@ -4434,6 +6094,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4434
6094
|
return txSig;
|
|
4435
6095
|
}
|
|
4436
6096
|
|
|
6097
|
+
/**
|
|
6098
|
+
* Builds the `updateFeatureBitFlagsMedianTriggerPrice` instruction without sending
|
|
6099
|
+
* it. See `updateFeatureBitFlagsMedianTriggerPrice`.
|
|
6100
|
+
* @returns The unsigned `updateFeatureBitFlagsMedianTriggerPrice` instruction.
|
|
6101
|
+
*/
|
|
4437
6102
|
public async getUpdateFeatureBitFlagsMedianTriggerPriceIx(
|
|
4438
6103
|
enable: boolean
|
|
4439
6104
|
): Promise<TransactionInstruction> {
|
|
@@ -4450,6 +6115,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4450
6115
|
);
|
|
4451
6116
|
}
|
|
4452
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
|
+
*/
|
|
4453
6126
|
public async updateFeatureBitFlagsSettleLpPool(
|
|
4454
6127
|
enable: boolean
|
|
4455
6128
|
): Promise<TransactionSignature> {
|
|
@@ -4462,6 +6135,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4462
6135
|
return txSig;
|
|
4463
6136
|
}
|
|
4464
6137
|
|
|
6138
|
+
/**
|
|
6139
|
+
* Builds the `updateFeatureBitFlagsSettleLpPool` instruction without sending it.
|
|
6140
|
+
* See `updateFeatureBitFlagsSettleLpPool`.
|
|
6141
|
+
* @returns The unsigned `updateFeatureBitFlagsSettleLpPool` instruction.
|
|
6142
|
+
*/
|
|
4465
6143
|
public async getUpdateFeatureBitFlagsSettleLpPoolIx(
|
|
4466
6144
|
enable: boolean
|
|
4467
6145
|
): Promise<TransactionInstruction> {
|
|
@@ -4478,6 +6156,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4478
6156
|
);
|
|
4479
6157
|
}
|
|
4480
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
|
+
*/
|
|
4481
6167
|
public async updateFeatureBitFlagsSwapLpPool(
|
|
4482
6168
|
enable: boolean
|
|
4483
6169
|
): Promise<TransactionSignature> {
|
|
@@ -4490,6 +6176,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4490
6176
|
return txSig;
|
|
4491
6177
|
}
|
|
4492
6178
|
|
|
6179
|
+
/**
|
|
6180
|
+
* Builds the `updateFeatureBitFlagsSwapLpPool` instruction without sending it. See
|
|
6181
|
+
* `updateFeatureBitFlagsSwapLpPool`.
|
|
6182
|
+
* @returns The unsigned `updateFeatureBitFlagsSwapLpPool` instruction.
|
|
6183
|
+
*/
|
|
4493
6184
|
public async getUpdateFeatureBitFlagsSwapLpPoolIx(
|
|
4494
6185
|
enable: boolean
|
|
4495
6186
|
): Promise<TransactionInstruction> {
|
|
@@ -4506,6 +6197,14 @@ export class AdminClient extends VelocityClient {
|
|
|
4506
6197
|
);
|
|
4507
6198
|
}
|
|
4508
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
|
+
*/
|
|
4509
6208
|
public async updateFeatureBitFlagsMintRedeemLpPool(
|
|
4510
6209
|
enable: boolean
|
|
4511
6210
|
): Promise<TransactionSignature> {
|
|
@@ -4518,6 +6217,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4518
6217
|
return txSig;
|
|
4519
6218
|
}
|
|
4520
6219
|
|
|
6220
|
+
/**
|
|
6221
|
+
* Builds the `updateFeatureBitFlagsMintRedeemLpPool` instruction without sending
|
|
6222
|
+
* it. See `updateFeatureBitFlagsMintRedeemLpPool`.
|
|
6223
|
+
* @returns The unsigned `updateFeatureBitFlagsMintRedeemLpPool` instruction.
|
|
6224
|
+
*/
|
|
4521
6225
|
public async getUpdateFeatureBitFlagsMintRedeemLpPoolIx(
|
|
4522
6226
|
enable: boolean
|
|
4523
6227
|
): Promise<TransactionInstruction> {
|
|
@@ -4534,6 +6238,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4534
6238
|
);
|
|
4535
6239
|
}
|
|
4536
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
|
+
*/
|
|
4537
6252
|
public async adminUpdateUserStatsPausedOperations(
|
|
4538
6253
|
authority: PublicKey,
|
|
4539
6254
|
pausedOperations: number
|
|
@@ -4550,6 +6265,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4550
6265
|
return txSig;
|
|
4551
6266
|
}
|
|
4552
6267
|
|
|
6268
|
+
/**
|
|
6269
|
+
* Builds the `adminUpdateUserStatsPausedOperations` instruction without sending
|
|
6270
|
+
* it. See `adminUpdateUserStatsPausedOperations`.
|
|
6271
|
+
* @returns The unsigned `adminUpdateUserStatsPausedOperations` instruction.
|
|
6272
|
+
*/
|
|
4553
6273
|
public async getAdminUpdateUserStatsPausedOperationsIx(
|
|
4554
6274
|
authority: PublicKey,
|
|
4555
6275
|
pausedOperations: number
|
|
@@ -4571,6 +6291,21 @@ export class AdminClient extends VelocityClient {
|
|
|
4571
6291
|
);
|
|
4572
6292
|
}
|
|
4573
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
|
+
*/
|
|
4574
6309
|
public async initializeLpPool(
|
|
4575
6310
|
lpPoolId: number,
|
|
4576
6311
|
minMintFee: BN,
|
|
@@ -4592,6 +6327,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4592
6327
|
return txSig;
|
|
4593
6328
|
}
|
|
4594
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
|
+
*/
|
|
4595
6335
|
public async getInitializeLpPoolIx(
|
|
4596
6336
|
lpPoolId: number,
|
|
4597
6337
|
minMintFee: BN,
|
|
@@ -4664,6 +6404,18 @@ export class AdminClient extends VelocityClient {
|
|
|
4664
6404
|
];
|
|
4665
6405
|
}
|
|
4666
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
|
+
*/
|
|
4667
6419
|
public async initializeConstituent(
|
|
4668
6420
|
lpPoolId: number,
|
|
4669
6421
|
initializeConstituentParams: InitializeConstituentParams
|
|
@@ -4677,6 +6429,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4677
6429
|
return txSig;
|
|
4678
6430
|
}
|
|
4679
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
|
+
*/
|
|
4680
6437
|
public async getInitializeConstituentIx(
|
|
4681
6438
|
lpPoolId: number,
|
|
4682
6439
|
initializeConstituentParams: InitializeConstituentParams
|
|
@@ -4754,6 +6511,15 @@ export class AdminClient extends VelocityClient {
|
|
|
4754
6511
|
];
|
|
4755
6512
|
}
|
|
4756
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
|
+
*/
|
|
4757
6523
|
public async updateConstituentStatus(
|
|
4758
6524
|
constituent: PublicKey,
|
|
4759
6525
|
constituentStatus: ConstituentStatus
|
|
@@ -4770,6 +6536,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4770
6536
|
return txSig;
|
|
4771
6537
|
}
|
|
4772
6538
|
|
|
6539
|
+
/**
|
|
6540
|
+
* Builds the `updateConstituentStatus` instruction without sending it. See
|
|
6541
|
+
* `updateConstituentStatus`.
|
|
6542
|
+
* @returns The unsigned `updateConstituentStatus` instruction.
|
|
6543
|
+
*/
|
|
4773
6544
|
public async getUpdateConstituentStatusIx(
|
|
4774
6545
|
constituent: PublicKey,
|
|
4775
6546
|
constituentStatus: ConstituentStatus
|
|
@@ -4788,6 +6559,15 @@ export class AdminClient extends VelocityClient {
|
|
|
4788
6559
|
);
|
|
4789
6560
|
}
|
|
4790
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
|
+
*/
|
|
4791
6571
|
public async updateConstituentPausedOperations(
|
|
4792
6572
|
constituent: PublicKey,
|
|
4793
6573
|
pausedOperations: number
|
|
@@ -4805,6 +6585,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4805
6585
|
return txSig;
|
|
4806
6586
|
}
|
|
4807
6587
|
|
|
6588
|
+
/**
|
|
6589
|
+
* Builds the `updateConstituentPausedOperations` instruction without sending it.
|
|
6590
|
+
* See `updateConstituentPausedOperations`.
|
|
6591
|
+
* @returns The unsigned `updateConstituentPausedOperations` instruction.
|
|
6592
|
+
*/
|
|
4808
6593
|
public async getUpdateConstituentPausedOperationsIx(
|
|
4809
6594
|
constituent: PublicKey,
|
|
4810
6595
|
pausedOperations: number
|
|
@@ -4823,6 +6608,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4823
6608
|
);
|
|
4824
6609
|
}
|
|
4825
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
|
+
*/
|
|
4826
6622
|
public async updateConstituentParams(
|
|
4827
6623
|
lpPoolId: number,
|
|
4828
6624
|
constituentPublicKey: PublicKey,
|
|
@@ -4851,6 +6647,15 @@ export class AdminClient extends VelocityClient {
|
|
|
4851
6647
|
return txSig;
|
|
4852
6648
|
}
|
|
4853
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
|
+
*/
|
|
4854
6659
|
public async getUpdateConstituentParamsIx(
|
|
4855
6660
|
lpPoolId: number,
|
|
4856
6661
|
constituentPublicKey: PublicKey,
|
|
@@ -4906,6 +6711,15 @@ export class AdminClient extends VelocityClient {
|
|
|
4906
6711
|
];
|
|
4907
6712
|
}
|
|
4908
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
|
+
*/
|
|
4909
6723
|
public async updateLpPoolParams(
|
|
4910
6724
|
lpPoolId: number,
|
|
4911
6725
|
updateLpPoolParams: {
|
|
@@ -4926,6 +6740,11 @@ export class AdminClient extends VelocityClient {
|
|
|
4926
6740
|
return txSig;
|
|
4927
6741
|
}
|
|
4928
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
|
+
*/
|
|
4929
6748
|
public async getUpdateLpPoolParamsIx(
|
|
4930
6749
|
lpPoolId: number,
|
|
4931
6750
|
updateLpPoolParams: {
|
|
@@ -4963,6 +6782,17 @@ export class AdminClient extends VelocityClient {
|
|
|
4963
6782
|
];
|
|
4964
6783
|
}
|
|
4965
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
|
+
*/
|
|
4966
6796
|
public async addAmmConstituentMappingData(
|
|
4967
6797
|
lpPoolId: number,
|
|
4968
6798
|
addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]
|
|
@@ -4976,6 +6806,13 @@ export class AdminClient extends VelocityClient {
|
|
|
4976
6806
|
return txSig;
|
|
4977
6807
|
}
|
|
4978
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
|
+
*/
|
|
4979
6816
|
public async getAddAmmConstituentMappingDataIx(
|
|
4980
6817
|
lpPoolId: number,
|
|
4981
6818
|
addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]
|
|
@@ -5007,6 +6844,16 @@ export class AdminClient extends VelocityClient {
|
|
|
5007
6844
|
];
|
|
5008
6845
|
}
|
|
5009
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
|
+
*/
|
|
5010
6857
|
public async updateAmmConstituentMappingData(
|
|
5011
6858
|
lpPoolId: number,
|
|
5012
6859
|
addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]
|
|
@@ -5020,6 +6867,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5020
6867
|
return txSig;
|
|
5021
6868
|
}
|
|
5022
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
|
+
*/
|
|
5023
6875
|
public async getUpdateAmmConstituentMappingDataIx(
|
|
5024
6876
|
lpPoolId: number,
|
|
5025
6877
|
addAmmConstituentMappingData: AddAmmConstituentMappingDatum[]
|
|
@@ -5045,6 +6897,15 @@ export class AdminClient extends VelocityClient {
|
|
|
5045
6897
|
];
|
|
5046
6898
|
}
|
|
5047
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
|
+
*/
|
|
5048
6909
|
public async removeAmmConstituentMappingData(
|
|
5049
6910
|
lpPoolId: number,
|
|
5050
6911
|
perpMarketIndex: number,
|
|
@@ -5060,6 +6921,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5060
6921
|
return txSig;
|
|
5061
6922
|
}
|
|
5062
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
|
+
*/
|
|
5063
6929
|
public async getRemoveAmmConstituentMappingDataIx(
|
|
5064
6930
|
lpPoolId: number,
|
|
5065
6931
|
perpMarketIndex: number,
|
|
@@ -5088,6 +6954,16 @@ export class AdminClient extends VelocityClient {
|
|
|
5088
6954
|
];
|
|
5089
6955
|
}
|
|
5090
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
|
+
*/
|
|
5091
6967
|
public async updateConstituentCorrelationData(
|
|
5092
6968
|
lpPoolId: number,
|
|
5093
6969
|
index1: number,
|
|
@@ -5105,6 +6981,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5105
6981
|
return txSig;
|
|
5106
6982
|
}
|
|
5107
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
|
+
*/
|
|
5108
6989
|
public async getUpdateConstituentCorrelationDataIx(
|
|
5109
6990
|
lpPoolId: number,
|
|
5110
6991
|
index1: number,
|
|
@@ -5264,6 +7145,24 @@ export class AdminClient extends VelocityClient {
|
|
|
5264
7145
|
return { beginSwapIx, endSwapIx };
|
|
5265
7146
|
}
|
|
5266
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
|
+
*/
|
|
5267
7166
|
public async getLpJupiterSwapIxV6({
|
|
5268
7167
|
jupiterClient,
|
|
5269
7168
|
outMarketIndex,
|
|
@@ -5398,6 +7297,22 @@ export class AdminClient extends VelocityClient {
|
|
|
5398
7297
|
return { ixs, lookupTables };
|
|
5399
7298
|
}
|
|
5400
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
|
+
*/
|
|
5401
7316
|
public async getDevnetLpSwapIxs(
|
|
5402
7317
|
amountIn: BN,
|
|
5403
7318
|
amountOut: BN,
|
|
@@ -5470,6 +7385,18 @@ export class AdminClient extends VelocityClient {
|
|
|
5470
7385
|
return ixs;
|
|
5471
7386
|
}
|
|
5472
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
|
+
*/
|
|
5473
7400
|
public async getAllDevnetLpSwapIxs(
|
|
5474
7401
|
lpPoolId: number,
|
|
5475
7402
|
inMarketIndex: number,
|
|
@@ -5525,6 +7452,22 @@ export class AdminClient extends VelocityClient {
|
|
|
5525
7452
|
] as TransactionInstruction[];
|
|
5526
7453
|
}
|
|
5527
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
|
+
*/
|
|
5528
7471
|
public async depositWithdrawToProgramVault(
|
|
5529
7472
|
lpPoolId: number,
|
|
5530
7473
|
depositMarketIndex: number,
|
|
@@ -5546,6 +7489,13 @@ export class AdminClient extends VelocityClient {
|
|
|
5546
7489
|
return txSig;
|
|
5547
7490
|
}
|
|
5548
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
|
+
*/
|
|
5549
7499
|
public async getDepositWithdrawToProgramVaultIxs(
|
|
5550
7500
|
lpPoolId: number,
|
|
5551
7501
|
depositMarketIndex: number,
|
|
@@ -5627,6 +7577,15 @@ export class AdminClient extends VelocityClient {
|
|
|
5627
7577
|
return { depositIx, withdrawIx };
|
|
5628
7578
|
}
|
|
5629
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
|
+
*/
|
|
5630
7589
|
public async depositToProgramVault(
|
|
5631
7590
|
lpPoolId: number,
|
|
5632
7591
|
depositMarketIndex: number,
|
|
@@ -5643,6 +7602,16 @@ export class AdminClient extends VelocityClient {
|
|
|
5643
7602
|
return txSig;
|
|
5644
7603
|
}
|
|
5645
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
|
+
*/
|
|
5646
7615
|
public async withdrawFromProgramVault(
|
|
5647
7616
|
lpPoolId: number,
|
|
5648
7617
|
borrowMarketIndex: number,
|
|
@@ -5658,6 +7627,13 @@ export class AdminClient extends VelocityClient {
|
|
|
5658
7627
|
return txSig;
|
|
5659
7628
|
}
|
|
5660
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
|
+
*/
|
|
5661
7637
|
public async getDepositToProgramVaultIx(
|
|
5662
7638
|
lpPoolId: number,
|
|
5663
7639
|
depositMarketIndex: number,
|
|
@@ -5673,6 +7649,13 @@ export class AdminClient extends VelocityClient {
|
|
|
5673
7649
|
return depositIx;
|
|
5674
7650
|
}
|
|
5675
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
|
+
*/
|
|
5676
7659
|
public async getWithdrawFromProgramVaultIx(
|
|
5677
7660
|
lpPoolId: number,
|
|
5678
7661
|
borrowMarketIndex: number,
|
|
@@ -5688,6 +7671,16 @@ export class AdminClient extends VelocityClient {
|
|
|
5688
7671
|
return withdrawIx;
|
|
5689
7672
|
}
|
|
5690
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
|
+
*/
|
|
5691
7684
|
public async updatePerpMarketLpPoolFeeTransferScalar(
|
|
5692
7685
|
marketIndex: number,
|
|
5693
7686
|
lpFeeTransferScalar?: number,
|
|
@@ -5703,6 +7696,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5703
7696
|
return txSig;
|
|
5704
7697
|
}
|
|
5705
7698
|
|
|
7699
|
+
/**
|
|
7700
|
+
* Builds the `updatePerpMarketLpPoolFeeTransferScalar` instruction without
|
|
7701
|
+
* sending it. See `updatePerpMarketLpPoolFeeTransferScalar`.
|
|
7702
|
+
* @returns The unsigned `updatePerpMarketLpPoolFeeTransferScalar` instruction.
|
|
7703
|
+
*/
|
|
5706
7704
|
public async getUpdatePerpMarketLpPoolFeeTransferScalarIx(
|
|
5707
7705
|
marketIndex: number,
|
|
5708
7706
|
lpFeeTransferScalar?: number,
|
|
@@ -5724,6 +7722,17 @@ export class AdminClient extends VelocityClient {
|
|
|
5724
7722
|
);
|
|
5725
7723
|
}
|
|
5726
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
|
+
*/
|
|
5727
7736
|
public async updatePerpMarketLpPoolPausedOperations(
|
|
5728
7737
|
marketIndex: number,
|
|
5729
7738
|
pausedOperations: number
|
|
@@ -5737,6 +7746,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5737
7746
|
return txSig;
|
|
5738
7747
|
}
|
|
5739
7748
|
|
|
7749
|
+
/**
|
|
7750
|
+
* Builds the `updatePerpMarketLpPoolPausedOperations` instruction without
|
|
7751
|
+
* sending it. See `updatePerpMarketLpPoolPausedOperations`.
|
|
7752
|
+
* @returns The unsigned `updatePerpMarketLpPoolPausedOperations` instruction.
|
|
7753
|
+
*/
|
|
5740
7754
|
public async getUpdatePerpMarketLpPoolPausedOperationsIx(
|
|
5741
7755
|
marketIndex: number,
|
|
5742
7756
|
pausedOperations: number
|
|
@@ -5756,6 +7770,19 @@ export class AdminClient extends VelocityClient {
|
|
|
5756
7770
|
);
|
|
5757
7771
|
}
|
|
5758
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
|
+
*/
|
|
5759
7786
|
public async mintLpWhitelistToken(
|
|
5760
7787
|
lpPool: LPPoolAccount,
|
|
5761
7788
|
authority: PublicKey
|
|
@@ -5766,6 +7793,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5766
7793
|
return txSig;
|
|
5767
7794
|
}
|
|
5768
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
|
+
*/
|
|
5769
7801
|
public async getMintLpWhitelistTokenIx(
|
|
5770
7802
|
lpPool: LPPoolAccount,
|
|
5771
7803
|
authority: PublicKey
|
|
@@ -5798,6 +7830,17 @@ export class AdminClient extends VelocityClient {
|
|
|
5798
7830
|
return ixs;
|
|
5799
7831
|
}
|
|
5800
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
|
+
*/
|
|
5801
7844
|
public async updatePerpMarketConfig(
|
|
5802
7845
|
marketIndex: number,
|
|
5803
7846
|
marketConfig: number
|
|
@@ -5811,6 +7854,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5811
7854
|
return txSig;
|
|
5812
7855
|
}
|
|
5813
7856
|
|
|
7857
|
+
/**
|
|
7858
|
+
* Builds the `updatePerpMarketConfig` instruction without sending it. See
|
|
7859
|
+
* `updatePerpMarketConfig`.
|
|
7860
|
+
* @returns The unsigned `updatePerpMarketConfig` instruction.
|
|
7861
|
+
*/
|
|
5814
7862
|
public async getUpdatePerpMarketConfigIx(
|
|
5815
7863
|
marketIndex: number,
|
|
5816
7864
|
marketConfig: number
|
|
@@ -5827,6 +7875,22 @@ export class AdminClient extends VelocityClient {
|
|
|
5827
7875
|
});
|
|
5828
7876
|
}
|
|
5829
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
|
+
*/
|
|
5830
7894
|
public async transferFeeAndPnlPool(
|
|
5831
7895
|
perpMarketIndexWithFeePool: number,
|
|
5832
7896
|
perpMarketIndexWithPnlPool: number,
|
|
@@ -5844,6 +7908,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5844
7908
|
return txSig;
|
|
5845
7909
|
}
|
|
5846
7910
|
|
|
7911
|
+
/**
|
|
7912
|
+
* Builds the `transferFeeAndPnlPool` instruction without sending it. See
|
|
7913
|
+
* `transferFeeAndPnlPool`.
|
|
7914
|
+
* @returns The unsigned `transferFeeAndPnlPool` instruction.
|
|
7915
|
+
*/
|
|
5847
7916
|
public async getTransferFeeAndPnlPoolIx(
|
|
5848
7917
|
perpMarketIndexWithFeePool: number,
|
|
5849
7918
|
perpMarketIndexWithPnlPool: number,
|
|
@@ -5874,6 +7943,18 @@ export class AdminClient extends VelocityClient {
|
|
|
5874
7943
|
);
|
|
5875
7944
|
}
|
|
5876
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
|
+
*/
|
|
5877
7958
|
public async updateSpecialUserStatus(
|
|
5878
7959
|
userAccountPublicKey: PublicKey,
|
|
5879
7960
|
status: number,
|
|
@@ -5888,6 +7969,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5888
7969
|
return txSig;
|
|
5889
7970
|
}
|
|
5890
7971
|
|
|
7972
|
+
/**
|
|
7973
|
+
* Builds the `updateSpecialUserStatus` instruction without sending it. See
|
|
7974
|
+
* `updateSpecialUserStatus`.
|
|
7975
|
+
* @returns The unsigned `updateSpecialUserStatus` instruction.
|
|
7976
|
+
*/
|
|
5891
7977
|
public async getUpdateSpecialUserStatusIx(
|
|
5892
7978
|
userAccountPublicKey: PublicKey,
|
|
5893
7979
|
status: number
|
|
@@ -5910,6 +7996,13 @@ export class AdminClient extends VelocityClient {
|
|
|
5910
7996
|
// `handleInitialize` seeds `coldAdmin = warmAdmin = signer`; there is no
|
|
5911
7997
|
// separate "initialize admin authority config" ix.
|
|
5912
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
|
+
*/
|
|
5913
8006
|
public async updateWarmAdmin(
|
|
5914
8007
|
newWarmAdmin: PublicKey
|
|
5915
8008
|
): Promise<TransactionSignature> {
|
|
@@ -5919,6 +8012,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5919
8012
|
return txSig;
|
|
5920
8013
|
}
|
|
5921
8014
|
|
|
8015
|
+
/**
|
|
8016
|
+
* Builds the `updateWarmAdmin` instruction without sending it. See
|
|
8017
|
+
* `updateWarmAdmin`.
|
|
8018
|
+
* @returns The unsigned `updateWarmAdmin` instruction.
|
|
8019
|
+
*/
|
|
5922
8020
|
public async getUpdateWarmAdminIx(
|
|
5923
8021
|
newWarmAdmin: PublicKey
|
|
5924
8022
|
): Promise<TransactionInstruction> {
|
|
@@ -5932,6 +8030,53 @@ export class AdminClient extends VelocityClient {
|
|
|
5932
8030
|
});
|
|
5933
8031
|
}
|
|
5934
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
|
+
*/
|
|
5935
8080
|
public async updateHotAdmin(
|
|
5936
8081
|
role: HotRole,
|
|
5937
8082
|
newPubkey: PublicKey
|
|
@@ -5942,6 +8087,11 @@ export class AdminClient extends VelocityClient {
|
|
|
5942
8087
|
return txSig;
|
|
5943
8088
|
}
|
|
5944
8089
|
|
|
8090
|
+
/**
|
|
8091
|
+
* Builds the `updateHotAdmin` instruction without sending it. See
|
|
8092
|
+
* `updateHotAdmin`.
|
|
8093
|
+
* @returns The unsigned `updateHotAdmin` instruction.
|
|
8094
|
+
*/
|
|
5945
8095
|
public async getUpdateHotAdminIx(
|
|
5946
8096
|
role: HotRole,
|
|
5947
8097
|
newPubkey: PublicKey
|
|
@@ -5961,8 +8111,10 @@ export class AdminClient extends VelocityClient {
|
|
|
5961
8111
|
|
|
5962
8112
|
/**
|
|
5963
8113
|
* Hot-admin role identifier. Each role is a separate purpose-specific signer key
|
|
5964
|
-
* stored on the `
|
|
5965
|
-
*
|
|
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).
|
|
5966
8118
|
*/
|
|
5967
8119
|
export enum HotRole {
|
|
5968
8120
|
AmmCrank = 'ammCrank',
|