@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/lib/node/adminClient.js
CHANGED
|
@@ -26,11 +26,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.HotRole = exports.AdminClient = void 0;
|
|
27
27
|
/**
|
|
28
28
|
* AdminClient — governance and protocol administration instruction builders.
|
|
29
|
-
* Extends
|
|
29
|
+
* Extends `VelocityClient`; all trading/keeper methods are also available.
|
|
30
30
|
*
|
|
31
31
|
* Covers: perp/spot market initialization and updates, oracle guard rail config,
|
|
32
32
|
* fee structure updates, insurance fund operations, vault management, IF rebalancing,
|
|
33
|
-
* pause/unpause exchange, and all
|
|
33
|
+
* pause/unpause exchange, and all admin instruction handlers in `instructions/admin.rs`.
|
|
34
|
+
*
|
|
35
|
+
* Most methods require a specific admin tier, enforced on-chain by `state.cold_admin` /
|
|
36
|
+
* `state.warm_admin` / per-role `state.hot_*` keys (see `programs/velocity/src/auth.rs`).
|
|
37
|
+
* Tiers are additive — cold ⊇ warm ⊇ hot(role) — so the cold admin can always call a
|
|
38
|
+
* warm- or hot-gated instruction. Each method's doc below states the minimum tier
|
|
39
|
+
* required by the on-chain constraint; passing a lower-tier wallet fails the transaction
|
|
40
|
+
* with `Unauthorized`, not client-side.
|
|
34
41
|
*/
|
|
35
42
|
const web3_js_1 = require("@solana/web3.js");
|
|
36
43
|
const types_1 = require("./types");
|
|
@@ -45,6 +52,19 @@ const numericConstants_1 = require("./constants/numericConstants");
|
|
|
45
52
|
const trade_1 = require("./math/trade");
|
|
46
53
|
const amm_1 = require("./math/amm");
|
|
47
54
|
class AdminClient extends velocityClient_1.VelocityClient {
|
|
55
|
+
/**
|
|
56
|
+
* Creates the protocol's singleton `State` account (one-time setup). Fails client-side
|
|
57
|
+
* if `State` already exists. On a real mainnet build the on-chain `Initialize` accounts
|
|
58
|
+
* struct additionally locks the signer to `ids::state_init_authority` so the one-time
|
|
59
|
+
* init cannot be front-run; on devnet/localnet or the `anchor-test` build any signer may
|
|
60
|
+
* call it. Seeds `cold_admin` and `warm_admin` to the calling wallet and `pause_admin` to
|
|
61
|
+
* the default (unassigned) pubkey — rotate them afterward via `updateAdmin` /
|
|
62
|
+
* `updateWarmAdmin` / `updatePauseAdmin`.
|
|
63
|
+
* @param usdcMint - Mint of the protocol's quote asset (must have 6 decimals; becomes
|
|
64
|
+
* `state.quoteAssetMint`).
|
|
65
|
+
* @param _adminControlsPrices - Unused; retained for call-site compatibility.
|
|
66
|
+
* @returns Tuple containing the transaction signature.
|
|
67
|
+
*/
|
|
48
68
|
async initialize(usdcMint, _adminControlsPrices) {
|
|
49
69
|
const stateAccountRPCResponse = await this.connection.getParsedAccountInfo(await this.getStatePublicKey());
|
|
50
70
|
if (stateAccountRPCResponse.value !== null) {
|
|
@@ -68,6 +88,39 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
68
88
|
const { txSig } = await super.sendTransaction(tx, [], this.opts);
|
|
69
89
|
return [txSig];
|
|
70
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Initializes a new spot market: creates the `SpotMarket` PDA plus its token vault and
|
|
93
|
+
* insurance-fund vault, and appends it at `state.numberOfSpotMarkets` (or `marketIndex`
|
|
94
|
+
* if explicitly supplied — the on-chain handler asserts it matches the next sequential
|
|
95
|
+
* index). Requires warm admin (`check_warm`); if `activeStatus` is `true` the on-chain
|
|
96
|
+
* handler additionally requires the **cold** admin specifically (a market cannot be
|
|
97
|
+
* launched active by a warm-only signer). For `oracleSource: QuoteAsset` (used only for
|
|
98
|
+
* the index-0 quote market), `oracle` must be `PublicKey.default`.
|
|
99
|
+
* @param mint - Spot market's token mint. Must have >= 5 decimals (exactly 6 for the
|
|
100
|
+
* quote/index-0 market).
|
|
101
|
+
* @param optimalUtilization - Utilization at the borrow-rate kink, SPOT_UTILIZATION_PRECISION (1e6, 100% = 1e6).
|
|
102
|
+
* @param optimalRate - Borrow rate at `optimalUtilization`, SPOT_RATE_PRECISION (1e6, 100% APR = 1e6).
|
|
103
|
+
* @param maxRate - Borrow rate at 100% utilization, SPOT_RATE_PRECISION (1e6).
|
|
104
|
+
* @param oracle - Oracle account for this market's price feed (`PublicKey.default` for `OracleSource.QuoteAsset`).
|
|
105
|
+
* @param oracleSource - Oracle provider/format for `oracle`.
|
|
106
|
+
* @param initialAssetWeight - Initial (deposit) asset weight, SPOT_WEIGHT_PRECISION (1e4, 100% = 1e4).
|
|
107
|
+
* @param maintenanceAssetWeight - Maintenance asset weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
108
|
+
* @param initialLiabilityWeight - Initial (borrow) liability weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
109
|
+
* @param maintenanceLiabilityWeight - Maintenance liability weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
110
|
+
* @param imfFactor - Increases weight penalty as position size grows, SPOT_IMF_PRECISION (1e6). Default 0.
|
|
111
|
+
* @param liquidatorFee - Fee paid to liquidators, LIQUIDATION_FEE_PRECISION (1e6). Default 0.
|
|
112
|
+
* @param ifLiquidationFee - Portion of the liquidation fee routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6). Default 0.
|
|
113
|
+
* @param activeStatus - If `true`, market is `Active` immediately; otherwise `Initialized` (trading disabled until a later status update). Requires cold admin when `true`. Default `true`.
|
|
114
|
+
* @param assetTier - Collateral tier gating cross-margin usability. Default `AssetTier.COLLATERAL`.
|
|
115
|
+
* @param scaleInitialAssetWeightStart - Deposit-token-amount threshold, QUOTE_PRECISION (1e6) equivalent notional, above which `initialAssetWeight` scales down. Default 0 (disabled).
|
|
116
|
+
* @param withdrawGuardThreshold - Token-amount threshold, market's native decimals, above which large single withdraws/borrows are blocked. Default 0.
|
|
117
|
+
* @param orderTickSize - Minimum price increment for spot orders, PRICE_PRECISION (1e6). Default 1.
|
|
118
|
+
* @param orderStepSize - Minimum base size increment for spot orders, market's native decimals. Also seeds `minOrderSize`. Default 1.
|
|
119
|
+
* @param ifTotalFactor - Insurance fund fee share of the total spot fee, IF_FACTOR_PRECISION (1e6). Default 0.
|
|
120
|
+
* @param name - Market display name, UTF-8 encoded and padded/truncated to 32 bytes. Default `DEFAULT_MARKET_NAME`.
|
|
121
|
+
* @param marketIndex - Explicit spot market index; defaults to `state.numberOfSpotMarkets` (the next free slot) when omitted.
|
|
122
|
+
* @returns Transaction signature.
|
|
123
|
+
*/
|
|
71
124
|
async initializeSpotMarket(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0, liquidatorFee = 0, ifLiquidationFee = 0, activeStatus = true, assetTier = types_1.AssetTier.COLLATERAL, scaleInitialAssetWeightStart = numericConstants_1.ZERO, withdrawGuardThreshold = numericConstants_1.ZERO, orderTickSize = numericConstants_1.ONE, orderStepSize = numericConstants_1.ONE, ifTotalFactor = 0, name = userName_1.DEFAULT_MARKET_NAME, marketIndex) {
|
|
72
125
|
const spotMarketIndex = marketIndex !== null && marketIndex !== void 0 ? marketIndex : this.getStateAccount().numberOfSpotMarkets;
|
|
73
126
|
const initializeIx = await this.getInitializeSpotMarketIx(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, ifLiquidationFee, activeStatus, assetTier, scaleInitialAssetWeightStart, withdrawGuardThreshold, orderTickSize, orderStepSize, ifTotalFactor, name, marketIndex);
|
|
@@ -81,6 +134,14 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
81
134
|
await this.accountSubscriber.setSpotOracleMap();
|
|
82
135
|
return txSig;
|
|
83
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Builds the `initializeSpotMarket` instruction without sending it. See `initializeSpotMarket`
|
|
139
|
+
* for parameter units and the cold-admin-if-`activeStatus` rule. Looks up `mint`'s owning
|
|
140
|
+
* token program on-chain (throws if the mint account doesn't exist) and resolves the admin
|
|
141
|
+
* signer to `wallet.publicKey` when `useHotWalletAdmin` is set, otherwise to `state.coldAdmin`
|
|
142
|
+
* (or the wallet if not yet subscribed).
|
|
143
|
+
* @returns The unsigned `initializeSpotMarket` instruction.
|
|
144
|
+
*/
|
|
84
145
|
async getInitializeSpotMarketIx(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0, liquidatorFee = 0, ifLiquidationFee = 0, activeStatus = true, assetTier = types_1.AssetTier.COLLATERAL, scaleInitialAssetWeightStart = numericConstants_1.ZERO, withdrawGuardThreshold = numericConstants_1.ZERO, orderTickSize = numericConstants_1.ONE, orderStepSize = numericConstants_1.ONE, ifTotalFactor = 0, name = userName_1.DEFAULT_MARKET_NAME, marketIndex) {
|
|
85
146
|
const spotMarketIndex = marketIndex !== null && marketIndex !== void 0 ? marketIndex : this.getStateAccount().numberOfSpotMarkets;
|
|
86
147
|
const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
|
|
@@ -113,12 +174,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
113
174
|
});
|
|
114
175
|
return initializeIx;
|
|
115
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Closes a mis-initialized spot market and refunds rent to the admin. Requires warm admin
|
|
179
|
+
* (`check_warm`). On-chain the handler only allows deleting the **most recently created**
|
|
180
|
+
* market (`marketIndex == state.numberOfSpotMarkets - 1`), still in `Initialized` status
|
|
181
|
+
* (never activated), with zero deposit and borrow balances and empty vaults — otherwise it
|
|
182
|
+
* throws `InvalidMarketAccountforDeletion`.
|
|
183
|
+
* @param marketIndex - Index of the spot market to delete; must be the last-created, unactivated, empty market.
|
|
184
|
+
* @returns Transaction signature.
|
|
185
|
+
*/
|
|
116
186
|
async deleteInitializedSpotMarket(marketIndex) {
|
|
117
187
|
const deleteInitializeMarketIx = await this.getDeleteInitializedSpotMarketIx(marketIndex);
|
|
118
188
|
const tx = await this.buildTransaction(deleteInitializeMarketIx);
|
|
119
189
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
120
190
|
return txSig;
|
|
121
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Builds the `deleteInitializedSpotMarket` instruction without sending it. See
|
|
194
|
+
* `deleteInitializedSpotMarket` for the on-chain preconditions.
|
|
195
|
+
* @param marketIndex - Index of the spot market to delete.
|
|
196
|
+
* @returns The unsigned `deleteInitializedSpotMarket` instruction.
|
|
197
|
+
*/
|
|
122
198
|
async getDeleteInitializedSpotMarketIx(marketIndex) {
|
|
123
199
|
const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
|
|
124
200
|
const spotMarketVaultPublicKey = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, marketIndex);
|
|
@@ -137,6 +213,45 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
137
213
|
},
|
|
138
214
|
});
|
|
139
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Initializes a new perp market's `PerpMarket` PDA and seeds its AMM. Requires warm admin
|
|
218
|
+
* (`check_warm`); if `activeStatus` is `true` the on-chain handler additionally requires
|
|
219
|
+
* the **cold** admin (a market cannot launch active under a warm-only signer). The handler
|
|
220
|
+
* asserts `marketIndex === state.numberOfMarkets` (must be the next sequential index) and
|
|
221
|
+
* that `baseAssetReserve === quoteAssetReserve` (the initial mark price is exactly
|
|
222
|
+
* `pegMultiplier`). Does not add the market to the AMM cache — call `addMarketToAmmCache`
|
|
223
|
+
* separately (typically before the market can be traded/cranked).
|
|
224
|
+
* @param marketIndex - New market's index; must equal `state.numberOfMarkets`.
|
|
225
|
+
* @param priceOracle - Oracle account backing this market's price feed.
|
|
226
|
+
* @param baseAssetReserve - Initial AMM base reserve, BASE_PRECISION (1e9). Must equal `quoteAssetReserve`.
|
|
227
|
+
* @param quoteAssetReserve - Initial AMM quote reserve, BASE_PRECISION (1e9, AMM-internal units, not quote-asset dollars). Must equal `baseAssetReserve`.
|
|
228
|
+
* @param periodicity - Funding period, seconds (`market.marketStats.fundingPeriod`), as a BN.
|
|
229
|
+
* @param pegMultiplier - AMM peg, PEG_PRECISION (1e6). With equal reserves this fixes the initial mark price to `pegMultiplier`. Default `PEG_PRECISION` (price = 1.0).
|
|
230
|
+
* @param oracleSource - Oracle provider/format for `priceOracle`. Default `OracleSource.PYTH_LAZER`.
|
|
231
|
+
* @param contractTier - Risk/collateral tier for the contract. Default `ContractTier.SPECULATIVE`.
|
|
232
|
+
* @param marginRatioInitial - Initial margin ratio, MARGIN_PRECISION (1e4, e.g. 2000 = 20% = 5x max leverage). Default 2000.
|
|
233
|
+
* @param marginRatioMaintenance - Maintenance margin ratio, MARGIN_PRECISION (1e4). Default 500 (5%).
|
|
234
|
+
* @param liquidatorFee - Fee paid to liquidators, LIQUIDATION_FEE_PRECISION (1e6). Default 0.
|
|
235
|
+
* @param ifLiquidatorFee - Portion of the liquidation fee routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6). Default 10000 (1%).
|
|
236
|
+
* @param imfFactor - Increases the effective margin requirement as position size grows, PERCENTAGE_PRECISION-scaled (1e6). Default 0.
|
|
237
|
+
* @param activeStatus - If `true`, market is `Active` immediately; otherwise `Initialized`. Requires cold admin when `true`. Default `true`.
|
|
238
|
+
* @param baseSpread - Base bid/ask spread around the AMM reserve price, BID_ASK_SPREAD_PRECISION (1e6). Default 0.
|
|
239
|
+
* @param maxSpread - Maximum allowed total spread, BID_ASK_SPREAD_PRECISION (1e6). Default 142500 (14.25%).
|
|
240
|
+
* @param maxOpenInterest - Cap on base-asset open interest, BASE_PRECISION (1e9). Default 0 (unlimited — treated as no cap by downstream checks).
|
|
241
|
+
* @param maxRevenueWithdrawPerPeriod - Cap on revenue-pool withdrawals per settlement period, QUOTE_PRECISION (1e6). Default 0.
|
|
242
|
+
* @param quoteMaxInsurance - Lifetime cap on insurance draws for this market, QUOTE_PRECISION (1e6). Default 0.
|
|
243
|
+
* @param orderStepSize - Minimum base-size increment for orders, BASE_PRECISION (1e9). Default `BASE_PRECISION / 10000`.
|
|
244
|
+
* @param orderTickSize - Minimum price increment for orders, PRICE_PRECISION (1e6). Default `PRICE_PRECISION / 100000`.
|
|
245
|
+
* @param minOrderSize - Minimum base order size, BASE_PRECISION (1e9). Default `BASE_PRECISION / 10000`.
|
|
246
|
+
* @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.
|
|
247
|
+
* @param curveUpdateIntensity - 0-100 knob controlling how aggressively the AMM curve/peg re-centers on repegs. Default 0 (disabled).
|
|
248
|
+
* @param ammJitIntensity - 0-100 knob controlling how aggressively the AMM just-in-time-fills maker orders. Default 0 (disabled).
|
|
249
|
+
* @param name - Market display name, UTF-8 encoded and padded/truncated to 32 bytes. Default `DEFAULT_MARKET_NAME`.
|
|
250
|
+
* @param lpPoolId - LP pool this market's hedge exposure is routed to; 0 means unassigned. Default 0.
|
|
251
|
+
* @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.
|
|
252
|
+
* @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.
|
|
253
|
+
* @returns Transaction signature.
|
|
254
|
+
*/
|
|
140
255
|
async initializePerpMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH_LAZER, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0, fundingClampThreshold = 0, fundingRampSlope = 0) {
|
|
141
256
|
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
142
257
|
const initializeMarketIxs = await this.getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name, lpPoolId, fundingClampThreshold, fundingRampSlope);
|
|
@@ -153,6 +268,11 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
153
268
|
await this.accountSubscriber.setPerpOracleMap();
|
|
154
269
|
return txSig;
|
|
155
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Builds the `initializePerpMarket` instruction without sending it. See `initializePerpMarket`
|
|
273
|
+
* for parameter units and the cold-admin-if-`activeStatus` rule.
|
|
274
|
+
* @returns Single-element array containing the unsigned `initializePerpMarket` instruction.
|
|
275
|
+
*/
|
|
156
276
|
async getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH_LAZER, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0, fundingClampThreshold = 0, fundingRampSlope = 0) {
|
|
157
277
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
158
278
|
const ixs = [];
|
|
@@ -174,12 +294,21 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
174
294
|
ixs.push(initPerpIx);
|
|
175
295
|
return ixs;
|
|
176
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Creates the protocol-wide singleton `AmmCache` PDA (one-time setup, empty until
|
|
299
|
+
* `addMarketToAmmCache` is called per market). Requires warm admin (`check_warm`).
|
|
300
|
+
* @returns Transaction signature.
|
|
301
|
+
*/
|
|
177
302
|
async initializeAmmCache(txParams) {
|
|
178
303
|
const initializeAmmCacheIx = await this.getInitializeAmmCacheIx();
|
|
179
304
|
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
180
305
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
181
306
|
return txSig;
|
|
182
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Builds the `initializeAmmCache` instruction without sending it. See `initializeAmmCache`.
|
|
310
|
+
* @returns The unsigned `initializeAmmCache` instruction.
|
|
311
|
+
*/
|
|
183
312
|
async getInitializeAmmCacheIx() {
|
|
184
313
|
return await this.program.instruction.initializeAmmCache({
|
|
185
314
|
accounts: {
|
|
@@ -193,12 +322,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
193
322
|
},
|
|
194
323
|
});
|
|
195
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Appends a perp market's entry to the `AmmCache` (reallocating it larger by one slot).
|
|
327
|
+
* Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if the market index
|
|
328
|
+
* is already present in the cache. A market must be added here before keeper cranks that
|
|
329
|
+
* rely on the AMM cache (e.g. LP-pool settlement) can process it.
|
|
330
|
+
* @param perpMarketIndex - Index of the perp market to add.
|
|
331
|
+
* @returns Transaction signature.
|
|
332
|
+
*/
|
|
196
333
|
async addMarketToAmmCache(perpMarketIndex, txParams) {
|
|
197
334
|
const initializeAmmCacheIx = await this.getAddMarketToAmmCacheIx(perpMarketIndex);
|
|
198
335
|
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
199
336
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
200
337
|
return txSig;
|
|
201
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Builds the `addMarketToAmmCache` instruction without sending it. See `addMarketToAmmCache`.
|
|
341
|
+
* @param perpMarketIndex - Index of the perp market to add. Throws if the market is not
|
|
342
|
+
* already tracked by the local account subscriber.
|
|
343
|
+
* @returns The unsigned `addMarketToAmmCache` instruction.
|
|
344
|
+
*/
|
|
202
345
|
async getAddMarketToAmmCacheIx(perpMarketIndex) {
|
|
203
346
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
204
347
|
return await this.program.instruction.addMarketToAmmCache({
|
|
@@ -214,12 +357,22 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
214
357
|
},
|
|
215
358
|
});
|
|
216
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Closes the `AmmCache` PDA, refunding rent to the admin. Requires warm admin
|
|
362
|
+
* (`check_warm`). Removes tracking for every market at once — there is no per-market
|
|
363
|
+
* inverse of `addMarketToAmmCache`.
|
|
364
|
+
* @returns Transaction signature.
|
|
365
|
+
*/
|
|
217
366
|
async deleteAmmCache(txParams) {
|
|
218
367
|
const deleteAmmCacheIx = await this.getDeleteAmmCacheIx();
|
|
219
368
|
const tx = await this.buildTransaction(deleteAmmCacheIx, txParams);
|
|
220
369
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
221
370
|
return txSig;
|
|
222
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* Builds the `deleteAmmCache` instruction without sending it. See `deleteAmmCache`.
|
|
374
|
+
* @returns The unsigned `deleteAmmCache` instruction.
|
|
375
|
+
*/
|
|
223
376
|
async getDeleteAmmCacheIx() {
|
|
224
377
|
return await this.program.instruction.deleteAmmCache({
|
|
225
378
|
accounts: {
|
|
@@ -231,12 +384,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
231
384
|
},
|
|
232
385
|
});
|
|
233
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Refreshes the `AmmCache` entries for the given perp markets from their current on-chain
|
|
389
|
+
* state and oracle price (market stats, MM-oracle price/validity). Requires the `LpCache`
|
|
390
|
+
* hot key (or warm/cold). `perpMarketIndexes` are passed as readable perp markets in
|
|
391
|
+
* `remainingAccounts` (each market's oracle account must be resolvable via the local
|
|
392
|
+
* account subscriber); the quote spot market (index 0) is always included as readable.
|
|
393
|
+
* @param perpMarketIndexes - Perp market indexes to refresh in the cache.
|
|
394
|
+
* @returns Transaction signature.
|
|
395
|
+
*/
|
|
234
396
|
async updateInitialAmmCacheInfo(perpMarketIndexes, txParams) {
|
|
235
397
|
const initializeAmmCacheIx = await this.getUpdateInitialAmmCacheInfoIx(perpMarketIndexes);
|
|
236
398
|
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
237
399
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
238
400
|
return txSig;
|
|
239
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Builds the `updateInitialAmmCacheInfo` instruction without sending it. See
|
|
404
|
+
* `updateInitialAmmCacheInfo`.
|
|
405
|
+
* @param perpMarketIndexes - Perp market indexes to refresh in the cache.
|
|
406
|
+
* @returns The unsigned `updateInitialAmmCacheInfo` instruction.
|
|
407
|
+
*/
|
|
240
408
|
async getUpdateInitialAmmCacheInfoIx(perpMarketIndexes) {
|
|
241
409
|
const remainingAccounts = this.getRemainingAccounts({
|
|
242
410
|
userAccounts: [],
|
|
@@ -254,12 +422,38 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
254
422
|
remainingAccounts,
|
|
255
423
|
});
|
|
256
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* Force-overwrites one market's `AmmCache` entry fields (admin escape hatch, e.g. to
|
|
427
|
+
* recover from a bad cache after an incident). Requires the `LpCache` hot key (or
|
|
428
|
+
* warm/cold). Only fields present in `params` are changed; omitted fields keep their
|
|
429
|
+
* current cached value. No-op (does not throw) if `perpMarketIndex` has no cache entry yet.
|
|
430
|
+
*
|
|
431
|
+
* Caution: despite its name, `params.lastSettleTs` is **not** forwarded to the
|
|
432
|
+
* instruction — `getOverrideAmmCacheInfoIx` expects `lastSettleSlot` and this wrapper
|
|
433
|
+
* passes `params` straight through, so any `lastSettleTs` value is silently dropped and
|
|
434
|
+
* the cache's `lastSettleSlot` is left unchanged. Call `getOverrideAmmCacheInfoIx` directly
|
|
435
|
+
* with `lastSettleSlot` if that field needs to be overridden.
|
|
436
|
+
* @param perpMarketIndex - Perp market whose cache entry to override.
|
|
437
|
+
* @param params.quoteOwedFromLpPool - Quote owed from the LP pool to this market's hedge, QUOTE_PRECISION (1e6), signed.
|
|
438
|
+
* @param params.lastSettleTs - Not applied by this method; see caution above.
|
|
439
|
+
* @param params.lastFeePoolTokenAmount - Cached fee-pool token balance, quote spot market's native decimals.
|
|
440
|
+
* @param params.lastNetPnlPoolTokenAmount - Cached net PnL-pool token balance, quote spot market's native decimals, signed.
|
|
441
|
+
* @param params.ammPositionScalar - Unitless 0-100 scalar applied to the AMM's hedge position sizing.
|
|
442
|
+
* @param params.ammInventoryLimit - Inventory limit for the AMM's hedge position, BASE_PRECISION (1e9), signed.
|
|
443
|
+
* @returns Transaction signature.
|
|
444
|
+
*/
|
|
257
445
|
async overrideAmmCacheInfo(perpMarketIndex, params, txParams) {
|
|
258
446
|
const initializeAmmCacheIx = await this.getOverrideAmmCacheInfoIx(perpMarketIndex, params);
|
|
259
447
|
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
260
448
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
261
449
|
return txSig;
|
|
262
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* Builds the `overrideAmmCacheInfo` instruction without sending it. Unlike `overrideAmmCacheInfo`,
|
|
453
|
+
* this overload's `params` correctly uses `lastSettleSlot` (not `lastSettleTs`) and does
|
|
454
|
+
* forward it. See `overrideAmmCacheInfo` for field units.
|
|
455
|
+
* @returns The unsigned `overrideAmmCacheInfo` instruction.
|
|
456
|
+
*/
|
|
263
457
|
async getOverrideAmmCacheInfoIx(perpMarketIndex, params) {
|
|
264
458
|
return this.program.instruction.overrideAmmCacheInfo(perpMarketIndex, Object.assign({}, {
|
|
265
459
|
quoteOwedFromLpPool: null,
|
|
@@ -278,12 +472,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
278
472
|
},
|
|
279
473
|
});
|
|
280
474
|
}
|
|
475
|
+
/**
|
|
476
|
+
* Intended to reallocate the `AmmCache` to `state.numberOfMarkets` entries and reset it
|
|
477
|
+
* (`ResetAmmCache` accounts struct is gated on the `LpCache` hot key, or warm/cold, per
|
|
478
|
+
* `programs/velocity/src/instructions/admin.rs`). **Currently non-functional**: no
|
|
479
|
+
* `reset_amm_cache` handler is wired into the program's instruction dispatch, so this
|
|
480
|
+
* instruction does not exist in the IDL — `getResetAmmCacheIx` casts to `any` to bypass
|
|
481
|
+
* the missing type, but calling it throws at runtime (`program.instruction.resetAmmCache`
|
|
482
|
+
* is `undefined`). Use `deleteAmmCache` + `initializeAmmCache` + `addMarketToAmmCache` per
|
|
483
|
+
* market to achieve the same effect until this is wired up on-chain.
|
|
484
|
+
* @returns Transaction signature (in practice: throws before a transaction is built).
|
|
485
|
+
*/
|
|
281
486
|
async resetAmmCache(txParams) {
|
|
282
487
|
const initializeAmmCacheIx = await this.getResetAmmCacheIx();
|
|
283
488
|
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
284
489
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
285
490
|
return txSig;
|
|
286
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* Builds the (currently non-existent) `resetAmmCache` instruction. See `resetAmmCache` —
|
|
494
|
+
* this throws because the program does not expose a `resetAmmCache` instruction.
|
|
495
|
+
* @returns Never resolves successfully; throws when the missing instruction is invoked.
|
|
496
|
+
*/
|
|
287
497
|
async getResetAmmCacheIx() {
|
|
288
498
|
return this.program.instruction.resetAmmCache({
|
|
289
499
|
accounts: {
|
|
@@ -296,12 +506,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
296
506
|
},
|
|
297
507
|
});
|
|
298
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Closes a mis-initialized perp market and refunds rent to the admin. Requires warm admin
|
|
511
|
+
* (`check_warm`). On-chain the handler only allows deleting the **most recently created**
|
|
512
|
+
* market (`marketIndex == state.numberOfMarkets - 1`), still in `Initialized` status
|
|
513
|
+
* (never activated), with zero users — otherwise it throws `InvalidMarketAccountforDeletion`.
|
|
514
|
+
* @param marketIndex - Index of the perp market to delete; must be the last-created, unactivated, userless market.
|
|
515
|
+
* @returns Transaction signature.
|
|
516
|
+
*/
|
|
299
517
|
async deleteInitializedPerpMarket(marketIndex) {
|
|
300
518
|
const deleteInitializeMarketIx = await this.getDeleteInitializedPerpMarketIx(marketIndex);
|
|
301
519
|
const tx = await this.buildTransaction(deleteInitializeMarketIx);
|
|
302
520
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
303
521
|
return txSig;
|
|
304
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* Builds the `deleteInitializedPerpMarket` instruction without sending it. See
|
|
525
|
+
* `deleteInitializedPerpMarket` for the on-chain preconditions.
|
|
526
|
+
* @param marketIndex - Index of the perp market to delete.
|
|
527
|
+
* @returns The unsigned `deleteInitializedPerpMarket` instruction.
|
|
528
|
+
*/
|
|
305
529
|
async getDeleteInitializedPerpMarketIx(marketIndex) {
|
|
306
530
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
307
531
|
return await this.program.instruction.deleteInitializedPerpMarket(marketIndex, {
|
|
@@ -314,12 +538,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
314
538
|
},
|
|
315
539
|
});
|
|
316
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* Directly overwrites the AMM's base/quote reserves and `sqrtK` for a perp market — an
|
|
543
|
+
* admin escape hatch to force the AMM mark price (`quoteAssetReserve / baseAssetReserve *
|
|
544
|
+
* pegMultiplier`) without going through a repeg. Requires warm admin (`check_warm`).
|
|
545
|
+
* Re-derives min/max base reserve bounds from the new `sqrtK` and re-validates the market
|
|
546
|
+
* (`validate_perp_market`) before committing, so an inconsistent reserve/peg combination
|
|
547
|
+
* fails the transaction.
|
|
548
|
+
* @param perpMarketIndex - Perp market to move.
|
|
549
|
+
* @param baseAssetReserve - New AMM base reserve, BASE_PRECISION (1e9).
|
|
550
|
+
* @param quoteAssetReserve - New AMM quote reserve, BASE_PRECISION (1e9, AMM-internal units).
|
|
551
|
+
* @param sqrtK - New invariant `sqrt(baseAssetReserve * quoteAssetReserve)`, BASE_PRECISION (1e9). Defaults to the exact square root of `baseAssetReserve * quoteAssetReserve` when omitted.
|
|
552
|
+
* @returns Transaction signature.
|
|
553
|
+
*/
|
|
317
554
|
async moveAmmPrice(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
|
|
318
555
|
const moveAmmPriceIx = await this.getMoveAmmPriceIx(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK);
|
|
319
556
|
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
320
557
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
321
558
|
return txSig;
|
|
322
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Builds the `moveAmmPrice` instruction without sending it. See `moveAmmPrice` for units
|
|
562
|
+
* and the `sqrtK` default.
|
|
563
|
+
* @returns The unsigned `moveAmmPrice` instruction.
|
|
564
|
+
*/
|
|
323
565
|
async getMoveAmmPriceIx(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
|
|
324
566
|
const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
325
567
|
if (sqrtK == undefined) {
|
|
@@ -335,12 +577,29 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
335
577
|
},
|
|
336
578
|
});
|
|
337
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* Rescales a perp market's AMM invariant (`sqrtK`) while holding the mark price
|
|
582
|
+
* approximately constant, widening or tightening depth around the current peg. Requires
|
|
583
|
+
* warm admin (`check_warm`). On-chain, increasing `sqrtK` must cost the AMM's fee reserve
|
|
584
|
+
* a non-negative amount (charged against `totalFeeMinusDistributions`, capped at that
|
|
585
|
+
* balance) and decreasing it must yield a non-positive cost; the resulting price move must
|
|
586
|
+
* stay within `MAX_UPDATE_K_PRICE_CHANGE` and `sqrtK` may not increase past `MAX_SQRT_K` —
|
|
587
|
+
* violating any of these throws `InvalidUpdateK`.
|
|
588
|
+
* @param perpMarketIndex - Perp market to rescale.
|
|
589
|
+
* @param sqrtK - New invariant, BASE_PRECISION (1e9).
|
|
590
|
+
* @returns Transaction signature.
|
|
591
|
+
*/
|
|
338
592
|
async updateK(perpMarketIndex, sqrtK) {
|
|
339
593
|
const updateKIx = await this.getUpdateKIx(perpMarketIndex, sqrtK);
|
|
340
594
|
const tx = await this.buildTransaction(updateKIx);
|
|
341
595
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
342
596
|
return txSig;
|
|
343
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* Builds the `updateK` instruction without sending it. See `updateK` for units and the
|
|
600
|
+
* on-chain cost/price-change constraints.
|
|
601
|
+
* @returns The unsigned `updateK` instruction.
|
|
602
|
+
*/
|
|
344
603
|
async getUpdateKIx(perpMarketIndex, sqrtK) {
|
|
345
604
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
346
605
|
return await this.program.instruction.updateK(sqrtK, {
|
|
@@ -354,12 +613,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
354
613
|
},
|
|
355
614
|
});
|
|
356
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* Re-centers a perp market's AMM around a new peg and invariant while keeping the AMM's
|
|
618
|
+
* net position unchanged (`amm.recenter`) — the admin-driven counterpart of an automatic
|
|
619
|
+
* repeg, typically used to realign the AMM to the oracle after a large price move.
|
|
620
|
+
* Requires warm admin (`check_warm`). Re-derives min/max base reserve bounds and
|
|
621
|
+
* re-validates the market before committing.
|
|
622
|
+
* @param perpMarketIndex - Perp market to recenter.
|
|
623
|
+
* @param pegMultiplier - New AMM peg, PEG_PRECISION (1e6).
|
|
624
|
+
* @param sqrtK - New invariant, BASE_PRECISION (1e9).
|
|
625
|
+
* @returns Transaction signature.
|
|
626
|
+
*/
|
|
357
627
|
async recenterPerpMarketAmm(perpMarketIndex, pegMultiplier, sqrtK) {
|
|
358
628
|
const recenterPerpMarketAmmIx = await this.getRecenterPerpMarketAmmIx(perpMarketIndex, pegMultiplier, sqrtK);
|
|
359
629
|
const tx = await this.buildTransaction(recenterPerpMarketAmmIx);
|
|
360
630
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
361
631
|
return txSig;
|
|
362
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* Builds the `recenterPerpMarketAmm` instruction without sending it. See
|
|
635
|
+
* `recenterPerpMarketAmm` for units.
|
|
636
|
+
* @returns The unsigned `recenterPerpMarketAmm` instruction.
|
|
637
|
+
*/
|
|
363
638
|
async getRecenterPerpMarketAmmIx(perpMarketIndex, pegMultiplier, sqrtK) {
|
|
364
639
|
const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
365
640
|
return await this.program.instruction.recenterPerpMarketAmm(pegMultiplier, sqrtK, {
|
|
@@ -372,12 +647,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
372
647
|
},
|
|
373
648
|
});
|
|
374
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* Keeper-cranked variant of `recenterPerpMarketAmm`: derives the target peg/invariant from
|
|
652
|
+
* the current oracle price (and an optional target depth) instead of taking them as
|
|
653
|
+
* explicit params. Requires the `AmmCrank` hot key (or warm/cold).
|
|
654
|
+
* @param perpMarketIndex - Perp market to recenter.
|
|
655
|
+
* @param depth - Optional target liquidity depth to recenter around, BASE_PRECISION (1e9). Omit to use the market's existing depth.
|
|
656
|
+
* @returns Transaction signature.
|
|
657
|
+
*/
|
|
375
658
|
async recenterPerpMarketAmmCrank(perpMarketIndex, depth) {
|
|
376
659
|
const recenterPerpMarketAmmIx = await this.getRecenterPerpMarketAmmCrankIx(perpMarketIndex, depth);
|
|
377
660
|
const tx = await this.buildTransaction(recenterPerpMarketAmmIx);
|
|
378
661
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
379
662
|
return txSig;
|
|
380
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* Builds the `recenterPerpMarketAmmCrank` instruction without sending it. See
|
|
666
|
+
* `recenterPerpMarketAmmCrank`.
|
|
667
|
+
* @returns The unsigned `recenterPerpMarketAmmCrank` instruction.
|
|
668
|
+
*/
|
|
381
669
|
async getRecenterPerpMarketAmmCrankIx(perpMarketIndex, depth) {
|
|
382
670
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
383
671
|
return await this.program.instruction.recenterPerpMarketAmmCrank(depth !== null && depth !== void 0 ? depth : null, {
|
|
@@ -392,12 +680,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
392
680
|
},
|
|
393
681
|
});
|
|
394
682
|
}
|
|
683
|
+
/**
|
|
684
|
+
* Updates a perp market's AMM concentration coefficient, changing how tightly liquidity
|
|
685
|
+
* is concentrated around the peg (calls the on-chain `updatePerpMarketConcentrationCoef`
|
|
686
|
+
* instruction). Requires warm admin (`check_warm`).
|
|
687
|
+
* @param perpMarketIndex - Perp market to update.
|
|
688
|
+
* @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.
|
|
689
|
+
* @returns Transaction signature.
|
|
690
|
+
*/
|
|
395
691
|
async updatePerpMarketConcentrationScale(perpMarketIndex, concentrationScale) {
|
|
396
692
|
const updatePerpMarketConcentrationCoefIx = await this.getUpdatePerpMarketConcentrationScaleIx(perpMarketIndex, concentrationScale);
|
|
397
693
|
const tx = await this.buildTransaction(updatePerpMarketConcentrationCoefIx);
|
|
398
694
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
399
695
|
return txSig;
|
|
400
696
|
}
|
|
697
|
+
/**
|
|
698
|
+
* Builds the `updatePerpMarketConcentrationCoef` instruction without sending it. See
|
|
699
|
+
* `updatePerpMarketConcentrationScale`.
|
|
700
|
+
* @returns The unsigned `updatePerpMarketConcentrationCoef` instruction.
|
|
701
|
+
*/
|
|
401
702
|
async getUpdatePerpMarketConcentrationScaleIx(perpMarketIndex, concentrationScale) {
|
|
402
703
|
return await this.program.instruction.updatePerpMarketConcentrationCoef(concentrationScale, {
|
|
403
704
|
accounts: {
|
|
@@ -409,12 +710,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
409
710
|
},
|
|
410
711
|
});
|
|
411
712
|
}
|
|
713
|
+
/**
|
|
714
|
+
* Sets which LP pool a perp market's hedge exposure (`hedgeConfig.poolId`) is routed to.
|
|
715
|
+
* Requires warm admin (`check_warm`).
|
|
716
|
+
* @param perpMarketIndex - Perp market to update.
|
|
717
|
+
* @param lpPoolId - Target LP pool id; 0 means unassigned.
|
|
718
|
+
* @returns Transaction signature.
|
|
719
|
+
*/
|
|
412
720
|
async updatePerpMarketLpPoolId(perpMarketIndex, lpPoolId) {
|
|
413
721
|
const updatePerpMarketLpPoolIIx = await this.getUpdatePerpMarketLpPoolIdIx(perpMarketIndex, lpPoolId);
|
|
414
722
|
const tx = await this.buildTransaction(updatePerpMarketLpPoolIIx);
|
|
415
723
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
416
724
|
return txSig;
|
|
417
725
|
}
|
|
726
|
+
/**
|
|
727
|
+
* Builds the `updatePerpMarketLpPoolId` instruction without sending it. See
|
|
728
|
+
* `updatePerpMarketLpPoolId`.
|
|
729
|
+
* @returns The unsigned `updatePerpMarketLpPoolId` instruction.
|
|
730
|
+
*/
|
|
418
731
|
async getUpdatePerpMarketLpPoolIdIx(perpMarketIndex, lpPoolId) {
|
|
419
732
|
return await this.program.instruction.updatePerpMarketLpPoolId(lpPoolId, {
|
|
420
733
|
accounts: {
|
|
@@ -426,12 +739,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
426
739
|
},
|
|
427
740
|
});
|
|
428
741
|
}
|
|
742
|
+
/**
|
|
743
|
+
* Sets a perp market's LP-pool hedge status (`hedgeConfig.status`) and immediately
|
|
744
|
+
* refreshes its `AmmCache` entry from the new market state. Requires warm admin
|
|
745
|
+
* (`check_warm`).
|
|
746
|
+
* @param perpMarketIndex - Perp market to update.
|
|
747
|
+
* @param lpStatus - New hedge status bitmask/value for `hedgeConfig.status`.
|
|
748
|
+
* @returns Transaction signature.
|
|
749
|
+
*/
|
|
429
750
|
async updatePerpMarketLpPoolStatus(perpMarketIndex, lpStatus) {
|
|
430
751
|
const updatePerpMarketLpPoolStatusIx = await this.getUpdatePerpMarketLpPoolStatusIx(perpMarketIndex, lpStatus);
|
|
431
752
|
const tx = await this.buildTransaction(updatePerpMarketLpPoolStatusIx);
|
|
432
753
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
433
754
|
return txSig;
|
|
434
755
|
}
|
|
756
|
+
/**
|
|
757
|
+
* Builds the `updatePerpMarketLpPoolStatus` instruction without sending it. See
|
|
758
|
+
* `updatePerpMarketLpPoolStatus`.
|
|
759
|
+
* @returns The unsigned `updatePerpMarketLpPoolStatus` instruction.
|
|
760
|
+
*/
|
|
435
761
|
async getUpdatePerpMarketLpPoolStatusIx(perpMarketIndex, lpStatus) {
|
|
436
762
|
return await this.program.instruction.updatePerpMarketLpPoolStatus(lpStatus, {
|
|
437
763
|
accounts: {
|
|
@@ -444,12 +770,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
444
770
|
},
|
|
445
771
|
});
|
|
446
772
|
}
|
|
773
|
+
/**
|
|
774
|
+
* Convenience wrapper around `moveAmmPrice`: computes, from the locally cached
|
|
775
|
+
* `PerpMarket` account, the base/quote reserves that move the AMM's mark price to
|
|
776
|
+
* `targetPrice` (holding `sqrtK` fixed at its current value) and sends that instruction.
|
|
777
|
+
* Requires warm admin (`check_warm`, same as `moveAmmPrice`). Throws if the market isn't
|
|
778
|
+
* tracked by the local account subscriber.
|
|
779
|
+
* @param perpMarketIndex - Perp market to move.
|
|
780
|
+
* @param targetPrice - Desired AMM mark price, PRICE_PRECISION (1e6).
|
|
781
|
+
* @returns Transaction signature.
|
|
782
|
+
*/
|
|
447
783
|
async moveAmmToPrice(perpMarketIndex, targetPrice) {
|
|
448
784
|
const moveAmmPriceIx = await this.getMoveAmmToPriceIx(perpMarketIndex, targetPrice);
|
|
449
785
|
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
450
786
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
451
787
|
return txSig;
|
|
452
788
|
}
|
|
789
|
+
/**
|
|
790
|
+
* Builds the underlying `moveAmmPrice` instruction that moves the AMM to `targetPrice`.
|
|
791
|
+
* See `moveAmmToPrice`.
|
|
792
|
+
* @returns The unsigned `moveAmmPrice` instruction.
|
|
793
|
+
*/
|
|
453
794
|
async getMoveAmmToPriceIx(perpMarketIndex, targetPrice) {
|
|
454
795
|
const perpMarket = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
455
796
|
const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(perpMarket, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
|
|
@@ -466,12 +807,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
466
807
|
},
|
|
467
808
|
});
|
|
468
809
|
}
|
|
810
|
+
/**
|
|
811
|
+
* Repegs a perp market's AMM toward `newPeg`, adjusting reserves to keep the invariant
|
|
812
|
+
* (`sqrtK`) fixed while moving the mark price. Requires warm admin (`check_warm`). The
|
|
813
|
+
* on-chain `repeg` routine validates the oracle (per `state.oracleGuardRails`) and charges
|
|
814
|
+
* the reserve/fee-pool the resulting `adjustment_cost`; emits `AmmCurveChanged`.
|
|
815
|
+
* @param newPeg - Candidate new AMM peg, PEG_PRECISION (1e6).
|
|
816
|
+
* @param perpMarketIndex - Perp market to repeg.
|
|
817
|
+
* @returns Transaction signature.
|
|
818
|
+
*/
|
|
469
819
|
async repegAmmCurve(newPeg, perpMarketIndex) {
|
|
470
820
|
const repegAmmCurveIx = await this.getRepegAmmCurveIx(newPeg, perpMarketIndex);
|
|
471
821
|
const tx = await this.buildTransaction(repegAmmCurveIx);
|
|
472
822
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
473
823
|
return txSig;
|
|
474
824
|
}
|
|
825
|
+
/**
|
|
826
|
+
* Builds the `repegAmmCurve` instruction without sending it. See `repegAmmCurve`. Throws
|
|
827
|
+
* if `perpMarketIndex` isn't tracked by the local account subscriber (needed to resolve
|
|
828
|
+
* the market's oracle account).
|
|
829
|
+
* @returns The unsigned `repegAmmCurve` instruction.
|
|
830
|
+
*/
|
|
475
831
|
async getRepegAmmCurveIx(newPeg, perpMarketIndex) {
|
|
476
832
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
477
833
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
@@ -486,12 +842,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
486
842
|
},
|
|
487
843
|
});
|
|
488
844
|
}
|
|
845
|
+
/**
|
|
846
|
+
* Nudges a perp market's cached oracle TWAP (`marketStats.historicalOracleData.lastOraclePriceTwap`,
|
|
847
|
+
* PRICE_PRECISION 1e6) toward the freshly-sampled oracle TWAP, but only accepts the move
|
|
848
|
+
* if it narrows the mark/oracle TWAP gap or flips its sign (otherwise clamps the cached
|
|
849
|
+
* TWAP to the mark TWAP). Requires warm admin (`check_warm`); throws `PriceBandsBreached`
|
|
850
|
+
* on-chain if the new gap would be strictly larger with the same sign, and `InvalidOracle`
|
|
851
|
+
* if the oracle can't be read.
|
|
852
|
+
* @param perpMarketIndex - Perp market to update.
|
|
853
|
+
* @returns Transaction signature.
|
|
854
|
+
*/
|
|
489
855
|
async updatePerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
490
856
|
const updatePerpMarketAmmOracleTwapIx = await this.getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
491
857
|
const tx = await this.buildTransaction(updatePerpMarketAmmOracleTwapIx);
|
|
492
858
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
493
859
|
return txSig;
|
|
494
860
|
}
|
|
861
|
+
/**
|
|
862
|
+
* Builds the `updatePerpMarketAmmOracleTwap` instruction without sending it. See
|
|
863
|
+
* `updatePerpMarketAmmOracleTwap`.
|
|
864
|
+
* @returns The unsigned `updatePerpMarketAmmOracleTwap` instruction.
|
|
865
|
+
*/
|
|
495
866
|
async getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex) {
|
|
496
867
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
497
868
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
@@ -506,12 +877,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
506
877
|
},
|
|
507
878
|
});
|
|
508
879
|
}
|
|
880
|
+
/**
|
|
881
|
+
* Admin failsafe that force-resets a perp market's cached oracle TWAP to the current mark
|
|
882
|
+
* TWAP (unconditionally, unlike `updatePerpMarketAmmOracleTwap`'s gap-narrowing check).
|
|
883
|
+
* Requires warm admin (`check_warm`). Use when the oracle TWAP has drifted badly (e.g.
|
|
884
|
+
* after an oracle outage) and funding needs to be re-anchored immediately.
|
|
885
|
+
* @param perpMarketIndex - Perp market to reset.
|
|
886
|
+
* @returns Transaction signature.
|
|
887
|
+
*/
|
|
509
888
|
async resetPerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
510
889
|
const resetPerpMarketAmmOracleTwapIx = await this.getResetPerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
511
890
|
const tx = await this.buildTransaction(resetPerpMarketAmmOracleTwapIx);
|
|
512
891
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
513
892
|
return txSig;
|
|
514
893
|
}
|
|
894
|
+
/**
|
|
895
|
+
* Builds the `resetPerpMarketAmmOracleTwap` instruction without sending it. See
|
|
896
|
+
* `resetPerpMarketAmmOracleTwap`.
|
|
897
|
+
* @returns The unsigned `resetPerpMarketAmmOracleTwap` instruction.
|
|
898
|
+
*/
|
|
515
899
|
async getResetPerpMarketAmmOracleTwapIx(perpMarketIndex) {
|
|
516
900
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
517
901
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
@@ -526,12 +910,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
526
910
|
},
|
|
527
911
|
});
|
|
528
912
|
}
|
|
913
|
+
/**
|
|
914
|
+
* Tops up a perp market's AMM fee pool: transfers `amount` from `sourceVault` (a token
|
|
915
|
+
* account the caller controls) into the quote spot market's vault via CPI, and credits
|
|
916
|
+
* the same amount to `perpMarket.amm.totalFeeMinusDistributions` / `amm.feePool`. Requires
|
|
917
|
+
* the `VaultDeposit` hot key (or warm/cold).
|
|
918
|
+
* @param perpMarketIndex - Perp market whose fee pool to credit.
|
|
919
|
+
* @param amount - Amount to deposit, quote spot market's native decimals (QUOTE_PRECISION, 1e6, for the standard USDC quote market).
|
|
920
|
+
* @param sourceVault - Token account to transfer `amount` from; `admin` must be its authority.
|
|
921
|
+
* @returns Transaction signature.
|
|
922
|
+
*/
|
|
529
923
|
async depositIntoPerpMarketFeePool(perpMarketIndex, amount, sourceVault) {
|
|
530
924
|
const depositIntoPerpMarketFeePoolIx = await this.getDepositIntoPerpMarketFeePoolIx(perpMarketIndex, amount, sourceVault);
|
|
531
925
|
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
532
926
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
533
927
|
return txSig;
|
|
534
928
|
}
|
|
929
|
+
/**
|
|
930
|
+
* Builds the `depositIntoPerpMarketFeePool` instruction without sending it. See
|
|
931
|
+
* `depositIntoPerpMarketFeePool`.
|
|
932
|
+
* @returns The unsigned `depositIntoPerpMarketFeePool` instruction.
|
|
933
|
+
*/
|
|
535
934
|
async getDepositIntoPerpMarketFeePoolIx(perpMarketIndex, amount, sourceVault) {
|
|
536
935
|
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
537
936
|
const remainingAccounts = [
|
|
@@ -557,12 +956,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
557
956
|
remainingAccounts,
|
|
558
957
|
});
|
|
559
958
|
}
|
|
959
|
+
/**
|
|
960
|
+
* Credits `amount` to a perp market's PnL pool balance as pure internal accounting — it
|
|
961
|
+
* does **not** move any tokens. On-chain the handler only validates that the quote spot
|
|
962
|
+
* market's actual vault balance still covers the resulting internal balances
|
|
963
|
+
* (`validate_spot_market_vault_amount`); it does not itself deposit the backing tokens, so
|
|
964
|
+
* call this only after (or together with) a real deposit that gets the tokens into the
|
|
965
|
+
* vault. Requires warm admin (`check_warm`).
|
|
966
|
+
* @param perpMarketIndex - Perp market whose PnL pool to credit.
|
|
967
|
+
* @param amount - Amount to credit, quote spot market's native decimals (QUOTE_PRECISION, 1e6, for the standard USDC quote market).
|
|
968
|
+
* @returns Transaction signature.
|
|
969
|
+
*/
|
|
560
970
|
async updatePerpMarketPnlPool(perpMarketIndex, amount) {
|
|
561
971
|
const updatePerpMarketPnlPoolIx = await this.getUpdatePerpMarketPnlPoolIx(perpMarketIndex, amount);
|
|
562
972
|
const tx = await this.buildTransaction(updatePerpMarketPnlPoolIx);
|
|
563
973
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
564
974
|
return txSig;
|
|
565
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Builds the `updatePerpMarketPnlPool` instruction without sending it. See
|
|
978
|
+
* `updatePerpMarketPnlPool` — no tokens are moved by this instruction.
|
|
979
|
+
* @returns The unsigned `updatePerpMarketPnlPool` instruction.
|
|
980
|
+
*/
|
|
566
981
|
async getUpdatePerpMarketPnlPoolIx(perpMarketIndex, amount) {
|
|
567
982
|
return await this.program.instruction.updatePerpMarketPnlPool(amount, {
|
|
568
983
|
accounts: {
|
|
@@ -576,12 +991,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
576
991
|
},
|
|
577
992
|
});
|
|
578
993
|
}
|
|
994
|
+
/**
|
|
995
|
+
* Deposits `amount` from `sourceVault` (a token account the caller controls) directly into
|
|
996
|
+
* a spot market's vault via CPI and credits the market's deposit balance accordingly.
|
|
997
|
+
* Requires the `VaultDeposit` hot key (or warm/cold). Throws on-chain if the spot market
|
|
998
|
+
* has deposits paused (`SpotOperation::Deposit`).
|
|
999
|
+
* @param spotMarketIndex - Spot market whose vault to deposit into.
|
|
1000
|
+
* @param amount - Amount to deposit, the spot market's native token decimals.
|
|
1001
|
+
* @param sourceVault - Token account to transfer `amount` from; `admin` must be its authority.
|
|
1002
|
+
* @returns Transaction signature.
|
|
1003
|
+
*/
|
|
579
1004
|
async depositIntoSpotMarketVault(spotMarketIndex, amount, sourceVault) {
|
|
580
1005
|
const depositIntoPerpMarketFeePoolIx = await this.getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault);
|
|
581
1006
|
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
582
1007
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
583
1008
|
return txSig;
|
|
584
1009
|
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Builds the `depositIntoSpotMarketVault` instruction without sending it. See
|
|
1012
|
+
* `depositIntoSpotMarketVault`. Automatically appends transfer-hook extra account metas
|
|
1013
|
+
* when the mint requires them.
|
|
1014
|
+
* @returns The unsigned `depositIntoSpotMarketVault` instruction.
|
|
1015
|
+
*/
|
|
585
1016
|
async getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault) {
|
|
586
1017
|
const spotMarket = this.getSpotMarketAccountOrThrow(spotMarketIndex);
|
|
587
1018
|
const remainingAccounts = [];
|
|
@@ -604,12 +1035,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
604
1035
|
remainingAccounts,
|
|
605
1036
|
});
|
|
606
1037
|
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Rotates the root (`state.coldAdmin`) authority — the top of the cold ⊇ warm ⊇
|
|
1040
|
+
* hot(role) tier hierarchy. Cold-only: the `ColdAdminUpdateState` context requires
|
|
1041
|
+
* the current signer to equal `state.coldAdmin`. This is the one-time-per-rotation
|
|
1042
|
+
* root key change; `warmAdmin` and `pauseAdmin` are rotated separately via
|
|
1043
|
+
* `updateWarmAdmin`/`updatePauseAdmin` (also cold-only).
|
|
1044
|
+
* @param admin - New cold admin pubkey.
|
|
1045
|
+
* @returns Transaction signature.
|
|
1046
|
+
*/
|
|
607
1047
|
async updateAdmin(admin) {
|
|
608
1048
|
const updateAdminIx = await this.getUpdateAdminIx(admin);
|
|
609
1049
|
const tx = await this.buildTransaction(updateAdminIx);
|
|
610
1050
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
611
1051
|
return txSig;
|
|
612
1052
|
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Builds the `updateAdmin` instruction without sending it. See `updateAdmin`.
|
|
1055
|
+
* @returns The unsigned `updateAdmin` instruction.
|
|
1056
|
+
*/
|
|
613
1057
|
async getUpdateAdminIx(admin) {
|
|
614
1058
|
return await this.program.instruction.updateAdmin(admin, {
|
|
615
1059
|
accounts: {
|
|
@@ -620,12 +1064,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
620
1064
|
},
|
|
621
1065
|
});
|
|
622
1066
|
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Sets how aggressively a perp market's AMM curve auto-adjusts. Requires the market's
|
|
1069
|
+
* `HotAdminUpdatePerpMarket` gate — the `check_warm` constraint on that context currently
|
|
1070
|
+
* accepts cold or warm admin only (no dedicated hot role is wired to it). On-chain, values
|
|
1071
|
+
* `0..=100` control repeg/formulaic-k intensity and `101..=200` additionally enable
|
|
1072
|
+
* reference-price-offset intensity; values above 200 throw `DefaultError`.
|
|
1073
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1074
|
+
* @param curveUpdateIntensity - 0-200 intensity knob (see above for the two sub-ranges).
|
|
1075
|
+
* @returns Transaction signature.
|
|
1076
|
+
*/
|
|
623
1077
|
async updatePerpMarketCurveUpdateIntensity(perpMarketIndex, curveUpdateIntensity) {
|
|
624
1078
|
const updatePerpMarketCurveUpdateIntensityIx = await this.getUpdatePerpMarketCurveUpdateIntensityIx(perpMarketIndex, curveUpdateIntensity);
|
|
625
1079
|
const tx = await this.buildTransaction(updatePerpMarketCurveUpdateIntensityIx);
|
|
626
1080
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
627
1081
|
return txSig;
|
|
628
1082
|
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Builds the `updatePerpMarketCurveUpdateIntensity` instruction without sending it. See
|
|
1085
|
+
* `updatePerpMarketCurveUpdateIntensity`.
|
|
1086
|
+
* @returns The unsigned `updatePerpMarketCurveUpdateIntensity` instruction.
|
|
1087
|
+
*/
|
|
629
1088
|
async getUpdatePerpMarketCurveUpdateIntensityIx(perpMarketIndex, curveUpdateIntensity) {
|
|
630
1089
|
return await this.program.instruction.updatePerpMarketCurveUpdateIntensity(curveUpdateIntensity, {
|
|
631
1090
|
accounts: {
|
|
@@ -637,12 +1096,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
637
1096
|
},
|
|
638
1097
|
});
|
|
639
1098
|
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Sets the dead-band, as a percent of price, within which the AMM's reference-price offset
|
|
1101
|
+
* (used to bias the AMM's quoted price away from the raw oracle/mark price) is suppressed.
|
|
1102
|
+
* Gated the same as `updatePerpMarketCurveUpdateIntensity` (warm admin via
|
|
1103
|
+
* `HotAdminUpdatePerpMarket`'s `check_warm` constraint). Throws `DefaultError` on-chain if
|
|
1104
|
+
* `referencePriceOffsetDeadbandPct > 100`.
|
|
1105
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1106
|
+
* @param referencePriceOffsetDeadbandPct - 0-100 percent dead-band.
|
|
1107
|
+
* @returns Transaction signature.
|
|
1108
|
+
*/
|
|
640
1109
|
async updatePerpMarketReferencePriceOffsetDeadbandPct(perpMarketIndex, referencePriceOffsetDeadbandPct) {
|
|
641
1110
|
const updatePerpMarketReferencePriceOffsetDeadbandPctIx = await this.getUpdatePerpMarketReferencePriceOffsetDeadbandPctIx(perpMarketIndex, referencePriceOffsetDeadbandPct);
|
|
642
1111
|
const tx = await this.buildTransaction(updatePerpMarketReferencePriceOffsetDeadbandPctIx);
|
|
643
1112
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
644
1113
|
return txSig;
|
|
645
1114
|
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Builds the `updatePerpMarketReferencePriceOffsetDeadbandPct` instruction without sending
|
|
1117
|
+
* it. See `updatePerpMarketReferencePriceOffsetDeadbandPct`.
|
|
1118
|
+
* @returns The unsigned `updatePerpMarketReferencePriceOffsetDeadbandPct` instruction.
|
|
1119
|
+
*/
|
|
646
1120
|
async getUpdatePerpMarketReferencePriceOffsetDeadbandPctIx(perpMarketIndex, referencePriceOffsetDeadbandPct) {
|
|
647
1121
|
return await this.program.instruction.updatePerpMarketReferencePriceOffsetDeadbandPct(referencePriceOffsetDeadbandPct, {
|
|
648
1122
|
accounts: {
|
|
@@ -654,18 +1128,47 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
654
1128
|
},
|
|
655
1129
|
});
|
|
656
1130
|
}
|
|
1131
|
+
/**
|
|
1132
|
+
* **Currently non-functional**: the program does not expose an
|
|
1133
|
+
* `update_perp_market_target_base_asset_amount_per_lp` instruction (no such handler is
|
|
1134
|
+
* wired into `lib.rs`, and it's absent from the generated IDL). `getUpdatePerpMarketTargetBaseAssetAmountPerLpIx`
|
|
1135
|
+
* casts `this.program.instruction` to `any` to bypass the missing type, but the call
|
|
1136
|
+
* throws at runtime. `targetBaseAssetAmountPerLp` exists only as a legacy field in
|
|
1137
|
+
* `test_utils/legacy_snapshot.rs`, not on the live `PerpMarket`/`AMM` struct.
|
|
1138
|
+
* @param perpMarketIndex - Perp market that would be updated.
|
|
1139
|
+
* @param targetBaseAssetAmountPerLP - Intended target base-asset-amount-per-LP value.
|
|
1140
|
+
* @returns Transaction signature (in practice: throws before a transaction is built).
|
|
1141
|
+
*/
|
|
657
1142
|
async updatePerpMarketTargetBaseAssetAmountPerLp(perpMarketIndex, targetBaseAssetAmountPerLP) {
|
|
658
1143
|
const updatePerpMarketTargetBaseAssetAmountPerLpIx = await this.getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex, targetBaseAssetAmountPerLP);
|
|
659
1144
|
const tx = await this.buildTransaction(updatePerpMarketTargetBaseAssetAmountPerLpIx);
|
|
660
1145
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
661
1146
|
return txSig;
|
|
662
1147
|
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Admin recalibration of a perp market's AMM fee-accounting summary stats. Requires the
|
|
1150
|
+
* `AmmCrank` hot key (or warm/cold). If `netUnsettledFundingPnl` is provided it directly
|
|
1151
|
+
* overwrites `perpMarket.netUnsettledFundingPnl`. If `updateAmmSummaryStats` is `true`,
|
|
1152
|
+
* recomputes `amm.totalFeeMinusDistributions` from current market/spot-market/oracle state
|
|
1153
|
+
* and applies the resulting delta to `amm.totalFee` and `amm.totalMmFee`; omitted or
|
|
1154
|
+
* `false` leaves fee accounting untouched. Re-validates the market before committing.
|
|
1155
|
+
* @param perpMarketIndex - Perp market to recalibrate.
|
|
1156
|
+
* @param updateAmmSummaryStats - If `true`, recompute and correct AMM fee-accounting totals. Default: unset (no correction).
|
|
1157
|
+
* @param netUnsettledFundingPnl - Overwrite for `perpMarket.netUnsettledFundingPnl`, QUOTE_PRECISION (1e6), signed. Default: unset (unchanged).
|
|
1158
|
+
* @returns Transaction signature.
|
|
1159
|
+
*/
|
|
663
1160
|
async updatePerpMarketAmmSummaryStats(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl) {
|
|
664
1161
|
const updatePerpMarketMarginRatioIx = await this.getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl);
|
|
665
1162
|
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
666
1163
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
667
1164
|
return txSig;
|
|
668
1165
|
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Builds the `updatePerpMarketAmmSummaryStats` instruction without sending it. See
|
|
1168
|
+
* `updatePerpMarketAmmSummaryStats`. Throws if `perpMarketIndex` isn't tracked by the
|
|
1169
|
+
* local account subscriber (needed to resolve the market's oracle account).
|
|
1170
|
+
* @returns The unsigned `updatePerpMarketAmmSummaryStats` instruction.
|
|
1171
|
+
*/
|
|
669
1172
|
async getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl) {
|
|
670
1173
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
671
1174
|
return await this.program.instruction.updatePerpMarketAmmSummaryStats({
|
|
@@ -683,6 +1186,12 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
683
1186
|
},
|
|
684
1187
|
});
|
|
685
1188
|
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Builds the (currently non-existent) `updatePerpMarketTargetBaseAssetAmountPerLp`
|
|
1191
|
+
* instruction. See `updatePerpMarketTargetBaseAssetAmountPerLp` — this throws because the
|
|
1192
|
+
* program does not expose that instruction.
|
|
1193
|
+
* @returns Never resolves successfully; throws when the missing instruction is invoked.
|
|
1194
|
+
*/
|
|
686
1195
|
async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex, targetBaseAssetAmountPerLP) {
|
|
687
1196
|
return await this.program.instruction.updatePerpMarketTargetBaseAssetAmountPerLp(targetBaseAssetAmountPerLP, {
|
|
688
1197
|
accounts: {
|
|
@@ -694,12 +1203,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
694
1203
|
},
|
|
695
1204
|
});
|
|
696
1205
|
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Sets a perp market's initial and maintenance margin ratios (max leverage and
|
|
1208
|
+
* liquidation threshold). Requires warm admin (`check_warm`). On-chain, validates the pair
|
|
1209
|
+
* is internally consistent and compatible with the market's current `liquidatorFee`
|
|
1210
|
+
* (`amm.validate_compatible_with_margin_ratio`) before committing.
|
|
1211
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1212
|
+
* @param marginRatioInitial - Initial margin ratio, MARGIN_PRECISION (1e4, e.g. 2000 = 20% = 5x max leverage). Must be >= `marginRatioMaintenance`.
|
|
1213
|
+
* @param marginRatioMaintenance - Maintenance margin ratio, MARGIN_PRECISION (1e4).
|
|
1214
|
+
* @returns Transaction signature.
|
|
1215
|
+
*/
|
|
697
1216
|
async updatePerpMarketMarginRatio(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
698
1217
|
const updatePerpMarketMarginRatioIx = await this.getUpdatePerpMarketMarginRatioIx(perpMarketIndex, marginRatioInitial, marginRatioMaintenance);
|
|
699
1218
|
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
700
1219
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
701
1220
|
return txSig;
|
|
702
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Builds the `updatePerpMarketMarginRatio` instruction without sending it. See
|
|
1224
|
+
* `updatePerpMarketMarginRatio`.
|
|
1225
|
+
* @returns The unsigned `updatePerpMarketMarginRatio` instruction.
|
|
1226
|
+
*/
|
|
703
1227
|
async getUpdatePerpMarketMarginRatioIx(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
704
1228
|
return await this.program.instruction.updatePerpMarketMarginRatio(marginRatioInitial, marginRatioMaintenance, {
|
|
705
1229
|
accounts: {
|
|
@@ -711,12 +1235,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
711
1235
|
},
|
|
712
1236
|
});
|
|
713
1237
|
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Sets a perp market's funding dead-zone: the band around the oracle TWAP within which no
|
|
1240
|
+
* funding premium accrues, and the ramp applied to the premium beyond that band. Requires
|
|
1241
|
+
* warm admin (`check_warm`). Unlike `initializePerpMarket` (where `0` silently falls back
|
|
1242
|
+
* to defaults), the update handler validates its inputs directly and throws `DefaultError`
|
|
1243
|
+
* if `fundingClampThreshold >= BPS_PRECISION` (i.e. must be < 100%) or if
|
|
1244
|
+
* `fundingRampSlope === 0` (a zero slope would flatten every premium past the band to the
|
|
1245
|
+
* funding-rate offset).
|
|
1246
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1247
|
+
* @param fundingClampThreshold - Dead-zone half-width, basis points (BPS_PRECISION, 1e4). Must be < 10000.
|
|
1248
|
+
* @param fundingRampSlope - Slope applied beyond the dead zone, PERCENTAGE_PRECISION (1e6, 1e6 = 1.0x). Must be > 0.
|
|
1249
|
+
* @returns Transaction signature.
|
|
1250
|
+
*/
|
|
714
1251
|
async updatePerpMarketFundingDeadZone(perpMarketIndex, fundingClampThreshold, fundingRampSlope) {
|
|
715
1252
|
const updatePerpMarketFundingDeadZoneIx = await this.getUpdatePerpMarketFundingDeadZoneIx(perpMarketIndex, fundingClampThreshold, fundingRampSlope);
|
|
716
1253
|
const tx = await this.buildTransaction(updatePerpMarketFundingDeadZoneIx);
|
|
717
1254
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
718
1255
|
return txSig;
|
|
719
1256
|
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Builds the `updatePerpMarketFundingDeadZone` instruction without sending it. See
|
|
1259
|
+
* `updatePerpMarketFundingDeadZone` for units and validation.
|
|
1260
|
+
* @returns The unsigned `updatePerpMarketFundingDeadZone` instruction.
|
|
1261
|
+
*/
|
|
720
1262
|
async getUpdatePerpMarketFundingDeadZoneIx(perpMarketIndex, fundingClampThreshold, fundingRampSlope) {
|
|
721
1263
|
return await this.program.instruction.updatePerpMarketFundingDeadZone(fundingClampThreshold, fundingRampSlope, {
|
|
722
1264
|
accounts: {
|
|
@@ -728,12 +1270,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
728
1270
|
},
|
|
729
1271
|
});
|
|
730
1272
|
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Sets a perp market's IMF factors, which increase the effective margin requirement (and
|
|
1275
|
+
* shrink unrealized-PnL asset weight) as position size grows. Requires warm admin
|
|
1276
|
+
* (`check_warm`). Throws `DefaultError` on-chain if either value exceeds `SPOT_IMF_PRECISION` (1e6).
|
|
1277
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1278
|
+
* @param imfFactor - Position-size margin penalty factor, SPOT_IMF_PRECISION (1e6). Must be <= 1e6.
|
|
1279
|
+
* @param unrealizedPnlImfFactor - Position-size penalty factor applied to unrealized-PnL asset weight, SPOT_IMF_PRECISION (1e6). Must be <= 1e6.
|
|
1280
|
+
* @returns Transaction signature.
|
|
1281
|
+
*/
|
|
731
1282
|
async updatePerpMarketImfFactor(perpMarketIndex, imfFactor, unrealizedPnlImfFactor) {
|
|
732
1283
|
const updatePerpMarketImfFactorIx = await this.getUpdatePerpMarketImfFactorIx(perpMarketIndex, imfFactor, unrealizedPnlImfFactor);
|
|
733
1284
|
const tx = await this.buildTransaction(updatePerpMarketImfFactorIx);
|
|
734
1285
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
735
1286
|
return txSig;
|
|
736
1287
|
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Builds the `updatePerpMarketImfFactor` instruction without sending it. See
|
|
1290
|
+
* `updatePerpMarketImfFactor`.
|
|
1291
|
+
* @returns The unsigned `updatePerpMarketImfFactor` instruction.
|
|
1292
|
+
*/
|
|
737
1293
|
async getUpdatePerpMarketImfFactorIx(perpMarketIndex, imfFactor, unrealizedPnlImfFactor) {
|
|
738
1294
|
return await this.program.instruction.updatePerpMarketImfFactor(imfFactor, unrealizedPnlImfFactor, {
|
|
739
1295
|
accounts: {
|
|
@@ -745,12 +1301,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
745
1301
|
},
|
|
746
1302
|
});
|
|
747
1303
|
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Sets a perp market's base bid/ask spread around the AMM reserve price. Requires warm
|
|
1306
|
+
* admin (`check_warm`). The AMM's cached `longSpread`/`shortSpread` are refreshed from
|
|
1307
|
+
* this value on the next quote/fill rather than immediately.
|
|
1308
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1309
|
+
* @param baseSpread - New base spread, BID_ASK_SPREAD_PRECISION (1e6).
|
|
1310
|
+
* @returns Transaction signature.
|
|
1311
|
+
*/
|
|
748
1312
|
async updatePerpMarketBaseSpread(perpMarketIndex, baseSpread) {
|
|
749
1313
|
const updatePerpMarketBaseSpreadIx = await this.getUpdatePerpMarketBaseSpreadIx(perpMarketIndex, baseSpread);
|
|
750
1314
|
const tx = await this.buildTransaction(updatePerpMarketBaseSpreadIx);
|
|
751
1315
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
752
1316
|
return txSig;
|
|
753
1317
|
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Builds the `updatePerpMarketBaseSpread` instruction without sending it. See
|
|
1320
|
+
* `updatePerpMarketBaseSpread`.
|
|
1321
|
+
* @returns The unsigned `updatePerpMarketBaseSpread` instruction.
|
|
1322
|
+
*/
|
|
754
1323
|
async getUpdatePerpMarketBaseSpreadIx(perpMarketIndex, baseSpread) {
|
|
755
1324
|
return await this.program.instruction.updatePerpMarketBaseSpread(baseSpread, {
|
|
756
1325
|
accounts: {
|
|
@@ -762,12 +1331,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
762
1331
|
},
|
|
763
1332
|
});
|
|
764
1333
|
}
|
|
1334
|
+
/**
|
|
1335
|
+
* Sets how aggressively the AMM just-in-time-fills incoming taker orders against its own
|
|
1336
|
+
* inventory before routing to the DLOB. Gated the same as `updatePerpMarketCurveUpdateIntensity`
|
|
1337
|
+
* (warm admin via `HotAdminUpdatePerpMarket`'s `check_warm` constraint). Throws
|
|
1338
|
+
* `DefaultError` on-chain if outside `0..=100`.
|
|
1339
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1340
|
+
* @param ammJitIntensity - 0-100 intensity; 0 disables AMM JIT fills.
|
|
1341
|
+
* @returns Transaction signature.
|
|
1342
|
+
*/
|
|
765
1343
|
async updateAmmJitIntensity(perpMarketIndex, ammJitIntensity) {
|
|
766
1344
|
const updateAmmJitIntensityIx = await this.getUpdateAmmJitIntensityIx(perpMarketIndex, ammJitIntensity);
|
|
767
1345
|
const tx = await this.buildTransaction(updateAmmJitIntensityIx);
|
|
768
1346
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
769
1347
|
return txSig;
|
|
770
1348
|
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Builds the `updateAmmJitIntensity` instruction without sending it. See
|
|
1351
|
+
* `updateAmmJitIntensity`.
|
|
1352
|
+
* @returns The unsigned `updateAmmJitIntensity` instruction.
|
|
1353
|
+
*/
|
|
771
1354
|
async getUpdateAmmJitIntensityIx(perpMarketIndex, ammJitIntensity) {
|
|
772
1355
|
return await this.program.instruction.updateAmmJitIntensity(ammJitIntensity, {
|
|
773
1356
|
accounts: {
|
|
@@ -779,12 +1362,22 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
779
1362
|
},
|
|
780
1363
|
});
|
|
781
1364
|
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Sets a perp market's display name. Requires warm admin (`check_warm`).
|
|
1367
|
+
* @param perpMarketIndex - Perp market to rename.
|
|
1368
|
+
* @param name - New display name, UTF-8 encoded and padded/truncated to 32 bytes.
|
|
1369
|
+
* @returns Transaction signature.
|
|
1370
|
+
*/
|
|
782
1371
|
async updatePerpMarketName(perpMarketIndex, name) {
|
|
783
1372
|
const updatePerpMarketNameIx = await this.getUpdatePerpMarketNameIx(perpMarketIndex, name);
|
|
784
1373
|
const tx = await this.buildTransaction(updatePerpMarketNameIx);
|
|
785
1374
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
786
1375
|
return txSig;
|
|
787
1376
|
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Builds the `updatePerpMarketName` instruction without sending it. See `updatePerpMarketName`.
|
|
1379
|
+
* @returns The unsigned `updatePerpMarketName` instruction.
|
|
1380
|
+
*/
|
|
788
1381
|
async getUpdatePerpMarketNameIx(perpMarketIndex, name) {
|
|
789
1382
|
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
790
1383
|
return await this.program.instruction.updatePerpMarketName(nameBuffer, {
|
|
@@ -797,12 +1390,22 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
797
1390
|
},
|
|
798
1391
|
});
|
|
799
1392
|
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Sets a spot market's display name. Requires warm admin (`check_warm`).
|
|
1395
|
+
* @param spotMarketIndex - Spot market to rename.
|
|
1396
|
+
* @param name - New display name, UTF-8 encoded and padded/truncated to 32 bytes.
|
|
1397
|
+
* @returns Transaction signature.
|
|
1398
|
+
*/
|
|
800
1399
|
async updateSpotMarketName(spotMarketIndex, name) {
|
|
801
1400
|
const updateSpotMarketNameIx = await this.getUpdateSpotMarketNameIx(spotMarketIndex, name);
|
|
802
1401
|
const tx = await this.buildTransaction(updateSpotMarketNameIx);
|
|
803
1402
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
804
1403
|
return txSig;
|
|
805
1404
|
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Builds the `updateSpotMarketName` instruction without sending it. See `updateSpotMarketName`.
|
|
1407
|
+
* @returns The unsigned `updateSpotMarketName` instruction.
|
|
1408
|
+
*/
|
|
806
1409
|
async getUpdateSpotMarketNameIx(spotMarketIndex, name) {
|
|
807
1410
|
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
808
1411
|
return await this.program.instruction.updateSpotMarketName(nameBuffer, {
|
|
@@ -815,12 +1418,23 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
815
1418
|
},
|
|
816
1419
|
});
|
|
817
1420
|
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Sets which pool a spot market belongs to (used to segment markets, e.g. for LP-pool
|
|
1423
|
+
* constituent grouping). Requires warm admin (`check_warm`).
|
|
1424
|
+
* @param spotMarketIndex - Spot market to update.
|
|
1425
|
+
* @param poolId - Target pool id.
|
|
1426
|
+
* @returns Transaction signature.
|
|
1427
|
+
*/
|
|
818
1428
|
async updateSpotMarketPoolId(spotMarketIndex, poolId) {
|
|
819
1429
|
const updateSpotMarketPoolIdIx = await this.getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId);
|
|
820
1430
|
const tx = await this.buildTransaction(updateSpotMarketPoolIdIx);
|
|
821
1431
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
822
1432
|
return txSig;
|
|
823
1433
|
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Builds the `updateSpotMarketPoolId` instruction without sending it. See `updateSpotMarketPoolId`.
|
|
1436
|
+
* @returns The unsigned `updateSpotMarketPoolId` instruction.
|
|
1437
|
+
*/
|
|
824
1438
|
async getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId) {
|
|
825
1439
|
return await this.program.instruction.updateSpotMarketPoolId(poolId, {
|
|
826
1440
|
accounts: {
|
|
@@ -832,12 +1446,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
832
1446
|
},
|
|
833
1447
|
});
|
|
834
1448
|
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Sets a perp market's maximum allowed total bid/ask spread. Gated the same as
|
|
1451
|
+
* `updatePerpMarketCurveUpdateIntensity` (warm admin via `HotAdminUpdatePerpMarket`'s
|
|
1452
|
+
* `check_warm` constraint). Throws `DefaultError` on-chain if `maxSpread` is below the
|
|
1453
|
+
* market's current `baseSpread` or exceeds `marginRatioInitial * 100`.
|
|
1454
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1455
|
+
* @param maxSpread - New max spread, BID_ASK_SPREAD_PRECISION (1e6). Must be >= `baseSpread` and <= `marginRatioInitial * 100`.
|
|
1456
|
+
* @returns Transaction signature.
|
|
1457
|
+
*/
|
|
835
1458
|
async updatePerpMarketMaxSpread(perpMarketIndex, maxSpread) {
|
|
836
1459
|
const updatePerpMarketMaxSpreadIx = await this.getUpdatePerpMarketMaxSpreadIx(perpMarketIndex, maxSpread);
|
|
837
1460
|
const tx = await this.buildTransaction(updatePerpMarketMaxSpreadIx);
|
|
838
1461
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
839
1462
|
return txSig;
|
|
840
1463
|
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Builds the `updatePerpMarketMaxSpread` instruction without sending it. See
|
|
1466
|
+
* `updatePerpMarketMaxSpread` for units and validation.
|
|
1467
|
+
* @returns The unsigned `updatePerpMarketMaxSpread` instruction.
|
|
1468
|
+
*/
|
|
841
1469
|
async getUpdatePerpMarketMaxSpreadIx(perpMarketIndex, maxSpread) {
|
|
842
1470
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
843
1471
|
return await this.program.instruction.updatePerpMarketMaxSpread(maxSpread, {
|
|
@@ -850,12 +1478,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
850
1478
|
},
|
|
851
1479
|
});
|
|
852
1480
|
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Replaces the protocol-wide perp `FeeStructure` (fee tiers, filler reward, AMM/IF
|
|
1483
|
+
* fee split) wholesale. Requires warm admin (`check_warm`). On-chain,
|
|
1484
|
+
* `validate_fee_structure` rejects a structure whose `amm_fee_numerator +
|
|
1485
|
+
* if_fee_numerator` (both FEE_PERCENTAGE_DENOMINATOR-scaled) exceeds 100% of the
|
|
1486
|
+
* trade-fee remainder, among other tier sanity checks.
|
|
1487
|
+
* @param feeStructure - Full replacement fee structure (not a partial patch).
|
|
1488
|
+
* @returns Transaction signature.
|
|
1489
|
+
*/
|
|
853
1490
|
async updatePerpFeeStructure(feeStructure) {
|
|
854
1491
|
const updatePerpFeeStructureIx = await this.getUpdatePerpFeeStructureIx(feeStructure);
|
|
855
1492
|
const tx = await this.buildTransaction(updatePerpFeeStructureIx);
|
|
856
1493
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
857
1494
|
return txSig;
|
|
858
1495
|
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Builds the `updatePerpFeeStructure` instruction without sending it. See
|
|
1498
|
+
* `updatePerpFeeStructure`.
|
|
1499
|
+
* @returns The unsigned `updatePerpFeeStructure` instruction.
|
|
1500
|
+
*/
|
|
859
1501
|
async getUpdatePerpFeeStructureIx(feeStructure) {
|
|
860
1502
|
return this.program.instruction.updatePerpFeeStructure(feeStructure, {
|
|
861
1503
|
accounts: {
|
|
@@ -866,12 +1508,23 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
866
1508
|
},
|
|
867
1509
|
});
|
|
868
1510
|
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Replaces the protocol-wide spot `FeeStructure` wholesale. Requires warm admin
|
|
1513
|
+
* (`check_warm`); see `updatePerpFeeStructure` for validation.
|
|
1514
|
+
* @param feeStructure - Full replacement fee structure (not a partial patch).
|
|
1515
|
+
* @returns Transaction signature.
|
|
1516
|
+
*/
|
|
869
1517
|
async updateSpotFeeStructure(feeStructure) {
|
|
870
1518
|
const updateSpotFeeStructureIx = await this.getUpdateSpotFeeStructureIx(feeStructure);
|
|
871
1519
|
const tx = await this.buildTransaction(updateSpotFeeStructureIx);
|
|
872
1520
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
873
1521
|
return txSig;
|
|
874
1522
|
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Builds the `updateSpotFeeStructure` instruction without sending it. See
|
|
1525
|
+
* `updateSpotFeeStructure`.
|
|
1526
|
+
* @returns The unsigned `updateSpotFeeStructure` instruction.
|
|
1527
|
+
*/
|
|
875
1528
|
async getUpdateSpotFeeStructureIx(feeStructure) {
|
|
876
1529
|
return await this.program.instruction.updateSpotFeeStructure(feeStructure, {
|
|
877
1530
|
accounts: {
|
|
@@ -882,12 +1535,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
882
1535
|
},
|
|
883
1536
|
});
|
|
884
1537
|
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Sets the fraction of a liquidatable position that may be closed immediately
|
|
1540
|
+
* (before the `updateLiquidationDuration` ramp phases in the rest). Requires warm
|
|
1541
|
+
* admin (`check_warm`). On-chain the liquidatable fraction ramps linearly from this
|
|
1542
|
+
* floor up to 100% over `liquidationDuration` slots since the user's last active
|
|
1543
|
+
* slot (see `calculate_max_pct_to_liquidate`); shortages under 50 QUOTE_PRECISION
|
|
1544
|
+
* always liquidate in full regardless of this setting.
|
|
1545
|
+
* @param initialPctToLiquidate - Initial liquidatable fraction, LIQUIDATION_PCT_PRECISION (1e4, e.g. 2500 = 25%).
|
|
1546
|
+
* @returns Transaction signature.
|
|
1547
|
+
*/
|
|
885
1548
|
async updateInitialPctToLiquidate(initialPctToLiquidate) {
|
|
886
1549
|
const updateInitialPctToLiquidateIx = await this.getUpdateInitialPctToLiquidateIx(initialPctToLiquidate);
|
|
887
1550
|
const tx = await this.buildTransaction(updateInitialPctToLiquidateIx);
|
|
888
1551
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
889
1552
|
return txSig;
|
|
890
1553
|
}
|
|
1554
|
+
/**
|
|
1555
|
+
* Builds the `updateInitialPctToLiquidate` instruction without sending it. See
|
|
1556
|
+
* `updateInitialPctToLiquidate`.
|
|
1557
|
+
* @returns The unsigned `updateInitialPctToLiquidate` instruction.
|
|
1558
|
+
*/
|
|
891
1559
|
async getUpdateInitialPctToLiquidateIx(initialPctToLiquidate) {
|
|
892
1560
|
return await this.program.instruction.updateInitialPctToLiquidate(initialPctToLiquidate, {
|
|
893
1561
|
accounts: {
|
|
@@ -898,12 +1566,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
898
1566
|
},
|
|
899
1567
|
});
|
|
900
1568
|
}
|
|
1569
|
+
/**
|
|
1570
|
+
* Sets how many slots it takes for a liquidation's max-closeable fraction to ramp
|
|
1571
|
+
* from `initialPctToLiquidate` up to 100% (see `updateInitialPctToLiquidate`).
|
|
1572
|
+
* Requires warm admin (`check_warm`).
|
|
1573
|
+
* @param liquidationDuration - Ramp duration, slots (comment in `calculate_max_pct_to_liquidate` notes ~150 slots ≈ 1 minute at 400ms/slot).
|
|
1574
|
+
* @returns Transaction signature.
|
|
1575
|
+
*/
|
|
901
1576
|
async updateLiquidationDuration(liquidationDuration) {
|
|
902
1577
|
const updateLiquidationDurationIx = await this.getUpdateLiquidationDurationIx(liquidationDuration);
|
|
903
1578
|
const tx = await this.buildTransaction(updateLiquidationDurationIx);
|
|
904
1579
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
905
1580
|
return txSig;
|
|
906
1581
|
}
|
|
1582
|
+
/**
|
|
1583
|
+
* Builds the `updateLiquidationDuration` instruction without sending it. See
|
|
1584
|
+
* `updateLiquidationDuration`.
|
|
1585
|
+
* @returns The unsigned `updateLiquidationDuration` instruction.
|
|
1586
|
+
*/
|
|
907
1587
|
async getUpdateLiquidationDurationIx(liquidationDuration) {
|
|
908
1588
|
return await this.program.instruction.updateLiquidationDuration(liquidationDuration, {
|
|
909
1589
|
accounts: {
|
|
@@ -914,12 +1594,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
914
1594
|
},
|
|
915
1595
|
});
|
|
916
1596
|
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Sets the extra maintenance-margin buffer applied when deciding whether a user is
|
|
1599
|
+
* liquidatable, on top of the market's own maintenance margin ratio — a safety
|
|
1600
|
+
* margin so liquidation triggers before a user is fully underwater. Requires warm
|
|
1601
|
+
* admin (`check_warm`).
|
|
1602
|
+
* @param updateLiquidationMarginBufferRatio - Extra margin buffer, MARGIN_PRECISION (1e4).
|
|
1603
|
+
* @returns Transaction signature.
|
|
1604
|
+
*/
|
|
917
1605
|
async updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio) {
|
|
918
1606
|
const updateLiquidationMarginBufferRatioIx = await this.getUpdateLiquidationMarginBufferRatioIx(updateLiquidationMarginBufferRatio);
|
|
919
1607
|
const tx = await this.buildTransaction(updateLiquidationMarginBufferRatioIx);
|
|
920
1608
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
921
1609
|
return txSig;
|
|
922
1610
|
}
|
|
1611
|
+
/**
|
|
1612
|
+
* Builds the `updateLiquidationMarginBufferRatio` instruction without sending it.
|
|
1613
|
+
* See `updateLiquidationMarginBufferRatio`.
|
|
1614
|
+
* @returns The unsigned `updateLiquidationMarginBufferRatio` instruction.
|
|
1615
|
+
*/
|
|
923
1616
|
async getUpdateLiquidationMarginBufferRatioIx(updateLiquidationMarginBufferRatio) {
|
|
924
1617
|
return await this.program.instruction.updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio, {
|
|
925
1618
|
accounts: {
|
|
@@ -930,12 +1623,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
930
1623
|
},
|
|
931
1624
|
});
|
|
932
1625
|
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Replaces the protocol-wide `OracleGuardRails` (validity/confidence/divergence
|
|
1628
|
+
* thresholds used to gate oracle-price-driven actions across every market).
|
|
1629
|
+
* Requires warm admin (`check_warm`).
|
|
1630
|
+
* @param oracleGuardRails - Full replacement guard-rail config (not a partial patch).
|
|
1631
|
+
* @returns Transaction signature.
|
|
1632
|
+
*/
|
|
933
1633
|
async updateOracleGuardRails(oracleGuardRails) {
|
|
934
1634
|
const updateOracleGuardRailsIx = await this.getUpdateOracleGuardRailsIx(oracleGuardRails);
|
|
935
1635
|
const tx = await this.buildTransaction(updateOracleGuardRailsIx);
|
|
936
1636
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
937
1637
|
return txSig;
|
|
938
1638
|
}
|
|
1639
|
+
/**
|
|
1640
|
+
* Builds the `updateOracleGuardRails` instruction without sending it. See
|
|
1641
|
+
* `updateOracleGuardRails`.
|
|
1642
|
+
* @returns The unsigned `updateOracleGuardRails` instruction.
|
|
1643
|
+
*/
|
|
939
1644
|
async getUpdateOracleGuardRailsIx(oracleGuardRails) {
|
|
940
1645
|
return await this.program.instruction.updateOracleGuardRails(oracleGuardRails, {
|
|
941
1646
|
accounts: {
|
|
@@ -946,12 +1651,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
946
1651
|
},
|
|
947
1652
|
});
|
|
948
1653
|
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Sets the buffer (past a perp market's `expiry_ts`) that must elapse before user
|
|
1656
|
+
* positions in a `Settlement`-status market can be settled at the expiry price.
|
|
1657
|
+
* Requires warm admin (`check_warm`).
|
|
1658
|
+
* @param settlementDuration - Post-expiry settlement buffer, seconds.
|
|
1659
|
+
* @returns Transaction signature.
|
|
1660
|
+
*/
|
|
949
1661
|
async updateStateSettlementDuration(settlementDuration) {
|
|
950
1662
|
const updateStateSettlementDurationIx = await this.getUpdateStateSettlementDurationIx(settlementDuration);
|
|
951
1663
|
const tx = await this.buildTransaction(updateStateSettlementDurationIx);
|
|
952
1664
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
953
1665
|
return txSig;
|
|
954
1666
|
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Builds the `updateStateSettlementDuration` instruction without sending it. See
|
|
1669
|
+
* `updateStateSettlementDuration`.
|
|
1670
|
+
* @returns The unsigned `updateStateSettlementDuration` instruction.
|
|
1671
|
+
*/
|
|
955
1672
|
async getUpdateStateSettlementDurationIx(settlementDuration) {
|
|
956
1673
|
return await this.program.instruction.updateStateSettlementDuration(settlementDuration, {
|
|
957
1674
|
accounts: {
|
|
@@ -962,12 +1679,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
962
1679
|
},
|
|
963
1680
|
});
|
|
964
1681
|
}
|
|
1682
|
+
/**
|
|
1683
|
+
* Sets the protocol-wide cap on sub-accounts per authority
|
|
1684
|
+
* (`state.maxNumberOfSubAccounts`) and, via `get_init_user_fee`, the denominator
|
|
1685
|
+
* against which `state.numberOfSubAccounts` utilization phases in the
|
|
1686
|
+
* `initializeUser` anti-spam fee (see `updateStateMaxInitializeUserFee`). Requires
|
|
1687
|
+
* warm admin (`check_warm`).
|
|
1688
|
+
* @param maxNumberOfSubAccounts - New protocol-wide sub-account cap.
|
|
1689
|
+
* @returns Transaction signature.
|
|
1690
|
+
*/
|
|
965
1691
|
async updateStateMaxNumberOfSubAccounts(maxNumberOfSubAccounts) {
|
|
966
1692
|
const updateStateMaxNumberOfSubAccountsIx = await this.getUpdateStateMaxNumberOfSubAccountsIx(maxNumberOfSubAccounts);
|
|
967
1693
|
const tx = await this.buildTransaction(updateStateMaxNumberOfSubAccountsIx);
|
|
968
1694
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
969
1695
|
return txSig;
|
|
970
1696
|
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Builds the `updateStateMaxNumberOfSubAccounts` instruction without sending it.
|
|
1699
|
+
* See `updateStateMaxNumberOfSubAccounts`.
|
|
1700
|
+
* @returns The unsigned `updateStateMaxNumberOfSubAccounts` instruction.
|
|
1701
|
+
*/
|
|
971
1702
|
async getUpdateStateMaxNumberOfSubAccountsIx(maxNumberOfSubAccounts) {
|
|
972
1703
|
return await this.program.instruction.updateStateMaxNumberOfSubAccounts(maxNumberOfSubAccounts, {
|
|
973
1704
|
accounts: {
|
|
@@ -978,12 +1709,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
978
1709
|
},
|
|
979
1710
|
});
|
|
980
1711
|
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Sets the cap on the anti-spam fee `initializeUser` may charge as
|
|
1714
|
+
* `state.numberOfSubAccounts` approaches `state.maxNumberOfSubAccounts`. On-chain
|
|
1715
|
+
* (`State::get_init_user_fee`) the fee is 0 below ~80% utilization and then scales
|
|
1716
|
+
* up to this cap by the time the cap is reached; `0` disables the fee entirely.
|
|
1717
|
+
* Requires warm admin (`check_warm`).
|
|
1718
|
+
* @param maxInitializeUserFee - Fee cap, hundredths of a SOL (e.g. `100` = 1 SOL, `1` = 0.01 SOL).
|
|
1719
|
+
* @returns Transaction signature.
|
|
1720
|
+
*/
|
|
981
1721
|
async updateStateMaxInitializeUserFee(maxInitializeUserFee) {
|
|
982
1722
|
const updateStateMaxInitializeUserFeeIx = await this.getUpdateStateMaxInitializeUserFeeIx(maxInitializeUserFee);
|
|
983
1723
|
const tx = await this.buildTransaction(updateStateMaxInitializeUserFeeIx);
|
|
984
1724
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
985
1725
|
return txSig;
|
|
986
1726
|
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Builds the `updateStateMaxInitializeUserFee` instruction without sending it. See
|
|
1729
|
+
* `updateStateMaxInitializeUserFee`.
|
|
1730
|
+
* @returns The unsigned `updateStateMaxInitializeUserFee` instruction.
|
|
1731
|
+
*/
|
|
987
1732
|
async getUpdateStateMaxInitializeUserFeeIx(maxInitializeUserFee) {
|
|
988
1733
|
return await this.program.instruction.updateStateMaxInitializeUserFee(maxInitializeUserFee, {
|
|
989
1734
|
accounts: {
|
|
@@ -994,12 +1739,36 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
994
1739
|
},
|
|
995
1740
|
});
|
|
996
1741
|
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Sets a spot market's withdraw guard threshold — the token-amount cap above which a
|
|
1744
|
+
* single withdraw/borrow is blocked. Requires warm admin (`check_warm`, on the
|
|
1745
|
+
* `AdminUpdateSpotMarketWithdrawGuardThreshold` context). On-chain the notional is priced
|
|
1746
|
+
* with the max of the live oracle price and the 5-minute oracle TWAP (`StrictOraclePrice`),
|
|
1747
|
+
* so a momentarily-manipulated-down oracle can't let an oversized threshold through;
|
|
1748
|
+
* `validate_withdraw_guard_threshold` then re-derives the implied cap and rejects an
|
|
1749
|
+
* inconsistent value.
|
|
1750
|
+
* @param spotMarketIndex - Spot market to update.
|
|
1751
|
+
* @param withdrawGuardThreshold - New threshold, the market's native token decimals.
|
|
1752
|
+
* @param oracle - Must equal `spotMarket.oracle` — the account struct's `has_one = oracle`
|
|
1753
|
+
* constraint (`ErrorCode::InvalidOracle`) enforces this on-chain, so it is not a way to
|
|
1754
|
+
* point at a different price feed. When omitted, this is resolved automatically from the
|
|
1755
|
+
* local account cache (or, if not subscribed, by fetching and decoding the `SpotMarket`
|
|
1756
|
+
* account directly) — pass it explicitly only to avoid that extra lookup.
|
|
1757
|
+
* @returns Transaction signature.
|
|
1758
|
+
*/
|
|
997
1759
|
async updateWithdrawGuardThreshold(spotMarketIndex, withdrawGuardThreshold, oracle) {
|
|
998
1760
|
const updateWithdrawGuardThresholdIx = await this.getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold, oracle);
|
|
999
1761
|
const tx = await this.buildTransaction(updateWithdrawGuardThresholdIx);
|
|
1000
1762
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1001
1763
|
return txSig;
|
|
1002
1764
|
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Builds the `updateWithdrawGuardThreshold` instruction without sending it. See
|
|
1767
|
+
* `updateWithdrawGuardThreshold` — in particular, the `oracle` param must equal
|
|
1768
|
+
* `spotMarket.oracle` (enforced by the `has_one` constraint) and is auto-resolved when
|
|
1769
|
+
* omitted. Throws if the spot market account can't be found when not subscribed.
|
|
1770
|
+
* @returns The unsigned `updateWithdrawGuardThreshold` instruction.
|
|
1771
|
+
*/
|
|
1003
1772
|
async getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold, oracle) {
|
|
1004
1773
|
const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
|
|
1005
1774
|
if (!oracle) {
|
|
@@ -1029,12 +1798,29 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1029
1798
|
},
|
|
1030
1799
|
});
|
|
1031
1800
|
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Sets a spot market's lending-gain carveouts: the share of deposit interest routed to the
|
|
1803
|
+
* insurance fund (`ifFeeFactor`) and to the withdrawable protocol fee pool
|
|
1804
|
+
* (`protocolFeeFactor`); lenders keep the remainder. Requires warm admin (`check_warm`).
|
|
1805
|
+
* Throws `DefaultError` on-chain if the two factors don't sum to strictly less than 100%
|
|
1806
|
+
* (a full 100% carveout would zero out lender interest and freeze the entire accrual path,
|
|
1807
|
+
* including the IF/protocol credits themselves).
|
|
1808
|
+
* @param spotMarketIndex - Spot market to update; must match the market account passed.
|
|
1809
|
+
* @param ifFeeFactor - Insurance-fund carveout, IF_FACTOR_PRECISION (1e6).
|
|
1810
|
+
* @param protocolFeeFactor - Protocol-fee-pool carveout, IF_FACTOR_PRECISION (1e6). `ifFeeFactor + protocolFeeFactor` must be < 1e6.
|
|
1811
|
+
* @returns Transaction signature.
|
|
1812
|
+
*/
|
|
1032
1813
|
async updateSpotMarketIfFactor(spotMarketIndex, ifFeeFactor, protocolFeeFactor) {
|
|
1033
1814
|
const updateSpotMarketIfFactorIx = await this.getUpdateSpotMarketIfFactorIx(spotMarketIndex, ifFeeFactor, protocolFeeFactor);
|
|
1034
1815
|
const tx = await this.buildTransaction(updateSpotMarketIfFactorIx);
|
|
1035
1816
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1036
1817
|
return txSig;
|
|
1037
1818
|
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Builds the `updateSpotMarketIfFactor` instruction without sending it. See
|
|
1821
|
+
* `updateSpotMarketIfFactor` for units and validation.
|
|
1822
|
+
* @returns The unsigned `updateSpotMarketIfFactor` instruction.
|
|
1823
|
+
*/
|
|
1038
1824
|
async getUpdateSpotMarketIfFactorIx(spotMarketIndex, ifFeeFactor, protocolFeeFactor) {
|
|
1039
1825
|
return await this.program.instruction.updateSpotMarketIfFactor(spotMarketIndex, ifFeeFactor, protocolFeeFactor, {
|
|
1040
1826
|
accounts: {
|
|
@@ -1046,12 +1832,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1046
1832
|
},
|
|
1047
1833
|
});
|
|
1048
1834
|
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Sets how often a spot market's revenue pool may be settled to the insurance fund.
|
|
1837
|
+
* Requires warm admin (`check_warm`).
|
|
1838
|
+
* @param spotMarketIndex - Spot market to update.
|
|
1839
|
+
* @param revenueSettlePeriod - Minimum interval between revenue settlements, seconds.
|
|
1840
|
+
* @returns Transaction signature.
|
|
1841
|
+
*/
|
|
1049
1842
|
async updateSpotMarketRevenueSettlePeriod(spotMarketIndex, revenueSettlePeriod) {
|
|
1050
1843
|
const updateSpotMarketRevenueSettlePeriodIx = await this.getUpdateSpotMarketRevenueSettlePeriodIx(spotMarketIndex, revenueSettlePeriod);
|
|
1051
1844
|
const tx = await this.buildTransaction(updateSpotMarketRevenueSettlePeriodIx);
|
|
1052
1845
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1053
1846
|
return txSig;
|
|
1054
1847
|
}
|
|
1848
|
+
/**
|
|
1849
|
+
* Builds the `updateSpotMarketRevenueSettlePeriod` instruction without sending it. See
|
|
1850
|
+
* `updateSpotMarketRevenueSettlePeriod`.
|
|
1851
|
+
* @returns The unsigned `updateSpotMarketRevenueSettlePeriod` instruction.
|
|
1852
|
+
*/
|
|
1055
1853
|
async getUpdateSpotMarketRevenueSettlePeriodIx(spotMarketIndex, revenueSettlePeriod) {
|
|
1056
1854
|
return await this.program.instruction.updateSpotMarketRevenueSettlePeriod(revenueSettlePeriod, {
|
|
1057
1855
|
accounts: {
|
|
@@ -1063,12 +1861,23 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1063
1861
|
},
|
|
1064
1862
|
});
|
|
1065
1863
|
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Sets a spot market's maximum total deposit balance. Requires warm admin (`check_warm`).
|
|
1866
|
+
* @param spotMarketIndex - Spot market to update.
|
|
1867
|
+
* @param maxTokenDeposits - New deposit cap, the market's native token decimals. `0` disables the cap.
|
|
1868
|
+
* @returns Transaction signature.
|
|
1869
|
+
*/
|
|
1066
1870
|
async updateSpotMarketMaxTokenDeposits(spotMarketIndex, maxTokenDeposits) {
|
|
1067
1871
|
const updateSpotMarketMaxTokenDepositsIx = await this.getUpdateSpotMarketMaxTokenDepositsIx(spotMarketIndex, maxTokenDeposits);
|
|
1068
1872
|
const tx = await this.buildTransaction(updateSpotMarketMaxTokenDepositsIx);
|
|
1069
1873
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1070
1874
|
return txSig;
|
|
1071
1875
|
}
|
|
1876
|
+
/**
|
|
1877
|
+
* Builds the `updateSpotMarketMaxTokenDeposits` instruction without sending it. See
|
|
1878
|
+
* `updateSpotMarketMaxTokenDeposits`.
|
|
1879
|
+
* @returns The unsigned `updateSpotMarketMaxTokenDeposits` instruction.
|
|
1880
|
+
*/
|
|
1072
1881
|
async getUpdateSpotMarketMaxTokenDepositsIx(spotMarketIndex, maxTokenDeposits) {
|
|
1073
1882
|
return this.program.instruction.updateSpotMarketMaxTokenDeposits(maxTokenDeposits, {
|
|
1074
1883
|
accounts: {
|
|
@@ -1080,12 +1889,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1080
1889
|
},
|
|
1081
1890
|
});
|
|
1082
1891
|
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Caps a spot market's total borrows as a fraction of its `maxTokenDeposits`, rather than
|
|
1894
|
+
* an absolute token amount. Requires warm admin (`check_warm`). On-chain, the effective cap
|
|
1895
|
+
* is `maxTokenDeposits * maxTokenBorrowsFraction / 10000`; the handler throws
|
|
1896
|
+
* `InvalidSpotMarketInitialization` if current borrows already exceed the new cap.
|
|
1897
|
+
* @param spotMarketIndex - Spot market to update.
|
|
1898
|
+
* @param maxTokenBorrowsFraction - Fraction of `maxTokenDeposits` borrowable, in hundredths of a percent (10000 = 100%).
|
|
1899
|
+
* @returns Transaction signature.
|
|
1900
|
+
*/
|
|
1083
1901
|
async updateSpotMarketMaxTokenBorrows(spotMarketIndex, maxTokenBorrowsFraction) {
|
|
1084
1902
|
const updateSpotMarketMaxTokenBorrowsIx = await this.getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrowsFraction);
|
|
1085
1903
|
const tx = await this.buildTransaction(updateSpotMarketMaxTokenBorrowsIx);
|
|
1086
1904
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1087
1905
|
return txSig;
|
|
1088
1906
|
}
|
|
1907
|
+
/**
|
|
1908
|
+
* Builds the `updateSpotMarketMaxTokenBorrows` instruction without sending it. See
|
|
1909
|
+
* `updateSpotMarketMaxTokenBorrows`.
|
|
1910
|
+
* @returns The unsigned `updateSpotMarketMaxTokenBorrows` instruction.
|
|
1911
|
+
*/
|
|
1089
1912
|
async getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrowsFraction) {
|
|
1090
1913
|
return this.program.instruction.updateSpotMarketMaxTokenBorrows(maxTokenBorrowsFraction, {
|
|
1091
1914
|
accounts: {
|
|
@@ -1097,12 +1920,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1097
1920
|
},
|
|
1098
1921
|
});
|
|
1099
1922
|
}
|
|
1923
|
+
/**
|
|
1924
|
+
* Sets the deposit-notional threshold above which a spot market's `initialAssetWeight`
|
|
1925
|
+
* scales down (see `initializeSpotMarket`'s `scaleInitialAssetWeightStart`). Requires warm
|
|
1926
|
+
* admin (`check_warm`). `0` disables scaling.
|
|
1927
|
+
* @param spotMarketIndex - Spot market to update.
|
|
1928
|
+
* @param scaleInitialAssetWeightStart - Deposit-notional threshold, QUOTE_PRECISION (1e6). `0` disables scaling.
|
|
1929
|
+
* @returns Transaction signature.
|
|
1930
|
+
*/
|
|
1100
1931
|
async updateSpotMarketScaleInitialAssetWeightStart(spotMarketIndex, scaleInitialAssetWeightStart) {
|
|
1101
1932
|
const updateSpotMarketScaleInitialAssetWeightStartIx = await this.getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex, scaleInitialAssetWeightStart);
|
|
1102
1933
|
const tx = await this.buildTransaction(updateSpotMarketScaleInitialAssetWeightStartIx);
|
|
1103
1934
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1104
1935
|
return txSig;
|
|
1105
1936
|
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Builds the `updateSpotMarketScaleInitialAssetWeightStart` instruction without sending it.
|
|
1939
|
+
* See `updateSpotMarketScaleInitialAssetWeightStart`.
|
|
1940
|
+
* @returns The unsigned `updateSpotMarketScaleInitialAssetWeightStart` instruction.
|
|
1941
|
+
*/
|
|
1106
1942
|
async getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex, scaleInitialAssetWeightStart) {
|
|
1107
1943
|
return this.program.instruction.updateSpotMarketScaleInitialAssetWeightStart(scaleInitialAssetWeightStart, {
|
|
1108
1944
|
accounts: {
|
|
@@ -1114,12 +1950,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1114
1950
|
},
|
|
1115
1951
|
});
|
|
1116
1952
|
}
|
|
1953
|
+
/**
|
|
1954
|
+
* Sets how long an insurance-fund staker's unstake request must sit in escrow before it can
|
|
1955
|
+
* be completed for a given spot market. Requires warm admin (`check_warm`).
|
|
1956
|
+
* @param spotMarketIndex - Spot market whose insurance fund to update.
|
|
1957
|
+
* @param insuranceWithdrawEscrowPeriod - Unstaking escrow duration, seconds.
|
|
1958
|
+
* @returns Transaction signature.
|
|
1959
|
+
*/
|
|
1117
1960
|
async updateInsuranceFundUnstakingPeriod(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
|
|
1118
1961
|
const updateInsuranceFundUnstakingPeriodIx = await this.getUpdateInsuranceFundUnstakingPeriodIx(spotMarketIndex, insuranceWithdrawEscrowPeriod);
|
|
1119
1962
|
const tx = await this.buildTransaction(updateInsuranceFundUnstakingPeriodIx);
|
|
1120
1963
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1121
1964
|
return txSig;
|
|
1122
1965
|
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Builds the `updateInsuranceFundUnstakingPeriod` instruction without sending it. See
|
|
1968
|
+
* `updateInsuranceFundUnstakingPeriod`.
|
|
1969
|
+
* @returns The unsigned `updateInsuranceFundUnstakingPeriod` instruction.
|
|
1970
|
+
*/
|
|
1123
1971
|
async getUpdateInsuranceFundUnstakingPeriodIx(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
|
|
1124
1972
|
return await this.program.instruction.updateInsuranceFundUnstakingPeriod(insuranceWithdrawEscrowPeriod, {
|
|
1125
1973
|
accounts: {
|
|
@@ -1131,12 +1979,33 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1131
1979
|
},
|
|
1132
1980
|
});
|
|
1133
1981
|
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Swaps a perp market's oracle account/source. Requires **cold** admin
|
|
1984
|
+
* (`AdminUpdatePerpMarketOracle`'s `check_cold` constraint) — a lesser admin swapping the
|
|
1985
|
+
* oracle could re-price margin/liquidation math and any `AmmCache`-derived value at will.
|
|
1986
|
+
* On-chain the handler reads both the new and current (`oldOracle`) oracle prices and,
|
|
1987
|
+
* unless `skipInvaraintCheck` is `true`, throws `DefaultError` if the new price is
|
|
1988
|
+
* non-positive or diverges more than 10% from the old one. If the market is present in the
|
|
1989
|
+
* `AmmCache`, its cached fields are refreshed from the new oracle in the same instruction.
|
|
1990
|
+
* @param perpMarketIndex - Perp market to update.
|
|
1991
|
+
* @param oracle - New oracle account.
|
|
1992
|
+
* @param oracleSource - Oracle provider/format for `oracle`.
|
|
1993
|
+
* @param skipInvaraintCheck - If `true`, skips the on-chain non-positive/10%-divergence sanity check against the current oracle price. Default `false`.
|
|
1994
|
+
* @returns Transaction signature.
|
|
1995
|
+
*/
|
|
1134
1996
|
async updatePerpMarketOracle(perpMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
|
|
1135
1997
|
const updatePerpMarketOracleIx = await this.getUpdatePerpMarketOracleIx(perpMarketIndex, oracle, oracleSource, skipInvaraintCheck);
|
|
1136
1998
|
const tx = await this.buildTransaction(updatePerpMarketOracleIx);
|
|
1137
1999
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1138
2000
|
return txSig;
|
|
1139
2001
|
}
|
|
2002
|
+
/**
|
|
2003
|
+
* Builds the `updatePerpMarketOracle` instruction without sending it. See
|
|
2004
|
+
* `updatePerpMarketOracle`. Resolves `oldOracle` from the locally-cached perp market account
|
|
2005
|
+
* (throws if `perpMarketIndex` isn't tracked by the account subscriber) and passes the
|
|
2006
|
+
* program's singleton `AmmCache` PDA.
|
|
2007
|
+
* @returns The unsigned `updatePerpMarketOracle` instruction.
|
|
2008
|
+
*/
|
|
1140
2009
|
async getUpdatePerpMarketOracleIx(perpMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
|
|
1141
2010
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
1142
2011
|
return await this.program.instruction.updatePerpMarketOracle(oracle, oracleSource, skipInvaraintCheck, {
|
|
@@ -1152,12 +2021,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1152
2021
|
},
|
|
1153
2022
|
});
|
|
1154
2023
|
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Sets a perp market's minimum base-size increment and minimum price increment for orders.
|
|
2026
|
+
* Requires warm admin (`check_warm`). On-chain, throws `DefaultError` unless both are > 0
|
|
2027
|
+
* and `stepSize <= 2_000_000_000` (kept below `i32::MAX` for the LP's remainder-base-asset
|
|
2028
|
+
* accounting).
|
|
2029
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2030
|
+
* @param stepSize - Minimum base-size increment, BASE_PRECISION (1e9).
|
|
2031
|
+
* @param tickSize - Minimum price increment, PRICE_PRECISION (1e6).
|
|
2032
|
+
* @returns Transaction signature.
|
|
2033
|
+
*/
|
|
1155
2034
|
async updatePerpMarketStepSizeAndTickSize(perpMarketIndex, stepSize, tickSize) {
|
|
1156
2035
|
const updatePerpMarketStepSizeAndTickSizeIx = await this.getUpdatePerpMarketStepSizeAndTickSizeIx(perpMarketIndex, stepSize, tickSize);
|
|
1157
2036
|
const tx = await this.buildTransaction(updatePerpMarketStepSizeAndTickSizeIx);
|
|
1158
2037
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1159
2038
|
return txSig;
|
|
1160
2039
|
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Builds the `updatePerpMarketStepSizeAndTickSize` instruction without sending it. See
|
|
2042
|
+
* `updatePerpMarketStepSizeAndTickSize`.
|
|
2043
|
+
* @returns The unsigned `updatePerpMarketStepSizeAndTickSize` instruction.
|
|
2044
|
+
*/
|
|
1161
2045
|
async getUpdatePerpMarketStepSizeAndTickSizeIx(perpMarketIndex, stepSize, tickSize) {
|
|
1162
2046
|
return await this.program.instruction.updatePerpMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
1163
2047
|
accounts: {
|
|
@@ -1169,12 +2053,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1169
2053
|
},
|
|
1170
2054
|
});
|
|
1171
2055
|
}
|
|
2056
|
+
/**
|
|
2057
|
+
* Sets a perp market's minimum order base size (`market.marketStats.minOrderSize`). Requires
|
|
2058
|
+
* warm admin (`check_warm`). On-chain, throws `DefaultError` unless `orderSize > 0`.
|
|
2059
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2060
|
+
* @param orderSize - Minimum base order size, BASE_PRECISION (1e9).
|
|
2061
|
+
* @returns Transaction signature.
|
|
2062
|
+
*/
|
|
1172
2063
|
async updatePerpMarketMinOrderSize(perpMarketIndex, orderSize) {
|
|
1173
2064
|
const updatePerpMarketMinOrderSizeIx = await this.getUpdatePerpMarketMinOrderSizeIx(perpMarketIndex, orderSize);
|
|
1174
2065
|
const tx = await this.buildTransaction(updatePerpMarketMinOrderSizeIx);
|
|
1175
2066
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1176
2067
|
return txSig;
|
|
1177
2068
|
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Builds the `updatePerpMarketMinOrderSize` instruction without sending it. See
|
|
2071
|
+
* `updatePerpMarketMinOrderSize`.
|
|
2072
|
+
* @returns The unsigned `updatePerpMarketMinOrderSize` instruction.
|
|
2073
|
+
*/
|
|
1178
2074
|
async getUpdatePerpMarketMinOrderSizeIx(perpMarketIndex, orderSize) {
|
|
1179
2075
|
return await this.program.instruction.updatePerpMarketMinOrderSize(orderSize, {
|
|
1180
2076
|
accounts: {
|
|
@@ -1186,12 +2082,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1186
2082
|
},
|
|
1187
2083
|
});
|
|
1188
2084
|
}
|
|
2085
|
+
/**
|
|
2086
|
+
* Sets a spot market's minimum base-size increment and minimum price increment for orders.
|
|
2087
|
+
* Requires warm admin (`check_warm`). On-chain, the quote/index-0 market (`marketIndex ===
|
|
2088
|
+
* 0`) is exempt from the `> 0` check other spot markets must satisfy.
|
|
2089
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2090
|
+
* @param stepSize - Minimum base-size increment, market's native token decimals.
|
|
2091
|
+
* @param tickSize - Minimum price increment, PRICE_PRECISION (1e6).
|
|
2092
|
+
* @returns Transaction signature.
|
|
2093
|
+
*/
|
|
1189
2094
|
async updateSpotMarketStepSizeAndTickSize(spotMarketIndex, stepSize, tickSize) {
|
|
1190
2095
|
const updateSpotMarketStepSizeAndTickSizeIx = await this.getUpdateSpotMarketStepSizeAndTickSizeIx(spotMarketIndex, stepSize, tickSize);
|
|
1191
2096
|
const tx = await this.buildTransaction(updateSpotMarketStepSizeAndTickSizeIx);
|
|
1192
2097
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1193
2098
|
return txSig;
|
|
1194
2099
|
}
|
|
2100
|
+
/**
|
|
2101
|
+
* Builds the `updateSpotMarketStepSizeAndTickSize` instruction without sending it. See
|
|
2102
|
+
* `updateSpotMarketStepSizeAndTickSize`.
|
|
2103
|
+
* @returns The unsigned `updateSpotMarketStepSizeAndTickSize` instruction.
|
|
2104
|
+
*/
|
|
1195
2105
|
async getUpdateSpotMarketStepSizeAndTickSizeIx(spotMarketIndex, stepSize, tickSize) {
|
|
1196
2106
|
return await this.program.instruction.updateSpotMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
1197
2107
|
accounts: {
|
|
@@ -1203,6 +2113,13 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1203
2113
|
},
|
|
1204
2114
|
});
|
|
1205
2115
|
}
|
|
2116
|
+
/**
|
|
2117
|
+
* Sets a spot market's minimum order base size. Requires warm admin (`check_warm`). On-chain,
|
|
2118
|
+
* the quote/index-0 market is exempt from the `> 0` check other spot markets must satisfy.
|
|
2119
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2120
|
+
* @param orderSize - Minimum base order size, market's native token decimals.
|
|
2121
|
+
* @returns Transaction signature.
|
|
2122
|
+
*/
|
|
1206
2123
|
async updateSpotMarketMinOrderSize(spotMarketIndex, orderSize) {
|
|
1207
2124
|
const updateSpotMarketMinOrderSizeIx = await this.program.instruction.updateSpotMarketMinOrderSize(orderSize, {
|
|
1208
2125
|
accounts: {
|
|
@@ -1217,6 +2134,11 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1217
2134
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1218
2135
|
return txSig;
|
|
1219
2136
|
}
|
|
2137
|
+
/**
|
|
2138
|
+
* Builds the `updateSpotMarketMinOrderSize` instruction without sending it. See
|
|
2139
|
+
* `updateSpotMarketMinOrderSize`.
|
|
2140
|
+
* @returns The unsigned `updateSpotMarketMinOrderSize` instruction.
|
|
2141
|
+
*/
|
|
1220
2142
|
async getUpdateSpotMarketMinOrderSizeIx(spotMarketIndex, orderSize) {
|
|
1221
2143
|
return await this.program.instruction.updateSpotMarketMinOrderSize(orderSize, {
|
|
1222
2144
|
accounts: {
|
|
@@ -1228,12 +2150,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1228
2150
|
},
|
|
1229
2151
|
});
|
|
1230
2152
|
}
|
|
2153
|
+
/**
|
|
2154
|
+
* Schedules a perp market for expiry: sets `expiryTs` and immediately flips the market to
|
|
2155
|
+
* `MarketStatus.ReduceOnly` (existing positions can only be reduced from this point).
|
|
2156
|
+
* Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if `expiryTs` is not
|
|
2157
|
+
* strictly after the current on-chain clock timestamp. This does not settle or delist the
|
|
2158
|
+
* market — see `settleExpiredMarketPoolsToRevenuePool` for the later teardown step.
|
|
2159
|
+
* @param perpMarketIndex - Perp market to schedule for expiry.
|
|
2160
|
+
* @param expiryTs - Unix timestamp (seconds) after which the market is expired; must be in the future.
|
|
2161
|
+
* @returns Transaction signature.
|
|
2162
|
+
*/
|
|
1231
2163
|
async updatePerpMarketExpiry(perpMarketIndex, expiryTs) {
|
|
1232
2164
|
const updatePerpMarketExpiryIx = await this.getUpdatePerpMarketExpiryIx(perpMarketIndex, expiryTs);
|
|
1233
2165
|
const tx = await this.buildTransaction(updatePerpMarketExpiryIx);
|
|
1234
2166
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1235
2167
|
return txSig;
|
|
1236
2168
|
}
|
|
2169
|
+
/**
|
|
2170
|
+
* Builds the `updatePerpMarketExpiry` instruction without sending it. See
|
|
2171
|
+
* `updatePerpMarketExpiry`.
|
|
2172
|
+
* @returns The unsigned `updatePerpMarketExpiry` instruction.
|
|
2173
|
+
*/
|
|
1237
2174
|
async getUpdatePerpMarketExpiryIx(perpMarketIndex, expiryTs) {
|
|
1238
2175
|
return await this.program.instruction.updatePerpMarketExpiry(expiryTs, {
|
|
1239
2176
|
accounts: {
|
|
@@ -1245,12 +2182,31 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1245
2182
|
},
|
|
1246
2183
|
});
|
|
1247
2184
|
}
|
|
2185
|
+
/**
|
|
2186
|
+
* Swaps a spot market's oracle account/source. Requires **cold** admin
|
|
2187
|
+
* (`AdminUpdateSpotMarketOracle`'s `check_cold` constraint) — a lesser admin swapping the
|
|
2188
|
+
* oracle could re-price the withdraw guard threshold notional cap and all margin math at
|
|
2189
|
+
* will. On-chain the handler reads both the new and current (`oldOracle`) oracle prices and,
|
|
2190
|
+
* unless `skipInvaraintCheck` is `true`, throws `DefaultError` if the new price is
|
|
2191
|
+
* non-positive or diverges more than 10% from the old one.
|
|
2192
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2193
|
+
* @param oracle - New oracle account.
|
|
2194
|
+
* @param oracleSource - Oracle provider/format for `oracle`.
|
|
2195
|
+
* @param skipInvaraintCheck - If `true`, skips the on-chain non-positive/10%-divergence sanity check against the current oracle price. Default `false`.
|
|
2196
|
+
* @returns Transaction signature.
|
|
2197
|
+
*/
|
|
1248
2198
|
async updateSpotMarketOracle(spotMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
|
|
1249
2199
|
const updateSpotMarketOracleIx = await this.getUpdateSpotMarketOracleIx(spotMarketIndex, oracle, oracleSource, skipInvaraintCheck);
|
|
1250
2200
|
const tx = await this.buildTransaction(updateSpotMarketOracleIx);
|
|
1251
2201
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1252
2202
|
return txSig;
|
|
1253
2203
|
}
|
|
2204
|
+
/**
|
|
2205
|
+
* Builds the `updateSpotMarketOracle` instruction without sending it. See
|
|
2206
|
+
* `updateSpotMarketOracle`. Resolves `oldOracle` from the locally-cached spot market account
|
|
2207
|
+
* (throws if `spotMarketIndex` isn't tracked by the account subscriber).
|
|
2208
|
+
* @returns The unsigned `updateSpotMarketOracle` instruction.
|
|
2209
|
+
*/
|
|
1254
2210
|
async getUpdateSpotMarketOracleIx(spotMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
|
|
1255
2211
|
const spotMarketAccount = this.getSpotMarketAccountOrThrow(spotMarketIndex);
|
|
1256
2212
|
return await this.program.instruction.updateSpotMarketOracle(oracle, oracleSource, skipInvaraintCheck, {
|
|
@@ -1265,12 +2221,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1265
2221
|
},
|
|
1266
2222
|
});
|
|
1267
2223
|
}
|
|
2224
|
+
/**
|
|
2225
|
+
* Enables or disables limit-order placement/fills on a spot market (`spotMarket.ordersEnabled`).
|
|
2226
|
+
* Requires warm admin (`check_warm`).
|
|
2227
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2228
|
+
* @param ordersEnabled - Whether spot orders are enabled for this market.
|
|
2229
|
+
* @returns Transaction signature.
|
|
2230
|
+
*/
|
|
1268
2231
|
async updateSpotMarketOrdersEnabled(spotMarketIndex, ordersEnabled) {
|
|
1269
2232
|
const updateSpotMarketOrdersEnabledIx = await this.getUpdateSpotMarketOrdersEnabledIx(spotMarketIndex, ordersEnabled);
|
|
1270
2233
|
const tx = await this.buildTransaction(updateSpotMarketOrdersEnabledIx);
|
|
1271
2234
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1272
2235
|
return txSig;
|
|
1273
2236
|
}
|
|
2237
|
+
/**
|
|
2238
|
+
* Builds the `updateSpotMarketOrdersEnabled` instruction without sending it. See
|
|
2239
|
+
* `updateSpotMarketOrdersEnabled`.
|
|
2240
|
+
* @returns The unsigned `updateSpotMarketOrdersEnabled` instruction.
|
|
2241
|
+
*/
|
|
1274
2242
|
async getUpdateSpotMarketOrdersEnabledIx(spotMarketIndex, ordersEnabled) {
|
|
1275
2243
|
return await this.program.instruction.updateSpotMarketOrdersEnabled(ordersEnabled, {
|
|
1276
2244
|
accounts: {
|
|
@@ -1282,12 +2250,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1282
2250
|
},
|
|
1283
2251
|
});
|
|
1284
2252
|
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Sets a spot market's insurance-fund operation pause bitmask (`InsuranceFundOperation`:
|
|
2255
|
+
* `Init` 0b0001, `Add` 0b0010, `RequestRemove` 0b0100, `Remove` 0b1000). Gated by
|
|
2256
|
+
* `PauseAdminUpdateSpotMarket` — callable by cold, warm, or the dedicated `pause_admin`; a
|
|
2257
|
+
* caller authorized only via `pause_admin` (not warm/cold) may only *add* pause bits, never
|
|
2258
|
+
* clear existing ones (`require_pause_only_added`).
|
|
2259
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2260
|
+
* @param pausedOperations - New `InsuranceFundOperation` bitmask.
|
|
2261
|
+
* @returns Transaction signature.
|
|
2262
|
+
*/
|
|
1285
2263
|
async updateSpotMarketIfPausedOperations(spotMarketIndex, pausedOperations) {
|
|
1286
2264
|
const updateSpotMarketIfStakingDisabledIx = await this.getUpdateSpotMarketIfPausedOperationsIx(spotMarketIndex, pausedOperations);
|
|
1287
2265
|
const tx = await this.buildTransaction(updateSpotMarketIfStakingDisabledIx);
|
|
1288
2266
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1289
2267
|
return txSig;
|
|
1290
2268
|
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Builds the `updateSpotMarketIfPausedOperations` instruction without sending it. See
|
|
2271
|
+
* `updateSpotMarketIfPausedOperations`.
|
|
2272
|
+
* @returns The unsigned `updateSpotMarketIfPausedOperations` instruction.
|
|
2273
|
+
*/
|
|
1291
2274
|
async getUpdateSpotMarketIfPausedOperationsIx(spotMarketIndex, pausedOperations) {
|
|
1292
2275
|
return await this.program.instruction.updateSpotMarketIfPausedOperations(pausedOperations, {
|
|
1293
2276
|
accounts: {
|
|
@@ -1299,12 +2282,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1299
2282
|
},
|
|
1300
2283
|
});
|
|
1301
2284
|
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Schedules a spot market for expiry: sets `expiryTs` and immediately flips the market to
|
|
2287
|
+
* `MarketStatus.ReduceOnly`. Requires warm admin (`check_warm`). Throws `DefaultError`
|
|
2288
|
+
* on-chain if `expiryTs` is not strictly after the current on-chain clock timestamp.
|
|
2289
|
+
* @param spotMarketIndex - Spot market to schedule for expiry.
|
|
2290
|
+
* @param expiryTs - Unix timestamp (seconds) after which the market is expired; must be in the future.
|
|
2291
|
+
* @returns Transaction signature.
|
|
2292
|
+
*/
|
|
1302
2293
|
async updateSpotMarketExpiry(spotMarketIndex, expiryTs) {
|
|
1303
2294
|
const updateSpotMarketExpiryIx = await this.getUpdateSpotMarketExpiryIx(spotMarketIndex, expiryTs);
|
|
1304
2295
|
const tx = await this.buildTransaction(updateSpotMarketExpiryIx);
|
|
1305
2296
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1306
2297
|
return txSig;
|
|
1307
2298
|
}
|
|
2299
|
+
/**
|
|
2300
|
+
* Builds the `updateSpotMarketExpiry` instruction without sending it. See
|
|
2301
|
+
* `updateSpotMarketExpiry`.
|
|
2302
|
+
* @returns The unsigned `updateSpotMarketExpiry` instruction.
|
|
2303
|
+
*/
|
|
1308
2304
|
async getUpdateSpotMarketExpiryIx(spotMarketIndex, expiryTs) {
|
|
1309
2305
|
return await this.program.instruction.updateSpotMarketExpiry(expiryTs, {
|
|
1310
2306
|
accounts: {
|
|
@@ -1316,12 +2312,29 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1316
2312
|
},
|
|
1317
2313
|
});
|
|
1318
2314
|
}
|
|
2315
|
+
/**
|
|
2316
|
+
* @deprecated The `update_whitelist_mint` instruction handler exists in the Rust
|
|
2317
|
+
* program (`handle_update_whitelist_mint`) but its `#[program]` entry point is
|
|
2318
|
+
* currently commented out in `lib.rs`, so it is absent from the deployed program
|
|
2319
|
+
* and from the generated IDL. Calling this (or `getUpdateWhitelistMintIx`) throws
|
|
2320
|
+
* at runtime — `this.program.instruction` has no `updateWhitelistMint` member —
|
|
2321
|
+
* regardless of the `as any` cast used to bypass the TS type check. Do not call
|
|
2322
|
+
* until the on-chain entry point is re-enabled.
|
|
2323
|
+
* @param whitelistMint - Intended new `state.whitelistMint` (unused while dead).
|
|
2324
|
+
* @returns Transaction signature (never reached).
|
|
2325
|
+
*/
|
|
1319
2326
|
async updateWhitelistMint(whitelistMint) {
|
|
1320
2327
|
const updateWhitelistMintIx = await this.getUpdateWhitelistMintIx(whitelistMint);
|
|
1321
2328
|
const tx = await this.buildTransaction(updateWhitelistMintIx);
|
|
1322
2329
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1323
2330
|
return txSig;
|
|
1324
2331
|
}
|
|
2332
|
+
/**
|
|
2333
|
+
* @deprecated See `updateWhitelistMint` — the underlying `update_whitelist_mint`
|
|
2334
|
+
* instruction is not wired up on-chain and is missing from the IDL; this throws
|
|
2335
|
+
* at runtime.
|
|
2336
|
+
* @returns Never resolves successfully.
|
|
2337
|
+
*/
|
|
1325
2338
|
async getUpdateWhitelistMintIx(whitelistMint) {
|
|
1326
2339
|
return await this.program.instruction.updateWhitelistMint(whitelistMint, {
|
|
1327
2340
|
accounts: {
|
|
@@ -1332,12 +2345,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1332
2345
|
},
|
|
1333
2346
|
});
|
|
1334
2347
|
}
|
|
2348
|
+
/**
|
|
2349
|
+
* Sets `state.discountMint` — a token that grants trade-fee discounts to holders
|
|
2350
|
+
* (checked against the `FeeTier` discount rules at fill time). Requires warm admin
|
|
2351
|
+
* (`check_warm`).
|
|
2352
|
+
* @param discountMint - New discount-token mint.
|
|
2353
|
+
* @returns Transaction signature.
|
|
2354
|
+
*/
|
|
1335
2355
|
async updateDiscountMint(discountMint) {
|
|
1336
2356
|
const updateDiscountMintIx = await this.getUpdateDiscountMintIx(discountMint);
|
|
1337
2357
|
const tx = await this.buildTransaction(updateDiscountMintIx);
|
|
1338
2358
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1339
2359
|
return txSig;
|
|
1340
2360
|
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Builds the `updateDiscountMint` instruction without sending it. See
|
|
2363
|
+
* `updateDiscountMint`.
|
|
2364
|
+
* @returns The unsigned `updateDiscountMint` instruction.
|
|
2365
|
+
*/
|
|
1341
2366
|
async getUpdateDiscountMintIx(discountMint) {
|
|
1342
2367
|
return await this.program.instruction.updateDiscountMint(discountMint, {
|
|
1343
2368
|
accounts: {
|
|
@@ -1348,12 +2373,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1348
2373
|
},
|
|
1349
2374
|
});
|
|
1350
2375
|
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Sets a spot market's deposit/borrow margin weights and IMF factor. Requires warm admin
|
|
2378
|
+
* (`check_warm`). On-chain, `validate_margin_weights` enforces the standard invariants
|
|
2379
|
+
* (asset weights <= SPOT_WEIGHT_PRECISION, liability weights >= SPOT_WEIGHT_PRECISION,
|
|
2380
|
+
* initial at least as conservative as maintenance, and consistency with `imfFactor`).
|
|
2381
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2382
|
+
* @param initialAssetWeight - Initial (deposit) asset weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
2383
|
+
* @param maintenanceAssetWeight - Maintenance asset weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
2384
|
+
* @param initialLiabilityWeight - Initial (borrow) liability weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
2385
|
+
* @param maintenanceLiabilityWeight - Maintenance liability weight, SPOT_WEIGHT_PRECISION (1e4).
|
|
2386
|
+
* @param imfFactor - Increases weight penalty as position size grows, SPOT_IMF_PRECISION (1e6). Default 0.
|
|
2387
|
+
* @returns Transaction signature.
|
|
2388
|
+
*/
|
|
1351
2389
|
async updateSpotMarketMarginWeights(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0) {
|
|
1352
2390
|
const updateSpotMarketMarginWeightsIx = await this.getUpdateSpotMarketMarginWeightsIx(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor);
|
|
1353
2391
|
const tx = await this.buildTransaction(updateSpotMarketMarginWeightsIx);
|
|
1354
2392
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1355
2393
|
return txSig;
|
|
1356
2394
|
}
|
|
2395
|
+
/**
|
|
2396
|
+
* Builds the `updateSpotMarketMarginWeights` instruction without sending it. See
|
|
2397
|
+
* `updateSpotMarketMarginWeights`.
|
|
2398
|
+
* @returns The unsigned `updateSpotMarketMarginWeights` instruction.
|
|
2399
|
+
*/
|
|
1357
2400
|
async getUpdateSpotMarketMarginWeightsIx(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0) {
|
|
1358
2401
|
return await this.program.instruction.updateSpotMarketMarginWeights(initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, {
|
|
1359
2402
|
accounts: {
|
|
@@ -1365,12 +2408,29 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1365
2408
|
},
|
|
1366
2409
|
});
|
|
1367
2410
|
}
|
|
2411
|
+
/**
|
|
2412
|
+
* Sets a spot market's interest-rate curve: the utilization/rate kink plus the max rate at
|
|
2413
|
+
* 100% utilization. Requires warm admin (`check_warm`). On-chain, `validate_borrow_rate`
|
|
2414
|
+
* checks the curve is well-formed (kink within bounds, rates monotonically increasing,
|
|
2415
|
+
* `min_borrow_rate` at or below `optimal_borrow_rate`).
|
|
2416
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2417
|
+
* @param optimalUtilization - Utilization at the borrow-rate kink, SPOT_UTILIZATION_PRECISION (1e6, 100% = 1e6).
|
|
2418
|
+
* @param optimalBorrowRate - Borrow rate at `optimalUtilization`, SPOT_RATE_PRECISION (1e6, 100% APR = 1e6).
|
|
2419
|
+
* @param optimalMaxRate - Borrow rate at 100% utilization, SPOT_RATE_PRECISION (1e6).
|
|
2420
|
+
* @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.
|
|
2421
|
+
* @returns Transaction signature.
|
|
2422
|
+
*/
|
|
1368
2423
|
async updateSpotMarketBorrowRate(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate) {
|
|
1369
2424
|
const updateSpotMarketBorrowRateIx = await this.getUpdateSpotMarketBorrowRateIx(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate);
|
|
1370
2425
|
const tx = await this.buildTransaction(updateSpotMarketBorrowRateIx);
|
|
1371
2426
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1372
2427
|
return txSig;
|
|
1373
2428
|
}
|
|
2429
|
+
/**
|
|
2430
|
+
* Builds the `updateSpotMarketBorrowRate` instruction without sending it. See
|
|
2431
|
+
* `updateSpotMarketBorrowRate`.
|
|
2432
|
+
* @returns The unsigned `updateSpotMarketBorrowRate` instruction.
|
|
2433
|
+
*/
|
|
1374
2434
|
async getUpdateSpotMarketBorrowRateIx(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate) {
|
|
1375
2435
|
return await this.program.instruction.updateSpotMarketBorrowRate(optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate, {
|
|
1376
2436
|
accounts: {
|
|
@@ -1382,12 +2442,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1382
2442
|
},
|
|
1383
2443
|
});
|
|
1384
2444
|
}
|
|
2445
|
+
/**
|
|
2446
|
+
* Sets a spot market's `AssetTier` (collateral-usability gate for cross-margin). Requires
|
|
2447
|
+
* warm admin (`check_warm`). On-chain, if `spotMarket.initialAssetWeight > 0` (the market is
|
|
2448
|
+
* currently usable as collateral), the new tier must be `AssetTier.COLLATERAL` or
|
|
2449
|
+
* `AssetTier.PROTECTED` — otherwise it throws `DefaultError`; zero the initial asset weight
|
|
2450
|
+
* first to move a market to a lesser tier.
|
|
2451
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2452
|
+
* @param assetTier - New asset tier.
|
|
2453
|
+
* @returns Transaction signature.
|
|
2454
|
+
*/
|
|
1385
2455
|
async updateSpotMarketAssetTier(spotMarketIndex, assetTier) {
|
|
1386
2456
|
const updateSpotMarketAssetTierIx = await this.getUpdateSpotMarketAssetTierIx(spotMarketIndex, assetTier);
|
|
1387
2457
|
const tx = await this.buildTransaction(updateSpotMarketAssetTierIx);
|
|
1388
2458
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1389
2459
|
return txSig;
|
|
1390
2460
|
}
|
|
2461
|
+
/**
|
|
2462
|
+
* Builds the `updateSpotMarketAssetTier` instruction without sending it. See
|
|
2463
|
+
* `updateSpotMarketAssetTier`.
|
|
2464
|
+
* @returns The unsigned `updateSpotMarketAssetTier` instruction.
|
|
2465
|
+
*/
|
|
1391
2466
|
async getUpdateSpotMarketAssetTierIx(spotMarketIndex, assetTier) {
|
|
1392
2467
|
return await this.program.instruction.updateSpotMarketAssetTier(assetTier, {
|
|
1393
2468
|
accounts: {
|
|
@@ -1399,12 +2474,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1399
2474
|
},
|
|
1400
2475
|
});
|
|
1401
2476
|
}
|
|
2477
|
+
/**
|
|
2478
|
+
* Sets a spot market's `MarketStatus` directly. Requires warm admin (`check_warm`). Unlike
|
|
2479
|
+
* `updatePerpMarketStatus`, the spot handler applies no restriction on the target status —
|
|
2480
|
+
* `Delisted`/`Settlement` can be set here directly (there is no separate spot
|
|
2481
|
+
* settlement-teardown instruction).
|
|
2482
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2483
|
+
* @param marketStatus - New market status.
|
|
2484
|
+
* @returns Transaction signature.
|
|
2485
|
+
*/
|
|
1402
2486
|
async updateSpotMarketStatus(spotMarketIndex, marketStatus) {
|
|
1403
2487
|
const updateSpotMarketStatusIx = await this.getUpdateSpotMarketStatusIx(spotMarketIndex, marketStatus);
|
|
1404
2488
|
const tx = await this.buildTransaction(updateSpotMarketStatusIx);
|
|
1405
2489
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1406
2490
|
return txSig;
|
|
1407
2491
|
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Builds the `updateSpotMarketStatus` instruction without sending it. See
|
|
2494
|
+
* `updateSpotMarketStatus`.
|
|
2495
|
+
* @returns The unsigned `updateSpotMarketStatus` instruction.
|
|
2496
|
+
*/
|
|
1408
2497
|
async getUpdateSpotMarketStatusIx(spotMarketIndex, marketStatus) {
|
|
1409
2498
|
return await this.program.instruction.updateSpotMarketStatus(marketStatus, {
|
|
1410
2499
|
accounts: {
|
|
@@ -1416,12 +2505,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1416
2505
|
},
|
|
1417
2506
|
});
|
|
1418
2507
|
}
|
|
2508
|
+
/**
|
|
2509
|
+
* Sets a spot market's operation pause bitmask (`SpotOperation`: `UpdateCumulativeInterest`
|
|
2510
|
+
* 0b00001, `Fill` 0b00010, `Deposit` 0b00100, `Withdraw` 0b01000, `Liquidation` 0b10000).
|
|
2511
|
+
* Gated by `PauseAdminUpdateSpotMarket` — callable by cold, warm, or the dedicated
|
|
2512
|
+
* `pause_admin`; a caller authorized only via `pause_admin` may only *add* pause bits, never
|
|
2513
|
+
* clear existing ones (`require_pause_only_added`).
|
|
2514
|
+
* @param spotMarketIndex - Spot market to update.
|
|
2515
|
+
* @param pausedOperations - New `SpotOperation` bitmask.
|
|
2516
|
+
* @returns Transaction signature.
|
|
2517
|
+
*/
|
|
1419
2518
|
async updateSpotMarketPausedOperations(spotMarketIndex, pausedOperations) {
|
|
1420
2519
|
const updateSpotMarketPausedOperationsIx = await this.getUpdateSpotMarketPausedOperationsIx(spotMarketIndex, pausedOperations);
|
|
1421
2520
|
const tx = await this.buildTransaction(updateSpotMarketPausedOperationsIx);
|
|
1422
2521
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1423
2522
|
return txSig;
|
|
1424
2523
|
}
|
|
2524
|
+
/**
|
|
2525
|
+
* Builds the `updateSpotMarketPausedOperations` instruction without sending it. See
|
|
2526
|
+
* `updateSpotMarketPausedOperations`.
|
|
2527
|
+
* @returns The unsigned `updateSpotMarketPausedOperations` instruction.
|
|
2528
|
+
*/
|
|
1425
2529
|
async getUpdateSpotMarketPausedOperationsIx(spotMarketIndex, pausedOperations) {
|
|
1426
2530
|
return await this.program.instruction.updateSpotMarketPausedOperations(pausedOperations, {
|
|
1427
2531
|
accounts: {
|
|
@@ -1433,12 +2537,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1433
2537
|
},
|
|
1434
2538
|
});
|
|
1435
2539
|
}
|
|
2540
|
+
/**
|
|
2541
|
+
* Sets a perp market's `MarketStatus` directly. Requires warm admin (`check_warm`). On-chain,
|
|
2542
|
+
* throws `DefaultError` if the target status is `Delisted` or `Settlement` — those are only
|
|
2543
|
+
* reached through the market-expiry lifecycle (`updatePerpMarketExpiry` -> `ReduceOnly`,
|
|
2544
|
+
* then the keeper's `settleExpiredMarket` -> `Settlement`, then
|
|
2545
|
+
* `settleExpiredMarketPoolsToRevenuePool` -> `Delisted`), never set directly here.
|
|
2546
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2547
|
+
* @param marketStatus - New market status; must not be `Delisted` or `Settlement`.
|
|
2548
|
+
* @returns Transaction signature.
|
|
2549
|
+
*/
|
|
1436
2550
|
async updatePerpMarketStatus(perpMarketIndex, marketStatus) {
|
|
1437
2551
|
const updatePerpMarketStatusIx = await this.getUpdatePerpMarketStatusIx(perpMarketIndex, marketStatus);
|
|
1438
2552
|
const tx = await this.buildTransaction(updatePerpMarketStatusIx);
|
|
1439
2553
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1440
2554
|
return txSig;
|
|
1441
2555
|
}
|
|
2556
|
+
/**
|
|
2557
|
+
* Builds the `updatePerpMarketStatus` instruction without sending it. See
|
|
2558
|
+
* `updatePerpMarketStatus`.
|
|
2559
|
+
* @returns The unsigned `updatePerpMarketStatus` instruction.
|
|
2560
|
+
*/
|
|
1442
2561
|
async getUpdatePerpMarketStatusIx(perpMarketIndex, marketStatus) {
|
|
1443
2562
|
return await this.program.instruction.updatePerpMarketStatus(marketStatus, {
|
|
1444
2563
|
accounts: {
|
|
@@ -1450,12 +2569,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1450
2569
|
},
|
|
1451
2570
|
});
|
|
1452
2571
|
}
|
|
2572
|
+
/**
|
|
2573
|
+
* Sets a perp market's operation pause bitmask (`PerpOperation`: `UpdateFunding` 0b00000001,
|
|
2574
|
+
* `AmmFill` 0b00000010, `Fill` 0b00000100, `SettlePnl` 0b00001000, `SettlePnlWithPosition`
|
|
2575
|
+
* 0b00010000, `Liquidation` 0b00100000, `AmmImmediateFill` 0b01000000, `SettleRevPool`
|
|
2576
|
+
* 0b10000000). Gated by `PauseAdminUpdatePerpMarket` — callable by cold, warm, or the
|
|
2577
|
+
* dedicated `pause_admin`. Authority matrix on-chain: **cold** may set any value; **warm**
|
|
2578
|
+
* may only flip the `UpdateFunding` / `SettleRevPool` bits, all others must be preserved
|
|
2579
|
+
* (throws `DefaultError` otherwise); **pause_admin** may set any bit but only *add* pause
|
|
2580
|
+
* bits, never clear them (`require_pause_only_added`).
|
|
2581
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2582
|
+
* @param pausedOperations - New `PerpOperation` bitmask.
|
|
2583
|
+
* @returns Transaction signature.
|
|
2584
|
+
*/
|
|
1453
2585
|
async updatePerpMarketPausedOperations(perpMarketIndex, pausedOperations) {
|
|
1454
2586
|
const updatePerpMarketPausedOperationsIx = await this.getUpdatePerpMarketPausedOperationsIx(perpMarketIndex, pausedOperations);
|
|
1455
2587
|
const tx = await this.buildTransaction(updatePerpMarketPausedOperationsIx);
|
|
1456
2588
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1457
2589
|
return txSig;
|
|
1458
2590
|
}
|
|
2591
|
+
/**
|
|
2592
|
+
* Builds the `updatePerpMarketPausedOperations` instruction without sending it. See
|
|
2593
|
+
* `updatePerpMarketPausedOperations`.
|
|
2594
|
+
* @returns The unsigned `updatePerpMarketPausedOperations` instruction.
|
|
2595
|
+
*/
|
|
1459
2596
|
async getUpdatePerpMarketPausedOperationsIx(perpMarketIndex, pausedOperations) {
|
|
1460
2597
|
return await this.program.instruction.updatePerpMarketPausedOperations(pausedOperations, {
|
|
1461
2598
|
accounts: {
|
|
@@ -1467,12 +2604,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1467
2604
|
},
|
|
1468
2605
|
});
|
|
1469
2606
|
}
|
|
2607
|
+
/**
|
|
2608
|
+
* Sets a perp market's `ContractTier` (risk/collateral classification). Requires warm admin
|
|
2609
|
+
* (`check_warm`).
|
|
2610
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2611
|
+
* @param contractTier - New contract tier.
|
|
2612
|
+
* @returns Transaction signature.
|
|
2613
|
+
*/
|
|
1470
2614
|
async updatePerpMarketContractTier(perpMarketIndex, contractTier) {
|
|
1471
2615
|
const updatePerpMarketContractTierIx = await this.getUpdatePerpMarketContractTierIx(perpMarketIndex, contractTier);
|
|
1472
2616
|
const tx = await this.buildTransaction(updatePerpMarketContractTierIx);
|
|
1473
2617
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1474
2618
|
return txSig;
|
|
1475
2619
|
}
|
|
2620
|
+
/**
|
|
2621
|
+
* Builds the `updatePerpMarketContractTier` instruction without sending it. See
|
|
2622
|
+
* `updatePerpMarketContractTier`.
|
|
2623
|
+
* @returns The unsigned `updatePerpMarketContractTier` instruction.
|
|
2624
|
+
*/
|
|
1476
2625
|
async getUpdatePerpMarketContractTierIx(perpMarketIndex, contractTier) {
|
|
1477
2626
|
return await this.program.instruction.updatePerpMarketContractTier(contractTier, {
|
|
1478
2627
|
accounts: {
|
|
@@ -1485,12 +2634,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1485
2634
|
},
|
|
1486
2635
|
});
|
|
1487
2636
|
}
|
|
2637
|
+
/**
|
|
2638
|
+
* Sets `state.exchangeStatus`, the protocol-wide pause bitmask (`ExchangeStatus`).
|
|
2639
|
+
* Reachable by cold, warm, or `pauseAdmin` (`PauseAdminUpdateState`'s
|
|
2640
|
+
* `check_pause`), but the handler enforces `require_pause_only_added`: a caller
|
|
2641
|
+
* authorised only via `pauseAdmin` (not warm/cold) may add pause bits but never
|
|
2642
|
+
* clear one — cold/warm can set any value, including unpausing. The `admin`
|
|
2643
|
+
* account below defaults to `coldAdmin`; a pause-admin-only caller must override it
|
|
2644
|
+
* with their own pubkey.
|
|
2645
|
+
* @param exchangeStatus - New pause bitmask, `ExchangeStatus` (bit values; `PAUSED` = 255 pauses everything).
|
|
2646
|
+
* @returns Transaction signature.
|
|
2647
|
+
*/
|
|
1488
2648
|
async updateExchangeStatus(exchangeStatus) {
|
|
1489
2649
|
const updateExchangeStatusIx = await this.getUpdateExchangeStatusIx(exchangeStatus);
|
|
1490
2650
|
const tx = await this.buildTransaction(updateExchangeStatusIx);
|
|
1491
2651
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1492
2652
|
return txSig;
|
|
1493
2653
|
}
|
|
2654
|
+
/**
|
|
2655
|
+
* Builds the `updateExchangeStatus` instruction without sending it. See
|
|
2656
|
+
* `updateExchangeStatus`.
|
|
2657
|
+
* @returns The unsigned `updateExchangeStatus` instruction.
|
|
2658
|
+
*/
|
|
1494
2659
|
async getUpdateExchangeStatusIx(exchangeStatus) {
|
|
1495
2660
|
return await this.program.instruction.updateExchangeStatus(exchangeStatus, {
|
|
1496
2661
|
accounts: {
|
|
@@ -1501,12 +2666,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1501
2666
|
},
|
|
1502
2667
|
});
|
|
1503
2668
|
}
|
|
2669
|
+
/**
|
|
2670
|
+
* Sets `state.solvencyStatus` (`SolvencyStatus`), gating internal solvency-repair
|
|
2671
|
+
* flows (bankruptcy / pnl-deficit resolution) independently of
|
|
2672
|
+
* `ExchangeStatus.WITHDRAW_PAUSED`. Cold-only — unlike `updateExchangeStatus`, the
|
|
2673
|
+
* `ColdAdminUpdateState` context accepts only `state.coldAdmin`; there is no
|
|
2674
|
+
* pause-admin or warm-admin path and no bit-add-only restriction.
|
|
2675
|
+
* @param solvencyStatus - New bitmask, `SolvencyStatus` (currently one bit: `SOLVENCY_REPAIR_PAUSED`).
|
|
2676
|
+
* @returns Transaction signature.
|
|
2677
|
+
*/
|
|
1504
2678
|
async updateSolvencyStatus(solvencyStatus) {
|
|
1505
2679
|
const updateSolvencyStatusIx = await this.getUpdateSolvencyStatusIx(solvencyStatus);
|
|
1506
2680
|
const tx = await this.buildTransaction(updateSolvencyStatusIx);
|
|
1507
2681
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1508
2682
|
return txSig;
|
|
1509
2683
|
}
|
|
2684
|
+
/**
|
|
2685
|
+
* Builds the `updateSolvencyStatus` instruction without sending it. See
|
|
2686
|
+
* `updateSolvencyStatus`.
|
|
2687
|
+
* @returns The unsigned `updateSolvencyStatus` instruction.
|
|
2688
|
+
*/
|
|
1510
2689
|
async getUpdateSolvencyStatusIx(solvencyStatus) {
|
|
1511
2690
|
return await this.program.instruction.updateSolvencyStatus(solvencyStatus, {
|
|
1512
2691
|
accounts: {
|
|
@@ -1517,12 +2696,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1517
2696
|
},
|
|
1518
2697
|
});
|
|
1519
2698
|
}
|
|
2699
|
+
/**
|
|
2700
|
+
* Sets the protocol-wide default minimum perp-order auction duration
|
|
2701
|
+
* (`state.minPerpAuctionDuration`) — orders placed without an explicit longer
|
|
2702
|
+
* auction fall back to this floor. Requires warm admin (`check_warm`).
|
|
2703
|
+
* @param minDuration - Minimum auction duration, slots.
|
|
2704
|
+
* @returns Transaction signature.
|
|
2705
|
+
*/
|
|
1520
2706
|
async updatePerpAuctionDuration(minDuration) {
|
|
1521
2707
|
const updatePerpAuctionDurationIx = await this.getUpdatePerpAuctionDurationIx(minDuration);
|
|
1522
2708
|
const tx = await this.buildTransaction(updatePerpAuctionDurationIx);
|
|
1523
2709
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1524
2710
|
return txSig;
|
|
1525
2711
|
}
|
|
2712
|
+
/**
|
|
2713
|
+
* Builds the `updatePerpAuctionDuration` instruction without sending it. See
|
|
2714
|
+
* `updatePerpAuctionDuration`.
|
|
2715
|
+
* @returns The unsigned `updatePerpAuctionDuration` instruction.
|
|
2716
|
+
*/
|
|
1526
2717
|
async getUpdatePerpAuctionDurationIx(minDuration) {
|
|
1527
2718
|
return await this.program.instruction.updatePerpAuctionDuration(typeof minDuration === 'number' ? minDuration : minDuration.toNumber(), {
|
|
1528
2719
|
accounts: {
|
|
@@ -1533,12 +2724,23 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1533
2724
|
},
|
|
1534
2725
|
});
|
|
1535
2726
|
}
|
|
2727
|
+
/**
|
|
2728
|
+
* Sets the protocol-wide default spot-order auction duration
|
|
2729
|
+
* (`state.defaultSpotAuctionDuration`). Requires warm admin (`check_warm`).
|
|
2730
|
+
* @param defaultAuctionDuration - Default auction duration, slots.
|
|
2731
|
+
* @returns Transaction signature.
|
|
2732
|
+
*/
|
|
1536
2733
|
async updateSpotAuctionDuration(defaultAuctionDuration) {
|
|
1537
2734
|
const updateSpotAuctionDurationIx = await this.getUpdateSpotAuctionDurationIx(defaultAuctionDuration);
|
|
1538
2735
|
const tx = await this.buildTransaction(updateSpotAuctionDurationIx);
|
|
1539
2736
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1540
2737
|
return txSig;
|
|
1541
2738
|
}
|
|
2739
|
+
/**
|
|
2740
|
+
* Builds the `updateSpotAuctionDuration` instruction without sending it. See
|
|
2741
|
+
* `updateSpotAuctionDuration`.
|
|
2742
|
+
* @returns The unsigned `updateSpotAuctionDuration` instruction.
|
|
2743
|
+
*/
|
|
1542
2744
|
async getUpdateSpotAuctionDurationIx(defaultAuctionDuration) {
|
|
1543
2745
|
return await this.program.instruction.updateSpotAuctionDuration(defaultAuctionDuration, {
|
|
1544
2746
|
accounts: {
|
|
@@ -1549,12 +2751,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1549
2751
|
},
|
|
1550
2752
|
});
|
|
1551
2753
|
}
|
|
2754
|
+
/**
|
|
2755
|
+
* Sets the fraction of a perp market's AMM base reserve a single fill may consume
|
|
2756
|
+
* (`amm.maxFillReserveFraction`; a single fill is capped at
|
|
2757
|
+
* `baseAssetReserve / maxFillReserveFraction`, further bounded by half the AMM's
|
|
2758
|
+
* per-side available liquidity). Requires warm admin (`check_warm`). Throws `DefaultError`
|
|
2759
|
+
* on-chain if `maxBaseAssetAmountRatio` is 0. Smaller values allow larger single fills.
|
|
2760
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2761
|
+
* @param maxBaseAssetAmountRatio - Divisor applied to `baseAssetReserve` to cap a single fill's size; must be > 0.
|
|
2762
|
+
* @returns Transaction signature.
|
|
2763
|
+
*/
|
|
1552
2764
|
async updatePerpMarketMaxFillReserveFraction(perpMarketIndex, maxBaseAssetAmountRatio) {
|
|
1553
2765
|
const updatePerpMarketMaxFillReserveFractionIx = await this.getUpdatePerpMarketMaxFillReserveFractionIx(perpMarketIndex, maxBaseAssetAmountRatio);
|
|
1554
2766
|
const tx = await this.buildTransaction(updatePerpMarketMaxFillReserveFractionIx);
|
|
1555
2767
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1556
2768
|
return txSig;
|
|
1557
2769
|
}
|
|
2770
|
+
/**
|
|
2771
|
+
* Builds the `updatePerpMarketMaxFillReserveFraction` instruction without sending it. See
|
|
2772
|
+
* `updatePerpMarketMaxFillReserveFraction`.
|
|
2773
|
+
* @returns The unsigned `updatePerpMarketMaxFillReserveFraction` instruction.
|
|
2774
|
+
*/
|
|
1558
2775
|
async getUpdatePerpMarketMaxFillReserveFractionIx(perpMarketIndex, maxBaseAssetAmountRatio) {
|
|
1559
2776
|
return await this.program.instruction.updatePerpMarketMaxFillReserveFraction(maxBaseAssetAmountRatio, {
|
|
1560
2777
|
accounts: {
|
|
@@ -1566,12 +2783,34 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1566
2783
|
},
|
|
1567
2784
|
});
|
|
1568
2785
|
}
|
|
2786
|
+
/**
|
|
2787
|
+
* **Currently broken and a dead config knob even if fixed.** Intended to set a perp market's
|
|
2788
|
+
* `amm.maxSlippageRatio` (on-chain default 50, i.e. ~2% per the seed comment in
|
|
2789
|
+
* `initializePerpMarket`'s default config) — but `getUpdateMaxSlippageRatioIx` calls
|
|
2790
|
+
* `this.program.instruction.updateMaxSlippageRatio` (cast to `any` to bypass the missing
|
|
2791
|
+
* type); the actual on-chain/IDL instruction is named `updatePerpMarketMaxSlippageRatio`, so
|
|
2792
|
+
* this throws at runtime (`... is not a function`). Separately, even the correctly-named
|
|
2793
|
+
* instruction's target field, `amm.maxSlippageRatio`, is not read by any fill/slippage-check
|
|
2794
|
+
* path in the program — it is write-only. Requires warm admin (`check_warm`) on the
|
|
2795
|
+
* `update_perp_market_max_slippage_ratio` handler.
|
|
2796
|
+
* @param perpMarketIndex - Perp market that would be updated.
|
|
2797
|
+
* @param maxSlippageRatio - Intended `amm.maxSlippageRatio` value, unitless (would validate `> 0`).
|
|
2798
|
+
* @returns Transaction signature (in practice: throws before a transaction is built).
|
|
2799
|
+
*/
|
|
1569
2800
|
async updateMaxSlippageRatio(perpMarketIndex, maxSlippageRatio) {
|
|
1570
2801
|
const updateMaxSlippageRatioIx = await this.getUpdateMaxSlippageRatioIx(perpMarketIndex, maxSlippageRatio);
|
|
1571
2802
|
const tx = await this.buildTransaction(updateMaxSlippageRatioIx);
|
|
1572
2803
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1573
2804
|
return txSig;
|
|
1574
2805
|
}
|
|
2806
|
+
/**
|
|
2807
|
+
* Builds the (currently broken) `updateMaxSlippageRatio` instruction. See
|
|
2808
|
+
* `updateMaxSlippageRatio` — this throws because the program has no `updateMaxSlippageRatio`
|
|
2809
|
+
* instruction (the real name is `updatePerpMarketMaxSlippageRatio`). Throws if
|
|
2810
|
+
* `perpMarketIndex` isn't tracked by the local account subscriber, before it even reaches
|
|
2811
|
+
* the bad instruction-name call.
|
|
2812
|
+
* @returns Never resolves successfully; throws when the missing instruction is invoked.
|
|
2813
|
+
*/
|
|
1575
2814
|
async getUpdateMaxSlippageRatioIx(perpMarketIndex, maxSlippageRatio) {
|
|
1576
2815
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(perpMarketIndex);
|
|
1577
2816
|
return await this.program.instruction.updateMaxSlippageRatio(maxSlippageRatio, {
|
|
@@ -1584,12 +2823,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1584
2823
|
},
|
|
1585
2824
|
});
|
|
1586
2825
|
}
|
|
2826
|
+
/**
|
|
2827
|
+
* Sets the asset weights applied to a user's unrealized (unsettled) perp PnL when it counts
|
|
2828
|
+
* toward free collateral. Requires warm admin (`check_warm`). On-chain, both weights must be
|
|
2829
|
+
* <= SPOT_WEIGHT_PRECISION and `unrealizedInitialAssetWeight <= unrealizedMaintenanceAssetWeight`,
|
|
2830
|
+
* or the handler throws `DefaultError`.
|
|
2831
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2832
|
+
* @param unrealizedInitialAssetWeight - Initial-margin weight on unrealized PnL, SPOT_WEIGHT_PRECISION (1e4).
|
|
2833
|
+
* @param unrealizedMaintenanceAssetWeight - Maintenance-margin weight on unrealized PnL, SPOT_WEIGHT_PRECISION (1e4). Must be >= the initial weight.
|
|
2834
|
+
* @returns Transaction signature.
|
|
2835
|
+
*/
|
|
1587
2836
|
async updatePerpMarketUnrealizedAssetWeight(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight) {
|
|
1588
2837
|
const updatePerpMarketUnrealizedAssetWeightIx = await this.getUpdatePerpMarketUnrealizedAssetWeightIx(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight);
|
|
1589
2838
|
const tx = await this.buildTransaction(updatePerpMarketUnrealizedAssetWeightIx);
|
|
1590
2839
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1591
2840
|
return txSig;
|
|
1592
2841
|
}
|
|
2842
|
+
/**
|
|
2843
|
+
* Builds the `updatePerpMarketUnrealizedAssetWeight` instruction without sending it. See
|
|
2844
|
+
* `updatePerpMarketUnrealizedAssetWeight`.
|
|
2845
|
+
* @returns The unsigned `updatePerpMarketUnrealizedAssetWeight` instruction.
|
|
2846
|
+
*/
|
|
1593
2847
|
async getUpdatePerpMarketUnrealizedAssetWeightIx(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight) {
|
|
1594
2848
|
return await this.program.instruction.updatePerpMarketUnrealizedAssetWeight(unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight, {
|
|
1595
2849
|
accounts: {
|
|
@@ -1601,12 +2855,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1601
2855
|
},
|
|
1602
2856
|
});
|
|
1603
2857
|
}
|
|
2858
|
+
/**
|
|
2859
|
+
* Sets a perp market's insurance/revenue-pool caps. Requires warm admin (`check_warm`).
|
|
2860
|
+
* On-chain, all three are bounded by the tier-specific `INSURANCE_{A,B,C,SPECULATIVE}_MAX`
|
|
2861
|
+
* constant for the market's current `contractTier` (`maxRevenueWithdrawPerPeriod` may
|
|
2862
|
+
* alternatively be as large as `FEE_POOL_TO_REVENUE_POOL_THRESHOLD` if that's bigger than
|
|
2863
|
+
* the tier max), and `quoteMaxInsurance` must be >= the market's already-settled insurance
|
|
2864
|
+
* claim — violating either throws `DefaultError`.
|
|
2865
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2866
|
+
* @param unrealizedMaxImbalance - Cap on unrealized-PnL imbalance eligible for insurance backing, QUOTE_PRECISION (1e6).
|
|
2867
|
+
* @param maxRevenueWithdrawPerPeriod - Cap on revenue-pool withdrawals per settlement period, QUOTE_PRECISION (1e6).
|
|
2868
|
+
* @param quoteMaxInsurance - Lifetime cap on insurance draws for this market, QUOTE_PRECISION (1e6). Must be >= the market's already-settled insurance claim.
|
|
2869
|
+
* @returns Transaction signature.
|
|
2870
|
+
*/
|
|
1604
2871
|
async updatePerpMarketMaxImbalances(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
|
|
1605
2872
|
const updatePerpMarketMaxImabalancesIx = await this.getUpdatePerpMarketMaxImbalancesIx(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance);
|
|
1606
2873
|
const tx = await this.buildTransaction(updatePerpMarketMaxImabalancesIx);
|
|
1607
2874
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1608
2875
|
return txSig;
|
|
1609
2876
|
}
|
|
2877
|
+
/**
|
|
2878
|
+
* Builds the `updatePerpMarketMaxImbalances` instruction without sending it. See
|
|
2879
|
+
* `updatePerpMarketMaxImbalances`.
|
|
2880
|
+
* @returns The unsigned `updatePerpMarketMaxImbalances` instruction.
|
|
2881
|
+
*/
|
|
1610
2882
|
async getUpdatePerpMarketMaxImbalancesIx(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
|
|
1611
2883
|
return await this.program.instruction.updatePerpMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
|
|
1612
2884
|
accounts: {
|
|
@@ -1618,12 +2890,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1618
2890
|
},
|
|
1619
2891
|
});
|
|
1620
2892
|
}
|
|
2893
|
+
/**
|
|
2894
|
+
* Sets a perp market's open-interest cap. Requires warm admin (`check_warm`). Throws
|
|
2895
|
+
* `DefaultError` on-chain unless `maxOpenInterest` is an exact multiple of the market's
|
|
2896
|
+
* `orderStepSize`.
|
|
2897
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2898
|
+
* @param maxOpenInterest - Cap on base-asset open interest, BASE_PRECISION (1e9). Must be a multiple of `orderStepSize`.
|
|
2899
|
+
* @returns Transaction signature.
|
|
2900
|
+
*/
|
|
1621
2901
|
async updatePerpMarketMaxOpenInterest(perpMarketIndex, maxOpenInterest) {
|
|
1622
2902
|
const updatePerpMarketMaxOpenInterestIx = await this.getUpdatePerpMarketMaxOpenInterestIx(perpMarketIndex, maxOpenInterest);
|
|
1623
2903
|
const tx = await this.buildTransaction(updatePerpMarketMaxOpenInterestIx);
|
|
1624
2904
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1625
2905
|
return txSig;
|
|
1626
2906
|
}
|
|
2907
|
+
/**
|
|
2908
|
+
* Builds the `updatePerpMarketMaxOpenInterest` instruction without sending it. See
|
|
2909
|
+
* `updatePerpMarketMaxOpenInterest`.
|
|
2910
|
+
* @returns The unsigned `updatePerpMarketMaxOpenInterest` instruction.
|
|
2911
|
+
*/
|
|
1627
2912
|
async getUpdatePerpMarketMaxOpenInterestIx(perpMarketIndex, maxOpenInterest) {
|
|
1628
2913
|
return await this.program.instruction.updatePerpMarketMaxOpenInterest(maxOpenInterest, {
|
|
1629
2914
|
accounts: {
|
|
@@ -1635,12 +2920,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1635
2920
|
},
|
|
1636
2921
|
});
|
|
1637
2922
|
}
|
|
2923
|
+
/**
|
|
2924
|
+
* Directly overwrites a perp market's user-count counters (`numberOfUsers` /
|
|
2925
|
+
* `numberOfUsersWithBase`), used to correct drift from the incrementally-maintained
|
|
2926
|
+
* counters. Requires warm admin (`check_warm`). Either counter can be omitted to leave it
|
|
2927
|
+
* unchanged. On-chain, throws `DefaultError` if the resulting `numberOfUsers <
|
|
2928
|
+
* numberOfUsersWithBase`.
|
|
2929
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2930
|
+
* @param numberOfUsers - New total open-position-or-order user count. Omit to leave unchanged.
|
|
2931
|
+
* @param numberOfUsersWithBase - New count of users with a nonzero base position. Omit to leave unchanged. Must not exceed `numberOfUsers`.
|
|
2932
|
+
* @returns Transaction signature.
|
|
2933
|
+
*/
|
|
1638
2934
|
async updatePerpMarketNumberOfUser(perpMarketIndex, numberOfUsers, numberOfUsersWithBase) {
|
|
1639
2935
|
const updatepPerpMarketFeeAdjustmentIx = await this.getUpdatePerpMarketNumberOfUsersIx(perpMarketIndex, numberOfUsers, numberOfUsersWithBase);
|
|
1640
2936
|
const tx = await this.buildTransaction(updatepPerpMarketFeeAdjustmentIx);
|
|
1641
2937
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1642
2938
|
return txSig;
|
|
1643
2939
|
}
|
|
2940
|
+
/**
|
|
2941
|
+
* Builds the `updatePerpMarketNumberOfUsers` instruction without sending it. See
|
|
2942
|
+
* `updatePerpMarketNumberOfUser`.
|
|
2943
|
+
* @returns The unsigned `updatePerpMarketNumberOfUsers` instruction.
|
|
2944
|
+
*/
|
|
1644
2945
|
async getUpdatePerpMarketNumberOfUsersIx(perpMarketIndex, numberOfUsers, numberOfUsersWithBase) {
|
|
1645
2946
|
return await this.program.instruction.updatePerpMarketNumberOfUsers(numberOfUsers, numberOfUsersWithBase, {
|
|
1646
2947
|
accounts: {
|
|
@@ -1652,12 +2953,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1652
2953
|
},
|
|
1653
2954
|
});
|
|
1654
2955
|
}
|
|
2956
|
+
/**
|
|
2957
|
+
* Scales a perp market's taker fee and maker rebate up or down by a percentage of the base
|
|
2958
|
+
* fee tier. Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if
|
|
2959
|
+
* `abs(feeAdjustment) > FEE_ADJUSTMENT_MAX` (100).
|
|
2960
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2961
|
+
* @param feeAdjustment - Percent adjustment applied to the base taker fee / maker rebate, -100..100 (negative reduces, positive increases; 0 = no adjustment).
|
|
2962
|
+
* @returns Transaction signature.
|
|
2963
|
+
*/
|
|
1655
2964
|
async updatePerpMarketFeeAdjustment(perpMarketIndex, feeAdjustment) {
|
|
1656
2965
|
const updatepPerpMarketFeeAdjustmentIx = await this.getUpdatePerpMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment);
|
|
1657
2966
|
const tx = await this.buildTransaction(updatepPerpMarketFeeAdjustmentIx);
|
|
1658
2967
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1659
2968
|
return txSig;
|
|
1660
2969
|
}
|
|
2970
|
+
/**
|
|
2971
|
+
* Builds the `updatePerpMarketFeeAdjustment` instruction without sending it. See
|
|
2972
|
+
* `updatePerpMarketFeeAdjustment`.
|
|
2973
|
+
* @returns The unsigned `updatePerpMarketFeeAdjustment` instruction.
|
|
2974
|
+
*/
|
|
1661
2975
|
async getUpdatePerpMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment) {
|
|
1662
2976
|
return await this.program.instruction.updatePerpMarketFeeAdjustment(feeAdjustment, {
|
|
1663
2977
|
accounts: {
|
|
@@ -1669,12 +2983,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1669
2983
|
},
|
|
1670
2984
|
});
|
|
1671
2985
|
}
|
|
2986
|
+
/**
|
|
2987
|
+
* Sets the retention buffer the streaming fee sweep leaves in a perp market's pnl pool on top
|
|
2988
|
+
* of `max(netUserPnl, 0)` before the IF/AMM-provision drains take their cut (the protocol
|
|
2989
|
+
* drain is exempt and always runs). Requires warm admin (`check_warm`). See
|
|
2990
|
+
* `perp_market.fee_pool_buffer_target`'s doc comment for why the buffer exists (a swept pool
|
|
2991
|
+
* is short on the next adverse oracle tick, and sweeps are a one-way valve).
|
|
2992
|
+
* @param perpMarketIndex - Perp market to update.
|
|
2993
|
+
* @param feePoolBufferTarget - Pnl-pool retention buffer, QUOTE_PRECISION (1e6).
|
|
2994
|
+
* @returns Transaction signature.
|
|
2995
|
+
*/
|
|
1672
2996
|
async updatePerpMarketFeePoolBufferTarget(perpMarketIndex, feePoolBufferTarget) {
|
|
1673
2997
|
const updatePerpMarketFeePoolBufferTargetIx = await this.getUpdatePerpMarketFeePoolBufferTargetIx(perpMarketIndex, feePoolBufferTarget);
|
|
1674
2998
|
const tx = await this.buildTransaction(updatePerpMarketFeePoolBufferTargetIx);
|
|
1675
2999
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1676
3000
|
return txSig;
|
|
1677
3001
|
}
|
|
3002
|
+
/**
|
|
3003
|
+
* Builds the `updatePerpMarketFeePoolBufferTarget` instruction without sending it. See
|
|
3004
|
+
* `updatePerpMarketFeePoolBufferTarget`.
|
|
3005
|
+
* @returns The unsigned `updatePerpMarketFeePoolBufferTarget` instruction.
|
|
3006
|
+
*/
|
|
1678
3007
|
async getUpdatePerpMarketFeePoolBufferTargetIx(perpMarketIndex, feePoolBufferTarget) {
|
|
1679
3008
|
return await this.program.instruction.updatePerpMarketFeePoolBufferTarget(feePoolBufferTarget, {
|
|
1680
3009
|
accounts: {
|
|
@@ -1686,12 +3015,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1686
3015
|
},
|
|
1687
3016
|
});
|
|
1688
3017
|
}
|
|
3018
|
+
/**
|
|
3019
|
+
* Scales a spot market's taker fee and maker rebate up or down by a percentage of the base
|
|
3020
|
+
* fee tier. Requires warm admin (`check_warm`). Throws `DefaultError` on-chain if
|
|
3021
|
+
* `abs(feeAdjustment) > FEE_ADJUSTMENT_MAX` (100). Note: the first parameter is a **spot**
|
|
3022
|
+
* market index despite being named `perpMarketIndex` here.
|
|
3023
|
+
* @param perpMarketIndex - Spot market index to update (misnamed; not a perp market index).
|
|
3024
|
+
* @param feeAdjustment - Percent adjustment applied to the base taker fee / maker rebate, -100..100 (negative reduces, positive increases; 0 = no adjustment).
|
|
3025
|
+
* @returns Transaction signature.
|
|
3026
|
+
*/
|
|
1689
3027
|
async updateSpotMarketFeeAdjustment(perpMarketIndex, feeAdjustment) {
|
|
1690
3028
|
const updateSpotMarketFeeAdjustmentIx = await this.getUpdateSpotMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment);
|
|
1691
3029
|
const tx = await this.buildTransaction(updateSpotMarketFeeAdjustmentIx);
|
|
1692
3030
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1693
3031
|
return txSig;
|
|
1694
3032
|
}
|
|
3033
|
+
/**
|
|
3034
|
+
* Builds the `updateSpotMarketFeeAdjustment` instruction without sending it. See
|
|
3035
|
+
* `updateSpotMarketFeeAdjustment`.
|
|
3036
|
+
* @returns The unsigned `updateSpotMarketFeeAdjustment` instruction.
|
|
3037
|
+
*/
|
|
1695
3038
|
async getUpdateSpotMarketFeeAdjustmentIx(spotMarketIndex, feeAdjustment) {
|
|
1696
3039
|
return await this.program.instruction.updateSpotMarketFeeAdjustment(feeAdjustment, {
|
|
1697
3040
|
accounts: {
|
|
@@ -1703,12 +3046,31 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1703
3046
|
},
|
|
1704
3047
|
});
|
|
1705
3048
|
}
|
|
3049
|
+
/**
|
|
3050
|
+
* Sets the three-way split of a perp market's liquidation fee: the cut paid to the
|
|
3051
|
+
* liquidator, the cut routed to the insurance fund, and the cut kept by the protocol.
|
|
3052
|
+
* Requires warm admin (`check_warm`). On-chain, throws `DefaultError` unless
|
|
3053
|
+
* `liquidatorFee + ifLiquidationFee + protocolLiquidationFee < LIQUIDATION_FEE_PRECISION`,
|
|
3054
|
+
* `ifLiquidationFee < LIQUIDATION_FEE_PRECISION`, and `protocolLiquidationFee <=
|
|
3055
|
+
* LIQUIDATION_FEE_PRECISION / 10` (10%); also re-validates `liquidatorFee` against the
|
|
3056
|
+
* market's current margin ratios (`amm.validate_compatible_with_liquidation_fee`).
|
|
3057
|
+
* @param perpMarketIndex - Perp market to update.
|
|
3058
|
+
* @param liquidatorFee - Fee paid to the liquidator, LIQUIDATION_FEE_PRECISION (1e6).
|
|
3059
|
+
* @param ifLiquidationFee - Portion routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6).
|
|
3060
|
+
* @param protocolLiquidationFee - Portion kept by the protocol, LIQUIDATION_FEE_PRECISION (1e6). Max 10% of precision. Default 0.
|
|
3061
|
+
* @returns Transaction signature.
|
|
3062
|
+
*/
|
|
1706
3063
|
async updatePerpMarketLiquidationFee(perpMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee = 0) {
|
|
1707
3064
|
const updatePerpMarketLiquidationFeeIx = await this.getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee);
|
|
1708
3065
|
const tx = await this.buildTransaction(updatePerpMarketLiquidationFeeIx);
|
|
1709
3066
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1710
3067
|
return txSig;
|
|
1711
3068
|
}
|
|
3069
|
+
/**
|
|
3070
|
+
* Builds the `updatePerpMarketLiquidationFee` instruction without sending it. See
|
|
3071
|
+
* `updatePerpMarketLiquidationFee`.
|
|
3072
|
+
* @returns The unsigned `updatePerpMarketLiquidationFee` instruction.
|
|
3073
|
+
*/
|
|
1712
3074
|
async getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee = 0) {
|
|
1713
3075
|
return await this.program.instruction.updatePerpMarketLiquidationFee(liquidatorFee, ifLiquidationFee, protocolLiquidationFee, {
|
|
1714
3076
|
accounts: {
|
|
@@ -1720,12 +3082,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1720
3082
|
},
|
|
1721
3083
|
});
|
|
1722
3084
|
}
|
|
3085
|
+
/**
|
|
3086
|
+
* Sets the three-way split of a spot market's liquidation fee: the cut paid to the
|
|
3087
|
+
* liquidator, the cut routed to the insurance fund, and the cut kept by the protocol.
|
|
3088
|
+
* Requires warm admin (`check_warm`). On-chain, throws `DefaultError` unless
|
|
3089
|
+
* `liquidatorFee + ifLiquidationFee + protocolLiquidationFee < LIQUIDATION_FEE_PRECISION`,
|
|
3090
|
+
* and both `ifLiquidationFee` and `protocolLiquidationFee` are each
|
|
3091
|
+
* <= `LIQUIDATION_FEE_PRECISION / 10` (10%).
|
|
3092
|
+
* @param spotMarketIndex - Spot market to update.
|
|
3093
|
+
* @param liquidatorFee - Fee paid to the liquidator, LIQUIDATION_FEE_PRECISION (1e6).
|
|
3094
|
+
* @param ifLiquidationFee - Portion routed to the insurance fund, LIQUIDATION_FEE_PRECISION (1e6). Max 10% of precision.
|
|
3095
|
+
* @param protocolLiquidationFee - Portion kept by the protocol, LIQUIDATION_FEE_PRECISION (1e6). Max 10% of precision. Default 0.
|
|
3096
|
+
* @returns Transaction signature.
|
|
3097
|
+
*/
|
|
1723
3098
|
async updateSpotMarketLiquidationFee(spotMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee = 0) {
|
|
1724
3099
|
const updateSpotMarketLiquidationFeeIx = await this.getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee);
|
|
1725
3100
|
const tx = await this.buildTransaction(updateSpotMarketLiquidationFeeIx);
|
|
1726
3101
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1727
3102
|
return txSig;
|
|
1728
3103
|
}
|
|
3104
|
+
/**
|
|
3105
|
+
* Builds the `updateSpotMarketLiquidationFee` instruction without sending it. See
|
|
3106
|
+
* `updateSpotMarketLiquidationFee`.
|
|
3107
|
+
* @returns The unsigned `updateSpotMarketLiquidationFee` instruction.
|
|
3108
|
+
*/
|
|
1729
3109
|
async getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee, protocolLiquidationFee = 0) {
|
|
1730
3110
|
return await this.program.instruction.updateSpotMarketLiquidationFee(liquidatorFee, ifLiquidationFee, protocolLiquidationFee, {
|
|
1731
3111
|
accounts: {
|
|
@@ -1737,12 +3117,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1737
3117
|
},
|
|
1738
3118
|
});
|
|
1739
3119
|
}
|
|
3120
|
+
/**
|
|
3121
|
+
* Cold-only. Sets the treasury pubkey that `withdrawProtocolFeesPerp` /
|
|
3122
|
+
* `withdrawProtocolFeesSpot` pay out to. Perp (quote-denominated) and spot
|
|
3123
|
+
* (per-market-token) recipients are independent — `marketType` selects which one
|
|
3124
|
+
* this call updates. Withdrawals for a market type are inert (the fee-withdraw ix
|
|
3125
|
+
* always fails) until its recipient is set to a non-default pubkey.
|
|
3126
|
+
* @param protocolFeeRecipient - New recipient wallet; its ATA (per mint) receives future withdrawals.
|
|
3127
|
+
* @param marketType - Which recipient slot to update, `MarketType.PERP` or `MarketType.SPOT`.
|
|
3128
|
+
* @returns Transaction signature.
|
|
3129
|
+
*/
|
|
1740
3130
|
async updateProtocolFeeRecipient(protocolFeeRecipient, marketType) {
|
|
1741
3131
|
const ix = await this.getUpdateProtocolFeeRecipientIx(protocolFeeRecipient, marketType);
|
|
1742
3132
|
const tx = await this.buildTransaction(ix);
|
|
1743
3133
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1744
3134
|
return txSig;
|
|
1745
3135
|
}
|
|
3136
|
+
/**
|
|
3137
|
+
* Builds the `updateProtocolFeeRecipient` instruction without sending it. See
|
|
3138
|
+
* `updateProtocolFeeRecipient`.
|
|
3139
|
+
* @returns The unsigned `updateProtocolFeeRecipient` instruction.
|
|
3140
|
+
*/
|
|
1746
3141
|
async getUpdateProtocolFeeRecipientIx(protocolFeeRecipient, marketType) {
|
|
1747
3142
|
return await this.program.instruction.updateProtocolFeeRecipient(protocolFeeRecipient, marketType, {
|
|
1748
3143
|
accounts: {
|
|
@@ -1753,12 +3148,32 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1753
3148
|
},
|
|
1754
3149
|
});
|
|
1755
3150
|
}
|
|
3151
|
+
/**
|
|
3152
|
+
* Withdraws a spot market's accrued protocol fees (lending-interest + spot-liquidation
|
|
3153
|
+
* carveouts, tracked in `spotMarket.protocolFeePool`) from its vault to
|
|
3154
|
+
* `state.protocolFeeRecipientSpot`'s ATA. Requires `HotRole.FeeWithdraw` (cold, warm,
|
|
3155
|
+
* or the configured fee-withdraw hot key) — `this.wallet` must hold that role, since
|
|
3156
|
+
* `getWithdrawProtocolFeesSpotIx` signs as `this.wallet.publicKey` for both `payer`
|
|
3157
|
+
* and `authority`. The recipient ATA is created (`init_if_needed`) if missing. The
|
|
3158
|
+
* withdrawn amount is capped at whatever is actually available, and the vault must
|
|
3159
|
+
* still fully cover depositor backing afterward or the instruction fails.
|
|
3160
|
+
* @param marketIndex - Spot market to withdraw protocol fees from.
|
|
3161
|
+
* @param amount - Requested amount, the market's native token decimals (clamped down to the available balance on-chain).
|
|
3162
|
+
* @param txParams - Optional transaction-building overrides.
|
|
3163
|
+
* @returns Transaction signature.
|
|
3164
|
+
*/
|
|
1756
3165
|
async withdrawProtocolFeesSpot(marketIndex, amount, txParams) {
|
|
1757
3166
|
const ix = await this.getWithdrawProtocolFeesSpotIx(marketIndex, amount);
|
|
1758
3167
|
const tx = await this.buildTransaction(ix, txParams);
|
|
1759
3168
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1760
3169
|
return txSig;
|
|
1761
3170
|
}
|
|
3171
|
+
/**
|
|
3172
|
+
* Builds the `withdrawProtocolFeesSpot` instruction without sending it. Also wires
|
|
3173
|
+
* up transfer-hook remaining accounts if the market's mint requires them. See
|
|
3174
|
+
* `withdrawProtocolFeesSpot`.
|
|
3175
|
+
* @returns The unsigned `withdrawProtocolFeesSpot` instruction.
|
|
3176
|
+
*/
|
|
1762
3177
|
async getWithdrawProtocolFeesSpotIx(marketIndex, amount) {
|
|
1763
3178
|
const spotMarket = this.getSpotMarketAccountOrThrow(marketIndex);
|
|
1764
3179
|
const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarket);
|
|
@@ -1786,12 +3201,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1786
3201
|
remainingAccounts,
|
|
1787
3202
|
});
|
|
1788
3203
|
}
|
|
3204
|
+
/**
|
|
3205
|
+
* Withdraws a perp market's accrued protocol fees (quote-denominated, tracked in
|
|
3206
|
+
* `perpMarket.protocolFeePool`) from the quote spot market's vault to
|
|
3207
|
+
* `state.protocolFeeRecipientPerp`'s ATA. Requires `HotRole.FeeWithdraw` — see
|
|
3208
|
+
* `withdrawProtocolFeesSpot` for the same signer/ATA/clamping/vault-invariant
|
|
3209
|
+
* behavior (this mirrors it against the perp market's quote-denominated pool
|
|
3210
|
+
* instead of a spot market's own token).
|
|
3211
|
+
* @param marketIndex - Perp market to withdraw protocol fees from.
|
|
3212
|
+
* @param amount - Requested amount, QUOTE_PRECISION (1e6) (clamped down to the available balance on-chain).
|
|
3213
|
+
* @param txParams - Optional transaction-building overrides.
|
|
3214
|
+
* @returns Transaction signature.
|
|
3215
|
+
*/
|
|
1789
3216
|
async withdrawProtocolFeesPerp(marketIndex, amount, txParams) {
|
|
1790
3217
|
const ix = await this.getWithdrawProtocolFeesPerpIx(marketIndex, amount);
|
|
1791
3218
|
const tx = await this.buildTransaction(ix, txParams);
|
|
1792
3219
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1793
3220
|
return txSig;
|
|
1794
3221
|
}
|
|
3222
|
+
/**
|
|
3223
|
+
* Builds the `withdrawProtocolFeesPerp` instruction without sending it. Also wires
|
|
3224
|
+
* up transfer-hook remaining accounts if the quote market's mint requires them. See
|
|
3225
|
+
* `withdrawProtocolFeesPerp`.
|
|
3226
|
+
* @returns The unsigned `withdrawProtocolFeesPerp` instruction.
|
|
3227
|
+
*/
|
|
1795
3228
|
async getWithdrawProtocolFeesPerpIx(marketIndex, amount) {
|
|
1796
3229
|
const perpMarket = this.getPerpMarketAccountOrThrow(marketIndex);
|
|
1797
3230
|
const quoteSpotMarket = this.getSpotMarketAccountOrThrow(perpMarket.quoteSpotMarketIndex);
|
|
@@ -1821,12 +3254,31 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1821
3254
|
remainingAccounts,
|
|
1822
3255
|
});
|
|
1823
3256
|
}
|
|
3257
|
+
/**
|
|
3258
|
+
* Creates a market-local synthetic "oracle" account (`PrelaunchOracle`) for a perp market
|
|
3259
|
+
* that has no real price feed yet (e.g. a pre-launch/pre-listing market), seeded with an
|
|
3260
|
+
* admin-supplied price. Requires warm admin (`check_warm`). Set the market's `oracle` to
|
|
3261
|
+
* this account's address (via `updatePerpMarketOracle`, with a matching `OracleSource`) to
|
|
3262
|
+
* use it. `PrelaunchOracle::validate` runs at the end of the handler and throws
|
|
3263
|
+
* `InvalidOracle` if `price` or `maxPrice` end up `0` (both are zero-initialized and only
|
|
3264
|
+
* set when the corresponding argument is provided) or if `price > maxPrice` — in practice
|
|
3265
|
+
* both must be supplied and satisfy `price <= maxPrice`.
|
|
3266
|
+
* @param perpMarketIndex - Perp market this oracle backs; fixes the PDA seed.
|
|
3267
|
+
* @param price - Initial synthetic price, PRICE_PRECISION (1e6). Must be nonzero and <= `maxPrice`.
|
|
3268
|
+
* @param maxPrice - Ceiling the price is allowed to move to, PRICE_PRECISION (1e6). Must be nonzero and >= `price`.
|
|
3269
|
+
* @returns Transaction signature.
|
|
3270
|
+
*/
|
|
1824
3271
|
async initializePrelaunchOracle(perpMarketIndex, price, maxPrice) {
|
|
1825
3272
|
const initializePrelaunchOracleIx = await this.getInitializePrelaunchOracleIx(perpMarketIndex, price, maxPrice);
|
|
1826
3273
|
const tx = await this.buildTransaction(initializePrelaunchOracleIx);
|
|
1827
3274
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1828
3275
|
return txSig;
|
|
1829
3276
|
}
|
|
3277
|
+
/**
|
|
3278
|
+
* Builds the `initializePrelaunchOracle` instruction without sending it. See
|
|
3279
|
+
* `initializePrelaunchOracle`.
|
|
3280
|
+
* @returns The unsigned `initializePrelaunchOracle` instruction.
|
|
3281
|
+
*/
|
|
1830
3282
|
async getInitializePrelaunchOracleIx(perpMarketIndex, price, maxPrice) {
|
|
1831
3283
|
const params = {
|
|
1832
3284
|
perpMarketIndex,
|
|
@@ -1845,12 +3297,31 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1845
3297
|
},
|
|
1846
3298
|
});
|
|
1847
3299
|
}
|
|
3300
|
+
/**
|
|
3301
|
+
* Updates a perp market's `PrelaunchOracle` price and/or ceiling. Requires warm admin
|
|
3302
|
+
* (`check_warm`). If `price` is provided, this **also directly overwrites the perp market's
|
|
3303
|
+
* mark-price TWAPs** (`lastMarkPriceTwap`, `lastMarkPriceTwap5min`, and clamps
|
|
3304
|
+
* `lastBidPriceTwap`/`lastAskPriceTwap` toward the new price) and their timestamp — a much
|
|
3305
|
+
* broader side effect than the field name suggests. `PrelaunchOracle::validate` re-runs at
|
|
3306
|
+
* the end and throws `InvalidOracle` if the resulting `price`/`maxPrice` are `0` or
|
|
3307
|
+
* `price > maxPrice`. Either argument omitted leaves that field (and, for `price`, the TWAPs)
|
|
3308
|
+
* unchanged.
|
|
3309
|
+
* @param perpMarketIndex - Perp market whose prelaunch oracle to update.
|
|
3310
|
+
* @param price - New synthetic price, PRICE_PRECISION (1e6). Also overwrites the market's mark-price TWAPs when provided. Omit to leave unchanged.
|
|
3311
|
+
* @param maxPrice - New price ceiling, PRICE_PRECISION (1e6). Omit to leave unchanged.
|
|
3312
|
+
* @returns Transaction signature.
|
|
3313
|
+
*/
|
|
1848
3314
|
async updatePrelaunchOracleParams(perpMarketIndex, price, maxPrice) {
|
|
1849
3315
|
const updatePrelaunchOracleParamsIx = await this.getUpdatePrelaunchOracleParamsIx(perpMarketIndex, price, maxPrice);
|
|
1850
3316
|
const tx = await this.buildTransaction(updatePrelaunchOracleParamsIx);
|
|
1851
3317
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1852
3318
|
return txSig;
|
|
1853
3319
|
}
|
|
3320
|
+
/**
|
|
3321
|
+
* Builds the `updatePrelaunchOracleParams` instruction without sending it. See
|
|
3322
|
+
* `updatePrelaunchOracleParams`.
|
|
3323
|
+
* @returns The unsigned `updatePrelaunchOracleParams` instruction.
|
|
3324
|
+
*/
|
|
1854
3325
|
async getUpdatePrelaunchOracleParamsIx(perpMarketIndex, price, maxPrice) {
|
|
1855
3326
|
const params = {
|
|
1856
3327
|
perpMarketIndex,
|
|
@@ -1869,12 +3340,32 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1869
3340
|
},
|
|
1870
3341
|
});
|
|
1871
3342
|
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Closes a perp market's `PrelaunchOracle` account and refunds rent to the admin. Requires
|
|
3345
|
+
* warm admin (`check_warm`). On-chain, throws `DefaultError` if the oracle is still the
|
|
3346
|
+
* market's active `oracle` — repoint the market to a different oracle first (via
|
|
3347
|
+
* `updatePerpMarketOracle`).
|
|
3348
|
+
*
|
|
3349
|
+
* **Currently broken**: `getDeletePrelaunchOracleIx` builds a `PrelaunchOracleParams`-shaped
|
|
3350
|
+
* object (`{ perpMarketIndex, price, maxPrice }`) as the instruction argument, but the
|
|
3351
|
+
* on-chain `deletePrelaunchOracle` instruction (and its IDL) takes a single `u16`
|
|
3352
|
+
* `perpMarketIndex` scalar, not that object — this throws when the Borsh encoder tries to
|
|
3353
|
+
* serialize an object where a `u16` is expected.
|
|
3354
|
+
* @param perpMarketIndex - Perp market whose prelaunch oracle to delete; must not be the market's current oracle.
|
|
3355
|
+
* @returns Transaction signature (in practice: throws before a transaction is built).
|
|
3356
|
+
*/
|
|
1872
3357
|
async deletePrelaunchOracle(perpMarketIndex) {
|
|
1873
3358
|
const deletePrelaunchOracleIx = await this.getDeletePrelaunchOracleIx(perpMarketIndex);
|
|
1874
3359
|
const tx = await this.buildTransaction(deletePrelaunchOracleIx);
|
|
1875
3360
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1876
3361
|
return txSig;
|
|
1877
3362
|
}
|
|
3363
|
+
/**
|
|
3364
|
+
* Builds the (currently broken) `deletePrelaunchOracle` instruction. See
|
|
3365
|
+
* `deletePrelaunchOracle` — throws because the argument shape doesn't match the IDL's `u16`.
|
|
3366
|
+
* `price`/`maxPrice` are accepted but unused; the underlying call never reads them.
|
|
3367
|
+
* @returns Never resolves successfully; throws when the malformed instruction args are encoded.
|
|
3368
|
+
*/
|
|
1878
3369
|
async getDeletePrelaunchOracleIx(perpMarketIndex, price, maxPrice) {
|
|
1879
3370
|
const params = {
|
|
1880
3371
|
perpMarketIndex,
|
|
@@ -1893,12 +3384,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1893
3384
|
},
|
|
1894
3385
|
});
|
|
1895
3386
|
}
|
|
3387
|
+
/**
|
|
3388
|
+
* Overrides how many slots of oracle delay a perp market tolerates before its "low-risk"
|
|
3389
|
+
* oracle-staleness check (`OracleValidity`'s `is_stale_for_amm_low_risk`, consumed by margin
|
|
3390
|
+
* calculations, order fills, AMM repeg/refresh, and the AMM cache) trips. Gated on
|
|
3391
|
+
* `HotAdminUpdatePerpMarket`, whose account constraint is actually `check_warm` — this
|
|
3392
|
+
* requires **warm** admin (or cold), not a dedicated hot key, despite the struct's name.
|
|
3393
|
+
* `0` (the default) means no override — the market falls back to the global
|
|
3394
|
+
* `state.oracleGuardRails.validity.slotsBeforeStaleForAmm`; a nonzero value is clamped to
|
|
3395
|
+
* `>= 0` and used as the slot threshold directly.
|
|
3396
|
+
* @param perpMarketIndex - Perp market to update.
|
|
3397
|
+
* @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`.
|
|
3398
|
+
* @returns Transaction signature.
|
|
3399
|
+
*/
|
|
1896
3400
|
async updatePerpMarketOracleLowRiskSlotDelayOverride(perpMarketIndex, oracleLowRiskSlotDelayOverride) {
|
|
1897
3401
|
const updatePerpMarketOracleLowRiskSlotDelayOverrideIx = await this.getUpdatePerpMarketOracleLowRiskSlotDelayOverrideIx(perpMarketIndex, oracleLowRiskSlotDelayOverride);
|
|
1898
3402
|
const tx = await this.buildTransaction(updatePerpMarketOracleLowRiskSlotDelayOverrideIx);
|
|
1899
3403
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1900
3404
|
return txSig;
|
|
1901
3405
|
}
|
|
3406
|
+
/**
|
|
3407
|
+
* Builds the `updatePerpMarketOracleLowRiskSlotDelayOverride` instruction without sending it.
|
|
3408
|
+
* See `updatePerpMarketOracleLowRiskSlotDelayOverride`.
|
|
3409
|
+
* @returns The unsigned `updatePerpMarketOracleLowRiskSlotDelayOverride` instruction.
|
|
3410
|
+
*/
|
|
1902
3411
|
async getUpdatePerpMarketOracleLowRiskSlotDelayOverrideIx(perpMarketIndex, oracleLowRiskSlotDelayOverride) {
|
|
1903
3412
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1904
3413
|
return await this.program.instruction.updatePerpMarketOracleLowRiskSlotDelayOverride(oracleLowRiskSlotDelayOverride, {
|
|
@@ -1911,12 +3420,29 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1911
3420
|
},
|
|
1912
3421
|
});
|
|
1913
3422
|
}
|
|
3423
|
+
/**
|
|
3424
|
+
* Overrides how many slots of oracle delay a perp market tolerates before its "immediate"
|
|
3425
|
+
* per-fill staleness check trips (used for AMM-immediate fills; the on-chain field is
|
|
3426
|
+
* `perpMarket.oracleSlotDelayOverride`, default `-1`). Gated on `HotAdminUpdatePerpMarket`,
|
|
3427
|
+
* whose account constraint is actually `check_warm` — this requires **warm** admin (or
|
|
3428
|
+
* cold), not a dedicated hot key. `0` means the market is always treated as stale for
|
|
3429
|
+
* immediate AMM actions; any other value is clamped to `>= 0` and used as the slot threshold
|
|
3430
|
+
* (delay > threshold is stale).
|
|
3431
|
+
* @param perpMarketIndex - Perp market to update.
|
|
3432
|
+
* @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.
|
|
3433
|
+
* @returns Transaction signature.
|
|
3434
|
+
*/
|
|
1914
3435
|
async updatePerpMarketOracleSlotDelayOverride(perpMarketIndex, oracleSlotDelay) {
|
|
1915
3436
|
const updatePerpMarketOracleSlotDelayOverrideIx = await this.getUpdatePerpMarketOracleSlotDelayOverrideIx(perpMarketIndex, oracleSlotDelay);
|
|
1916
3437
|
const tx = await this.buildTransaction(updatePerpMarketOracleSlotDelayOverrideIx);
|
|
1917
3438
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1918
3439
|
return txSig;
|
|
1919
3440
|
}
|
|
3441
|
+
/**
|
|
3442
|
+
* Builds the `updatePerpMarketOracleSlotDelayOverride` instruction without sending it. See
|
|
3443
|
+
* `updatePerpMarketOracleSlotDelayOverride`.
|
|
3444
|
+
* @returns The unsigned `updatePerpMarketOracleSlotDelayOverride` instruction.
|
|
3445
|
+
*/
|
|
1920
3446
|
async getUpdatePerpMarketOracleSlotDelayOverrideIx(perpMarketIndex, oracleSlotDelay) {
|
|
1921
3447
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1922
3448
|
return await this.program.instruction.updatePerpMarketOracleSlotDelayOverride(oracleSlotDelay, {
|
|
@@ -1929,12 +3455,31 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1929
3455
|
},
|
|
1930
3456
|
});
|
|
1931
3457
|
}
|
|
3458
|
+
/**
|
|
3459
|
+
* Sets a perp market's manual spread-widening scalars. Gated on `HotAdminUpdatePerpMarket`,
|
|
3460
|
+
* whose account constraint is actually `check_warm` — this requires **warm** admin (or
|
|
3461
|
+
* cold), not a dedicated hot key. **`referencePriceOffset` is accepted for wire/IDL
|
|
3462
|
+
* compatibility but ignored on-chain** — `amm.referencePriceOffset` is a per-crank output
|
|
3463
|
+
* recomputed from inventory and market stats by
|
|
3464
|
+
* `crate::vlp::amm::math::spread::update_amm_quote_state`, not an admin-settable value; pass
|
|
3465
|
+
* any value.
|
|
3466
|
+
* @param perpMarketIndex - Perp market to update.
|
|
3467
|
+
* @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).
|
|
3468
|
+
* @param ammInventorySpreadAdjustment - Signed scalar on the inventory-skew component of the spread, same -100..100 convention.
|
|
3469
|
+
* @param referencePriceOffset - Ignored on-chain; retained only for instruction-argument compatibility.
|
|
3470
|
+
* @returns Transaction signature.
|
|
3471
|
+
*/
|
|
1932
3472
|
async updatePerpMarketAmmSpreadAdjustment(perpMarketIndex, ammSpreadAdjustment, ammInventorySpreadAdjustment, referencePriceOffset) {
|
|
1933
3473
|
const updatePerpMarketAmmSpreadAdjustmentIx = await this.getUpdatePerpMarketAmmSpreadAdjustmentIx(perpMarketIndex, ammSpreadAdjustment, ammInventorySpreadAdjustment, referencePriceOffset);
|
|
1934
3474
|
const tx = await this.buildTransaction(updatePerpMarketAmmSpreadAdjustmentIx);
|
|
1935
3475
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1936
3476
|
return txSig;
|
|
1937
3477
|
}
|
|
3478
|
+
/**
|
|
3479
|
+
* Builds the `updatePerpMarketAmmSpreadAdjustment` instruction without sending it. See
|
|
3480
|
+
* `updatePerpMarketAmmSpreadAdjustment`.
|
|
3481
|
+
* @returns The unsigned `updatePerpMarketAmmSpreadAdjustment` instruction.
|
|
3482
|
+
*/
|
|
1938
3483
|
async getUpdatePerpMarketAmmSpreadAdjustmentIx(perpMarketIndex, ammSpreadAdjustment, ammInventorySpreadAdjustment, referencePriceOffset) {
|
|
1939
3484
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1940
3485
|
return await this.program.instruction.updatePerpMarketAmmSpreadAdjustment(ammSpreadAdjustment, ammInventorySpreadAdjustment, referencePriceOffset, {
|
|
@@ -1947,12 +3492,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1947
3492
|
},
|
|
1948
3493
|
});
|
|
1949
3494
|
}
|
|
3495
|
+
/**
|
|
3496
|
+
* Sets how much a perp market's paying-side spread widens while the vAMM's inventory is
|
|
3497
|
+
* paying funding: `amm.fundingBiasSensitivity = s` gives multiplier `β(f) = 1 + s/100 * ρ(f)`
|
|
3498
|
+
* (at full ramp, `ρ = 1`: 50 -> 1.5x, 100 -> 2x). Gated on `HotAdminUpdatePerpMarket`, whose
|
|
3499
|
+
* account constraint is actually `check_warm` — this requires **warm** admin (or cold), not
|
|
3500
|
+
* a dedicated hot key.
|
|
3501
|
+
* @param perpMarketIndex - Perp market to update.
|
|
3502
|
+
* @param fundingBiasSensitivity - Sensitivity `s`, in hundredths (value/100 is the multiplier slope); `0` disables the bias. `u8` range caps `s` at 2.55.
|
|
3503
|
+
* @returns Transaction signature.
|
|
3504
|
+
*/
|
|
1950
3505
|
async updatePerpMarketFundingBiasSensitivity(perpMarketIndex, fundingBiasSensitivity) {
|
|
1951
3506
|
const updatePerpMarketFundingBiasSensitivityIx = await this.getUpdatePerpMarketFundingBiasSensitivityIx(perpMarketIndex, fundingBiasSensitivity);
|
|
1952
3507
|
const tx = await this.buildTransaction(updatePerpMarketFundingBiasSensitivityIx);
|
|
1953
3508
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1954
3509
|
return txSig;
|
|
1955
3510
|
}
|
|
3511
|
+
/**
|
|
3512
|
+
* Builds the `updatePerpMarketFundingBiasSensitivity` instruction without sending it. See
|
|
3513
|
+
* `updatePerpMarketFundingBiasSensitivity`.
|
|
3514
|
+
* @returns The unsigned `updatePerpMarketFundingBiasSensitivity` instruction.
|
|
3515
|
+
*/
|
|
1956
3516
|
async getUpdatePerpMarketFundingBiasSensitivityIx(perpMarketIndex, fundingBiasSensitivity) {
|
|
1957
3517
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1958
3518
|
return await this.program.instruction.updatePerpMarketFundingBiasSensitivity(fundingBiasSensitivity, {
|
|
@@ -1965,12 +3525,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1965
3525
|
},
|
|
1966
3526
|
});
|
|
1967
3527
|
}
|
|
3528
|
+
/**
|
|
3529
|
+
* Creates the zero'd `PythLazerOracle` PDA for a Pyth Lazer feed id (one-time setup
|
|
3530
|
+
* before that feed can be pushed to via `updatePythLazerOracle`/keeper cranks).
|
|
3531
|
+
* Requires warm admin (`check_warm`, `InitPythLazerOracle` context). Idempotent per
|
|
3532
|
+
* `feedId` — a second call for the same id fails (`init` on an existing PDA).
|
|
3533
|
+
* @param feedId - Pyth Lazer feed id; seeds the `PythLazerOracle` PDA (`getPythLazerOraclePublicKey`).
|
|
3534
|
+
* @returns Transaction signature.
|
|
3535
|
+
*/
|
|
1968
3536
|
async initializePythLazerOracle(feedId) {
|
|
1969
3537
|
const initializePythLazerOracleIx = await this.getInitializePythLazerOracleIx(feedId);
|
|
1970
3538
|
const tx = await this.buildTransaction(initializePythLazerOracleIx);
|
|
1971
3539
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1972
3540
|
return txSig;
|
|
1973
3541
|
}
|
|
3542
|
+
/**
|
|
3543
|
+
* Builds the `initializePythLazerOracle` instruction without sending it. See
|
|
3544
|
+
* `initializePythLazerOracle`.
|
|
3545
|
+
* @returns The unsigned `initializePythLazerOracle` instruction.
|
|
3546
|
+
*/
|
|
1974
3547
|
async getInitializePythLazerOracleIx(feedId) {
|
|
1975
3548
|
return await this.program.instruction.initializePythLazerOracle(feedId, {
|
|
1976
3549
|
accounts: {
|
|
@@ -1984,12 +3557,29 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
1984
3557
|
},
|
|
1985
3558
|
});
|
|
1986
3559
|
}
|
|
3560
|
+
/**
|
|
3561
|
+
* Deposits tokens from an admin-controlled token account directly into a user's
|
|
3562
|
+
* spot balance, recorded as a `DepositExplanation.Reward` deposit (e.g. crediting a
|
|
3563
|
+
* promotional/reward balance without the user signing). Requires
|
|
3564
|
+
* `HotRole.VaultDeposit` (cold, warm, or the configured vault-deposit hot key) —
|
|
3565
|
+
* `this.wallet` signs as `admin` and must hold that role.
|
|
3566
|
+
* @param marketIndex - Spot market to deposit into.
|
|
3567
|
+
* @param amount - Deposit amount, the market's native token decimals.
|
|
3568
|
+
* @param depositUserAccount - User account (`User` PDA pubkey) to credit.
|
|
3569
|
+
* @param adminTokenAccount - Source token account (must belong to `this.wallet`). Defaults to `this.wallet`'s associated token account for the market's mint.
|
|
3570
|
+
* @returns Transaction signature.
|
|
3571
|
+
*/
|
|
1987
3572
|
async adminDeposit(marketIndex, amount, depositUserAccount, adminTokenAccount) {
|
|
1988
3573
|
const ix = await this.getAdminDepositIx(marketIndex, amount, depositUserAccount, adminTokenAccount);
|
|
1989
3574
|
const tx = await this.buildTransaction(ix);
|
|
1990
3575
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1991
3576
|
return txSig;
|
|
1992
3577
|
}
|
|
3578
|
+
/**
|
|
3579
|
+
* Builds the `adminDeposit` instruction without sending it. Also wires up the
|
|
3580
|
+
* mint and transfer-hook remaining accounts the deposit needs. See `adminDeposit`.
|
|
3581
|
+
* @returns The unsigned `adminDeposit` instruction.
|
|
3582
|
+
*/
|
|
1993
3583
|
async getAdminDepositIx(marketIndex, amount, depositUserAccount, adminTokenAccount) {
|
|
1994
3584
|
const state = await this.getStatePublicKey();
|
|
1995
3585
|
const spotMarket = this.getSpotMarketAccountOrThrow(marketIndex);
|
|
@@ -2013,12 +3603,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2013
3603
|
},
|
|
2014
3604
|
});
|
|
2015
3605
|
}
|
|
3606
|
+
/**
|
|
3607
|
+
* Resets a perp market's push-oracle ("MM oracle") state — `marketStats.mmOraclePrice`,
|
|
3608
|
+
* `mmOracleSequenceId`, and `mmOracleSlot` — all to `0`. Requires warm admin (the
|
|
3609
|
+
* `HotAdminUpdatePerpMarket` context's `check_warm` constraint — despite the name,
|
|
3610
|
+
* no dedicated hot role is wired to it; see `updatePerpMarketCurveUpdateIntensity`
|
|
3611
|
+
* for the same gate). Use to force the next `updateMmOracleNative` push to be
|
|
3612
|
+
* treated as a fresh bootstrap (its step-size cap is skipped when the previous
|
|
3613
|
+
* price is `0`).
|
|
3614
|
+
* @param marketIndex - Perp market whose MM oracle fields to zero.
|
|
3615
|
+
* @returns Transaction signature.
|
|
3616
|
+
*/
|
|
2016
3617
|
async zeroMMOracleFields(marketIndex) {
|
|
2017
3618
|
const zeroMMOracleFieldsIx = await this.getZeroMMOracleFieldsIx(marketIndex);
|
|
2018
3619
|
const tx = await this.buildTransaction(zeroMMOracleFieldsIx);
|
|
2019
3620
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2020
3621
|
return txSig;
|
|
2021
3622
|
}
|
|
3623
|
+
/**
|
|
3624
|
+
* Builds the `zeroMMOracleFields` instruction without sending it. See
|
|
3625
|
+
* `zeroMMOracleFields`.
|
|
3626
|
+
* @returns The unsigned `zeroMmOracleFields` instruction.
|
|
3627
|
+
*/
|
|
2022
3628
|
async getZeroMMOracleFieldsIx(marketIndex) {
|
|
2023
3629
|
return await this.program.instruction.zeroMmOracleFields({
|
|
2024
3630
|
accounts: {
|
|
@@ -2030,12 +3636,29 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2030
3636
|
},
|
|
2031
3637
|
});
|
|
2032
3638
|
}
|
|
3639
|
+
/**
|
|
3640
|
+
* Toggles the `FeatureBitFlags.MM_ORACLE_UPDATE` bit on `state.featureBitFlags`,
|
|
3641
|
+
* which gates the native (non-Anchor) `updateMmOracleNative` push-oracle
|
|
3642
|
+
* dispatch — the on-chain handler asserts this bit before accepting a push.
|
|
3643
|
+
* Requires `HotRole.FeatureFlag` (`HotAdminUpdateState`'s `check_hot`) to disable,
|
|
3644
|
+
* but **enabling requires `state.coldAdmin` specifically** — the handler rejects
|
|
3645
|
+
* `enable: true` from any other signer, even one otherwise authorised for the
|
|
3646
|
+
* `FeatureFlag` role, so a compromised feature-flag hot key can only trip this
|
|
3647
|
+
* kill switch, never clear it.
|
|
3648
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
3649
|
+
* @returns Transaction signature.
|
|
3650
|
+
*/
|
|
2033
3651
|
async updateFeatureBitFlagsMMOracle(enable) {
|
|
2034
3652
|
const updateFeatureBitFlagsMMOracleIx = await this.getUpdateFeatureBitFlagsMMOracleIx(enable);
|
|
2035
3653
|
const tx = await this.buildTransaction(updateFeatureBitFlagsMMOracleIx);
|
|
2036
3654
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2037
3655
|
return txSig;
|
|
2038
3656
|
}
|
|
3657
|
+
/**
|
|
3658
|
+
* Builds the `updateFeatureBitFlagsMMOracle` instruction without sending it. See
|
|
3659
|
+
* `updateFeatureBitFlagsMMOracle`.
|
|
3660
|
+
* @returns The unsigned `updateFeatureBitFlagsMmOracle` instruction.
|
|
3661
|
+
*/
|
|
2039
3662
|
async getUpdateFeatureBitFlagsMMOracleIx(enable) {
|
|
2040
3663
|
return await this.program.instruction.updateFeatureBitFlagsMmOracle(enable, {
|
|
2041
3664
|
accounts: {
|
|
@@ -2046,12 +3669,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2046
3669
|
},
|
|
2047
3670
|
});
|
|
2048
3671
|
}
|
|
3672
|
+
/**
|
|
3673
|
+
* Toggles the `FeatureBitFlags.BUILDER_CODES` bit on `state.featureBitFlags`
|
|
3674
|
+
* (gates builder-code fee-attribution instructions protocol-wide). Same
|
|
3675
|
+
* kill-switch gating as `updateFeatureBitFlagsMMOracle`: `HotRole.FeatureFlag` may
|
|
3676
|
+
* disable, only `coldAdmin` may enable.
|
|
3677
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
3678
|
+
* @returns Transaction signature.
|
|
3679
|
+
*/
|
|
2049
3680
|
async updateFeatureBitFlagsBuilderCodes(enable) {
|
|
2050
3681
|
const updateFeatureBitFlagsBuilderCodesIx = await this.getUpdateFeatureBitFlagsBuilderCodesIx(enable);
|
|
2051
3682
|
const tx = await this.buildTransaction(updateFeatureBitFlagsBuilderCodesIx);
|
|
2052
3683
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2053
3684
|
return txSig;
|
|
2054
3685
|
}
|
|
3686
|
+
/**
|
|
3687
|
+
* Builds the `updateFeatureBitFlagsBuilderCodes` instruction without sending it.
|
|
3688
|
+
* See `updateFeatureBitFlagsBuilderCodes`.
|
|
3689
|
+
* @returns The unsigned `updateFeatureBitFlagsBuilderCodes` instruction.
|
|
3690
|
+
*/
|
|
2055
3691
|
async getUpdateFeatureBitFlagsBuilderCodesIx(enable) {
|
|
2056
3692
|
return this.program.instruction.updateFeatureBitFlagsBuilderCodes(enable, {
|
|
2057
3693
|
accounts: {
|
|
@@ -2062,12 +3698,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2062
3698
|
},
|
|
2063
3699
|
});
|
|
2064
3700
|
}
|
|
3701
|
+
/**
|
|
3702
|
+
* @deprecated There is no `BuilderReferral` bit in the on-chain `FeatureBitFlags`
|
|
3703
|
+
* enum (only `MmOracleUpdate`, `MedianTriggerPrice`, `BuilderCodes` exist) and no
|
|
3704
|
+
* `update_feature_bit_flags_builder_referral` instruction is defined in the
|
|
3705
|
+
* program or present in the IDL. Calling this (or
|
|
3706
|
+
* `getUpdateFeatureBitFlagsBuilderReferralIx`) throws at runtime — hence the
|
|
3707
|
+
* `as any` cast on `this.program.instruction` used to bypass the TS type check.
|
|
3708
|
+
* Do not call until (and unless) a matching on-chain instruction ships.
|
|
3709
|
+
* @param enable - Intended flag state (unused while dead).
|
|
3710
|
+
* @returns Transaction signature (never reached).
|
|
3711
|
+
*/
|
|
2065
3712
|
async updateFeatureBitFlagsBuilderReferral(enable) {
|
|
2066
3713
|
const updateFeatureBitFlagsBuilderReferralIx = await this.getUpdateFeatureBitFlagsBuilderReferralIx(enable);
|
|
2067
3714
|
const tx = await this.buildTransaction(updateFeatureBitFlagsBuilderReferralIx);
|
|
2068
3715
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2069
3716
|
return txSig;
|
|
2070
3717
|
}
|
|
3718
|
+
/**
|
|
3719
|
+
* @deprecated See `updateFeatureBitFlagsBuilderReferral` — no matching instruction
|
|
3720
|
+
* exists on-chain or in the IDL; this throws at runtime.
|
|
3721
|
+
* @returns Never resolves successfully.
|
|
3722
|
+
*/
|
|
2071
3723
|
async getUpdateFeatureBitFlagsBuilderReferralIx(enable) {
|
|
2072
3724
|
return this.program.instruction.updateFeatureBitFlagsBuilderReferral(enable, {
|
|
2073
3725
|
accounts: {
|
|
@@ -2078,12 +3730,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2078
3730
|
},
|
|
2079
3731
|
});
|
|
2080
3732
|
}
|
|
3733
|
+
/**
|
|
3734
|
+
* Toggles the `FeatureBitFlags.MEDIAN_TRIGGER_PRICE` bit on
|
|
3735
|
+
* `state.featureBitFlags` (gates using a median of price sources for trigger-order
|
|
3736
|
+
* evaluation). Same kill-switch gating as `updateFeatureBitFlagsMMOracle`:
|
|
3737
|
+
* `HotRole.FeatureFlag` may disable, only `coldAdmin` may enable.
|
|
3738
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
3739
|
+
* @returns Transaction signature.
|
|
3740
|
+
*/
|
|
2081
3741
|
async updateFeatureBitFlagsMedianTriggerPrice(enable) {
|
|
2082
3742
|
const updateFeatureBitFlagsMedianTriggerPriceIx = await this.getUpdateFeatureBitFlagsMedianTriggerPriceIx(enable);
|
|
2083
3743
|
const tx = await this.buildTransaction(updateFeatureBitFlagsMedianTriggerPriceIx);
|
|
2084
3744
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2085
3745
|
return txSig;
|
|
2086
3746
|
}
|
|
3747
|
+
/**
|
|
3748
|
+
* Builds the `updateFeatureBitFlagsMedianTriggerPrice` instruction without sending
|
|
3749
|
+
* it. See `updateFeatureBitFlagsMedianTriggerPrice`.
|
|
3750
|
+
* @returns The unsigned `updateFeatureBitFlagsMedianTriggerPrice` instruction.
|
|
3751
|
+
*/
|
|
2087
3752
|
async getUpdateFeatureBitFlagsMedianTriggerPriceIx(enable) {
|
|
2088
3753
|
return await this.program.instruction.updateFeatureBitFlagsMedianTriggerPrice(enable, {
|
|
2089
3754
|
accounts: {
|
|
@@ -2094,12 +3759,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2094
3759
|
},
|
|
2095
3760
|
});
|
|
2096
3761
|
}
|
|
3762
|
+
/**
|
|
3763
|
+
* Toggles the `LpPoolFeatureBitFlags.SettleLpPool`-equivalent bit on
|
|
3764
|
+
* `state.lpPoolFeatureBitFlags` (gates `settlePerpToLpPool`/LP-pool settlement
|
|
3765
|
+
* protocol-wide). Same kill-switch gating as `updateFeatureBitFlagsMMOracle`:
|
|
3766
|
+
* `HotRole.FeatureFlag` may disable, only `coldAdmin` may enable.
|
|
3767
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
3768
|
+
* @returns Transaction signature.
|
|
3769
|
+
*/
|
|
2097
3770
|
async updateFeatureBitFlagsSettleLpPool(enable) {
|
|
2098
3771
|
const updateFeatureBitFlagsSettleLpPoolIx = await this.getUpdateFeatureBitFlagsSettleLpPoolIx(enable);
|
|
2099
3772
|
const tx = await this.buildTransaction(updateFeatureBitFlagsSettleLpPoolIx);
|
|
2100
3773
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2101
3774
|
return txSig;
|
|
2102
3775
|
}
|
|
3776
|
+
/**
|
|
3777
|
+
* Builds the `updateFeatureBitFlagsSettleLpPool` instruction without sending it.
|
|
3778
|
+
* See `updateFeatureBitFlagsSettleLpPool`.
|
|
3779
|
+
* @returns The unsigned `updateFeatureBitFlagsSettleLpPool` instruction.
|
|
3780
|
+
*/
|
|
2103
3781
|
async getUpdateFeatureBitFlagsSettleLpPoolIx(enable) {
|
|
2104
3782
|
return await this.program.instruction.updateFeatureBitFlagsSettleLpPool(enable, {
|
|
2105
3783
|
accounts: {
|
|
@@ -2110,12 +3788,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2110
3788
|
},
|
|
2111
3789
|
});
|
|
2112
3790
|
}
|
|
3791
|
+
/**
|
|
3792
|
+
* Toggles the LP-pool swap-enabled bit on `state.lpPoolFeatureBitFlags` (gates
|
|
3793
|
+
* `lpPoolSwap`/begin-end swap flows protocol-wide). Same kill-switch gating as
|
|
3794
|
+
* `updateFeatureBitFlagsMMOracle`: `HotRole.FeatureFlag` may disable, only
|
|
3795
|
+
* `coldAdmin` may enable.
|
|
3796
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
3797
|
+
* @returns Transaction signature.
|
|
3798
|
+
*/
|
|
2113
3799
|
async updateFeatureBitFlagsSwapLpPool(enable) {
|
|
2114
3800
|
const updateFeatureBitFlagsSettleLpPoolIx = await this.getUpdateFeatureBitFlagsSwapLpPoolIx(enable);
|
|
2115
3801
|
const tx = await this.buildTransaction(updateFeatureBitFlagsSettleLpPoolIx);
|
|
2116
3802
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2117
3803
|
return txSig;
|
|
2118
3804
|
}
|
|
3805
|
+
/**
|
|
3806
|
+
* Builds the `updateFeatureBitFlagsSwapLpPool` instruction without sending it. See
|
|
3807
|
+
* `updateFeatureBitFlagsSwapLpPool`.
|
|
3808
|
+
* @returns The unsigned `updateFeatureBitFlagsSwapLpPool` instruction.
|
|
3809
|
+
*/
|
|
2119
3810
|
async getUpdateFeatureBitFlagsSwapLpPoolIx(enable) {
|
|
2120
3811
|
return await this.program.instruction.updateFeatureBitFlagsSwapLpPool(enable, {
|
|
2121
3812
|
accounts: {
|
|
@@ -2126,12 +3817,25 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2126
3817
|
},
|
|
2127
3818
|
});
|
|
2128
3819
|
}
|
|
3820
|
+
/**
|
|
3821
|
+
* Toggles the LP-pool mint/redeem-enabled bit on `state.lpPoolFeatureBitFlags`
|
|
3822
|
+
* (gates `lpPoolAddLiquidity`/`lpPoolRemoveLiquidity` protocol-wide). Same
|
|
3823
|
+
* kill-switch gating as `updateFeatureBitFlagsMMOracle`: `HotRole.FeatureFlag` may
|
|
3824
|
+
* disable, only `coldAdmin` may enable.
|
|
3825
|
+
* @param enable - `true` to enable (cold-admin-only), `false` to disable (any `FeatureFlag`-authorised signer).
|
|
3826
|
+
* @returns Transaction signature.
|
|
3827
|
+
*/
|
|
2129
3828
|
async updateFeatureBitFlagsMintRedeemLpPool(enable) {
|
|
2130
3829
|
const updateFeatureBitFlagsSettleLpPoolIx = await this.getUpdateFeatureBitFlagsMintRedeemLpPoolIx(enable);
|
|
2131
3830
|
const tx = await this.buildTransaction(updateFeatureBitFlagsSettleLpPoolIx);
|
|
2132
3831
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2133
3832
|
return txSig;
|
|
2134
3833
|
}
|
|
3834
|
+
/**
|
|
3835
|
+
* Builds the `updateFeatureBitFlagsMintRedeemLpPool` instruction without sending
|
|
3836
|
+
* it. See `updateFeatureBitFlagsMintRedeemLpPool`.
|
|
3837
|
+
* @returns The unsigned `updateFeatureBitFlagsMintRedeemLpPool` instruction.
|
|
3838
|
+
*/
|
|
2135
3839
|
async getUpdateFeatureBitFlagsMintRedeemLpPoolIx(enable) {
|
|
2136
3840
|
return await this.program.instruction.updateFeatureBitFlagsMintRedeemLpPool(enable, {
|
|
2137
3841
|
accounts: {
|
|
@@ -2142,12 +3846,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2142
3846
|
},
|
|
2143
3847
|
});
|
|
2144
3848
|
}
|
|
3849
|
+
/**
|
|
3850
|
+
* Sets a user's `UserStats.pausedOperations` bitmask. Reachable by cold, warm,
|
|
3851
|
+
* `HotRole.UserFlag`, or `pauseAdmin` (`PauseAdminUpdateUserStats`'s constraint
|
|
3852
|
+
* ORs `check_pause` with `check_hot(.., UserFlag)`). A caller authorised only via
|
|
3853
|
+
* `pauseAdmin` (i.e. not cold/warm/`UserFlag`) may add pause bits but never clear
|
|
3854
|
+
* one; cold/warm/`UserFlag` may set any value. The `admin` account below defaults
|
|
3855
|
+
* to `coldAdmin`; other roles must override it with their own pubkey.
|
|
3856
|
+
* @param authority - Wallet authority whose `UserStats` PDA to update (derives the PDA).
|
|
3857
|
+
* @param pausedOperations - New pause bitmask for the user's stats account.
|
|
3858
|
+
* @returns Transaction signature.
|
|
3859
|
+
*/
|
|
2145
3860
|
async adminUpdateUserStatsPausedOperations(authority, pausedOperations) {
|
|
2146
3861
|
const updateUserStatsPausedOperationsIx = await this.getAdminUpdateUserStatsPausedOperationsIx(authority, pausedOperations);
|
|
2147
3862
|
const tx = await this.buildTransaction(updateUserStatsPausedOperationsIx);
|
|
2148
3863
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2149
3864
|
return txSig;
|
|
2150
3865
|
}
|
|
3866
|
+
/**
|
|
3867
|
+
* Builds the `adminUpdateUserStatsPausedOperations` instruction without sending
|
|
3868
|
+
* it. See `adminUpdateUserStatsPausedOperations`.
|
|
3869
|
+
* @returns The unsigned `adminUpdateUserStatsPausedOperations` instruction.
|
|
3870
|
+
*/
|
|
2151
3871
|
async getAdminUpdateUserStatsPausedOperationsIx(authority, pausedOperations) {
|
|
2152
3872
|
return await this.program.instruction.adminUpdateUserStatsPausedOperations(pausedOperations, {
|
|
2153
3873
|
accounts: {
|
|
@@ -2159,12 +3879,32 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2159
3879
|
},
|
|
2160
3880
|
});
|
|
2161
3881
|
}
|
|
3882
|
+
/**
|
|
3883
|
+
* Creates a new LP pool: mints its 6-decimal LP-token mint (fresh `mint` keypair,
|
|
3884
|
+
* mint authority set to the `lpPool` PDA), then initializes the `LPPool` account
|
|
3885
|
+
* plus its (initially empty) `AmmConstituentMapping`, `ConstituentTargetBase`, and
|
|
3886
|
+
* `ConstituentCorrelations` side accounts. Requires warm admin (`check_warm`).
|
|
3887
|
+
* Constituents (backing spot-market assets) are added afterward via
|
|
3888
|
+
* `initializeConstituent`.
|
|
3889
|
+
* @param lpPoolId - New pool's id byte; seeds the `LPPool` PDA (`getLpPoolPublicKey`).
|
|
3890
|
+
* @param minMintFee - Minimum fee floor charged on mint, signed, PERCENTAGE_PRECISION (1e6).
|
|
3891
|
+
* @param maxAum - AUM cap above which minting new LP tokens is rejected, QUOTE_PRECISION (1e6).
|
|
3892
|
+
* @param maxSettleQuoteAmountPerMarket - Per-perp-market cap on quote settled into/out of the pool per settlement, QUOTE_PRECISION (1e6).
|
|
3893
|
+
* @param mint - Fresh keypair for the pool's LP-token mint; funded and initialized by this call, and must co-sign.
|
|
3894
|
+
* @param whitelistMint - Optional token that gates who may mint/redeem this pool's LP token (see `updateLpPoolParams`). Defaults to `PublicKey.default` (no gating).
|
|
3895
|
+
* @returns Transaction signature.
|
|
3896
|
+
*/
|
|
2162
3897
|
async initializeLpPool(lpPoolId, minMintFee, maxAum, maxSettleQuoteAmountPerMarket, mint, whitelistMint) {
|
|
2163
3898
|
const ixs = await this.getInitializeLpPoolIx(lpPoolId, minMintFee, maxAum, maxSettleQuoteAmountPerMarket, mint, whitelistMint);
|
|
2164
3899
|
const tx = await this.buildTransaction(ixs);
|
|
2165
3900
|
const { txSig } = await this.sendTransaction(tx, [mint]);
|
|
2166
3901
|
return txSig;
|
|
2167
3902
|
}
|
|
3903
|
+
/**
|
|
3904
|
+
* Builds the `createAccount` + `initializeMint2` + `initializeLpPool` instructions
|
|
3905
|
+
* without sending them. See `initializeLpPool`.
|
|
3906
|
+
* @returns The unsigned instructions (mint account creation, mint init, pool init) in order; `mint` must also sign the transaction.
|
|
3907
|
+
*/
|
|
2168
3908
|
async getInitializeLpPoolIx(lpPoolId, minMintFee, maxAum, maxSettleQuoteAmountPerMarket, mint, whitelistMint) {
|
|
2169
3909
|
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2170
3910
|
const ammConstituentMapping = (0, pda_1.getAmmConstituentMappingPublicKey)(this.program.programId, lpPool);
|
|
@@ -2199,12 +3939,29 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2199
3939
|
}),
|
|
2200
3940
|
];
|
|
2201
3941
|
}
|
|
3942
|
+
/**
|
|
3943
|
+
* Adds a new constituent (backing spot-market asset) to an existing LP pool:
|
|
3944
|
+
* creates its `Constituent` PDA + token vault, appends a slot to
|
|
3945
|
+
* `ConstituentTargetBase`, and records its correlation row in
|
|
3946
|
+
* `ConstituentCorrelations`. Requires warm admin (`check_warm`). On-chain,
|
|
3947
|
+
* `newConstituentCorrelations`'s length must equal the pool's current constituent
|
|
3948
|
+
* count *before* this call (one correlation entry per existing constituent); the
|
|
3949
|
+
* new constituent's `constituentIndex` is assigned as the next sequential index.
|
|
3950
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
3951
|
+
* @param initializeConstituentParams - Constituent configuration; see `InitializeConstituentParams` for per-field precision.
|
|
3952
|
+
* @returns Transaction signature.
|
|
3953
|
+
*/
|
|
2202
3954
|
async initializeConstituent(lpPoolId, initializeConstituentParams) {
|
|
2203
3955
|
const ixs = await this.getInitializeConstituentIx(lpPoolId, initializeConstituentParams);
|
|
2204
3956
|
const tx = await this.buildTransaction(ixs);
|
|
2205
3957
|
const { txSig } = await this.sendTransaction(tx, []);
|
|
2206
3958
|
return txSig;
|
|
2207
3959
|
}
|
|
3960
|
+
/**
|
|
3961
|
+
* Builds the `initializeConstituent` instruction without sending it. See
|
|
3962
|
+
* `initializeConstituent`.
|
|
3963
|
+
* @returns The unsigned `initializeConstituent` instruction, as a single-element array.
|
|
3964
|
+
*/
|
|
2208
3965
|
async getInitializeConstituentIx(lpPoolId, initializeConstituentParams) {
|
|
2209
3966
|
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2210
3967
|
const spotMarketIndex = initializeConstituentParams.spotMarketIndex;
|
|
@@ -2245,12 +4002,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2245
4002
|
}),
|
|
2246
4003
|
];
|
|
2247
4004
|
}
|
|
4005
|
+
/**
|
|
4006
|
+
* Sets an LP-pool constituent's lifecycle `status` (`ConstituentStatus`: `ACTIVE`,
|
|
4007
|
+
* `REDUCE_ONLY`, or `DECOMMISSIONED`). Requires warm admin (`check_warm`).
|
|
4008
|
+
* `REDUCE_ONLY` restricts flows to only shrink the constituent toward its target
|
|
4009
|
+
* weight; `DECOMMISSIONED` marks it as having no remaining participants.
|
|
4010
|
+
* @param constituent - Constituent PDA to update.
|
|
4011
|
+
* @param constituentStatus - New status.
|
|
4012
|
+
* @returns Transaction signature.
|
|
4013
|
+
*/
|
|
2248
4014
|
async updateConstituentStatus(constituent, constituentStatus) {
|
|
2249
4015
|
const updateConstituentStatusIx = await this.getUpdateConstituentStatusIx(constituent, constituentStatus);
|
|
2250
4016
|
const tx = await this.buildTransaction(updateConstituentStatusIx);
|
|
2251
4017
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2252
4018
|
return txSig;
|
|
2253
4019
|
}
|
|
4020
|
+
/**
|
|
4021
|
+
* Builds the `updateConstituentStatus` instruction without sending it. See
|
|
4022
|
+
* `updateConstituentStatus`.
|
|
4023
|
+
* @returns The unsigned `updateConstituentStatus` instruction.
|
|
4024
|
+
*/
|
|
2254
4025
|
async getUpdateConstituentStatusIx(constituent, constituentStatus) {
|
|
2255
4026
|
return await this.program.instruction.updateConstituentStatus(constituentStatus, {
|
|
2256
4027
|
accounts: {
|
|
@@ -2262,12 +4033,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2262
4033
|
},
|
|
2263
4034
|
});
|
|
2264
4035
|
}
|
|
4036
|
+
/**
|
|
4037
|
+
* Sets an LP-pool constituent's `pausedOperations` bitmask (`ConstituentLpOperation`:
|
|
4038
|
+
* `Swap`/`Deposit`/`Withdraw`). Requires warm admin (`check_warm`) — despite the
|
|
4039
|
+
* `useHotWalletAdmin` flag name used for the default `admin` account below, no
|
|
4040
|
+
* dedicated hot role exists for this ix; the signer must be cold or warm.
|
|
4041
|
+
* @param constituent - Constituent PDA to update.
|
|
4042
|
+
* @param pausedOperations - New pause bitmask, `ConstituentLpOperation` bit values.
|
|
4043
|
+
* @returns Transaction signature.
|
|
4044
|
+
*/
|
|
2265
4045
|
async updateConstituentPausedOperations(constituent, pausedOperations) {
|
|
2266
4046
|
const updateConstituentPausedOperationsIx = await this.getUpdateConstituentPausedOperationsIx(constituent, pausedOperations);
|
|
2267
4047
|
const tx = await this.buildTransaction(updateConstituentPausedOperationsIx);
|
|
2268
4048
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2269
4049
|
return txSig;
|
|
2270
4050
|
}
|
|
4051
|
+
/**
|
|
4052
|
+
* Builds the `updateConstituentPausedOperations` instruction without sending it.
|
|
4053
|
+
* See `updateConstituentPausedOperations`.
|
|
4054
|
+
* @returns The unsigned `updateConstituentPausedOperations` instruction.
|
|
4055
|
+
*/
|
|
2271
4056
|
async getUpdateConstituentPausedOperationsIx(constituent, pausedOperations) {
|
|
2272
4057
|
return await this.program.instruction.updateConstituentPausedOperations(pausedOperations, {
|
|
2273
4058
|
accounts: {
|
|
@@ -2279,12 +4064,32 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2279
4064
|
},
|
|
2280
4065
|
});
|
|
2281
4066
|
}
|
|
4067
|
+
/**
|
|
4068
|
+
* Patches an LP-pool constituent's tunable params — each field is optional and
|
|
4069
|
+
* only the ones provided overwrite the on-chain value (see `ConstituentAccount`
|
|
4070
|
+
* for per-field precision, which matches these params 1:1). Requires warm admin
|
|
4071
|
+
* (`check_warm`); the underlying ix builder resolves `admin` as `this.wallet`
|
|
4072
|
+
* directly (no cold/warm fallback), so `this.wallet` must itself hold that role.
|
|
4073
|
+
* @param lpPoolId - Constituent's parent LP pool id byte.
|
|
4074
|
+
* @param constituentPublicKey - Constituent PDA to patch.
|
|
4075
|
+
* @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.
|
|
4076
|
+
* @returns Transaction signature.
|
|
4077
|
+
*/
|
|
2282
4078
|
async updateConstituentParams(lpPoolId, constituentPublicKey, updateConstituentParams) {
|
|
2283
4079
|
const ixs = await this.getUpdateConstituentParamsIx(lpPoolId, constituentPublicKey, updateConstituentParams);
|
|
2284
4080
|
const tx = await this.buildTransaction(ixs);
|
|
2285
4081
|
const { txSig } = await this.sendTransaction(tx, []);
|
|
2286
4082
|
return txSig;
|
|
2287
4083
|
}
|
|
4084
|
+
/**
|
|
4085
|
+
* Builds the `updateConstituentParams` instruction without sending it. Note this
|
|
4086
|
+
* method's parameter type omits `costToTradeBps` even though the public
|
|
4087
|
+
* `updateConstituentParams` wrapper's type includes it and forwards it through
|
|
4088
|
+
* unchanged at runtime — call via `updateConstituentParams` (or add the field
|
|
4089
|
+
* manually) if you need to set it while calling this builder directly. See
|
|
4090
|
+
* `updateConstituentParams`.
|
|
4091
|
+
* @returns The unsigned `updateConstituentParams` instruction, as a single-element array.
|
|
4092
|
+
*/
|
|
2288
4093
|
async getUpdateConstituentParamsIx(lpPoolId, constituentPublicKey, updateConstituentParams) {
|
|
2289
4094
|
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2290
4095
|
return [
|
|
@@ -2314,12 +4119,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2314
4119
|
}),
|
|
2315
4120
|
];
|
|
2316
4121
|
}
|
|
4122
|
+
/**
|
|
4123
|
+
* Patches an LP pool's tunable params — each field is optional and only the ones
|
|
4124
|
+
* provided overwrite the on-chain value. Requires warm admin (`check_warm`). If
|
|
4125
|
+
* `maxAum` is provided, on-chain validation rejects lowering it below the pool's
|
|
4126
|
+
* current `maxAum` (the cap may only be raised via this ix).
|
|
4127
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
4128
|
+
* @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.
|
|
4129
|
+
* @returns Transaction signature.
|
|
4130
|
+
*/
|
|
2317
4131
|
async updateLpPoolParams(lpPoolId, updateLpPoolParams) {
|
|
2318
4132
|
const ixs = await this.getUpdateLpPoolParamsIx(lpPoolId, updateLpPoolParams);
|
|
2319
4133
|
const tx = await this.buildTransaction(ixs);
|
|
2320
4134
|
const { txSig } = await this.sendTransaction(tx, []);
|
|
2321
4135
|
return txSig;
|
|
2322
4136
|
}
|
|
4137
|
+
/**
|
|
4138
|
+
* Builds the `updateLpPoolParams` instruction without sending it. See
|
|
4139
|
+
* `updateLpPoolParams`.
|
|
4140
|
+
* @returns The unsigned `updateLpPoolParams` instruction, as a single-element array.
|
|
4141
|
+
*/
|
|
2323
4142
|
async getUpdateLpPoolParamsIx(lpPoolId, updateLpPoolParams) {
|
|
2324
4143
|
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2325
4144
|
return [
|
|
@@ -2340,12 +4159,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2340
4159
|
}),
|
|
2341
4160
|
];
|
|
2342
4161
|
}
|
|
4162
|
+
/**
|
|
4163
|
+
* Adds new (perp market, constituent) weight entries to an LP pool's
|
|
4164
|
+
* `AmmConstituentMapping` — routing that fraction of the perp market's hedge flow
|
|
4165
|
+
* into the given constituent. Requires warm admin (`check_warm`). On-chain,
|
|
4166
|
+
* inserting a `(perpMarketIndex, constituentIndex)` pair that already exists fails
|
|
4167
|
+
* (`InvalidAmmConstituentMappingArgument`) — use `updateAmmConstituentMappingData`
|
|
4168
|
+
* to change an existing entry's weight instead.
|
|
4169
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
4170
|
+
* @param addAmmConstituentMappingData - New entries to add; see `AddAmmConstituentMappingDatum` (`weight` is PERCENTAGE_PRECISION, 1e6).
|
|
4171
|
+
* @returns Transaction signature.
|
|
4172
|
+
*/
|
|
2343
4173
|
async addAmmConstituentMappingData(lpPoolId, addAmmConstituentMappingData) {
|
|
2344
4174
|
const ixs = await this.getAddAmmConstituentMappingDataIx(lpPoolId, addAmmConstituentMappingData);
|
|
2345
4175
|
const tx = await this.buildTransaction(ixs);
|
|
2346
4176
|
const { txSig } = await this.sendTransaction(tx, []);
|
|
2347
4177
|
return txSig;
|
|
2348
4178
|
}
|
|
4179
|
+
/**
|
|
4180
|
+
* Builds the `addAmmConstituentMappingData` instruction without sending it (the
|
|
4181
|
+
* `as any` cast works around a generated-type mismatch, not a missing on-chain
|
|
4182
|
+
* instruction — `add_amm_constituent_mapping_data` is present in the IDL). See
|
|
4183
|
+
* `addAmmConstituentMappingData`.
|
|
4184
|
+
* @returns The unsigned `addAmmConstituentMappingData` instruction, as a single-element array.
|
|
4185
|
+
*/
|
|
2349
4186
|
async getAddAmmConstituentMappingDataIx(lpPoolId, addAmmConstituentMappingData) {
|
|
2350
4187
|
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2351
4188
|
const ammConstituentMapping = (0, pda_1.getAmmConstituentMappingPublicKey)(this.program.programId, lpPool);
|
|
@@ -2364,12 +4201,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2364
4201
|
}),
|
|
2365
4202
|
];
|
|
2366
4203
|
}
|
|
4204
|
+
/**
|
|
4205
|
+
* Updates the weight (and refreshes `lastSlot`) of existing entries in an LP
|
|
4206
|
+
* pool's `AmmConstituentMapping`. Requires warm admin (`check_warm`). On-chain,
|
|
4207
|
+
* every `(perpMarketIndex, constituentIndex)` pair must already exist — an unknown
|
|
4208
|
+
* pair fails with `InvalidAmmConstituentMappingArgument` (use
|
|
4209
|
+
* `addAmmConstituentMappingData` to create new entries).
|
|
4210
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
4211
|
+
* @param addAmmConstituentMappingData - Entries to update in place; see `AddAmmConstituentMappingDatum` (`weight` is PERCENTAGE_PRECISION, 1e6).
|
|
4212
|
+
* @returns Transaction signature.
|
|
4213
|
+
*/
|
|
2367
4214
|
async updateAmmConstituentMappingData(lpPoolId, addAmmConstituentMappingData) {
|
|
2368
4215
|
const ixs = await this.getUpdateAmmConstituentMappingDataIx(lpPoolId, addAmmConstituentMappingData);
|
|
2369
4216
|
const tx = await this.buildTransaction(ixs);
|
|
2370
4217
|
const { txSig } = await this.sendTransaction(tx, []);
|
|
2371
4218
|
return txSig;
|
|
2372
4219
|
}
|
|
4220
|
+
/**
|
|
4221
|
+
* Builds the `updateAmmConstituentMappingData` instruction without sending it. See
|
|
4222
|
+
* `updateAmmConstituentMappingData`.
|
|
4223
|
+
* @returns The unsigned `updateAmmConstituentMappingData` instruction, as a single-element array.
|
|
4224
|
+
*/
|
|
2373
4225
|
async getUpdateAmmConstituentMappingDataIx(lpPoolId, addAmmConstituentMappingData) {
|
|
2374
4226
|
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2375
4227
|
const ammConstituentMapping = (0, pda_1.getAmmConstituentMappingPublicKey)(this.program.programId, lpPool);
|
|
@@ -2385,12 +4237,26 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2385
4237
|
}),
|
|
2386
4238
|
];
|
|
2387
4239
|
}
|
|
4240
|
+
/**
|
|
4241
|
+
* Removes a single `(perpMarketIndex, constituentIndex)` entry from an LP pool's
|
|
4242
|
+
* `AmmConstituentMapping`. Requires warm admin (`check_warm`). Fails
|
|
4243
|
+
* (`InvalidAmmConstituentMappingArgument`) if no matching entry exists.
|
|
4244
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
4245
|
+
* @param perpMarketIndex - Perp market side of the entry to remove.
|
|
4246
|
+
* @param constituentIndex - Constituent side of the entry to remove.
|
|
4247
|
+
* @returns Transaction signature.
|
|
4248
|
+
*/
|
|
2388
4249
|
async removeAmmConstituentMappingData(lpPoolId, perpMarketIndex, constituentIndex) {
|
|
2389
4250
|
const ixs = await this.getRemoveAmmConstituentMappingDataIx(lpPoolId, perpMarketIndex, constituentIndex);
|
|
2390
4251
|
const tx = await this.buildTransaction(ixs);
|
|
2391
4252
|
const { txSig } = await this.sendTransaction(tx, []);
|
|
2392
4253
|
return txSig;
|
|
2393
4254
|
}
|
|
4255
|
+
/**
|
|
4256
|
+
* Builds the `removeAmmConstituentMappingData` instruction without sending it. See
|
|
4257
|
+
* `removeAmmConstituentMappingData`.
|
|
4258
|
+
* @returns The unsigned `removeAmmConstituentMappingData` instruction, as a single-element array.
|
|
4259
|
+
*/
|
|
2394
4260
|
async getRemoveAmmConstituentMappingDataIx(lpPoolId, perpMarketIndex, constituentIndex) {
|
|
2395
4261
|
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2396
4262
|
const ammConstituentMapping = (0, pda_1.getAmmConstituentMappingPublicKey)(this.program.programId, lpPool);
|
|
@@ -2406,12 +4272,27 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2406
4272
|
}),
|
|
2407
4273
|
];
|
|
2408
4274
|
}
|
|
4275
|
+
/**
|
|
4276
|
+
* Sets the correlation between two constituents in an LP pool's
|
|
4277
|
+
* `ConstituentCorrelations` matrix (symmetric — updates both `(index1, index2)`
|
|
4278
|
+
* and `(index2, index1)`). Requires warm admin (`check_warm`).
|
|
4279
|
+
* @param lpPoolId - Target LP pool's id byte.
|
|
4280
|
+
* @param index1 - First constituent's index.
|
|
4281
|
+
* @param index2 - Second constituent's index.
|
|
4282
|
+
* @param correlation - New correlation, PERCENTAGE_PRECISION (1e6), signed.
|
|
4283
|
+
* @returns Transaction signature.
|
|
4284
|
+
*/
|
|
2409
4285
|
async updateConstituentCorrelationData(lpPoolId, index1, index2, correlation) {
|
|
2410
4286
|
const ixs = await this.getUpdateConstituentCorrelationDataIx(lpPoolId, index1, index2, correlation);
|
|
2411
4287
|
const tx = await this.buildTransaction(ixs);
|
|
2412
4288
|
const { txSig } = await this.sendTransaction(tx, []);
|
|
2413
4289
|
return txSig;
|
|
2414
4290
|
}
|
|
4291
|
+
/**
|
|
4292
|
+
* Builds the `updateConstituentCorrelationData` instruction without sending it.
|
|
4293
|
+
* See `updateConstituentCorrelationData`.
|
|
4294
|
+
* @returns The unsigned `updateConstituentCorrelationData` instruction, as a single-element array.
|
|
4295
|
+
*/
|
|
2415
4296
|
async getUpdateConstituentCorrelationDataIx(lpPoolId, index1, index2, correlation) {
|
|
2416
4297
|
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2417
4298
|
return [
|
|
@@ -2498,6 +4379,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2498
4379
|
});
|
|
2499
4380
|
return { beginSwapIx, endSwapIx };
|
|
2500
4381
|
}
|
|
4382
|
+
/**
|
|
4383
|
+
* Builds a flash-loan-style LP-pool swap that routes the actual trade through
|
|
4384
|
+
* Jupiter: wraps a Jupiter swap quote/instruction set between the same
|
|
4385
|
+
* `beginLpSwap`/`endLpSwap` instruction pair `getSwapIx` uses, so the LP pool's
|
|
4386
|
+
* constituent vaults temporarily fund the swap and are repaid by the end of the
|
|
4387
|
+
* transaction (`endLpSwap` fails if the constituents aren't made whole). Fetches
|
|
4388
|
+
* a quote from `jupiterClient` if one isn't passed in.
|
|
4389
|
+
* @param jupiterClient - Jupiter client used to fetch the quote/swap transaction and lookup tables.
|
|
4390
|
+
* @param outMarketIndex - Spot market of the token being bought.
|
|
4391
|
+
* @param inMarketIndex - Spot market of the token being sold.
|
|
4392
|
+
* @param amount - Swap amount, in-market's native decimals (interpreted as exact-in or exact-out per `swapMode`).
|
|
4393
|
+
* @param slippageBps - Optional slippage tolerance passed to Jupiter, basis points.
|
|
4394
|
+
* @param swapMode - Optional `'ExactIn'` / `'ExactOut'`; also inferred from `quote.swapMode` if a quote is supplied.
|
|
4395
|
+
* @param onlyDirectRoutes - Optional, restricts the Jupiter quote to single-hop routes.
|
|
4396
|
+
* @param quote - Optional pre-fetched Jupiter quote; skips the internal fetch if provided.
|
|
4397
|
+
* @param lpPoolId - LP pool id byte the swap routes through.
|
|
4398
|
+
* @returns The unsigned instruction sequence (begin-swap, Jupiter swap instructions, end-swap) and any address lookup tables the Jupiter instructions require.
|
|
4399
|
+
*/
|
|
2501
4400
|
async getLpJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, amount, slippageBps, swapMode, onlyDirectRoutes, quote, lpPoolId, }) {
|
|
2502
4401
|
const outMarket = this.getSpotMarketAccountOrThrow(outMarketIndex);
|
|
2503
4402
|
const inMarket = this.getSpotMarketAccountOrThrow(inMarketIndex);
|
|
@@ -2560,6 +4459,22 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2560
4459
|
];
|
|
2561
4460
|
return { ixs, lookupTables };
|
|
2562
4461
|
}
|
|
4462
|
+
/**
|
|
4463
|
+
* Devnet/test-only helper: builds a plain SPL-token transfer pair simulating an
|
|
4464
|
+
* external counterparty swapping against `this.wallet`'s own token accounts (not
|
|
4465
|
+
* an atomic on-chain program instruction, and not gated by any admin tier — it's
|
|
4466
|
+
* ordinary token transfers assembled for local test flows, typically alongside
|
|
4467
|
+
* `getSwapIx`'s begin/end pair as in `getAllDevnetLpSwapIxs`). Also idempotently
|
|
4468
|
+
* creates the external user's in/out ATAs.
|
|
4469
|
+
* @param amountIn - Amount `this.wallet` sends of the in-market token, that market's native decimals.
|
|
4470
|
+
* @param amountOut - Amount `this.wallet` receives of the out-market token, that market's native decimals.
|
|
4471
|
+
* @param externalUserAuthority - The simulated counterparty's wallet authority.
|
|
4472
|
+
* @param externalUserInTokenAccount - Counterparty's ATA that receives the in-market token.
|
|
4473
|
+
* @param externalUserOutTokenAccount - Counterparty's ATA that sends the out-market token.
|
|
4474
|
+
* @param inSpotMarketIndex - Spot market of the token `this.wallet` sends.
|
|
4475
|
+
* @param outSpotMarketIndex - Spot market of the token `this.wallet` receives.
|
|
4476
|
+
* @returns Unsigned instructions: create both ATAs, then the two transfers.
|
|
4477
|
+
*/
|
|
2563
4478
|
async getDevnetLpSwapIxs(amountIn, amountOut, externalUserAuthority, externalUserInTokenAccount, externalUserOutTokenAccount, inSpotMarketIndex, outSpotMarketIndex) {
|
|
2564
4479
|
const inSpotMarketAccount = this.getSpotMarketAccountOrThrow(inSpotMarketIndex);
|
|
2565
4480
|
const outSpotMarketAccount = this.getSpotMarketAccountOrThrow(outSpotMarketIndex);
|
|
@@ -2577,6 +4492,18 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2577
4492
|
];
|
|
2578
4493
|
return ixs;
|
|
2579
4494
|
}
|
|
4495
|
+
/**
|
|
4496
|
+
* Devnet/test-only helper: wraps `getSwapIx`'s begin/end LP-pool swap pair around
|
|
4497
|
+
* `getDevnetLpSwapIxs`'s simulated-counterparty transfers, producing the full
|
|
4498
|
+
* instruction sequence for an end-to-end devnet LP-pool swap test.
|
|
4499
|
+
* @param lpPoolId - LP pool id byte the swap routes through.
|
|
4500
|
+
* @param inMarketIndex - Spot market of the token going in.
|
|
4501
|
+
* @param outMarketIndex - Spot market of the token coming out.
|
|
4502
|
+
* @param inAmount - Amount going in, in-market's native decimals.
|
|
4503
|
+
* @param minOutAmount - Minimum acceptable amount out, out-market's native decimals (also used as the simulated counterparty's exact transfer amount).
|
|
4504
|
+
* @param externalUserAuthority - The simulated counterparty's wallet authority.
|
|
4505
|
+
* @returns Unsigned instructions: begin-swap, the simulated transfer pair, end-swap, in order.
|
|
4506
|
+
*/
|
|
2580
4507
|
async getAllDevnetLpSwapIxs(lpPoolId, inMarketIndex, outMarketIndex, inAmount, minOutAmount, externalUserAuthority) {
|
|
2581
4508
|
const inMarket = this.getSpotMarketAccountOrThrow(inMarketIndex);
|
|
2582
4509
|
const outMarket = this.getSpotMarketAccountOrThrow(outMarketIndex);
|
|
@@ -2595,12 +4522,35 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2595
4522
|
endSwapIx,
|
|
2596
4523
|
];
|
|
2597
4524
|
}
|
|
4525
|
+
/**
|
|
4526
|
+
* Atomically moves an LP-pool constituent's idle tokens into a spot market's
|
|
4527
|
+
* lending vault (earning yield) and borrows another constituent's tokens back out
|
|
4528
|
+
* of a (possibly different) spot market's vault, in one transaction. Requires
|
|
4529
|
+
* `HotRole.LpSwap` on both legs (`DepositProgramVault`/`WithdrawProgramVault`
|
|
4530
|
+
* contexts) — `this.wallet` signs as `admin` directly and must hold that role.
|
|
4531
|
+
* Each leg re-validates the constituent's borrow/token-amount invariants
|
|
4532
|
+
* on-chain; the withdraw leg additionally caps the transfer at
|
|
4533
|
+
* `constituent.maxBorrowTokenAmount` (+5% buffer).
|
|
4534
|
+
* @param lpPoolId - LP pool whose constituents to move tokens for.
|
|
4535
|
+
* @param depositMarketIndex - Spot market (and matching constituent) to deposit into.
|
|
4536
|
+
* @param borrowMarketIndex - Spot market (and matching constituent) to borrow/withdraw from.
|
|
4537
|
+
* @param amountToDeposit - Deposit amount, the deposit market's native decimals.
|
|
4538
|
+
* @param amountToBorrow - Withdraw amount, the borrow market's native decimals.
|
|
4539
|
+
* @returns Transaction signature.
|
|
4540
|
+
*/
|
|
2598
4541
|
async depositWithdrawToProgramVault(lpPoolId, depositMarketIndex, borrowMarketIndex, amountToDeposit, amountToBorrow) {
|
|
2599
4542
|
const { depositIx, withdrawIx } = await this.getDepositWithdrawToProgramVaultIxs(lpPoolId, depositMarketIndex, borrowMarketIndex, amountToDeposit, amountToBorrow);
|
|
2600
4543
|
const tx = await this.buildTransaction([depositIx, withdrawIx]);
|
|
2601
4544
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2602
4545
|
return txSig;
|
|
2603
4546
|
}
|
|
4547
|
+
/**
|
|
4548
|
+
* Builds the `depositToProgramVault` and `withdrawFromProgramVault` instructions
|
|
4549
|
+
* without sending them. See `depositWithdrawToProgramVault`; also the building
|
|
4550
|
+
* block for `getDepositToProgramVaultIx`/`getWithdrawFromProgramVaultIx`
|
|
4551
|
+
* (each of which calls this with the unused leg's amount set to `0`).
|
|
4552
|
+
* @returns The unsigned `{ depositIx, withdrawIx }` pair.
|
|
4553
|
+
*/
|
|
2604
4554
|
async getDepositWithdrawToProgramVaultIxs(lpPoolId, depositMarketIndex, borrowMarketIndex, amountToDeposit, amountToBorrow) {
|
|
2605
4555
|
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2606
4556
|
const depositSpotMarket = this.getSpotMarketAccountOrThrow(depositMarketIndex);
|
|
@@ -2640,32 +4590,80 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2640
4590
|
});
|
|
2641
4591
|
return { depositIx, withdrawIx };
|
|
2642
4592
|
}
|
|
4593
|
+
/**
|
|
4594
|
+
* Deposits an LP-pool constituent's idle tokens into its spot market's lending
|
|
4595
|
+
* vault, on its own (single-leg version of `depositWithdrawToProgramVault`).
|
|
4596
|
+
* Requires `HotRole.LpSwap`; `this.wallet` must hold that role.
|
|
4597
|
+
* @param lpPoolId - LP pool whose constituent to deposit from.
|
|
4598
|
+
* @param depositMarketIndex - Spot market (and matching constituent) to deposit into.
|
|
4599
|
+
* @param amountToDeposit - Deposit amount, the market's native decimals.
|
|
4600
|
+
* @returns Transaction signature.
|
|
4601
|
+
*/
|
|
2643
4602
|
async depositToProgramVault(lpPoolId, depositMarketIndex, amountToDeposit) {
|
|
2644
4603
|
const depositIx = await this.getDepositToProgramVaultIx(lpPoolId, depositMarketIndex, amountToDeposit);
|
|
2645
4604
|
const tx = await this.buildTransaction([depositIx]);
|
|
2646
4605
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2647
4606
|
return txSig;
|
|
2648
4607
|
}
|
|
4608
|
+
/**
|
|
4609
|
+
* Borrows tokens from a spot market's lending vault back into an LP-pool
|
|
4610
|
+
* constituent, on its own (single-leg version of `depositWithdrawToProgramVault`).
|
|
4611
|
+
* Requires `HotRole.LpSwap`; `this.wallet` must hold that role. On-chain, capped
|
|
4612
|
+
* at `constituent.maxBorrowTokenAmount` (+5% buffer).
|
|
4613
|
+
* @param lpPoolId - LP pool whose constituent to borrow into.
|
|
4614
|
+
* @param borrowMarketIndex - Spot market (and matching constituent) to borrow from.
|
|
4615
|
+
* @param amountToWithdraw - Withdraw amount, the market's native decimals.
|
|
4616
|
+
* @returns Transaction signature.
|
|
4617
|
+
*/
|
|
2649
4618
|
async withdrawFromProgramVault(lpPoolId, borrowMarketIndex, amountToWithdraw) {
|
|
2650
4619
|
const withdrawIx = await this.getWithdrawFromProgramVaultIx(lpPoolId, borrowMarketIndex, amountToWithdraw);
|
|
2651
4620
|
const tx = await this.buildTransaction([withdrawIx]);
|
|
2652
4621
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2653
4622
|
return txSig;
|
|
2654
4623
|
}
|
|
4624
|
+
/**
|
|
4625
|
+
* Builds the `depositToProgramVault` instruction without sending it, via
|
|
4626
|
+
* `getDepositWithdrawToProgramVaultIxs` with a `0` withdraw amount (the
|
|
4627
|
+
* accompanying zero-amount withdraw instruction is discarded, not sent). See
|
|
4628
|
+
* `depositToProgramVault`.
|
|
4629
|
+
* @returns The unsigned `depositToProgramVault` instruction.
|
|
4630
|
+
*/
|
|
2655
4631
|
async getDepositToProgramVaultIx(lpPoolId, depositMarketIndex, amountToDeposit) {
|
|
2656
4632
|
const { depositIx } = await this.getDepositWithdrawToProgramVaultIxs(lpPoolId, depositMarketIndex, depositMarketIndex, amountToDeposit, new anchor_1.BN(0));
|
|
2657
4633
|
return depositIx;
|
|
2658
4634
|
}
|
|
4635
|
+
/**
|
|
4636
|
+
* Builds the `withdrawFromProgramVault` instruction without sending it, via
|
|
4637
|
+
* `getDepositWithdrawToProgramVaultIxs` with a `0` deposit amount (the
|
|
4638
|
+
* accompanying zero-amount deposit instruction is discarded, not sent). See
|
|
4639
|
+
* `withdrawFromProgramVault`.
|
|
4640
|
+
* @returns The unsigned `withdrawFromProgramVault` instruction.
|
|
4641
|
+
*/
|
|
2659
4642
|
async getWithdrawFromProgramVaultIx(lpPoolId, borrowMarketIndex, amountToWithdraw) {
|
|
2660
4643
|
const { withdrawIx } = await this.getDepositWithdrawToProgramVaultIxs(lpPoolId, borrowMarketIndex, borrowMarketIndex, new anchor_1.BN(0), amountToWithdraw);
|
|
2661
4644
|
return withdrawIx;
|
|
2662
4645
|
}
|
|
4646
|
+
/**
|
|
4647
|
+
* Patches a perp market's `hedgeConfig` fee-routing scalars that control how much
|
|
4648
|
+
* of the AMM's fee growth is swept to its LP pool (see `sweepPerpMarketFees`).
|
|
4649
|
+
* Requires warm admin (the `HotAdminUpdatePerpMarketDlp` context's `check_warm`
|
|
4650
|
+
* constraint). Both params are optional; only the ones provided are updated.
|
|
4651
|
+
* @param marketIndex - Perp market to update.
|
|
4652
|
+
* @param lpFeeTransferScalar - `hedgeConfig.feeTransferScalar`, percent 0-100 (divided by 100 on-chain) of AMM fee-pool growth routed to the LP pool.
|
|
4653
|
+
* @param lpExchangeFeeExcluscionScalar - `hedgeConfig.exchangeFeeExclusionScalar`, percent 0-100 of the period's exchange-fee growth excluded from that sweep.
|
|
4654
|
+
* @returns Transaction signature.
|
|
4655
|
+
*/
|
|
2663
4656
|
async updatePerpMarketLpPoolFeeTransferScalar(marketIndex, lpFeeTransferScalar, lpExchangeFeeExcluscionScalar) {
|
|
2664
4657
|
const ix = await this.getUpdatePerpMarketLpPoolFeeTransferScalarIx(marketIndex, lpFeeTransferScalar, lpExchangeFeeExcluscionScalar);
|
|
2665
4658
|
const tx = await this.buildTransaction(ix);
|
|
2666
4659
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2667
4660
|
return txSig;
|
|
2668
4661
|
}
|
|
4662
|
+
/**
|
|
4663
|
+
* Builds the `updatePerpMarketLpPoolFeeTransferScalar` instruction without
|
|
4664
|
+
* sending it. See `updatePerpMarketLpPoolFeeTransferScalar`.
|
|
4665
|
+
* @returns The unsigned `updatePerpMarketLpPoolFeeTransferScalar` instruction.
|
|
4666
|
+
*/
|
|
2669
4667
|
async getUpdatePerpMarketLpPoolFeeTransferScalarIx(marketIndex, lpFeeTransferScalar, lpExchangeFeeExcluscionScalar) {
|
|
2670
4668
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(marketIndex);
|
|
2671
4669
|
return this.program.instruction.updatePerpMarketLpPoolFeeTransferScalar(lpFeeTransferScalar !== null && lpFeeTransferScalar !== void 0 ? lpFeeTransferScalar : null, lpExchangeFeeExcluscionScalar !== null && lpExchangeFeeExcluscionScalar !== void 0 ? lpExchangeFeeExcluscionScalar : null, {
|
|
@@ -2678,12 +4676,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2678
4676
|
},
|
|
2679
4677
|
});
|
|
2680
4678
|
}
|
|
4679
|
+
/**
|
|
4680
|
+
* Sets a perp market's `hedgeConfig.pausedOperations` bitmask
|
|
4681
|
+
* (`ConstituentLpOperation`: `Swap`/`Deposit`/`Withdraw`), pausing that market's
|
|
4682
|
+
* side of LP-pool hedge flow. Reachable by cold, warm, or `pauseAdmin`
|
|
4683
|
+
* (`PauseAdminUpdatePerpMarket`'s `check_pause`), with the same bit-add-only
|
|
4684
|
+
* restriction for a pause-admin-only caller as `updateExchangeStatus`. The
|
|
4685
|
+
* `admin` account below defaults to `coldAdmin`; other roles must override it.
|
|
4686
|
+
* @param marketIndex - Perp market to update.
|
|
4687
|
+
* @param pausedOperations - New pause bitmask, `ConstituentLpOperation` bit values.
|
|
4688
|
+
* @returns Transaction signature.
|
|
4689
|
+
*/
|
|
2681
4690
|
async updatePerpMarketLpPoolPausedOperations(marketIndex, pausedOperations) {
|
|
2682
4691
|
const ix = await this.getUpdatePerpMarketLpPoolPausedOperationsIx(marketIndex, pausedOperations);
|
|
2683
4692
|
const tx = await this.buildTransaction(ix);
|
|
2684
4693
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2685
4694
|
return txSig;
|
|
2686
4695
|
}
|
|
4696
|
+
/**
|
|
4697
|
+
* Builds the `updatePerpMarketLpPoolPausedOperations` instruction without
|
|
4698
|
+
* sending it. See `updatePerpMarketLpPoolPausedOperations`.
|
|
4699
|
+
* @returns The unsigned `updatePerpMarketLpPoolPausedOperations` instruction.
|
|
4700
|
+
*/
|
|
2687
4701
|
async getUpdatePerpMarketLpPoolPausedOperationsIx(marketIndex, pausedOperations) {
|
|
2688
4702
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(marketIndex);
|
|
2689
4703
|
return this.program.instruction.updatePerpMarketLpPoolPausedOperations(pausedOperations, {
|
|
@@ -2696,12 +4710,30 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2696
4710
|
},
|
|
2697
4711
|
});
|
|
2698
4712
|
}
|
|
4713
|
+
/**
|
|
4714
|
+
* Mints `1000` units of an LP pool's `whitelistMint` to `authority`'s associated
|
|
4715
|
+
* token account, creating the ATA if needed. This is a plain SPL-token mint, not
|
|
4716
|
+
* a velocity program instruction — no `HotRole`/tier gate applies; instead the
|
|
4717
|
+
* token program itself requires `this.wallet` to be the mint's authority (set
|
|
4718
|
+
* whenever the whitelist mint was created — typically the same admin that called
|
|
4719
|
+
* `initializeLpPool`/`updateLpPoolParams` to configure it). Holding units of the
|
|
4720
|
+
* whitelist mint is what gates `authority`'s ability to mint/redeem this pool's LP
|
|
4721
|
+
* token, if `lpPool.whitelistMint` is set to a non-default pubkey.
|
|
4722
|
+
* @param lpPool - LP pool whose `whitelistMint` to mint from.
|
|
4723
|
+
* @param authority - Wallet to receive the whitelist tokens.
|
|
4724
|
+
* @returns Transaction signature.
|
|
4725
|
+
*/
|
|
2699
4726
|
async mintLpWhitelistToken(lpPool, authority) {
|
|
2700
4727
|
const ix = await this.getMintLpWhitelistTokenIx(lpPool, authority);
|
|
2701
4728
|
const tx = await this.buildTransaction(ix);
|
|
2702
4729
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2703
4730
|
return txSig;
|
|
2704
4731
|
}
|
|
4732
|
+
/**
|
|
4733
|
+
* Builds the ATA-creation and `mintTo` instructions without sending them. See
|
|
4734
|
+
* `mintLpWhitelistToken`.
|
|
4735
|
+
* @returns The unsigned instructions: idempotent ATA creation, then mint-to, in order.
|
|
4736
|
+
*/
|
|
2705
4737
|
async getMintLpWhitelistTokenIx(lpPool, authority) {
|
|
2706
4738
|
const mintAmount = 1000;
|
|
2707
4739
|
const associatedTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(lpPool.whitelistMint, authority, false);
|
|
@@ -2712,12 +4744,28 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2712
4744
|
ixs.push(mintToInstruction);
|
|
2713
4745
|
return ixs;
|
|
2714
4746
|
}
|
|
4747
|
+
/**
|
|
4748
|
+
* Sets a perp market's `marketConfig` bitmask (currently one bit:
|
|
4749
|
+
* `MarketConfigFlag.DisableFormulaicKUpdate`, which turns off the AMM's automatic
|
|
4750
|
+
* k-adjustment for the market). Requires warm admin (the `HotAdminUpdatePerpMarket`
|
|
4751
|
+
* context's `check_warm` constraint), but **setting any bit (a non-zero value)
|
|
4752
|
+
* requires `state.coldAdmin` specifically** — a warm-only signer may only pass `0`
|
|
4753
|
+
* (clear all bits). Unknown bits are rejected (`InvalidPerpMarketConfig`).
|
|
4754
|
+
* @param marketIndex - Perp market to update.
|
|
4755
|
+
* @param marketConfig - New bitmask; non-zero values require cold admin.
|
|
4756
|
+
* @returns Transaction signature.
|
|
4757
|
+
*/
|
|
2715
4758
|
async updatePerpMarketConfig(marketIndex, marketConfig) {
|
|
2716
4759
|
const ix = await this.getUpdatePerpMarketConfigIx(marketIndex, marketConfig);
|
|
2717
4760
|
const tx = await this.buildTransaction(ix);
|
|
2718
4761
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2719
4762
|
return txSig;
|
|
2720
4763
|
}
|
|
4764
|
+
/**
|
|
4765
|
+
* Builds the `updatePerpMarketConfig` instruction without sending it. See
|
|
4766
|
+
* `updatePerpMarketConfig`.
|
|
4767
|
+
* @returns The unsigned `updatePerpMarketConfig` instruction.
|
|
4768
|
+
*/
|
|
2721
4769
|
async getUpdatePerpMarketConfigIx(marketIndex, marketConfig) {
|
|
2722
4770
|
const perpMarketAccount = this.getPerpMarketAccountOrThrow(marketIndex);
|
|
2723
4771
|
return this.program.instruction.updatePerpMarketConfig(marketConfig, {
|
|
@@ -2730,12 +4778,33 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2730
4778
|
},
|
|
2731
4779
|
});
|
|
2732
4780
|
}
|
|
4781
|
+
/**
|
|
4782
|
+
* Moves quote value between one perp market's protocol fee pool and another (or
|
|
4783
|
+
* the same) perp market's pnl pool — a pure internal ledger transfer against the
|
|
4784
|
+
* shared quote spot market's scaled balances, no tokens actually move. Requires
|
|
4785
|
+
* warm admin (`check_warm`). On-chain, the transfer is capped at the source
|
|
4786
|
+
* pool's available token amount. For a same-market move the AMM's
|
|
4787
|
+
* `totalFeeMinusDistributions` ledger is left untouched (equity-neutral within
|
|
4788
|
+
* one market's perimeter); for a cross-market move, the fee-pool market's ledger
|
|
4789
|
+
* is adjusted to reflect quote leaving/entering its perimeter (reconciled later
|
|
4790
|
+
* by the summary-stats recompute ix).
|
|
4791
|
+
* @param perpMarketIndexWithFeePool - Perp market whose fee pool is the transfer source/destination.
|
|
4792
|
+
* @param perpMarketIndexWithPnlPool - Perp market whose pnl pool is the transfer destination/source.
|
|
4793
|
+
* @param amount - Amount to move, QUOTE_PRECISION (1e6) (clamped down to the source pool's available balance on-chain).
|
|
4794
|
+
* @param direction - `TransferFeeAndPnlPoolDirection.FEE_TO_PNL_POOL` or `.PNL_TO_FEE_POOL`.
|
|
4795
|
+
* @returns Transaction signature.
|
|
4796
|
+
*/
|
|
2733
4797
|
async transferFeeAndPnlPool(perpMarketIndexWithFeePool, perpMarketIndexWithPnlPool, amount, direction) {
|
|
2734
4798
|
const transferFeeAndPnlPoolIx = await this.getTransferFeeAndPnlPoolIx(perpMarketIndexWithFeePool, perpMarketIndexWithPnlPool, amount, direction);
|
|
2735
4799
|
const tx = await this.buildTransaction(transferFeeAndPnlPoolIx);
|
|
2736
4800
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2737
4801
|
return txSig;
|
|
2738
4802
|
}
|
|
4803
|
+
/**
|
|
4804
|
+
* Builds the `transferFeeAndPnlPool` instruction without sending it. See
|
|
4805
|
+
* `transferFeeAndPnlPool`.
|
|
4806
|
+
* @returns The unsigned `transferFeeAndPnlPool` instruction.
|
|
4807
|
+
*/
|
|
2739
4808
|
async getTransferFeeAndPnlPoolIx(perpMarketIndexWithFeePool, perpMarketIndexWithPnlPool, amount, direction) {
|
|
2740
4809
|
return await this.program.instruction.transferFeeAndPnlPool(amount, direction, {
|
|
2741
4810
|
accounts: {
|
|
@@ -2750,12 +4819,29 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2750
4819
|
},
|
|
2751
4820
|
});
|
|
2752
4821
|
}
|
|
4822
|
+
/**
|
|
4823
|
+
* Sets a `User` account's `specialUserStatus` bitmask (`SpecialUserStatus`;
|
|
4824
|
+
* currently one bit, `VAMM_HEDGER`, marking the account the protocol's own
|
|
4825
|
+
* vAMM-hedging bot trades from). Requires `HotRole.UserFlag` (cold, warm, or the
|
|
4826
|
+
* configured user-flag hot key), but **setting any bit (a non-zero value)
|
|
4827
|
+
* requires `state.coldAdmin` specifically** — a `UserFlag`-hot-only signer may
|
|
4828
|
+
* only pass `0` (clear all bits). Unknown bits are rejected (`DefaultError`).
|
|
4829
|
+
* @param userAccountPublicKey - `User` PDA to update.
|
|
4830
|
+
* @param status - New bitmask; non-zero values require cold admin.
|
|
4831
|
+
* @param txParams - Optional transaction-building overrides.
|
|
4832
|
+
* @returns Transaction signature.
|
|
4833
|
+
*/
|
|
2753
4834
|
async updateSpecialUserStatus(userAccountPublicKey, status, txParams) {
|
|
2754
4835
|
const ix = await this.getUpdateSpecialUserStatusIx(userAccountPublicKey, status);
|
|
2755
4836
|
const tx = await this.buildTransaction(ix, txParams);
|
|
2756
4837
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2757
4838
|
return txSig;
|
|
2758
4839
|
}
|
|
4840
|
+
/**
|
|
4841
|
+
* Builds the `updateSpecialUserStatus` instruction without sending it. See
|
|
4842
|
+
* `updateSpecialUserStatus`.
|
|
4843
|
+
* @returns The unsigned `updateSpecialUserStatus` instruction.
|
|
4844
|
+
*/
|
|
2759
4845
|
async getUpdateSpecialUserStatusIx(userAccountPublicKey, status) {
|
|
2760
4846
|
return this.program.instruction.updateSpecialUserStatus(status, {
|
|
2761
4847
|
accounts: {
|
|
@@ -2773,12 +4859,24 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2773
4859
|
// `state.hot*` field is rotated by warm (or cold). COLD ⊇ WARM ⊇ HOT(role).
|
|
2774
4860
|
// `handleInitialize` seeds `coldAdmin = warmAdmin = signer`; there is no
|
|
2775
4861
|
// separate "initialize admin authority config" ix.
|
|
4862
|
+
/**
|
|
4863
|
+
* Rotates `state.warmAdmin`, the operational (multisig+timelock) tier that can
|
|
4864
|
+
* rotate every hot-role key (`updateHotAdmin`). Cold-only: the `UpdateWarmAdmin`
|
|
4865
|
+
* context requires `state.coldAdmin == admin.key()`.
|
|
4866
|
+
* @param newWarmAdmin - New warm admin pubkey. `PublicKey.default()` unsets the role — only `coldAdmin` can then act where warm was accepted.
|
|
4867
|
+
* @returns Transaction signature.
|
|
4868
|
+
*/
|
|
2776
4869
|
async updateWarmAdmin(newWarmAdmin) {
|
|
2777
4870
|
const ix = await this.getUpdateWarmAdminIx(newWarmAdmin);
|
|
2778
4871
|
const tx = await this.buildTransaction(ix);
|
|
2779
4872
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2780
4873
|
return txSig;
|
|
2781
4874
|
}
|
|
4875
|
+
/**
|
|
4876
|
+
* Builds the `updateWarmAdmin` instruction without sending it. See
|
|
4877
|
+
* `updateWarmAdmin`.
|
|
4878
|
+
* @returns The unsigned `updateWarmAdmin` instruction.
|
|
4879
|
+
*/
|
|
2782
4880
|
async getUpdateWarmAdminIx(newWarmAdmin) {
|
|
2783
4881
|
return this.program.instruction.updateWarmAdmin(newWarmAdmin, {
|
|
2784
4882
|
accounts: {
|
|
@@ -2789,12 +4887,58 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2789
4887
|
},
|
|
2790
4888
|
});
|
|
2791
4889
|
}
|
|
4890
|
+
/**
|
|
4891
|
+
* Rotates `state.pauseAdmin`, the no-timelock emergency-pause key authorised (in
|
|
4892
|
+
* addition to cold/warm) for handlers that flip pause bitmasks
|
|
4893
|
+
* (`updateExchangeStatus`, per-market/per-user paused-operations updates) —
|
|
4894
|
+
* restricted at the handler level to *adding* pause bits, never clearing them.
|
|
4895
|
+
* Cold-only: the `UpdatePauseAdmin` context requires `state.coldAdmin ==
|
|
4896
|
+
* admin.key()`.
|
|
4897
|
+
* @param newPauseAdmin - New pause admin pubkey. `PublicKey.default()` unsets the role — only cold/warm can then pause.
|
|
4898
|
+
* @returns Transaction signature.
|
|
4899
|
+
*/
|
|
4900
|
+
async updatePauseAdmin(newPauseAdmin) {
|
|
4901
|
+
const ix = await this.getUpdatePauseAdminIx(newPauseAdmin);
|
|
4902
|
+
const tx = await this.buildTransaction(ix);
|
|
4903
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4904
|
+
return txSig;
|
|
4905
|
+
}
|
|
4906
|
+
/**
|
|
4907
|
+
* Builds the `updatePauseAdmin` instruction without sending it. See
|
|
4908
|
+
* `updatePauseAdmin`.
|
|
4909
|
+
* @returns The unsigned `updatePauseAdmin` instruction.
|
|
4910
|
+
*/
|
|
4911
|
+
async getUpdatePauseAdminIx(newPauseAdmin) {
|
|
4912
|
+
return this.program.instruction.updatePauseAdmin(newPauseAdmin, {
|
|
4913
|
+
accounts: {
|
|
4914
|
+
state: await this.getStatePublicKey(),
|
|
4915
|
+
admin: this.isSubscribed
|
|
4916
|
+
? this.getStateAccount().coldAdmin
|
|
4917
|
+
: this.wallet.publicKey,
|
|
4918
|
+
},
|
|
4919
|
+
});
|
|
4920
|
+
}
|
|
4921
|
+
/**
|
|
4922
|
+
* Rotates one purpose-specific hot-role key on `state` (e.g. `hotFeeWithdraw`,
|
|
4923
|
+
* `hotVaultDeposit`). Warm-or-cold: the `UpdateHotAdmin` context requires
|
|
4924
|
+
* `state.isWarm(admin.key())`. Compromise of one hot key only exposes the
|
|
4925
|
+
* instructions gated on that specific `HotRole` — rotating it here fully revokes
|
|
4926
|
+
* the old key for that role.
|
|
4927
|
+
* @param role - Which hot role's key to rotate.
|
|
4928
|
+
* @param newPubkey - New key for that role. `PublicKey.default()` unsets it — only warm/cold can then call handlers gated on that role.
|
|
4929
|
+
* @returns Transaction signature.
|
|
4930
|
+
*/
|
|
2792
4931
|
async updateHotAdmin(role, newPubkey) {
|
|
2793
4932
|
const ix = await this.getUpdateHotAdminIx(role, newPubkey);
|
|
2794
4933
|
const tx = await this.buildTransaction(ix);
|
|
2795
4934
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2796
4935
|
return txSig;
|
|
2797
4936
|
}
|
|
4937
|
+
/**
|
|
4938
|
+
* Builds the `updateHotAdmin` instruction without sending it. See
|
|
4939
|
+
* `updateHotAdmin`.
|
|
4940
|
+
* @returns The unsigned `updateHotAdmin` instruction.
|
|
4941
|
+
*/
|
|
2798
4942
|
async getUpdateHotAdminIx(role, newPubkey) {
|
|
2799
4943
|
return this.program.instruction.updateHotAdmin(encodeHotRole(role), newPubkey, {
|
|
2800
4944
|
accounts: {
|
|
@@ -2807,8 +4951,10 @@ class AdminClient extends velocityClient_1.VelocityClient {
|
|
|
2807
4951
|
exports.AdminClient = AdminClient;
|
|
2808
4952
|
/**
|
|
2809
4953
|
* Hot-admin role identifier. Each role is a separate purpose-specific signer key
|
|
2810
|
-
* stored on the `
|
|
2811
|
-
*
|
|
4954
|
+
* stored directly on the `State` account (one `hot*` pubkey field per role, e.g.
|
|
4955
|
+
* `state.hotFeeWithdraw` for `FeeWithdraw`) — there is no separate
|
|
4956
|
+
* "AdminAuthorityConfig" account. Compromise of one role's key only enables that
|
|
4957
|
+
* role's instructions (see `updateHotAdmin` to rotate one).
|
|
2812
4958
|
*/
|
|
2813
4959
|
var HotRole;
|
|
2814
4960
|
(function (HotRole) {
|