@velocity-exchange/sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +1 -0
- package/.yarn/install-state.gz +0 -0
- package/README.md +275 -0
- package/VERSION +1 -0
- package/build-browser.js +58 -0
- package/bun.lock +1885 -0
- package/esbuild-shims.js +12 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.js +38 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/basicUserStatsAccountSubscriber.js +38 -0
- package/lib/browser/accounts/bulkAccountLoader.d.ts +37 -0
- package/lib/browser/accounts/bulkAccountLoader.js +222 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/browser/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/browser/accounts/bulkUserSubscription.d.ts +7 -0
- package/lib/browser/accounts/bulkUserSubscription.js +21 -0
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.d.ts +44 -0
- package/lib/browser/accounts/customizedCadenceBulkAccountLoader.js +152 -0
- package/lib/browser/accounts/fetch.d.ts +17 -0
- package/lib/browser/accounts/fetch.js +60 -0
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +17 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +162 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +37 -0
- package/lib/browser/accounts/grpcMultiAccountSubscriber.js +378 -0
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +25 -0
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +203 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +179 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcUserAccountSubscriber.js +28 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +28 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +16 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +101 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +69 -0
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +457 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +162 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +48 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.js +48 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/pollingOracleAccountSubscriber.js +78 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +26 -0
- package/lib/browser/accounts/pollingTokenAccountSubscriber.js +78 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +102 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +94 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +73 -0
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +420 -0
- package/lib/browser/accounts/testBulkAccountLoader.d.ts +4 -0
- package/lib/browser/accounts/testBulkAccountLoader.js +43 -0
- package/lib/browser/accounts/types.d.ts +205 -0
- package/lib/browser/accounts/types.js +16 -0
- package/lib/browser/accounts/utils.d.ts +8 -0
- package/lib/browser/accounts/utils.js +49 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/webSocketAccountSubscriber.js +170 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +109 -0
- package/lib/browser/accounts/webSocketAccountSubscriberV2.js +395 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +31 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +120 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +145 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +744 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +145 -0
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.js +744 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/webSocketUserAccountSubscriber.js +61 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +22 -0
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +77 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +400 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +91 -0
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +446 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +22 -0
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.js +54 -0
- package/lib/browser/addresses/marketAddresses.d.ts +2 -0
- package/lib/browser/addresses/marketAddresses.js +15 -0
- package/lib/browser/addresses/pda.d.ts +47 -0
- package/lib/browser/addresses/pda.js +263 -0
- package/lib/browser/adminClient.d.ts +402 -0
- package/lib/browser/adminClient.js +2798 -0
- package/lib/browser/assert/assert.d.ts +1 -0
- package/lib/browser/assert/assert.js +9 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +14 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +32 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/browser/auctionSubscriber/index.d.ts +3 -0
- package/lib/browser/auctionSubscriber/index.js +19 -0
- package/lib/browser/auctionSubscriber/types.d.ts +14 -0
- package/lib/browser/auctionSubscriber/types.js +2 -0
- package/lib/browser/bankrun/bankrunConnection.d.ts +76 -0
- package/lib/browser/bankrun/bankrunConnection.js +348 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.d.ts +27 -0
- package/lib/browser/blockhashSubscriber/BlockhashSubscriber.js +89 -0
- package/lib/browser/blockhashSubscriber/index.d.ts +1 -0
- package/lib/browser/blockhashSubscriber/index.js +17 -0
- package/lib/browser/blockhashSubscriber/types.d.ts +7 -0
- package/lib/browser/blockhashSubscriber/types.js +2 -0
- package/lib/browser/clock/clockSubscriber.d.ts +31 -0
- package/lib/browser/clock/clockSubscriber.js +80 -0
- package/lib/browser/config.d.ts +75 -0
- package/lib/browser/config.js +164 -0
- package/lib/browser/constants/index.d.ts +10 -0
- package/lib/browser/constants/index.js +26 -0
- package/lib/browser/constants/insuranceFund.d.ts +5 -0
- package/lib/browser/constants/insuranceFund.js +9 -0
- package/lib/browser/constants/numericConstants.d.ts +73 -0
- package/lib/browser/constants/numericConstants.js +79 -0
- package/lib/browser/constants/perpMarkets.d.ts +21 -0
- package/lib/browser/constants/perpMarkets.js +971 -0
- package/lib/browser/constants/spotMarkets.d.ts +24 -0
- package/lib/browser/constants/spotMarkets.js +797 -0
- package/lib/browser/constants/txConstants.d.ts +1 -0
- package/lib/browser/constants/txConstants.js +4 -0
- package/lib/browser/constituentMap/constituentMap.d.ts +66 -0
- package/lib/browser/constituentMap/constituentMap.js +177 -0
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.d.ts +24 -0
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +60 -0
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +24 -0
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +58 -0
- package/lib/browser/core/VelocityCore.d.ts +226 -0
- package/lib/browser/core/VelocityCore.js +138 -0
- package/lib/browser/core/index.d.ts +12 -0
- package/lib/browser/core/index.js +28 -0
- package/lib/browser/core/instructions/deposit.d.ts +19 -0
- package/lib/browser/core/instructions/deposit.js +19 -0
- package/lib/browser/core/instructions/fill.d.ts +13 -0
- package/lib/browser/core/instructions/fill.js +17 -0
- package/lib/browser/core/instructions/funding.d.ts +9 -0
- package/lib/browser/core/instructions/funding.js +13 -0
- package/lib/browser/core/instructions/liquidation.d.ts +15 -0
- package/lib/browser/core/instructions/liquidation.js +17 -0
- package/lib/browser/core/instructions/orders.d.ts +22 -0
- package/lib/browser/core/instructions/orders.js +27 -0
- package/lib/browser/core/instructions/perpOrders.d.ts +78 -0
- package/lib/browser/core/instructions/perpOrders.js +99 -0
- package/lib/browser/core/instructions/settlement.d.ts +11 -0
- package/lib/browser/core/instructions/settlement.js +15 -0
- package/lib/browser/core/instructions/trigger.d.ts +11 -0
- package/lib/browser/core/instructions/trigger.js +15 -0
- package/lib/browser/core/instructions/withdraw.d.ts +20 -0
- package/lib/browser/core/instructions/withdraw.js +20 -0
- package/lib/browser/core/remainingAccounts.d.ts +27 -0
- package/lib/browser/core/remainingAccounts.js +122 -0
- package/lib/browser/core/signedMsg.d.ts +17 -0
- package/lib/browser/core/signedMsg.js +39 -0
- package/lib/browser/decode/customCoder.d.ts +44 -0
- package/lib/browser/decode/customCoder.js +64 -0
- package/lib/browser/decode/user.d.ts +4 -0
- package/lib/browser/decode/user.js +337 -0
- package/lib/browser/dlob/DLOB.d.ts +253 -0
- package/lib/browser/dlob/DLOB.js +1137 -0
- package/lib/browser/dlob/DLOBNode.d.ts +70 -0
- package/lib/browser/dlob/DLOBNode.js +103 -0
- package/lib/browser/dlob/DLOBSubscriber.d.ts +57 -0
- package/lib/browser/dlob/DLOBSubscriber.js +143 -0
- package/lib/browser/dlob/NodeList.d.ts +27 -0
- package/lib/browser/dlob/NodeList.js +126 -0
- package/lib/browser/dlob/orderBookLevels.d.ts +77 -0
- package/lib/browser/dlob/orderBookLevels.js +404 -0
- package/lib/browser/dlob/types.d.ts +18 -0
- package/lib/browser/dlob/types.js +2 -0
- package/lib/browser/events/eventList.d.ts +22 -0
- package/lib/browser/events/eventList.js +80 -0
- package/lib/browser/events/eventSubscriber.d.ts +55 -0
- package/lib/browser/events/eventSubscriber.js +229 -0
- package/lib/browser/events/eventsServerLogProvider.d.ts +21 -0
- package/lib/browser/events/eventsServerLogProvider.js +121 -0
- package/lib/browser/events/fetchLogs.d.ts +25 -0
- package/lib/browser/events/fetchLogs.js +99 -0
- package/lib/browser/events/parse.d.ts +8 -0
- package/lib/browser/events/parse.js +199 -0
- package/lib/browser/events/pollingLogProvider.d.ts +17 -0
- package/lib/browser/events/pollingLogProvider.js +58 -0
- package/lib/browser/events/sort.d.ts +2 -0
- package/lib/browser/events/sort.js +24 -0
- package/lib/browser/events/txEventCache.d.ts +24 -0
- package/lib/browser/events/txEventCache.js +71 -0
- package/lib/browser/events/types.d.ts +104 -0
- package/lib/browser/events/types.js +36 -0
- package/lib/browser/events/webSocketLogProvider.d.ts +24 -0
- package/lib/browser/events/webSocketLogProvider.js +96 -0
- package/lib/browser/factory/bigNum.d.ts +122 -0
- package/lib/browser/factory/bigNum.js +500 -0
- package/lib/browser/factory/oracleClient.d.ts +5 -0
- package/lib/browser/factory/oracleClient.js +53 -0
- package/lib/browser/idl/drift.d.ts +23894 -0
- package/lib/browser/idl/drift.js +2 -0
- package/lib/browser/idl/drift.json +18698 -0
- package/lib/browser/idl/pyth.d.ts +97 -0
- package/lib/browser/idl/pyth.js +2 -0
- package/lib/browser/idl/token_faucet.d.ts +197 -0
- package/lib/browser/idl/token_faucet.js +2 -0
- package/lib/browser/idl/token_faucet.json +229 -0
- package/lib/browser/index.d.ts +144 -0
- package/lib/browser/index.js +175 -0
- package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +35 -0
- package/lib/browser/indicative-quotes/indicativeQuotesSender.js +192 -0
- package/lib/browser/isomorphic/anchor.browser.d.ts +24 -0
- package/lib/browser/isomorphic/anchor.browser.js +60 -0
- package/lib/browser/isomorphic/anchor.d.ts +24 -0
- package/lib/browser/isomorphic/anchor.js +60 -0
- package/lib/browser/isomorphic/anchor29.browser.d.ts +12 -0
- package/lib/browser/isomorphic/anchor29.browser.js +48 -0
- package/lib/browser/isomorphic/anchor29.d.ts +12 -0
- package/lib/browser/isomorphic/anchor29.js +48 -0
- package/lib/browser/isomorphic/grpc.browser.d.ts +1 -0
- package/lib/browser/isomorphic/grpc.browser.js +8 -0
- package/lib/browser/isomorphic/grpc.d.ts +1 -0
- package/lib/browser/isomorphic/grpc.js +8 -0
- package/lib/browser/jupiter/jupiterClient.d.ts +291 -0
- package/lib/browser/jupiter/jupiterClient.js +164 -0
- package/lib/browser/keypair.d.ts +2 -0
- package/lib/browser/keypair.js +28 -0
- package/lib/browser/marginCalculation.d.ts +67 -0
- package/lib/browser/marginCalculation.js +176 -0
- package/lib/browser/marinade/index.d.ts +12 -0
- package/lib/browser/marinade/index.js +36 -0
- package/lib/browser/marinade/types.d.ts +1963 -0
- package/lib/browser/marinade/types.js +1965 -0
- package/lib/browser/math/amm.d.ts +98 -0
- package/lib/browser/math/amm.js +671 -0
- package/lib/browser/math/auction.d.ts +65 -0
- package/lib/browser/math/auction.js +261 -0
- package/lib/browser/math/bankruptcy.d.ts +2 -0
- package/lib/browser/math/bankruptcy.js +32 -0
- package/lib/browser/math/builder.d.ts +5 -0
- package/lib/browser/math/builder.js +22 -0
- package/lib/browser/math/conversion.d.ts +4 -0
- package/lib/browser/math/conversion.js +21 -0
- package/lib/browser/math/exchangeStatus.d.ts +8 -0
- package/lib/browser/math/exchangeStatus.js +85 -0
- package/lib/browser/math/funding.d.ts +44 -0
- package/lib/browser/math/funding.js +260 -0
- package/lib/browser/math/insurance.d.ts +8 -0
- package/lib/browser/math/insurance.js +74 -0
- package/lib/browser/math/liquidation.d.ts +7 -0
- package/lib/browser/math/liquidation.js +134 -0
- package/lib/browser/math/margin.d.ts +45 -0
- package/lib/browser/math/margin.js +205 -0
- package/lib/browser/math/market.d.ts +50 -0
- package/lib/browser/math/market.js +234 -0
- package/lib/browser/math/oracles.d.ts +19 -0
- package/lib/browser/math/oracles.js +215 -0
- package/lib/browser/math/orders.d.ts +36 -0
- package/lib/browser/math/orders.js +294 -0
- package/lib/browser/math/position.d.ts +71 -0
- package/lib/browser/math/position.js +232 -0
- package/lib/browser/math/repeg.d.ts +22 -0
- package/lib/browser/math/repeg.js +164 -0
- package/lib/browser/math/spotBalance.d.ts +85 -0
- package/lib/browser/math/spotBalance.js +438 -0
- package/lib/browser/math/spotMarket.d.ts +11 -0
- package/lib/browser/math/spotMarket.js +49 -0
- package/lib/browser/math/spotPosition.d.ts +19 -0
- package/lib/browser/math/spotPosition.js +79 -0
- package/lib/browser/math/state.d.ts +8 -0
- package/lib/browser/math/state.js +44 -0
- package/lib/browser/math/superStake.d.ts +168 -0
- package/lib/browser/math/superStake.js +308 -0
- package/lib/browser/math/tiers.d.ts +4 -0
- package/lib/browser/math/tiers.js +52 -0
- package/lib/browser/math/trade.d.ts +93 -0
- package/lib/browser/math/trade.js +503 -0
- package/lib/browser/math/utils.d.ts +23 -0
- package/lib/browser/math/utils.js +113 -0
- package/lib/browser/memcmp.d.ts +18 -0
- package/lib/browser/memcmp.js +162 -0
- package/lib/browser/oracles/oracleClientCache.d.ts +9 -0
- package/lib/browser/oracles/oracleClientCache.js +19 -0
- package/lib/browser/oracles/oracleId.d.ts +9 -0
- package/lib/browser/oracles/oracleId.js +89 -0
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +12 -0
- package/lib/browser/oracles/prelaunchOracleClient.js +24 -0
- package/lib/browser/oracles/pythClient.d.ts +14 -0
- package/lib/browser/oracles/pythClient.js +51 -0
- package/lib/browser/oracles/pythLazerClient.d.ts +16 -0
- package/lib/browser/oracles/pythLazerClient.js +61 -0
- package/lib/browser/oracles/quoteAssetOracleClient.d.ts +10 -0
- package/lib/browser/oracles/quoteAssetOracleClient.js +21 -0
- package/lib/browser/oracles/strictOraclePrice.d.ts +9 -0
- package/lib/browser/oracles/strictOraclePrice.js +17 -0
- package/lib/browser/oracles/types.d.ts +33 -0
- package/lib/browser/oracles/types.js +2 -0
- package/lib/browser/oracles/utils.d.ts +4 -0
- package/lib/browser/oracles/utils.js +8 -0
- package/lib/browser/orderParams.d.ts +29 -0
- package/lib/browser/orderParams.js +44 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +45 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.js +193 -0
- package/lib/browser/orderSubscriber/PollingSubscription.d.ts +12 -0
- package/lib/browser/orderSubscriber/PollingSubscription.js +23 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.d.ts +23 -0
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +67 -0
- package/lib/browser/orderSubscriber/grpcSubscription.d.ts +22 -0
- package/lib/browser/orderSubscriber/grpcSubscription.js +75 -0
- package/lib/browser/orderSubscriber/index.d.ts +7 -0
- package/lib/browser/orderSubscriber/index.js +23 -0
- package/lib/browser/orderSubscriber/types.d.ts +35 -0
- package/lib/browser/orderSubscriber/types.js +2 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.d.ts +5 -0
- package/lib/browser/priorityFee/averageOverSlotsStrategy.js +16 -0
- package/lib/browser/priorityFee/averageStrategy.d.ts +5 -0
- package/lib/browser/priorityFee/averageStrategy.js +11 -0
- package/lib/browser/priorityFee/ewmaStrategy.d.ts +11 -0
- package/lib/browser/priorityFee/ewmaStrategy.js +33 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.d.ts +20 -0
- package/lib/browser/priorityFee/heliusPriorityFeeMethod.js +46 -0
- package/lib/browser/priorityFee/index.d.ts +16 -0
- package/lib/browser/priorityFee/index.js +32 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.d.ts +5 -0
- package/lib/browser/priorityFee/maxOverSlotsStrategy.js +17 -0
- package/lib/browser/priorityFee/maxStrategy.d.ts +7 -0
- package/lib/browser/priorityFee/maxStrategy.js +9 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +48 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +193 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +50 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +96 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.d.ts +6 -0
- package/lib/browser/priorityFee/solanaPriorityFeeMethod.js +21 -0
- package/lib/browser/priorityFee/types.d.ts +35 -0
- package/lib/browser/priorityFee/types.js +10 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +21 -0
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +28 -0
- package/lib/browser/pyth/constants.d.ts +3 -0
- package/lib/browser/pyth/constants.js +6 -0
- package/lib/browser/pyth/index.d.ts +4 -0
- package/lib/browser/pyth/index.js +12 -0
- package/lib/browser/pyth/pythLazerSubscriber.d.ts +91 -0
- package/lib/browser/pyth/pythLazerSubscriber.js +276 -0
- package/lib/browser/pyth/types.d.ts +2226 -0
- package/lib/browser/pyth/types.js +2224 -0
- package/lib/browser/pyth/utils.d.ts +2 -0
- package/lib/browser/pyth/utils.js +10 -0
- package/lib/browser/slot/SlotSubscriber.d.ts +27 -0
- package/lib/browser/slot/SlotSubscriber.js +76 -0
- package/lib/browser/slot/SlothashSubscriber.d.ts +25 -0
- package/lib/browser/slot/SlothashSubscriber.js +88 -0
- package/lib/browser/swap/UnifiedSwapClient.d.ts +120 -0
- package/lib/browser/swap/UnifiedSwapClient.js +179 -0
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +22 -0
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +57 -0
- package/lib/browser/swift/index.d.ts +10 -0
- package/lib/browser/swift/index.js +26 -0
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +42 -0
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +118 -0
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +63 -0
- package/lib/browser/swift/swiftOrderSubscriber.js +187 -0
- package/lib/browser/testClient.d.ts +8 -0
- package/lib/browser/testClient.js +24 -0
- package/lib/browser/titan/titanClient.d.ts +90 -0
- package/lib/browser/titan/titanClient.js +227 -0
- package/lib/browser/token/index.d.ts +5 -0
- package/lib/browser/token/index.js +15 -0
- package/lib/browser/tokenFaucet.d.ts +41 -0
- package/lib/browser/tokenFaucet.js +188 -0
- package/lib/browser/tx/baseTxSender.d.ts +59 -0
- package/lib/browser/tx/baseTxSender.js +292 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +8 -0
- package/lib/browser/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +28 -0
- package/lib/browser/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
- package/lib/browser/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/browser/tx/blockhashFetcher/types.js +2 -0
- package/lib/browser/tx/fastSingleTxSender.d.ts +41 -0
- package/lib/browser/tx/fastSingleTxSender.js +86 -0
- package/lib/browser/tx/forwardOnlyTxSender.d.ts +37 -0
- package/lib/browser/tx/forwardOnlyTxSender.js +92 -0
- package/lib/browser/tx/priorityFeeCalculator.d.ts +44 -0
- package/lib/browser/tx/priorityFeeCalculator.js +85 -0
- package/lib/browser/tx/reportTransactionError.d.ts +20 -0
- package/lib/browser/tx/reportTransactionError.js +103 -0
- package/lib/browser/tx/retryTxSender.d.ts +37 -0
- package/lib/browser/tx/retryTxSender.js +86 -0
- package/lib/browser/tx/txHandler.d.ts +173 -0
- package/lib/browser/tx/txHandler.js +522 -0
- package/lib/browser/tx/txParamProcessor.d.ts +26 -0
- package/lib/browser/tx/txParamProcessor.js +92 -0
- package/lib/browser/tx/types.d.ts +29 -0
- package/lib/browser/tx/types.js +20 -0
- package/lib/browser/tx/utils.d.ts +6 -0
- package/lib/browser/tx/utils.js +78 -0
- package/lib/browser/tx/whileValidTxSender.d.ts +45 -0
- package/lib/browser/tx/whileValidTxSender.js +168 -0
- package/lib/browser/types.d.ts +1747 -0
- package/lib/browser/types.js +427 -0
- package/lib/browser/user.d.ts +446 -0
- package/lib/browser/user.js +2372 -0
- package/lib/browser/userConfig.d.ts +31 -0
- package/lib/browser/userConfig.js +2 -0
- package/lib/browser/userMap/PollingSubscription.d.ts +15 -0
- package/lib/browser/userMap/PollingSubscription.js +30 -0
- package/lib/browser/userMap/WebsocketSubscription.d.ts +27 -0
- package/lib/browser/userMap/WebsocketSubscription.js +45 -0
- package/lib/browser/userMap/grpcSubscription.d.ts +27 -0
- package/lib/browser/userMap/grpcSubscription.js +44 -0
- package/lib/browser/userMap/referrerMap.d.ts +45 -0
- package/lib/browser/userMap/referrerMap.js +184 -0
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +66 -0
- package/lib/browser/userMap/revenueShareEscrowMap.js +210 -0
- package/lib/browser/userMap/userMap.d.ts +114 -0
- package/lib/browser/userMap/userMap.js +486 -0
- package/lib/browser/userMap/userMapConfig.d.ts +40 -0
- package/lib/browser/userMap/userMapConfig.js +2 -0
- package/lib/browser/userMap/userStatsMap.d.ts +66 -0
- package/lib/browser/userMap/userStatsMap.js +266 -0
- package/lib/browser/userName.d.ts +5 -0
- package/lib/browser/userName.js +21 -0
- package/lib/browser/userStats.d.ts +24 -0
- package/lib/browser/userStats.js +70 -0
- package/lib/browser/userStatsConfig.d.ts +26 -0
- package/lib/browser/userStatsConfig.js +2 -0
- package/lib/browser/util/TransactionConfirmationManager.d.ts +16 -0
- package/lib/browser/util/TransactionConfirmationManager.js +174 -0
- package/lib/browser/util/chainClock.d.ts +17 -0
- package/lib/browser/util/chainClock.js +29 -0
- package/lib/browser/util/computeUnits.d.ts +8 -0
- package/lib/browser/util/computeUnits.js +48 -0
- package/lib/browser/util/digest.d.ts +5 -0
- package/lib/browser/util/digest.js +19 -0
- package/lib/browser/util/ed25519Utils.d.ts +10 -0
- package/lib/browser/util/ed25519Utils.js +80 -0
- package/lib/browser/util/promiseTimeout.d.ts +1 -0
- package/lib/browser/util/promiseTimeout.js +14 -0
- package/lib/browser/util/tps.d.ts +2 -0
- package/lib/browser/util/tps.js +16 -0
- package/lib/browser/velocityClient.d.ts +1230 -0
- package/lib/browser/velocityClient.js +5778 -0
- package/lib/browser/velocityClientConfig.d.ts +84 -0
- package/lib/browser/velocityClientConfig.js +2 -0
- package/lib/browser/wallet.d.ts +16 -0
- package/lib/browser/wallet.js +46 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/basicUserAccountSubscriber.js +38 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/basicUserStatsAccountSubscriber.js +38 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts +38 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts.map +1 -0
- package/lib/node/accounts/bulkAccountLoader.js +222 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts +8 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts.map +1 -0
- package/lib/node/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/node/accounts/bulkUserSubscription.d.ts +8 -0
- package/lib/node/accounts/bulkUserSubscription.d.ts.map +1 -0
- package/lib/node/accounts/bulkUserSubscription.js +21 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts +45 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.d.ts.map +1 -0
- package/lib/node/accounts/customizedCadenceBulkAccountLoader.js +152 -0
- package/lib/node/accounts/fetch.d.ts +18 -0
- package/lib/node/accounts/fetch.d.ts.map +1 -0
- package/lib/node/accounts/fetch.js +60 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcAccountSubscriber.js +162 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +11 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +31 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +38 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcMultiAccountSubscriber.js +378 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +26 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +203 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +179 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +11 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.js +28 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +11 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +28 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +17 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +101 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +70 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +457 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +24 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/laserProgramAccountSubscriber.js +162 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +48 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +19 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.js +48 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.js +102 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +28 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +94 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +74 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +420 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts +5 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -0
- package/lib/node/accounts/testBulkAccountLoader.js +43 -0
- package/lib/node/accounts/types.d.ts +206 -0
- package/lib/node/accounts/types.d.ts.map +1 -0
- package/lib/node/accounts/types.js +16 -0
- package/lib/node/accounts/utils.d.ts +9 -0
- package/lib/node/accounts/utils.d.ts.map +1 -0
- package/lib/node/accounts/utils.js +49 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +30 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketAccountSubscriber.js +170 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +110 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketAccountSubscriberV2.js +395 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +24 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +120 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +146 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +744 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +146 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.js +744 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +24 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +61 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +23 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +78 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +400 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +92 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +446 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.js +54 -0
- package/lib/node/addresses/marketAddresses.d.ts +3 -0
- package/lib/node/addresses/marketAddresses.d.ts.map +1 -0
- package/lib/node/addresses/marketAddresses.js +15 -0
- package/lib/node/addresses/pda.d.ts +48 -0
- package/lib/node/addresses/pda.d.ts.map +1 -0
- package/lib/node/addresses/pda.js +263 -0
- package/lib/node/adminClient.d.ts +403 -0
- package/lib/node/adminClient.d.ts.map +1 -0
- package/lib/node/adminClient.js +2798 -0
- package/lib/node/assert/assert.d.ts +2 -0
- package/lib/node/assert/assert.d.ts.map +1 -0
- package/lib/node/assert/assert.js +9 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.js +32 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +16 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/node/auctionSubscriber/index.d.ts +4 -0
- package/lib/node/auctionSubscriber/index.d.ts.map +1 -0
- package/lib/node/auctionSubscriber/index.js +19 -0
- package/lib/node/auctionSubscriber/types.d.ts +15 -0
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -0
- package/lib/node/auctionSubscriber/types.js +2 -0
- package/lib/node/bankrun/bankrunConnection.d.ts +77 -0
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -0
- package/lib/node/bankrun/bankrunConnection.js +348 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +28 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts.map +1 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +89 -0
- package/lib/node/blockhashSubscriber/index.d.ts +2 -0
- package/lib/node/blockhashSubscriber/index.d.ts.map +1 -0
- package/lib/node/blockhashSubscriber/index.js +17 -0
- package/lib/node/blockhashSubscriber/types.d.ts +8 -0
- package/lib/node/blockhashSubscriber/types.d.ts.map +1 -0
- package/lib/node/blockhashSubscriber/types.js +2 -0
- package/lib/node/clock/clockSubscriber.d.ts +32 -0
- package/lib/node/clock/clockSubscriber.d.ts.map +1 -0
- package/lib/node/clock/clockSubscriber.js +80 -0
- package/lib/node/config.d.ts +76 -0
- package/lib/node/config.d.ts.map +1 -0
- package/lib/node/config.js +164 -0
- package/lib/node/constants/index.d.ts +11 -0
- package/lib/node/constants/index.d.ts.map +1 -0
- package/lib/node/constants/index.js +26 -0
- package/lib/node/constants/insuranceFund.d.ts +6 -0
- package/lib/node/constants/insuranceFund.d.ts.map +1 -0
- package/lib/node/constants/insuranceFund.js +9 -0
- package/lib/node/constants/numericConstants.d.ts +74 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -0
- package/lib/node/constants/numericConstants.js +79 -0
- package/lib/node/constants/perpMarkets.d.ts +22 -0
- package/lib/node/constants/perpMarkets.d.ts.map +1 -0
- package/lib/node/constants/perpMarkets.js +971 -0
- package/lib/node/constants/spotMarkets.d.ts +25 -0
- package/lib/node/constants/spotMarkets.d.ts.map +1 -0
- package/lib/node/constants/spotMarkets.js +797 -0
- package/lib/node/constants/txConstants.d.ts +2 -0
- package/lib/node/constants/txConstants.d.ts.map +1 -0
- package/lib/node/constants/txConstants.js +4 -0
- package/lib/node/constituentMap/constituentMap.d.ts +67 -0
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -0
- package/lib/node/constituentMap/constituentMap.js +177 -0
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts +25 -0
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -0
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +60 -0
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +25 -0
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -0
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +58 -0
- package/lib/node/core/VelocityCore.d.ts +227 -0
- package/lib/node/core/VelocityCore.d.ts.map +1 -0
- package/lib/node/core/VelocityCore.js +138 -0
- package/lib/node/core/index.d.ts +13 -0
- package/lib/node/core/index.d.ts.map +1 -0
- package/lib/node/core/index.js +28 -0
- package/lib/node/core/instructions/deposit.d.ts +20 -0
- package/lib/node/core/instructions/deposit.d.ts.map +1 -0
- package/lib/node/core/instructions/deposit.js +19 -0
- package/lib/node/core/instructions/fill.d.ts +14 -0
- package/lib/node/core/instructions/fill.d.ts.map +1 -0
- package/lib/node/core/instructions/fill.js +17 -0
- package/lib/node/core/instructions/funding.d.ts +10 -0
- package/lib/node/core/instructions/funding.d.ts.map +1 -0
- package/lib/node/core/instructions/funding.js +13 -0
- package/lib/node/core/instructions/liquidation.d.ts +16 -0
- package/lib/node/core/instructions/liquidation.d.ts.map +1 -0
- package/lib/node/core/instructions/liquidation.js +17 -0
- package/lib/node/core/instructions/orders.d.ts +23 -0
- package/lib/node/core/instructions/orders.d.ts.map +1 -0
- package/lib/node/core/instructions/orders.js +27 -0
- package/lib/node/core/instructions/perpOrders.d.ts +79 -0
- package/lib/node/core/instructions/perpOrders.d.ts.map +1 -0
- package/lib/node/core/instructions/perpOrders.js +99 -0
- package/lib/node/core/instructions/settlement.d.ts +12 -0
- package/lib/node/core/instructions/settlement.d.ts.map +1 -0
- package/lib/node/core/instructions/settlement.js +15 -0
- package/lib/node/core/instructions/trigger.d.ts +12 -0
- package/lib/node/core/instructions/trigger.d.ts.map +1 -0
- 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 -0
- package/lib/node/core/instructions/withdraw.js +20 -0
- package/lib/node/core/remainingAccounts.d.ts +28 -0
- package/lib/node/core/remainingAccounts.d.ts.map +1 -0
- package/lib/node/core/remainingAccounts.js +122 -0
- package/lib/node/core/signedMsg.d.ts +18 -0
- package/lib/node/core/signedMsg.d.ts.map +1 -0
- package/lib/node/core/signedMsg.js +39 -0
- package/lib/node/decode/customCoder.d.ts +45 -0
- package/lib/node/decode/customCoder.d.ts.map +1 -0
- package/lib/node/decode/customCoder.js +64 -0
- package/lib/node/decode/user.d.ts +5 -0
- package/lib/node/decode/user.d.ts.map +1 -0
- package/lib/node/decode/user.js +337 -0
- package/lib/node/dlob/DLOB.d.ts +254 -0
- package/lib/node/dlob/DLOB.d.ts.map +1 -0
- package/lib/node/dlob/DLOB.js +1137 -0
- package/lib/node/dlob/DLOBNode.d.ts +71 -0
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -0
- package/lib/node/dlob/DLOBNode.js +103 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts +58 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -0
- package/lib/node/dlob/DLOBSubscriber.js +143 -0
- package/lib/node/dlob/NodeList.d.ts +28 -0
- package/lib/node/dlob/NodeList.d.ts.map +1 -0
- package/lib/node/dlob/NodeList.js +126 -0
- package/lib/node/dlob/orderBookLevels.d.ts +78 -0
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -0
- package/lib/node/dlob/orderBookLevels.js +404 -0
- package/lib/node/dlob/types.d.ts +19 -0
- package/lib/node/dlob/types.d.ts.map +1 -0
- package/lib/node/dlob/types.js +2 -0
- package/lib/node/events/eventList.d.ts +23 -0
- package/lib/node/events/eventList.d.ts.map +1 -0
- package/lib/node/events/eventList.js +80 -0
- package/lib/node/events/eventSubscriber.d.ts +56 -0
- package/lib/node/events/eventSubscriber.d.ts.map +1 -0
- package/lib/node/events/eventSubscriber.js +229 -0
- package/lib/node/events/eventsServerLogProvider.d.ts +22 -0
- package/lib/node/events/eventsServerLogProvider.d.ts.map +1 -0
- package/lib/node/events/eventsServerLogProvider.js +121 -0
- package/lib/node/events/fetchLogs.d.ts +26 -0
- package/lib/node/events/fetchLogs.d.ts.map +1 -0
- package/lib/node/events/fetchLogs.js +99 -0
- package/lib/node/events/parse.d.ts +9 -0
- package/lib/node/events/parse.d.ts.map +1 -0
- package/lib/node/events/parse.js +199 -0
- package/lib/node/events/pollingLogProvider.d.ts +18 -0
- package/lib/node/events/pollingLogProvider.d.ts.map +1 -0
- package/lib/node/events/pollingLogProvider.js +58 -0
- package/lib/node/events/sort.d.ts +3 -0
- package/lib/node/events/sort.d.ts.map +1 -0
- package/lib/node/events/sort.js +24 -0
- package/lib/node/events/txEventCache.d.ts +25 -0
- package/lib/node/events/txEventCache.d.ts.map +1 -0
- package/lib/node/events/txEventCache.js +71 -0
- package/lib/node/events/types.d.ts +105 -0
- package/lib/node/events/types.d.ts.map +1 -0
- package/lib/node/events/types.js +36 -0
- package/lib/node/events/webSocketLogProvider.d.ts +25 -0
- package/lib/node/events/webSocketLogProvider.d.ts.map +1 -0
- package/lib/node/events/webSocketLogProvider.js +96 -0
- package/lib/node/factory/bigNum.d.ts +123 -0
- package/lib/node/factory/bigNum.d.ts.map +1 -0
- package/lib/node/factory/bigNum.js +500 -0
- package/lib/node/factory/oracleClient.d.ts +6 -0
- package/lib/node/factory/oracleClient.d.ts.map +1 -0
- package/lib/node/factory/oracleClient.js +53 -0
- package/lib/node/idl/drift.d.ts +23895 -0
- package/lib/node/idl/drift.d.ts.map +1 -0
- package/lib/node/idl/drift.js +2 -0
- package/lib/node/idl/drift.json +18698 -0
- package/lib/node/idl/pyth.d.ts +98 -0
- package/lib/node/idl/pyth.d.ts.map +1 -0
- package/lib/node/idl/pyth.js +2 -0
- package/lib/node/idl/token_faucet.d.ts +198 -0
- package/lib/node/idl/token_faucet.d.ts.map +1 -0
- package/lib/node/idl/token_faucet.js +2 -0
- package/lib/node/idl/token_faucet.json +229 -0
- package/lib/node/index.d.ts +145 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +175 -0
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +36 -0
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -0
- package/lib/node/indicative-quotes/indicativeQuotesSender.js +192 -0
- package/lib/node/isomorphic/anchor.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.d.ts +2 -0
- package/lib/node/isomorphic/anchor.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.js +17 -0
- package/lib/node/isomorphic/anchor.node.d.ts +2 -0
- package/lib/node/isomorphic/anchor.node.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor.node.js +17 -0
- package/lib/node/isomorphic/anchor29.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.d.ts +2 -0
- package/lib/node/isomorphic/anchor29.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.js +17 -0
- package/lib/node/isomorphic/anchor29.node.d.ts +2 -0
- package/lib/node/isomorphic/anchor29.node.d.ts.map +1 -0
- package/lib/node/isomorphic/anchor29.node.js +17 -0
- package/lib/node/isomorphic/grpc.browser.d.ts.map +1 -0
- package/lib/node/isomorphic/grpc.d.ts +18 -0
- package/lib/node/isomorphic/grpc.d.ts.map +1 -0
- package/lib/node/isomorphic/grpc.js +109 -0
- package/lib/node/isomorphic/grpc.node.d.ts +18 -0
- package/lib/node/isomorphic/grpc.node.d.ts.map +1 -0
- package/lib/node/isomorphic/grpc.node.js +109 -0
- package/lib/node/jupiter/jupiterClient.d.ts +292 -0
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -0
- package/lib/node/jupiter/jupiterClient.js +164 -0
- package/lib/node/keypair.d.ts +3 -0
- package/lib/node/keypair.d.ts.map +1 -0
- package/lib/node/keypair.js +28 -0
- package/lib/node/marginCalculation.d.ts +68 -0
- package/lib/node/marginCalculation.d.ts.map +1 -0
- package/lib/node/marginCalculation.js +176 -0
- package/lib/node/marinade/index.d.ts +13 -0
- package/lib/node/marinade/index.d.ts.map +1 -0
- package/lib/node/marinade/index.js +36 -0
- package/lib/node/marinade/types.d.ts +1964 -0
- package/lib/node/marinade/types.d.ts.map +1 -0
- package/lib/node/marinade/types.js +1965 -0
- package/lib/node/math/amm.d.ts +99 -0
- package/lib/node/math/amm.d.ts.map +1 -0
- package/lib/node/math/amm.js +671 -0
- package/lib/node/math/auction.d.ts +66 -0
- package/lib/node/math/auction.d.ts.map +1 -0
- package/lib/node/math/auction.js +261 -0
- package/lib/node/math/bankruptcy.d.ts +3 -0
- package/lib/node/math/bankruptcy.d.ts.map +1 -0
- package/lib/node/math/bankruptcy.js +32 -0
- package/lib/node/math/builder.d.ts +6 -0
- package/lib/node/math/builder.d.ts.map +1 -0
- package/lib/node/math/builder.js +22 -0
- package/lib/node/math/conversion.d.ts +5 -0
- package/lib/node/math/conversion.d.ts.map +1 -0
- package/lib/node/math/conversion.js +21 -0
- package/lib/node/math/exchangeStatus.d.ts +9 -0
- package/lib/node/math/exchangeStatus.d.ts.map +1 -0
- package/lib/node/math/exchangeStatus.js +85 -0
- package/lib/node/math/funding.d.ts +45 -0
- package/lib/node/math/funding.d.ts.map +1 -0
- package/lib/node/math/funding.js +260 -0
- package/lib/node/math/insurance.d.ts +9 -0
- package/lib/node/math/insurance.d.ts.map +1 -0
- package/lib/node/math/insurance.js +74 -0
- package/lib/node/math/liquidation.d.ts +8 -0
- package/lib/node/math/liquidation.d.ts.map +1 -0
- package/lib/node/math/liquidation.js +134 -0
- package/lib/node/math/margin.d.ts +46 -0
- package/lib/node/math/margin.d.ts.map +1 -0
- package/lib/node/math/margin.js +205 -0
- package/lib/node/math/market.d.ts +51 -0
- package/lib/node/math/market.d.ts.map +1 -0
- package/lib/node/math/market.js +234 -0
- package/lib/node/math/oracles.d.ts +20 -0
- package/lib/node/math/oracles.d.ts.map +1 -0
- package/lib/node/math/oracles.js +215 -0
- package/lib/node/math/orders.d.ts +37 -0
- package/lib/node/math/orders.d.ts.map +1 -0
- package/lib/node/math/orders.js +294 -0
- package/lib/node/math/position.d.ts +72 -0
- package/lib/node/math/position.d.ts.map +1 -0
- package/lib/node/math/position.js +232 -0
- package/lib/node/math/repeg.d.ts +23 -0
- package/lib/node/math/repeg.d.ts.map +1 -0
- package/lib/node/math/repeg.js +164 -0
- package/lib/node/math/spotBalance.d.ts +86 -0
- package/lib/node/math/spotBalance.d.ts.map +1 -0
- package/lib/node/math/spotBalance.js +438 -0
- package/lib/node/math/spotMarket.d.ts +12 -0
- package/lib/node/math/spotMarket.d.ts.map +1 -0
- package/lib/node/math/spotMarket.js +49 -0
- package/lib/node/math/spotPosition.d.ts +20 -0
- package/lib/node/math/spotPosition.d.ts.map +1 -0
- package/lib/node/math/spotPosition.js +79 -0
- package/lib/node/math/state.d.ts +9 -0
- package/lib/node/math/state.d.ts.map +1 -0
- package/lib/node/math/state.js +44 -0
- package/lib/node/math/superStake.d.ts +169 -0
- package/lib/node/math/superStake.d.ts.map +1 -0
- package/lib/node/math/superStake.js +308 -0
- package/lib/node/math/tiers.d.ts +5 -0
- package/lib/node/math/tiers.d.ts.map +1 -0
- package/lib/node/math/tiers.js +52 -0
- package/lib/node/math/trade.d.ts +94 -0
- package/lib/node/math/trade.d.ts.map +1 -0
- package/lib/node/math/trade.js +503 -0
- package/lib/node/math/utils.d.ts +24 -0
- package/lib/node/math/utils.d.ts.map +1 -0
- package/lib/node/math/utils.js +113 -0
- package/lib/node/memcmp.d.ts +19 -0
- package/lib/node/memcmp.d.ts.map +1 -0
- package/lib/node/memcmp.js +162 -0
- package/lib/node/oracles/oracleClientCache.d.ts +10 -0
- package/lib/node/oracles/oracleClientCache.d.ts.map +1 -0
- package/lib/node/oracles/oracleClientCache.js +19 -0
- package/lib/node/oracles/oracleId.d.ts +10 -0
- package/lib/node/oracles/oracleId.d.ts.map +1 -0
- package/lib/node/oracles/oracleId.js +89 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts +13 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -0
- package/lib/node/oracles/prelaunchOracleClient.js +24 -0
- package/lib/node/oracles/pythClient.d.ts +15 -0
- package/lib/node/oracles/pythClient.d.ts.map +1 -0
- package/lib/node/oracles/pythClient.js +51 -0
- package/lib/node/oracles/pythLazerClient.d.ts +17 -0
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -0
- package/lib/node/oracles/pythLazerClient.js +61 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts +11 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts.map +1 -0
- package/lib/node/oracles/quoteAssetOracleClient.js +21 -0
- package/lib/node/oracles/strictOraclePrice.d.ts +10 -0
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -0
- package/lib/node/oracles/strictOraclePrice.js +17 -0
- package/lib/node/oracles/types.d.ts +34 -0
- package/lib/node/oracles/types.d.ts.map +1 -0
- package/lib/node/oracles/types.js +2 -0
- package/lib/node/oracles/utils.d.ts +5 -0
- package/lib/node/oracles/utils.d.ts.map +1 -0
- package/lib/node/oracles/utils.js +8 -0
- package/lib/node/orderParams.d.ts +30 -0
- package/lib/node/orderParams.d.ts.map +1 -0
- package/lib/node/orderParams.js +44 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +46 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -0
- package/lib/node/orderSubscriber/OrderSubscriber.js +193 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts +13 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts.map +1 -0
- package/lib/node/orderSubscriber/PollingSubscription.js +23 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +24 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts.map +1 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.js +67 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts +23 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts.map +1 -0
- package/lib/node/orderSubscriber/grpcSubscription.js +75 -0
- package/lib/node/orderSubscriber/index.d.ts +8 -0
- package/lib/node/orderSubscriber/index.d.ts.map +1 -0
- package/lib/node/orderSubscriber/index.js +23 -0
- package/lib/node/orderSubscriber/types.d.ts +36 -0
- package/lib/node/orderSubscriber/types.d.ts.map +1 -0
- package/lib/node/orderSubscriber/types.js +2 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +6 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.js +16 -0
- package/lib/node/priorityFee/averageStrategy.d.ts +6 -0
- package/lib/node/priorityFee/averageStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/averageStrategy.js +11 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts +12 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/ewmaStrategy.js +33 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +21 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts.map +1 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.js +46 -0
- package/lib/node/priorityFee/index.d.ts +17 -0
- package/lib/node/priorityFee/index.d.ts.map +1 -0
- package/lib/node/priorityFee/index.js +32 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +6 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.js +17 -0
- package/lib/node/priorityFee/maxStrategy.d.ts +8 -0
- package/lib/node/priorityFee/maxStrategy.d.ts.map +1 -0
- package/lib/node/priorityFee/maxStrategy.js +9 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +49 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.js +193 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +51 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +96 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +7 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts.map +1 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.js +21 -0
- package/lib/node/priorityFee/types.d.ts +36 -0
- package/lib/node/priorityFee/types.d.ts.map +1 -0
- package/lib/node/priorityFee/types.js +10 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +22 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -0
- package/lib/node/priorityFee/velocityPriorityFeeMethod.js +28 -0
- package/lib/node/pyth/constants.d.ts +4 -0
- package/lib/node/pyth/constants.d.ts.map +1 -0
- package/lib/node/pyth/constants.js +6 -0
- package/lib/node/pyth/index.d.ts +5 -0
- package/lib/node/pyth/index.d.ts.map +1 -0
- package/lib/node/pyth/index.js +12 -0
- package/lib/node/pyth/pythLazerSubscriber.d.ts +92 -0
- package/lib/node/pyth/pythLazerSubscriber.d.ts.map +1 -0
- package/lib/node/pyth/pythLazerSubscriber.js +276 -0
- package/lib/node/pyth/types.d.ts +2227 -0
- package/lib/node/pyth/types.d.ts.map +1 -0
- package/lib/node/pyth/types.js +2224 -0
- package/lib/node/pyth/utils.d.ts +3 -0
- package/lib/node/pyth/utils.d.ts.map +1 -0
- package/lib/node/pyth/utils.js +10 -0
- package/lib/node/slot/SlotSubscriber.d.ts +28 -0
- package/lib/node/slot/SlotSubscriber.d.ts.map +1 -0
- package/lib/node/slot/SlotSubscriber.js +76 -0
- package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/node/slot/SlothashSubscriber.d.ts.map +1 -0
- package/lib/node/slot/SlothashSubscriber.js +88 -0
- package/lib/node/swap/UnifiedSwapClient.d.ts +121 -0
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -0
- package/lib/node/swap/UnifiedSwapClient.js +179 -0
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +23 -0
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +57 -0
- package/lib/node/swift/index.d.ts +11 -0
- package/lib/node/swift/index.d.ts.map +1 -0
- package/lib/node/swift/index.js +26 -0
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +43 -0
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -0
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +118 -0
- package/lib/node/swift/swiftOrderSubscriber.d.ts +64 -0
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -0
- package/lib/node/swift/swiftOrderSubscriber.js +187 -0
- package/lib/node/testClient.d.ts +9 -0
- package/lib/node/testClient.d.ts.map +1 -0
- package/lib/node/testClient.js +24 -0
- package/lib/node/titan/titanClient.d.ts +91 -0
- package/lib/node/titan/titanClient.d.ts.map +1 -0
- package/lib/node/titan/titanClient.js +227 -0
- package/lib/node/token/index.d.ts +6 -0
- package/lib/node/token/index.d.ts.map +1 -0
- package/lib/node/token/index.js +15 -0
- package/lib/node/tokenFaucet.d.ts +42 -0
- package/lib/node/tokenFaucet.d.ts.map +1 -0
- package/lib/node/tokenFaucet.js +188 -0
- package/lib/node/tx/baseTxSender.d.ts +60 -0
- package/lib/node/tx/baseTxSender.d.ts.map +1 -0
- package/lib/node/tx/baseTxSender.js +292 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +9 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts.map +1 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +29 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts.map +1 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts +5 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts.map +1 -0
- package/lib/node/tx/blockhashFetcher/types.js +2 -0
- package/lib/node/tx/fastSingleTxSender.d.ts +42 -0
- package/lib/node/tx/fastSingleTxSender.d.ts.map +1 -0
- package/lib/node/tx/fastSingleTxSender.js +86 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts +38 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts.map +1 -0
- package/lib/node/tx/forwardOnlyTxSender.js +92 -0
- package/lib/node/tx/priorityFeeCalculator.d.ts +45 -0
- package/lib/node/tx/priorityFeeCalculator.d.ts.map +1 -0
- package/lib/node/tx/priorityFeeCalculator.js +85 -0
- package/lib/node/tx/reportTransactionError.d.ts +21 -0
- package/lib/node/tx/reportTransactionError.d.ts.map +1 -0
- package/lib/node/tx/reportTransactionError.js +103 -0
- package/lib/node/tx/retryTxSender.d.ts +38 -0
- package/lib/node/tx/retryTxSender.d.ts.map +1 -0
- package/lib/node/tx/retryTxSender.js +86 -0
- package/lib/node/tx/txHandler.d.ts +174 -0
- package/lib/node/tx/txHandler.d.ts.map +1 -0
- package/lib/node/tx/txHandler.js +522 -0
- package/lib/node/tx/txParamProcessor.d.ts +27 -0
- package/lib/node/tx/txParamProcessor.d.ts.map +1 -0
- package/lib/node/tx/txParamProcessor.js +92 -0
- package/lib/node/tx/types.d.ts +30 -0
- package/lib/node/tx/types.d.ts.map +1 -0
- package/lib/node/tx/types.js +20 -0
- package/lib/node/tx/utils.d.ts +7 -0
- package/lib/node/tx/utils.d.ts.map +1 -0
- package/lib/node/tx/utils.js +78 -0
- package/lib/node/tx/whileValidTxSender.d.ts +46 -0
- package/lib/node/tx/whileValidTxSender.d.ts.map +1 -0
- package/lib/node/tx/whileValidTxSender.js +168 -0
- package/lib/node/types.d.ts +1748 -0
- package/lib/node/types.d.ts.map +1 -0
- package/lib/node/types.js +427 -0
- package/lib/node/user.d.ts +447 -0
- package/lib/node/user.d.ts.map +1 -0
- package/lib/node/user.js +2372 -0
- package/lib/node/userConfig.d.ts +32 -0
- package/lib/node/userConfig.d.ts.map +1 -0
- package/lib/node/userConfig.js +2 -0
- package/lib/node/userMap/PollingSubscription.d.ts +16 -0
- package/lib/node/userMap/PollingSubscription.d.ts.map +1 -0
- package/lib/node/userMap/PollingSubscription.js +30 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts +28 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts.map +1 -0
- package/lib/node/userMap/WebsocketSubscription.js +45 -0
- package/lib/node/userMap/grpcSubscription.d.ts +28 -0
- package/lib/node/userMap/grpcSubscription.d.ts.map +1 -0
- package/lib/node/userMap/grpcSubscription.js +44 -0
- package/lib/node/userMap/referrerMap.d.ts +46 -0
- package/lib/node/userMap/referrerMap.d.ts.map +1 -0
- package/lib/node/userMap/referrerMap.js +184 -0
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +67 -0
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -0
- package/lib/node/userMap/revenueShareEscrowMap.js +210 -0
- package/lib/node/userMap/userMap.d.ts +115 -0
- package/lib/node/userMap/userMap.d.ts.map +1 -0
- package/lib/node/userMap/userMap.js +486 -0
- package/lib/node/userMap/userMapConfig.d.ts +41 -0
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -0
- package/lib/node/userMap/userMapConfig.js +2 -0
- package/lib/node/userMap/userStatsMap.d.ts +67 -0
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -0
- package/lib/node/userMap/userStatsMap.js +266 -0
- package/lib/node/userName.d.ts +6 -0
- package/lib/node/userName.d.ts.map +1 -0
- package/lib/node/userName.js +21 -0
- package/lib/node/userStats.d.ts +25 -0
- package/lib/node/userStats.d.ts.map +1 -0
- package/lib/node/userStats.js +70 -0
- package/lib/node/userStatsConfig.d.ts +27 -0
- package/lib/node/userStatsConfig.d.ts.map +1 -0
- package/lib/node/userStatsConfig.js +2 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts +17 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts.map +1 -0
- package/lib/node/util/TransactionConfirmationManager.js +174 -0
- package/lib/node/util/chainClock.d.ts +18 -0
- package/lib/node/util/chainClock.d.ts.map +1 -0
- package/lib/node/util/chainClock.js +29 -0
- package/lib/node/util/computeUnits.d.ts +9 -0
- package/lib/node/util/computeUnits.d.ts.map +1 -0
- package/lib/node/util/computeUnits.js +48 -0
- package/lib/node/util/digest.d.ts +6 -0
- package/lib/node/util/digest.d.ts.map +1 -0
- package/lib/node/util/digest.js +19 -0
- package/lib/node/util/ed25519Utils.d.ts +11 -0
- package/lib/node/util/ed25519Utils.d.ts.map +1 -0
- package/lib/node/util/ed25519Utils.js +80 -0
- package/lib/node/util/promiseTimeout.d.ts +2 -0
- package/lib/node/util/promiseTimeout.d.ts.map +1 -0
- package/lib/node/util/promiseTimeout.js +14 -0
- package/lib/node/util/tps.d.ts +3 -0
- package/lib/node/util/tps.d.ts.map +1 -0
- package/lib/node/util/tps.js +16 -0
- package/lib/node/velocityClient.d.ts +1231 -0
- package/lib/node/velocityClient.d.ts.map +1 -0
- package/lib/node/velocityClient.js +5778 -0
- package/lib/node/velocityClientConfig.d.ts +85 -0
- package/lib/node/velocityClientConfig.d.ts.map +1 -0
- package/lib/node/velocityClientConfig.js +2 -0
- package/lib/node/wallet.d.ts +17 -0
- package/lib/node/wallet.d.ts.map +1 -0
- package/lib/node/wallet.js +46 -0
- package/package.json +157 -0
- package/scripts/deposit-isolated-positions.ts +110 -0
- package/scripts/find-flagged-users.ts +213 -0
- package/scripts/grpc-client-test-comparison.ts +372 -0
- package/scripts/grpc-multiuser-client-test-comparison.ts +158 -0
- package/scripts/postbuild.js +95 -0
- package/scripts/single-grpc-client-test.ts +284 -0
- package/scripts/updateVersion.js +28 -0
- package/scripts/withdraw-isolated-positions.ts +174 -0
- package/src/accounts/README_WebSocketAccountSubscriberV2.md +95 -0
- package/src/accounts/README_WebSocketProgramAccountSubscriberV2.md +135 -0
- package/src/accounts/basicUserAccountSubscriber.ts +59 -0
- package/src/accounts/basicUserStatsAccountSubscriber.ts +65 -0
- package/src/accounts/bulkAccountLoader.ts +293 -0
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +33 -0
- package/src/accounts/customizedCadenceBulkAccountLoader.ts +213 -0
- package/src/accounts/fetch.ts +143 -0
- package/src/accounts/grpcAccountSubscriber.ts +187 -0
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +57 -0
- package/src/accounts/grpcMultiAccountSubscriber.ts +476 -0
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +281 -0
- package/src/accounts/grpcProgramAccountSubscriber.ts +223 -0
- package/src/accounts/grpcUserAccountSubscriber.ts +48 -0
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +50 -0
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +213 -0
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +762 -0
- package/src/accounts/laserProgramAccountSubscriber.ts +229 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +67 -0
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +70 -0
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +186 -0
- package/src/accounts/pollingOracleAccountSubscriber.ts +125 -0
- package/src/accounts/pollingTokenAccountSubscriber.ts +118 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +160 -0
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +156 -0
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +652 -0
- package/src/accounts/testBulkAccountLoader.ts +51 -0
- package/src/accounts/types.ts +284 -0
- package/src/accounts/utils.ts +62 -0
- package/src/accounts/webSocketAccountSubscriber.ts +250 -0
- package/src/accounts/webSocketAccountSubscriberV2.ts +517 -0
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +129 -0
- package/src/accounts/webSocketProgramAccountSubscriber.ts +183 -0
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +996 -0
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +996 -0
- package/src/accounts/webSocketUserAccountSubscriber.ts +104 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +98 -0
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +719 -0
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +755 -0
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +94 -0
- package/src/addresses/marketAddresses.ts +17 -0
- package/src/addresses/pda.ts +439 -0
- package/src/adminClient.ts +5936 -0
- package/src/assert/assert.ts +5 -0
- package/src/auctionSubscriber/auctionSubscriber.ts +68 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +72 -0
- package/src/auctionSubscriber/index.ts +3 -0
- package/src/auctionSubscriber/types.ts +20 -0
- package/src/bankrun/bankrunConnection.ts +560 -0
- package/src/blockhashSubscriber/BlockhashSubscriber.ts +126 -0
- package/src/blockhashSubscriber/index.ts +1 -0
- package/src/blockhashSubscriber/types.ts +12 -0
- package/src/clock/clockSubscriber.ts +121 -0
- package/src/config.ts +268 -0
- package/src/constants/index.ts +10 -0
- package/src/constants/insuranceFund.ts +8 -0
- package/src/constants/numericConstants.ts +119 -0
- package/src/constants/perpMarkets.ts +1042 -0
- package/src/constants/spotMarkets.ts +874 -0
- package/src/constants/txConstants.ts +1 -0
- package/src/constituentMap/constituentMap.ts +294 -0
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +97 -0
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +112 -0
- package/src/core/VelocityCore.ts +331 -0
- package/src/core/index.ts +12 -0
- package/src/core/instructions/deposit.ts +42 -0
- package/src/core/instructions/fill.ts +34 -0
- package/src/core/instructions/funding.ts +21 -0
- package/src/core/instructions/liquidation.ts +37 -0
- package/src/core/instructions/orders.ts +56 -0
- package/src/core/instructions/perpOrders.ts +192 -0
- package/src/core/instructions/settlement.ts +26 -0
- package/src/core/instructions/trigger.ts +26 -0
- package/src/core/instructions/withdraw.ts +44 -0
- package/src/core/remainingAccounts.ts +276 -0
- package/src/core/signedMsg.ts +71 -0
- package/src/decode/customCoder.ts +105 -0
- package/src/decode/user.ts +372 -0
- package/src/dlob/DLOB.ts +2098 -0
- package/src/dlob/DLOBNode.ts +193 -0
- package/src/dlob/DLOBSubscriber.ts +211 -0
- package/src/dlob/NodeList.ts +174 -0
- package/src/dlob/orderBookLevels.ts +575 -0
- package/src/dlob/types.ts +22 -0
- package/src/events/eventList.ts +97 -0
- package/src/events/eventSubscriber.ts +382 -0
- package/src/events/eventsServerLogProvider.ts +152 -0
- package/src/events/fetchLogs.ts +169 -0
- package/src/events/parse.ts +248 -0
- package/src/events/pollingLogProvider.ts +89 -0
- package/src/events/sort.ts +39 -0
- package/src/events/txEventCache.ts +74 -0
- package/src/events/types.ts +228 -0
- package/src/events/webSocketLogProvider.ts +121 -0
- package/src/factory/bigNum.ts +709 -0
- package/src/factory/oracleClient.ts +73 -0
- package/src/idl/drift.json +18698 -0
- package/src/idl/drift.ts +23894 -0
- package/src/idl/pyth.json +142 -0
- package/src/idl/pyth.ts +97 -0
- package/src/idl/pyth_solana_receiver.json +628 -0
- package/src/idl/token_faucet.json +229 -0
- package/src/idl/token_faucet.ts +197 -0
- package/src/index.ts +150 -0
- package/src/indicative-quotes/indicativeQuotesSender.ts +233 -0
- package/src/isomorphic/README.md +19 -0
- package/src/isomorphic/anchor.browser.ts +44 -0
- package/src/isomorphic/anchor.node.ts +1 -0
- package/src/isomorphic/anchor.ts +1 -0
- package/src/isomorphic/anchor29.browser.ts +24 -0
- package/src/isomorphic/anchor29.node.ts +1 -0
- package/src/isomorphic/anchor29.ts +1 -0
- package/src/isomorphic/grpc.browser.ts +4 -0
- package/src/isomorphic/grpc.node.ts +130 -0
- package/src/isomorphic/grpc.ts +1 -0
- package/src/jupiter/jupiterClient.ts +482 -0
- package/src/keypair.ts +24 -0
- package/src/margin/README.md +138 -0
- package/src/marginCalculation.ts +255 -0
- package/src/marinade/idl/idl.json +1962 -0
- package/src/marinade/index.ts +64 -0
- package/src/marinade/types.ts +3925 -0
- package/src/math/amm.ts +1246 -0
- package/src/math/auction.ts +374 -0
- package/src/math/bankruptcy.ts +35 -0
- package/src/math/builder.ts +20 -0
- package/src/math/conversion.ts +24 -0
- package/src/math/exchangeStatus.ts +136 -0
- package/src/math/funding.ts +436 -0
- package/src/math/insurance.ts +111 -0
- package/src/math/liquidation.ts +209 -0
- package/src/math/margin.ts +368 -0
- package/src/math/market.ts +438 -0
- package/src/math/oracles.ts +367 -0
- package/src/math/orders.ts +473 -0
- package/src/math/position.ts +340 -0
- package/src/math/repeg.ts +214 -0
- package/src/math/spotBalance.ts +752 -0
- package/src/math/spotMarket.ts +82 -0
- package/src/math/spotPosition.ts +191 -0
- package/src/math/state.ts +48 -0
- package/src/math/superStake.ts +528 -0
- package/src/math/tiers.ts +44 -0
- package/src/math/trade.ts +805 -0
- package/src/math/utils.ts +121 -0
- package/src/memcmp.ts +164 -0
- package/src/oracles/oracleClientCache.ts +25 -0
- package/src/oracles/oracleId.ts +66 -0
- package/src/oracles/prelaunchOracleClient.ts +38 -0
- package/src/oracles/pythClient.ts +85 -0
- package/src/oracles/pythLazerClient.ts +102 -0
- package/src/oracles/quoteAssetOracleClient.ts +25 -0
- package/src/oracles/strictOraclePrice.ts +19 -0
- package/src/oracles/types.ts +37 -0
- package/src/oracles/utils.ts +10 -0
- package/src/orderParams.ts +79 -0
- package/src/orderSubscriber/OrderSubscriber.ts +296 -0
- package/src/orderSubscriber/PollingSubscription.ts +39 -0
- package/src/orderSubscriber/WebsocketSubscription.ts +119 -0
- package/src/orderSubscriber/grpcSubscription.ts +139 -0
- package/src/orderSubscriber/index.ts +7 -0
- package/src/orderSubscriber/types.ts +55 -0
- package/src/priorityFee/averageOverSlotsStrategy.ts +16 -0
- package/src/priorityFee/averageStrategy.ts +12 -0
- package/src/priorityFee/ewmaStrategy.ts +41 -0
- package/src/priorityFee/heliusPriorityFeeMethod.ts +57 -0
- package/src/priorityFee/index.ts +16 -0
- package/src/priorityFee/maxOverSlotsStrategy.ts +17 -0
- package/src/priorityFee/maxStrategy.ts +7 -0
- package/src/priorityFee/priorityFeeSubscriber.ts +256 -0
- package/src/priorityFee/priorityFeeSubscriberMap.ts +125 -0
- package/src/priorityFee/solanaPriorityFeeMethod.ts +34 -0
- package/src/priorityFee/types.ts +64 -0
- package/src/priorityFee/velocityPriorityFeeMethod.ts +54 -0
- package/src/pyth/constants.ts +9 -0
- package/src/pyth/index.ts +15 -0
- package/src/pyth/pythLazerSubscriber.ts +365 -0
- package/src/pyth/types.ts +4453 -0
- package/src/pyth/utils.ts +13 -0
- package/src/slot/SlotSubscriber.ts +108 -0
- package/src/slot/SlothashSubscriber.ts +126 -0
- package/src/swap/UnifiedSwapClient.ts +315 -0
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +95 -0
- package/src/swift/index.ts +10 -0
- package/src/swift/signedMsgUserAccountSubscriber.ts +241 -0
- package/src/swift/swiftOrderSubscriber.ts +347 -0
- package/src/testClient.ts +42 -0
- package/src/titan/titanClient.ts +438 -0
- package/src/token/index.ts +13 -0
- package/src/tokenFaucet.ts +274 -0
- package/src/tx/baseTxSender.ts +471 -0
- package/src/tx/blockhashFetcher/baseBlockhashFetcher.ts +19 -0
- package/src/tx/blockhashFetcher/cachedBlockhashFetcher.ts +90 -0
- package/src/tx/blockhashFetcher/types.ts +5 -0
- package/src/tx/fastSingleTxSender.ts +142 -0
- package/src/tx/forwardOnlyTxSender.ts +145 -0
- package/src/tx/priorityFeeCalculator.ts +117 -0
- package/src/tx/reportTransactionError.ts +159 -0
- package/src/tx/retryTxSender.ts +135 -0
- package/src/tx/txHandler.ts +853 -0
- package/src/tx/txParamProcessor.ts +163 -0
- package/src/tx/types.ts +71 -0
- package/src/tx/utils.ts +107 -0
- package/src/tx/whileValidTxSender.ts +266 -0
- package/src/types.ts +1793 -0
- package/src/user.ts +4487 -0
- package/src/userConfig.ts +37 -0
- package/src/userMap/PollingSubscription.ts +47 -0
- package/src/userMap/WebsocketSubscription.ts +84 -0
- package/src/userMap/grpcSubscription.ts +85 -0
- package/src/userMap/referrerMap.ts +267 -0
- package/src/userMap/revenueShareEscrowMap.ts +310 -0
- package/src/userMap/userMap.ts +683 -0
- package/src/userMap/userMapConfig.ts +66 -0
- package/src/userMap/userStatsMap.ts +358 -0
- package/src/userName.ts +21 -0
- package/src/userStats.ts +117 -0
- package/src/userStatsConfig.ts +32 -0
- package/src/util/TransactionConfirmationManager.ts +292 -0
- package/src/util/chainClock.ts +41 -0
- package/src/util/computeUnits.ts +65 -0
- package/src/util/digest.ts +16 -0
- package/src/util/ed25519Utils.ts +85 -0
- package/src/util/promiseTimeout.ts +14 -0
- package/src/util/tps.ts +27 -0
- package/src/velocityClient.ts +11364 -0
- package/src/velocityClientConfig.ts +144 -0
- package/src/wallet.ts +54 -0
- package/tests/DriftCore/decode.test.ts +16 -0
- package/tests/DriftCore/fill_trigger.test.ts +73 -0
- package/tests/DriftCore/instructions.test.ts +46 -0
- package/tests/DriftCore/pdas.test.ts +28 -0
- package/tests/DriftCore/perp_orders.test.ts +205 -0
- package/tests/DriftCore/remainingAccounts.test.ts +73 -0
- package/tests/DriftCore/settlement_liquidation.test.ts +69 -0
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +203 -0
- package/tests/amm/test.ts +2095 -0
- package/tests/auctions/test.ts +81 -0
- package/tests/bn/test.ts +355 -0
- package/tests/ci/verifyConstants.ts +396 -0
- package/tests/decode/phoenix.ts +71 -0
- package/tests/decode/test.ts +262 -0
- package/tests/decode/userAccountBufferStrings.ts +102 -0
- package/tests/dlob/helpers.ts +740 -0
- package/tests/dlob/test.ts +6920 -0
- package/tests/events/parseLogsForCuUsage.ts +139 -0
- package/tests/insurance/test.ts +40 -0
- package/tests/spot/test.ts +226 -0
- package/tests/tx/TransactionConfirmationManager.test.ts +305 -0
- package/tests/tx/cachedBlockhashFetcher.test.ts +96 -0
- package/tests/tx/priorityFeeCalculator.ts +77 -0
- package/tests/tx/priorityFeeStrategy.ts +95 -0
- package/tests/user/getMarginCalculation.ts +361 -0
- package/tests/user/helpers.ts +185 -0
- package/tests/user/liquidations.ts +129 -0
- package/tests/user/marginCalculations.test.ts +321 -0
- package/tests/user/test.ts +826 -0
- package/tsconfig.browser.json +16 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,2798 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.HotRole = exports.AdminClient = void 0;
|
|
27
|
+
/**
|
|
28
|
+
* AdminClient — governance and protocol administration instruction builders.
|
|
29
|
+
* Extends {@link VelocityClient}; all trading/keeper methods are also available.
|
|
30
|
+
*
|
|
31
|
+
* Covers: perp/spot market initialization and updates, oracle guard rail config,
|
|
32
|
+
* fee structure updates, insurance fund operations, vault management, IF rebalancing,
|
|
33
|
+
* pause/unpause exchange, and all ~126 admin instruction handlers in `instructions/admin.rs`.
|
|
34
|
+
*/
|
|
35
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
36
|
+
const types_1 = require("./types");
|
|
37
|
+
const userName_1 = require("./userName");
|
|
38
|
+
const anchor_1 = require("./isomorphic/anchor");
|
|
39
|
+
const anchor = __importStar(require("./isomorphic/anchor"));
|
|
40
|
+
const pda_1 = require("./addresses/pda");
|
|
41
|
+
const utils_1 = require("./math/utils");
|
|
42
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
43
|
+
const velocityClient_1 = require("./velocityClient");
|
|
44
|
+
const numericConstants_1 = require("./constants/numericConstants");
|
|
45
|
+
const trade_1 = require("./math/trade");
|
|
46
|
+
const amm_1 = require("./math/amm");
|
|
47
|
+
class AdminClient extends velocityClient_1.VelocityClient {
|
|
48
|
+
async initialize(usdcMint, _adminControlsPrices) {
|
|
49
|
+
const stateAccountRPCResponse = await this.connection.getParsedAccountInfo(await this.getStatePublicKey());
|
|
50
|
+
if (stateAccountRPCResponse.value !== null) {
|
|
51
|
+
throw new Error('Clearing house already initialized');
|
|
52
|
+
}
|
|
53
|
+
const [driftStatePublicKey] = await (0, pda_1.getVelocityStateAccountPublicKeyAndNonce)(this.program.programId);
|
|
54
|
+
const initializeIx = await this.program.instruction.initialize({
|
|
55
|
+
accounts: {
|
|
56
|
+
admin: this.isSubscribed
|
|
57
|
+
? this.getStateAccount().coldAdmin
|
|
58
|
+
: this.wallet.publicKey,
|
|
59
|
+
state: driftStatePublicKey,
|
|
60
|
+
quoteAssetMint: usdcMint,
|
|
61
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
62
|
+
driftSigner: this.getSignerPublicKey(),
|
|
63
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
64
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
68
|
+
const { txSig } = await super.sendTransaction(tx, [], this.opts);
|
|
69
|
+
return [txSig];
|
|
70
|
+
}
|
|
71
|
+
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
|
+
const spotMarketIndex = marketIndex !== null && marketIndex !== void 0 ? marketIndex : this.getStateAccount().numberOfSpotMarkets;
|
|
73
|
+
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);
|
|
74
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
75
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
76
|
+
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
77
|
+
await this.accountSubscriber.addOracle({
|
|
78
|
+
source: oracleSource,
|
|
79
|
+
publicKey: oracle,
|
|
80
|
+
});
|
|
81
|
+
await this.accountSubscriber.setSpotOracleMap();
|
|
82
|
+
return txSig;
|
|
83
|
+
}
|
|
84
|
+
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
|
+
const spotMarketIndex = marketIndex !== null && marketIndex !== void 0 ? marketIndex : this.getStateAccount().numberOfSpotMarkets;
|
|
86
|
+
const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
|
|
87
|
+
const spotMarketVault = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, spotMarketIndex);
|
|
88
|
+
const insuranceFundVault = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, spotMarketIndex);
|
|
89
|
+
const tokenProgram = (await this.connection.getAccountInfo(mint)).owner;
|
|
90
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
91
|
+
const initializeIx = await this.program.instruction.initializeSpotMarket(optimalUtilization, optimalRate, maxRate, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, ifLiquidationFee, activeStatus, assetTier, scaleInitialAssetWeightStart, withdrawGuardThreshold, orderTickSize, orderStepSize, ifTotalFactor, nameBuffer, {
|
|
92
|
+
accounts: {
|
|
93
|
+
admin: this.useHotWalletAdmin
|
|
94
|
+
? this.wallet.publicKey
|
|
95
|
+
: this.isSubscribed
|
|
96
|
+
? this.getStateAccount().coldAdmin
|
|
97
|
+
: this.wallet.publicKey,
|
|
98
|
+
state: await this.getStatePublicKey(),
|
|
99
|
+
spotMarket,
|
|
100
|
+
spotMarketVault,
|
|
101
|
+
insuranceFundVault,
|
|
102
|
+
driftSigner: this.getSignerPublicKey(),
|
|
103
|
+
spotMarketMint: mint,
|
|
104
|
+
oracle,
|
|
105
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
106
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
107
|
+
tokenProgram,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
return initializeIx;
|
|
111
|
+
}
|
|
112
|
+
async deleteInitializedSpotMarket(marketIndex) {
|
|
113
|
+
const deleteInitializeMarketIx = await this.getDeleteInitializedSpotMarketIx(marketIndex);
|
|
114
|
+
const tx = await this.buildTransaction(deleteInitializeMarketIx);
|
|
115
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
116
|
+
return txSig;
|
|
117
|
+
}
|
|
118
|
+
async getDeleteInitializedSpotMarketIx(marketIndex) {
|
|
119
|
+
const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
|
|
120
|
+
const spotMarketVaultPublicKey = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, marketIndex);
|
|
121
|
+
const insuranceFundVaultPublicKey = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, marketIndex);
|
|
122
|
+
return await this.program.instruction.deleteInitializedSpotMarket(marketIndex, {
|
|
123
|
+
accounts: {
|
|
124
|
+
state: await this.getStatePublicKey(),
|
|
125
|
+
admin: this.isSubscribed
|
|
126
|
+
? this.getStateAccount().coldAdmin
|
|
127
|
+
: this.wallet.publicKey,
|
|
128
|
+
spotMarket: spotMarketPublicKey,
|
|
129
|
+
spotMarketVault: spotMarketVaultPublicKey,
|
|
130
|
+
insuranceFundVault: insuranceFundVaultPublicKey,
|
|
131
|
+
driftSigner: this.getSignerPublicKey(),
|
|
132
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
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) {
|
|
137
|
+
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
138
|
+
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);
|
|
139
|
+
const tx = await this.buildTransaction(initializeMarketIxs);
|
|
140
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
141
|
+
while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
|
|
142
|
+
await this.fetchAccounts();
|
|
143
|
+
}
|
|
144
|
+
await this.accountSubscriber.addPerpMarket(marketIndex);
|
|
145
|
+
await this.accountSubscriber.addOracle({
|
|
146
|
+
source: oracleSource,
|
|
147
|
+
publicKey: priceOracle,
|
|
148
|
+
});
|
|
149
|
+
await this.accountSubscriber.setPerpOracleMap();
|
|
150
|
+
return txSig;
|
|
151
|
+
}
|
|
152
|
+
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) {
|
|
153
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
154
|
+
const ixs = [];
|
|
155
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
156
|
+
const initPerpIx = await this.program.instruction.initializePerpMarket(marketIndex, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, nameBuffer, lpPoolId, {
|
|
157
|
+
accounts: {
|
|
158
|
+
state: await this.getStatePublicKey(),
|
|
159
|
+
admin: this.useHotWalletAdmin
|
|
160
|
+
? this.wallet.publicKey
|
|
161
|
+
: this.isSubscribed
|
|
162
|
+
? this.getStateAccount().coldAdmin
|
|
163
|
+
: this.wallet.publicKey,
|
|
164
|
+
oracle: priceOracle,
|
|
165
|
+
perpMarket: perpMarketPublicKey,
|
|
166
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
167
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
ixs.push(initPerpIx);
|
|
171
|
+
return ixs;
|
|
172
|
+
}
|
|
173
|
+
async initializeAmmCache(txParams) {
|
|
174
|
+
const initializeAmmCacheIx = await this.getInitializeAmmCacheIx();
|
|
175
|
+
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
176
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
177
|
+
return txSig;
|
|
178
|
+
}
|
|
179
|
+
async getInitializeAmmCacheIx() {
|
|
180
|
+
return await this.program.instruction.initializeAmmCache({
|
|
181
|
+
accounts: {
|
|
182
|
+
state: await this.getStatePublicKey(),
|
|
183
|
+
admin: this.useHotWalletAdmin
|
|
184
|
+
? this.wallet.publicKey
|
|
185
|
+
: this.getStateAccount().coldAdmin,
|
|
186
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
187
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
188
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
async addMarketToAmmCache(perpMarketIndex, txParams) {
|
|
193
|
+
const initializeAmmCacheIx = await this.getAddMarketToAmmCacheIx(perpMarketIndex);
|
|
194
|
+
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
195
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
196
|
+
return txSig;
|
|
197
|
+
}
|
|
198
|
+
async getAddMarketToAmmCacheIx(perpMarketIndex) {
|
|
199
|
+
return await this.program.instruction.addMarketToAmmCache({
|
|
200
|
+
accounts: {
|
|
201
|
+
state: await this.getStatePublicKey(),
|
|
202
|
+
admin: this.useHotWalletAdmin
|
|
203
|
+
? this.wallet.publicKey
|
|
204
|
+
: this.getStateAccount().coldAdmin,
|
|
205
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
206
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
207
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
208
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
async deleteAmmCache(txParams) {
|
|
213
|
+
const deleteAmmCacheIx = await this.getDeleteAmmCacheIx();
|
|
214
|
+
const tx = await this.buildTransaction(deleteAmmCacheIx, txParams);
|
|
215
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
216
|
+
return txSig;
|
|
217
|
+
}
|
|
218
|
+
async getDeleteAmmCacheIx() {
|
|
219
|
+
return await this.program.instruction.deleteAmmCache({
|
|
220
|
+
accounts: {
|
|
221
|
+
state: await this.getStatePublicKey(),
|
|
222
|
+
admin: this.useHotWalletAdmin
|
|
223
|
+
? this.wallet.publicKey
|
|
224
|
+
: this.getStateAccount().coldAdmin,
|
|
225
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
async updateInitialAmmCacheInfo(perpMarketIndexes, txParams) {
|
|
230
|
+
const initializeAmmCacheIx = await this.getUpdateInitialAmmCacheInfoIx(perpMarketIndexes);
|
|
231
|
+
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
232
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
233
|
+
return txSig;
|
|
234
|
+
}
|
|
235
|
+
async getUpdateInitialAmmCacheInfoIx(perpMarketIndexes) {
|
|
236
|
+
const remainingAccounts = this.getRemainingAccounts({
|
|
237
|
+
userAccounts: [],
|
|
238
|
+
readablePerpMarketIndex: perpMarketIndexes,
|
|
239
|
+
readableSpotMarketIndexes: [numericConstants_1.QUOTE_SPOT_MARKET_INDEX],
|
|
240
|
+
});
|
|
241
|
+
return await this.program.instruction.updateInitialAmmCacheInfo({
|
|
242
|
+
accounts: {
|
|
243
|
+
state: await this.getStatePublicKey(),
|
|
244
|
+
admin: this.useHotWalletAdmin
|
|
245
|
+
? this.wallet.publicKey
|
|
246
|
+
: this.getStateAccount().coldAdmin,
|
|
247
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
248
|
+
},
|
|
249
|
+
remainingAccounts,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
async overrideAmmCacheInfo(perpMarketIndex, params, txParams) {
|
|
253
|
+
const initializeAmmCacheIx = await this.getOverrideAmmCacheInfoIx(perpMarketIndex, params);
|
|
254
|
+
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
255
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
256
|
+
return txSig;
|
|
257
|
+
}
|
|
258
|
+
async getOverrideAmmCacheInfoIx(perpMarketIndex, params) {
|
|
259
|
+
return this.program.instruction.overrideAmmCacheInfo(perpMarketIndex, Object.assign({}, {
|
|
260
|
+
quoteOwedFromLpPool: null,
|
|
261
|
+
lastSettleSlot: null,
|
|
262
|
+
lastFeePoolTokenAmount: null,
|
|
263
|
+
lastNetPnlPoolTokenAmount: null,
|
|
264
|
+
ammPositionScalar: null,
|
|
265
|
+
ammInventoryLimit: null,
|
|
266
|
+
}, params), {
|
|
267
|
+
accounts: {
|
|
268
|
+
state: await this.getStatePublicKey(),
|
|
269
|
+
admin: this.useHotWalletAdmin
|
|
270
|
+
? this.wallet.publicKey
|
|
271
|
+
: this.getStateAccount().coldAdmin,
|
|
272
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
async resetAmmCache(txParams) {
|
|
277
|
+
const initializeAmmCacheIx = await this.getResetAmmCacheIx();
|
|
278
|
+
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
279
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
280
|
+
return txSig;
|
|
281
|
+
}
|
|
282
|
+
async getResetAmmCacheIx() {
|
|
283
|
+
return this.program.instruction.resetAmmCache({
|
|
284
|
+
accounts: {
|
|
285
|
+
state: await this.getStatePublicKey(),
|
|
286
|
+
admin: this.useHotWalletAdmin
|
|
287
|
+
? this.wallet.publicKey
|
|
288
|
+
: this.getStateAccount().coldAdmin,
|
|
289
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
290
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
async deleteInitializedPerpMarket(marketIndex) {
|
|
295
|
+
const deleteInitializeMarketIx = await this.getDeleteInitializedPerpMarketIx(marketIndex);
|
|
296
|
+
const tx = await this.buildTransaction(deleteInitializeMarketIx);
|
|
297
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
298
|
+
return txSig;
|
|
299
|
+
}
|
|
300
|
+
async getDeleteInitializedPerpMarketIx(marketIndex) {
|
|
301
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
302
|
+
return await this.program.instruction.deleteInitializedPerpMarket(marketIndex, {
|
|
303
|
+
accounts: {
|
|
304
|
+
state: await this.getStatePublicKey(),
|
|
305
|
+
admin: this.isSubscribed
|
|
306
|
+
? this.getStateAccount().coldAdmin
|
|
307
|
+
: this.wallet.publicKey,
|
|
308
|
+
perpMarket: perpMarketPublicKey,
|
|
309
|
+
},
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
async moveAmmPrice(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
|
|
313
|
+
const moveAmmPriceIx = await this.getMoveAmmPriceIx(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK);
|
|
314
|
+
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
315
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
316
|
+
return txSig;
|
|
317
|
+
}
|
|
318
|
+
async getMoveAmmPriceIx(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
|
|
319
|
+
const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
320
|
+
if (sqrtK == undefined) {
|
|
321
|
+
sqrtK = (0, utils_1.squareRootBN)(baseAssetReserve.mul(quoteAssetReserve));
|
|
322
|
+
}
|
|
323
|
+
return await this.program.instruction.moveAmmPrice(baseAssetReserve, quoteAssetReserve, sqrtK, {
|
|
324
|
+
accounts: {
|
|
325
|
+
state: await this.getStatePublicKey(),
|
|
326
|
+
admin: this.isSubscribed
|
|
327
|
+
? this.getStateAccount().coldAdmin
|
|
328
|
+
: this.wallet.publicKey,
|
|
329
|
+
perpMarket: marketPublicKey,
|
|
330
|
+
},
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
async updateK(perpMarketIndex, sqrtK) {
|
|
334
|
+
const updateKIx = await this.getUpdateKIx(perpMarketIndex, sqrtK);
|
|
335
|
+
const tx = await this.buildTransaction(updateKIx);
|
|
336
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
337
|
+
return txSig;
|
|
338
|
+
}
|
|
339
|
+
async getUpdateKIx(perpMarketIndex, sqrtK) {
|
|
340
|
+
return await this.program.instruction.updateK(sqrtK, {
|
|
341
|
+
accounts: {
|
|
342
|
+
state: await this.getStatePublicKey(),
|
|
343
|
+
admin: this.isSubscribed
|
|
344
|
+
? this.getStateAccount().coldAdmin
|
|
345
|
+
: this.wallet.publicKey,
|
|
346
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
347
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
async recenterPerpMarketAmm(perpMarketIndex, pegMultiplier, sqrtK) {
|
|
352
|
+
const recenterPerpMarketAmmIx = await this.getRecenterPerpMarketAmmIx(perpMarketIndex, pegMultiplier, sqrtK);
|
|
353
|
+
const tx = await this.buildTransaction(recenterPerpMarketAmmIx);
|
|
354
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
355
|
+
return txSig;
|
|
356
|
+
}
|
|
357
|
+
async getRecenterPerpMarketAmmIx(perpMarketIndex, pegMultiplier, sqrtK) {
|
|
358
|
+
const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
359
|
+
return await this.program.instruction.recenterPerpMarketAmm(pegMultiplier, sqrtK, {
|
|
360
|
+
accounts: {
|
|
361
|
+
state: await this.getStatePublicKey(),
|
|
362
|
+
admin: this.isSubscribed
|
|
363
|
+
? this.getStateAccount().coldAdmin
|
|
364
|
+
: this.wallet.publicKey,
|
|
365
|
+
perpMarket: marketPublicKey,
|
|
366
|
+
},
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
async recenterPerpMarketAmmCrank(perpMarketIndex, depth) {
|
|
370
|
+
const recenterPerpMarketAmmIx = await this.getRecenterPerpMarketAmmCrankIx(perpMarketIndex, depth);
|
|
371
|
+
const tx = await this.buildTransaction(recenterPerpMarketAmmIx);
|
|
372
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
373
|
+
return txSig;
|
|
374
|
+
}
|
|
375
|
+
async getRecenterPerpMarketAmmCrankIx(perpMarketIndex, depth) {
|
|
376
|
+
return await this.program.instruction.recenterPerpMarketAmmCrank(depth !== null && depth !== void 0 ? depth : null, {
|
|
377
|
+
accounts: {
|
|
378
|
+
admin: this.useHotWalletAdmin
|
|
379
|
+
? this.wallet.publicKey
|
|
380
|
+
: this.getStateAccount().coldAdmin,
|
|
381
|
+
state: await this.getStatePublicKey(),
|
|
382
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
383
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX),
|
|
384
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
async updatePerpMarketConcentrationScale(perpMarketIndex, concentrationScale) {
|
|
389
|
+
const updatePerpMarketConcentrationCoefIx = await this.getUpdatePerpMarketConcentrationScaleIx(perpMarketIndex, concentrationScale);
|
|
390
|
+
const tx = await this.buildTransaction(updatePerpMarketConcentrationCoefIx);
|
|
391
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
392
|
+
return txSig;
|
|
393
|
+
}
|
|
394
|
+
async getUpdatePerpMarketConcentrationScaleIx(perpMarketIndex, concentrationScale) {
|
|
395
|
+
return await this.program.instruction.updatePerpMarketConcentrationCoef(concentrationScale, {
|
|
396
|
+
accounts: {
|
|
397
|
+
state: await this.getStatePublicKey(),
|
|
398
|
+
admin: this.isSubscribed
|
|
399
|
+
? this.getStateAccount().coldAdmin
|
|
400
|
+
: this.wallet.publicKey,
|
|
401
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
402
|
+
},
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
async updatePerpMarketLpPoolId(perpMarketIndex, lpPoolId) {
|
|
406
|
+
const updatePerpMarketLpPoolIIx = await this.getUpdatePerpMarketLpPoolIdIx(perpMarketIndex, lpPoolId);
|
|
407
|
+
const tx = await this.buildTransaction(updatePerpMarketLpPoolIIx);
|
|
408
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
409
|
+
return txSig;
|
|
410
|
+
}
|
|
411
|
+
async getUpdatePerpMarketLpPoolIdIx(perpMarketIndex, lpPoolId) {
|
|
412
|
+
return await this.program.instruction.updatePerpMarketLpPoolId(lpPoolId, {
|
|
413
|
+
accounts: {
|
|
414
|
+
state: await this.getStatePublicKey(),
|
|
415
|
+
admin: this.isSubscribed
|
|
416
|
+
? this.getStateAccount().coldAdmin
|
|
417
|
+
: this.wallet.publicKey,
|
|
418
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
async updatePerpMarketLpPoolStatus(perpMarketIndex, lpStatus) {
|
|
423
|
+
const updatePerpMarketLpPoolStatusIx = await this.getUpdatePerpMarketLpPoolStatusIx(perpMarketIndex, lpStatus);
|
|
424
|
+
const tx = await this.buildTransaction(updatePerpMarketLpPoolStatusIx);
|
|
425
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
426
|
+
return txSig;
|
|
427
|
+
}
|
|
428
|
+
async getUpdatePerpMarketLpPoolStatusIx(perpMarketIndex, lpStatus) {
|
|
429
|
+
return await this.program.instruction.updatePerpMarketLpPoolStatus(lpStatus, {
|
|
430
|
+
accounts: {
|
|
431
|
+
state: await this.getStatePublicKey(),
|
|
432
|
+
admin: this.isSubscribed
|
|
433
|
+
? this.getStateAccount().coldAdmin
|
|
434
|
+
: this.wallet.publicKey,
|
|
435
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
436
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
437
|
+
},
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
async moveAmmToPrice(perpMarketIndex, targetPrice) {
|
|
441
|
+
const moveAmmPriceIx = await this.getMoveAmmToPriceIx(perpMarketIndex, targetPrice);
|
|
442
|
+
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
443
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
444
|
+
return txSig;
|
|
445
|
+
}
|
|
446
|
+
async getMoveAmmToPriceIx(perpMarketIndex, targetPrice) {
|
|
447
|
+
const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
|
|
448
|
+
const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(perpMarket, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
|
|
449
|
+
);
|
|
450
|
+
const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(perpMarket.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
|
|
451
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
452
|
+
return await this.program.instruction.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, perpMarket.amm.sqrtK, {
|
|
453
|
+
accounts: {
|
|
454
|
+
state: await this.getStatePublicKey(),
|
|
455
|
+
admin: this.isSubscribed
|
|
456
|
+
? this.getStateAccount().coldAdmin
|
|
457
|
+
: this.wallet.publicKey,
|
|
458
|
+
perpMarket: perpMarketPublicKey,
|
|
459
|
+
},
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
async repegAmmCurve(newPeg, perpMarketIndex) {
|
|
463
|
+
const repegAmmCurveIx = await this.getRepegAmmCurveIx(newPeg, perpMarketIndex);
|
|
464
|
+
const tx = await this.buildTransaction(repegAmmCurveIx);
|
|
465
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
466
|
+
return txSig;
|
|
467
|
+
}
|
|
468
|
+
async getRepegAmmCurveIx(newPeg, perpMarketIndex) {
|
|
469
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
470
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
471
|
+
return await this.program.instruction.repegAmmCurve(newPeg, {
|
|
472
|
+
accounts: {
|
|
473
|
+
state: await this.getStatePublicKey(),
|
|
474
|
+
admin: this.isSubscribed
|
|
475
|
+
? this.getStateAccount().coldAdmin
|
|
476
|
+
: this.wallet.publicKey,
|
|
477
|
+
oracle: ammData.oracle,
|
|
478
|
+
perpMarket: perpMarketPublicKey,
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
async updatePerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
483
|
+
const updatePerpMarketAmmOracleTwapIx = await this.getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
484
|
+
const tx = await this.buildTransaction(updatePerpMarketAmmOracleTwapIx);
|
|
485
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
486
|
+
return txSig;
|
|
487
|
+
}
|
|
488
|
+
async getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex) {
|
|
489
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
490
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
491
|
+
return await this.program.instruction.updatePerpMarketAmmOracleTwap({
|
|
492
|
+
accounts: {
|
|
493
|
+
state: await this.getStatePublicKey(),
|
|
494
|
+
admin: this.isSubscribed
|
|
495
|
+
? this.getStateAccount().coldAdmin
|
|
496
|
+
: this.wallet.publicKey,
|
|
497
|
+
oracle: ammData.oracle,
|
|
498
|
+
perpMarket: perpMarketPublicKey,
|
|
499
|
+
},
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
async resetPerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
503
|
+
const resetPerpMarketAmmOracleTwapIx = await this.getResetPerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
504
|
+
const tx = await this.buildTransaction(resetPerpMarketAmmOracleTwapIx);
|
|
505
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
506
|
+
return txSig;
|
|
507
|
+
}
|
|
508
|
+
async getResetPerpMarketAmmOracleTwapIx(perpMarketIndex) {
|
|
509
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
510
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
511
|
+
return await this.program.instruction.resetPerpMarketAmmOracleTwap({
|
|
512
|
+
accounts: {
|
|
513
|
+
state: await this.getStatePublicKey(),
|
|
514
|
+
admin: this.isSubscribed
|
|
515
|
+
? this.getStateAccount().coldAdmin
|
|
516
|
+
: this.wallet.publicKey,
|
|
517
|
+
oracle: ammData.oracle,
|
|
518
|
+
perpMarket: perpMarketPublicKey,
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
async depositIntoPerpMarketFeePool(perpMarketIndex, amount, sourceVault) {
|
|
523
|
+
const depositIntoPerpMarketFeePoolIx = await this.getDepositIntoPerpMarketFeePoolIx(perpMarketIndex, amount, sourceVault);
|
|
524
|
+
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
525
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
526
|
+
return txSig;
|
|
527
|
+
}
|
|
528
|
+
async getDepositIntoPerpMarketFeePoolIx(perpMarketIndex, amount, sourceVault) {
|
|
529
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
530
|
+
const remainingAccounts = [
|
|
531
|
+
{
|
|
532
|
+
pubkey: spotMarket.mint,
|
|
533
|
+
isWritable: false,
|
|
534
|
+
isSigner: false,
|
|
535
|
+
},
|
|
536
|
+
];
|
|
537
|
+
return await this.program.instruction.depositIntoPerpMarketFeePool(amount, {
|
|
538
|
+
accounts: {
|
|
539
|
+
admin: this.isSubscribed
|
|
540
|
+
? this.getStateAccount().coldAdmin
|
|
541
|
+
: this.wallet.publicKey,
|
|
542
|
+
state: await this.getStatePublicKey(),
|
|
543
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
544
|
+
sourceVault,
|
|
545
|
+
driftSigner: this.getSignerPublicKey(),
|
|
546
|
+
quoteSpotMarket: spotMarket.pubkey,
|
|
547
|
+
spotMarketVault: spotMarket.vault,
|
|
548
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
549
|
+
},
|
|
550
|
+
remainingAccounts,
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
async updatePerpMarketPnlPool(perpMarketIndex, amount) {
|
|
554
|
+
const updatePerpMarketPnlPoolIx = await this.getUpdatePerpMarketPnlPoolIx(perpMarketIndex, amount);
|
|
555
|
+
const tx = await this.buildTransaction(updatePerpMarketPnlPoolIx);
|
|
556
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
557
|
+
return txSig;
|
|
558
|
+
}
|
|
559
|
+
async getUpdatePerpMarketPnlPoolIx(perpMarketIndex, amount) {
|
|
560
|
+
return await this.program.instruction.updatePerpMarketPnlPool(amount, {
|
|
561
|
+
accounts: {
|
|
562
|
+
admin: this.isSubscribed
|
|
563
|
+
? this.getStateAccount().coldAdmin
|
|
564
|
+
: this.wallet.publicKey,
|
|
565
|
+
state: await this.getStatePublicKey(),
|
|
566
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
567
|
+
spotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
568
|
+
spotMarketVault: this.getQuoteSpotMarketAccount().vault,
|
|
569
|
+
},
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
async depositIntoSpotMarketVault(spotMarketIndex, amount, sourceVault) {
|
|
573
|
+
const depositIntoPerpMarketFeePoolIx = await this.getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault);
|
|
574
|
+
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
575
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
576
|
+
return txSig;
|
|
577
|
+
}
|
|
578
|
+
async getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault) {
|
|
579
|
+
const spotMarket = this.getSpotMarketAccount(spotMarketIndex);
|
|
580
|
+
const remainingAccounts = [];
|
|
581
|
+
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
582
|
+
if (this.isTransferHook(spotMarket)) {
|
|
583
|
+
await this.addExtraAccountMetasToRemainingAccounts(spotMarket.mint, remainingAccounts);
|
|
584
|
+
}
|
|
585
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
586
|
+
return await this.program.instruction.depositIntoSpotMarketVault(amount, {
|
|
587
|
+
accounts: {
|
|
588
|
+
admin: this.useHotWalletAdmin
|
|
589
|
+
? this.wallet.publicKey
|
|
590
|
+
: this.getStateAccount().coldAdmin,
|
|
591
|
+
state: await this.getStatePublicKey(),
|
|
592
|
+
sourceVault,
|
|
593
|
+
spotMarket: spotMarket.pubkey,
|
|
594
|
+
spotMarketVault: spotMarket.vault,
|
|
595
|
+
tokenProgram,
|
|
596
|
+
},
|
|
597
|
+
remainingAccounts,
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
async updateAdmin(admin) {
|
|
601
|
+
const updateAdminIx = await this.getUpdateAdminIx(admin);
|
|
602
|
+
const tx = await this.buildTransaction(updateAdminIx);
|
|
603
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
604
|
+
return txSig;
|
|
605
|
+
}
|
|
606
|
+
async getUpdateAdminIx(admin) {
|
|
607
|
+
return await this.program.instruction.updateAdmin(admin, {
|
|
608
|
+
accounts: {
|
|
609
|
+
admin: this.isSubscribed
|
|
610
|
+
? this.getStateAccount().coldAdmin
|
|
611
|
+
: this.wallet.publicKey,
|
|
612
|
+
state: await this.getStatePublicKey(),
|
|
613
|
+
},
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
async updatePerpMarketCurveUpdateIntensity(perpMarketIndex, curveUpdateIntensity) {
|
|
617
|
+
const updatePerpMarketCurveUpdateIntensityIx = await this.getUpdatePerpMarketCurveUpdateIntensityIx(perpMarketIndex, curveUpdateIntensity);
|
|
618
|
+
const tx = await this.buildTransaction(updatePerpMarketCurveUpdateIntensityIx);
|
|
619
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
620
|
+
return txSig;
|
|
621
|
+
}
|
|
622
|
+
async getUpdatePerpMarketCurveUpdateIntensityIx(perpMarketIndex, curveUpdateIntensity) {
|
|
623
|
+
return await this.program.instruction.updatePerpMarketCurveUpdateIntensity(curveUpdateIntensity, {
|
|
624
|
+
accounts: {
|
|
625
|
+
admin: this.useHotWalletAdmin
|
|
626
|
+
? this.wallet.publicKey
|
|
627
|
+
: this.getStateAccount().coldAdmin,
|
|
628
|
+
state: await this.getStatePublicKey(),
|
|
629
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
630
|
+
},
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
async updatePerpMarketReferencePriceOffsetDeadbandPct(perpMarketIndex, referencePriceOffsetDeadbandPct) {
|
|
634
|
+
const updatePerpMarketReferencePriceOffsetDeadbandPctIx = await this.getUpdatePerpMarketReferencePriceOffsetDeadbandPctIx(perpMarketIndex, referencePriceOffsetDeadbandPct);
|
|
635
|
+
const tx = await this.buildTransaction(updatePerpMarketReferencePriceOffsetDeadbandPctIx);
|
|
636
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
637
|
+
return txSig;
|
|
638
|
+
}
|
|
639
|
+
async getUpdatePerpMarketReferencePriceOffsetDeadbandPctIx(perpMarketIndex, referencePriceOffsetDeadbandPct) {
|
|
640
|
+
return await this.program.instruction.updatePerpMarketReferencePriceOffsetDeadbandPct(referencePriceOffsetDeadbandPct, {
|
|
641
|
+
accounts: {
|
|
642
|
+
admin: this.useHotWalletAdmin
|
|
643
|
+
? this.wallet.publicKey
|
|
644
|
+
: this.getStateAccount().coldAdmin,
|
|
645
|
+
state: await this.getStatePublicKey(),
|
|
646
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
async updatePerpMarketTargetBaseAssetAmountPerLp(perpMarketIndex, targetBaseAssetAmountPerLP) {
|
|
651
|
+
const updatePerpMarketTargetBaseAssetAmountPerLpIx = await this.getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex, targetBaseAssetAmountPerLP);
|
|
652
|
+
const tx = await this.buildTransaction(updatePerpMarketTargetBaseAssetAmountPerLpIx);
|
|
653
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
654
|
+
return txSig;
|
|
655
|
+
}
|
|
656
|
+
async updatePerpMarketAmmSummaryStats(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl, excludeTotalLiqFee) {
|
|
657
|
+
const updatePerpMarketMarginRatioIx = await this.getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl, excludeTotalLiqFee);
|
|
658
|
+
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
659
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
660
|
+
return txSig;
|
|
661
|
+
}
|
|
662
|
+
async getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, netUnsettledFundingPnl, excludeTotalLiqFee) {
|
|
663
|
+
return await this.program.instruction.updatePerpMarketAmmSummaryStats({
|
|
664
|
+
updateAmmSummaryStats: updateAmmSummaryStats !== null && updateAmmSummaryStats !== void 0 ? updateAmmSummaryStats : null,
|
|
665
|
+
netUnsettledFundingPnl: netUnsettledFundingPnl !== null && netUnsettledFundingPnl !== void 0 ? netUnsettledFundingPnl : null,
|
|
666
|
+
excludeTotalLiqFee: excludeTotalLiqFee !== null && excludeTotalLiqFee !== void 0 ? excludeTotalLiqFee : null,
|
|
667
|
+
}, {
|
|
668
|
+
accounts: {
|
|
669
|
+
admin: this.useHotWalletAdmin
|
|
670
|
+
? this.wallet.publicKey
|
|
671
|
+
: this.getStateAccount().coldAdmin,
|
|
672
|
+
state: await this.getStatePublicKey(),
|
|
673
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
674
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX),
|
|
675
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
676
|
+
},
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex, targetBaseAssetAmountPerLP) {
|
|
680
|
+
return await this.program.instruction.updatePerpMarketTargetBaseAssetAmountPerLp(targetBaseAssetAmountPerLP, {
|
|
681
|
+
accounts: {
|
|
682
|
+
admin: this.isSubscribed
|
|
683
|
+
? this.getStateAccount().coldAdmin
|
|
684
|
+
: this.wallet.publicKey,
|
|
685
|
+
state: await this.getStatePublicKey(),
|
|
686
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
687
|
+
},
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
async updatePerpMarketMarginRatio(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
691
|
+
const updatePerpMarketMarginRatioIx = await this.getUpdatePerpMarketMarginRatioIx(perpMarketIndex, marginRatioInitial, marginRatioMaintenance);
|
|
692
|
+
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
693
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
694
|
+
return txSig;
|
|
695
|
+
}
|
|
696
|
+
async getUpdatePerpMarketMarginRatioIx(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
697
|
+
return await this.program.instruction.updatePerpMarketMarginRatio(marginRatioInitial, marginRatioMaintenance, {
|
|
698
|
+
accounts: {
|
|
699
|
+
admin: this.isSubscribed
|
|
700
|
+
? this.getStateAccount().coldAdmin
|
|
701
|
+
: this.wallet.publicKey,
|
|
702
|
+
state: await this.getStatePublicKey(),
|
|
703
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
704
|
+
},
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
async updatePerpMarketImfFactor(perpMarketIndex, imfFactor, unrealizedPnlImfFactor) {
|
|
708
|
+
const updatePerpMarketImfFactorIx = await this.getUpdatePerpMarketImfFactorIx(perpMarketIndex, imfFactor, unrealizedPnlImfFactor);
|
|
709
|
+
const tx = await this.buildTransaction(updatePerpMarketImfFactorIx);
|
|
710
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
711
|
+
return txSig;
|
|
712
|
+
}
|
|
713
|
+
async getUpdatePerpMarketImfFactorIx(perpMarketIndex, imfFactor, unrealizedPnlImfFactor) {
|
|
714
|
+
return await this.program.instruction.updatePerpMarketImfFactor(imfFactor, unrealizedPnlImfFactor, {
|
|
715
|
+
accounts: {
|
|
716
|
+
admin: this.isSubscribed
|
|
717
|
+
? this.getStateAccount().coldAdmin
|
|
718
|
+
: this.wallet.publicKey,
|
|
719
|
+
state: await this.getStatePublicKey(),
|
|
720
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
721
|
+
},
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
async updatePerpMarketBaseSpread(perpMarketIndex, baseSpread) {
|
|
725
|
+
const updatePerpMarketBaseSpreadIx = await this.getUpdatePerpMarketBaseSpreadIx(perpMarketIndex, baseSpread);
|
|
726
|
+
const tx = await this.buildTransaction(updatePerpMarketBaseSpreadIx);
|
|
727
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
728
|
+
return txSig;
|
|
729
|
+
}
|
|
730
|
+
async getUpdatePerpMarketBaseSpreadIx(perpMarketIndex, baseSpread) {
|
|
731
|
+
return await this.program.instruction.updatePerpMarketBaseSpread(baseSpread, {
|
|
732
|
+
accounts: {
|
|
733
|
+
admin: this.isSubscribed
|
|
734
|
+
? this.getStateAccount().coldAdmin
|
|
735
|
+
: this.wallet.publicKey,
|
|
736
|
+
state: await this.getStatePublicKey(),
|
|
737
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
738
|
+
},
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
async updateAmmJitIntensity(perpMarketIndex, ammJitIntensity) {
|
|
742
|
+
const updateAmmJitIntensityIx = await this.getUpdateAmmJitIntensityIx(perpMarketIndex, ammJitIntensity);
|
|
743
|
+
const tx = await this.buildTransaction(updateAmmJitIntensityIx);
|
|
744
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
745
|
+
return txSig;
|
|
746
|
+
}
|
|
747
|
+
async getUpdateAmmJitIntensityIx(perpMarketIndex, ammJitIntensity) {
|
|
748
|
+
return await this.program.instruction.updateAmmJitIntensity(ammJitIntensity, {
|
|
749
|
+
accounts: {
|
|
750
|
+
admin: this.useHotWalletAdmin
|
|
751
|
+
? this.wallet.publicKey
|
|
752
|
+
: this.getStateAccount().coldAdmin,
|
|
753
|
+
state: await this.getStatePublicKey(),
|
|
754
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
755
|
+
},
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
async updatePerpMarketName(perpMarketIndex, name) {
|
|
759
|
+
const updatePerpMarketNameIx = await this.getUpdatePerpMarketNameIx(perpMarketIndex, name);
|
|
760
|
+
const tx = await this.buildTransaction(updatePerpMarketNameIx);
|
|
761
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
762
|
+
return txSig;
|
|
763
|
+
}
|
|
764
|
+
async getUpdatePerpMarketNameIx(perpMarketIndex, name) {
|
|
765
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
766
|
+
return await this.program.instruction.updatePerpMarketName(nameBuffer, {
|
|
767
|
+
accounts: {
|
|
768
|
+
admin: this.isSubscribed
|
|
769
|
+
? this.getStateAccount().coldAdmin
|
|
770
|
+
: this.wallet.publicKey,
|
|
771
|
+
state: await this.getStatePublicKey(),
|
|
772
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
773
|
+
},
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
async updateSpotMarketName(spotMarketIndex, name) {
|
|
777
|
+
const updateSpotMarketNameIx = await this.getUpdateSpotMarketNameIx(spotMarketIndex, name);
|
|
778
|
+
const tx = await this.buildTransaction(updateSpotMarketNameIx);
|
|
779
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
780
|
+
return txSig;
|
|
781
|
+
}
|
|
782
|
+
async getUpdateSpotMarketNameIx(spotMarketIndex, name) {
|
|
783
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
784
|
+
return await this.program.instruction.updateSpotMarketName(nameBuffer, {
|
|
785
|
+
accounts: {
|
|
786
|
+
admin: this.isSubscribed
|
|
787
|
+
? this.getStateAccount().coldAdmin
|
|
788
|
+
: this.wallet.publicKey,
|
|
789
|
+
state: await this.getStatePublicKey(),
|
|
790
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
791
|
+
},
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
async updateSpotMarketPoolId(spotMarketIndex, poolId) {
|
|
795
|
+
const updateSpotMarketPoolIdIx = await this.getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId);
|
|
796
|
+
const tx = await this.buildTransaction(updateSpotMarketPoolIdIx);
|
|
797
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
798
|
+
return txSig;
|
|
799
|
+
}
|
|
800
|
+
async getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId) {
|
|
801
|
+
return await this.program.instruction.updateSpotMarketPoolId(poolId, {
|
|
802
|
+
accounts: {
|
|
803
|
+
admin: this.isSubscribed
|
|
804
|
+
? this.getStateAccount().coldAdmin
|
|
805
|
+
: this.wallet.publicKey,
|
|
806
|
+
state: await this.getStatePublicKey(),
|
|
807
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
808
|
+
},
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
async updatePerpMarketMaxSpread(perpMarketIndex, maxSpread) {
|
|
812
|
+
const updatePerpMarketMaxSpreadIx = await this.getUpdatePerpMarketMaxSpreadIx(perpMarketIndex, maxSpread);
|
|
813
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxSpreadIx);
|
|
814
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
815
|
+
return txSig;
|
|
816
|
+
}
|
|
817
|
+
async getUpdatePerpMarketMaxSpreadIx(perpMarketIndex, maxSpread) {
|
|
818
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
819
|
+
return await this.program.instruction.updatePerpMarketMaxSpread(maxSpread, {
|
|
820
|
+
accounts: {
|
|
821
|
+
admin: this.isSubscribed
|
|
822
|
+
? this.getStateAccount().coldAdmin
|
|
823
|
+
: this.wallet.publicKey,
|
|
824
|
+
state: await this.getStatePublicKey(),
|
|
825
|
+
perpMarket: perpMarketPublicKey,
|
|
826
|
+
},
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
async updatePerpFeeStructure(feeStructure) {
|
|
830
|
+
const updatePerpFeeStructureIx = await this.getUpdatePerpFeeStructureIx(feeStructure);
|
|
831
|
+
const tx = await this.buildTransaction(updatePerpFeeStructureIx);
|
|
832
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
833
|
+
return txSig;
|
|
834
|
+
}
|
|
835
|
+
async getUpdatePerpFeeStructureIx(feeStructure) {
|
|
836
|
+
return this.program.instruction.updatePerpFeeStructure(feeStructure, {
|
|
837
|
+
accounts: {
|
|
838
|
+
admin: this.isSubscribed
|
|
839
|
+
? this.getStateAccount().coldAdmin
|
|
840
|
+
: this.wallet.publicKey,
|
|
841
|
+
state: await this.getStatePublicKey(),
|
|
842
|
+
},
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
async updateSpotFeeStructure(feeStructure) {
|
|
846
|
+
const updateSpotFeeStructureIx = await this.getUpdateSpotFeeStructureIx(feeStructure);
|
|
847
|
+
const tx = await this.buildTransaction(updateSpotFeeStructureIx);
|
|
848
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
849
|
+
return txSig;
|
|
850
|
+
}
|
|
851
|
+
async getUpdateSpotFeeStructureIx(feeStructure) {
|
|
852
|
+
return await this.program.instruction.updateSpotFeeStructure(feeStructure, {
|
|
853
|
+
accounts: {
|
|
854
|
+
admin: this.isSubscribed
|
|
855
|
+
? this.getStateAccount().coldAdmin
|
|
856
|
+
: this.wallet.publicKey,
|
|
857
|
+
state: await this.getStatePublicKey(),
|
|
858
|
+
},
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
async updateInitialPctToLiquidate(initialPctToLiquidate) {
|
|
862
|
+
const updateInitialPctToLiquidateIx = await this.getUpdateInitialPctToLiquidateIx(initialPctToLiquidate);
|
|
863
|
+
const tx = await this.buildTransaction(updateInitialPctToLiquidateIx);
|
|
864
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
865
|
+
return txSig;
|
|
866
|
+
}
|
|
867
|
+
async getUpdateInitialPctToLiquidateIx(initialPctToLiquidate) {
|
|
868
|
+
return await this.program.instruction.updateInitialPctToLiquidate(initialPctToLiquidate, {
|
|
869
|
+
accounts: {
|
|
870
|
+
admin: this.isSubscribed
|
|
871
|
+
? this.getStateAccount().coldAdmin
|
|
872
|
+
: this.wallet.publicKey,
|
|
873
|
+
state: await this.getStatePublicKey(),
|
|
874
|
+
},
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
async updateLiquidationDuration(liquidationDuration) {
|
|
878
|
+
const updateLiquidationDurationIx = await this.getUpdateLiquidationDurationIx(liquidationDuration);
|
|
879
|
+
const tx = await this.buildTransaction(updateLiquidationDurationIx);
|
|
880
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
881
|
+
return txSig;
|
|
882
|
+
}
|
|
883
|
+
async getUpdateLiquidationDurationIx(liquidationDuration) {
|
|
884
|
+
return await this.program.instruction.updateLiquidationDuration(liquidationDuration, {
|
|
885
|
+
accounts: {
|
|
886
|
+
admin: this.isSubscribed
|
|
887
|
+
? this.getStateAccount().coldAdmin
|
|
888
|
+
: this.wallet.publicKey,
|
|
889
|
+
state: await this.getStatePublicKey(),
|
|
890
|
+
},
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
async updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio) {
|
|
894
|
+
const updateLiquidationMarginBufferRatioIx = await this.getUpdateLiquidationMarginBufferRatioIx(updateLiquidationMarginBufferRatio);
|
|
895
|
+
const tx = await this.buildTransaction(updateLiquidationMarginBufferRatioIx);
|
|
896
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
897
|
+
return txSig;
|
|
898
|
+
}
|
|
899
|
+
async getUpdateLiquidationMarginBufferRatioIx(updateLiquidationMarginBufferRatio) {
|
|
900
|
+
return await this.program.instruction.updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio, {
|
|
901
|
+
accounts: {
|
|
902
|
+
admin: this.isSubscribed
|
|
903
|
+
? this.getStateAccount().coldAdmin
|
|
904
|
+
: this.wallet.publicKey,
|
|
905
|
+
state: await this.getStatePublicKey(),
|
|
906
|
+
},
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
async updateOracleGuardRails(oracleGuardRails) {
|
|
910
|
+
const updateOracleGuardRailsIx = await this.getUpdateOracleGuardRailsIx(oracleGuardRails);
|
|
911
|
+
const tx = await this.buildTransaction(updateOracleGuardRailsIx);
|
|
912
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
913
|
+
return txSig;
|
|
914
|
+
}
|
|
915
|
+
async getUpdateOracleGuardRailsIx(oracleGuardRails) {
|
|
916
|
+
return await this.program.instruction.updateOracleGuardRails(oracleGuardRails, {
|
|
917
|
+
accounts: {
|
|
918
|
+
admin: this.isSubscribed
|
|
919
|
+
? this.getStateAccount().coldAdmin
|
|
920
|
+
: this.wallet.publicKey,
|
|
921
|
+
state: await this.getStatePublicKey(),
|
|
922
|
+
},
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
async updateStateSettlementDuration(settlementDuration) {
|
|
926
|
+
const updateStateSettlementDurationIx = await this.getUpdateStateSettlementDurationIx(settlementDuration);
|
|
927
|
+
const tx = await this.buildTransaction(updateStateSettlementDurationIx);
|
|
928
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
929
|
+
return txSig;
|
|
930
|
+
}
|
|
931
|
+
async getUpdateStateSettlementDurationIx(settlementDuration) {
|
|
932
|
+
return await this.program.instruction.updateStateSettlementDuration(settlementDuration, {
|
|
933
|
+
accounts: {
|
|
934
|
+
admin: this.isSubscribed
|
|
935
|
+
? this.getStateAccount().coldAdmin
|
|
936
|
+
: this.wallet.publicKey,
|
|
937
|
+
state: await this.getStatePublicKey(),
|
|
938
|
+
},
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
async updateStateMaxNumberOfSubAccounts(maxNumberOfSubAccounts) {
|
|
942
|
+
const updateStateMaxNumberOfSubAccountsIx = await this.getUpdateStateMaxNumberOfSubAccountsIx(maxNumberOfSubAccounts);
|
|
943
|
+
const tx = await this.buildTransaction(updateStateMaxNumberOfSubAccountsIx);
|
|
944
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
945
|
+
return txSig;
|
|
946
|
+
}
|
|
947
|
+
async getUpdateStateMaxNumberOfSubAccountsIx(maxNumberOfSubAccounts) {
|
|
948
|
+
return await this.program.instruction.updateStateMaxNumberOfSubAccounts(maxNumberOfSubAccounts, {
|
|
949
|
+
accounts: {
|
|
950
|
+
admin: this.isSubscribed
|
|
951
|
+
? this.getStateAccount().coldAdmin
|
|
952
|
+
: this.wallet.publicKey,
|
|
953
|
+
state: await this.getStatePublicKey(),
|
|
954
|
+
},
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
async updateStateMaxInitializeUserFee(maxInitializeUserFee) {
|
|
958
|
+
const updateStateMaxInitializeUserFeeIx = await this.getUpdateStateMaxInitializeUserFeeIx(maxInitializeUserFee);
|
|
959
|
+
const tx = await this.buildTransaction(updateStateMaxInitializeUserFeeIx);
|
|
960
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
961
|
+
return txSig;
|
|
962
|
+
}
|
|
963
|
+
async getUpdateStateMaxInitializeUserFeeIx(maxInitializeUserFee) {
|
|
964
|
+
return await this.program.instruction.updateStateMaxInitializeUserFee(maxInitializeUserFee, {
|
|
965
|
+
accounts: {
|
|
966
|
+
admin: this.isSubscribed
|
|
967
|
+
? this.getStateAccount().coldAdmin
|
|
968
|
+
: this.wallet.publicKey,
|
|
969
|
+
state: await this.getStatePublicKey(),
|
|
970
|
+
},
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
async updateWithdrawGuardThreshold(spotMarketIndex, withdrawGuardThreshold) {
|
|
974
|
+
const updateWithdrawGuardThresholdIx = await this.getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold);
|
|
975
|
+
const tx = await this.buildTransaction(updateWithdrawGuardThresholdIx);
|
|
976
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
977
|
+
return txSig;
|
|
978
|
+
}
|
|
979
|
+
async getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold) {
|
|
980
|
+
return await this.program.instruction.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
|
|
981
|
+
accounts: {
|
|
982
|
+
admin: this.isSubscribed
|
|
983
|
+
? this.getStateAccount().coldAdmin
|
|
984
|
+
: this.wallet.publicKey,
|
|
985
|
+
state: await this.getStatePublicKey(),
|
|
986
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
987
|
+
},
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
async updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor) {
|
|
991
|
+
const updateSpotMarketIfFactorIx = await this.getUpdateSpotMarketIfFactorIx(spotMarketIndex, userIfFactor, totalIfFactor);
|
|
992
|
+
const tx = await this.buildTransaction(updateSpotMarketIfFactorIx);
|
|
993
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
994
|
+
return txSig;
|
|
995
|
+
}
|
|
996
|
+
async getUpdateSpotMarketIfFactorIx(spotMarketIndex, userIfFactor, totalIfFactor) {
|
|
997
|
+
return await this.program.instruction.updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor, {
|
|
998
|
+
accounts: {
|
|
999
|
+
admin: this.isSubscribed
|
|
1000
|
+
? this.getStateAccount().coldAdmin
|
|
1001
|
+
: this.wallet.publicKey,
|
|
1002
|
+
state: await this.getStatePublicKey(),
|
|
1003
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1004
|
+
},
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
async updateSpotMarketRevenueSettlePeriod(spotMarketIndex, revenueSettlePeriod) {
|
|
1008
|
+
const updateSpotMarketRevenueSettlePeriodIx = await this.getUpdateSpotMarketRevenueSettlePeriodIx(spotMarketIndex, revenueSettlePeriod);
|
|
1009
|
+
const tx = await this.buildTransaction(updateSpotMarketRevenueSettlePeriodIx);
|
|
1010
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1011
|
+
return txSig;
|
|
1012
|
+
}
|
|
1013
|
+
async getUpdateSpotMarketRevenueSettlePeriodIx(spotMarketIndex, revenueSettlePeriod) {
|
|
1014
|
+
return await this.program.instruction.updateSpotMarketRevenueSettlePeriod(revenueSettlePeriod, {
|
|
1015
|
+
accounts: {
|
|
1016
|
+
admin: this.isSubscribed
|
|
1017
|
+
? this.getStateAccount().coldAdmin
|
|
1018
|
+
: this.wallet.publicKey,
|
|
1019
|
+
state: await this.getStatePublicKey(),
|
|
1020
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1021
|
+
},
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
async updateSpotMarketMaxTokenDeposits(spotMarketIndex, maxTokenDeposits) {
|
|
1025
|
+
const updateSpotMarketMaxTokenDepositsIx = await this.getUpdateSpotMarketMaxTokenDepositsIx(spotMarketIndex, maxTokenDeposits);
|
|
1026
|
+
const tx = await this.buildTransaction(updateSpotMarketMaxTokenDepositsIx);
|
|
1027
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1028
|
+
return txSig;
|
|
1029
|
+
}
|
|
1030
|
+
async getUpdateSpotMarketMaxTokenDepositsIx(spotMarketIndex, maxTokenDeposits) {
|
|
1031
|
+
return this.program.instruction.updateSpotMarketMaxTokenDeposits(maxTokenDeposits, {
|
|
1032
|
+
accounts: {
|
|
1033
|
+
admin: this.isSubscribed
|
|
1034
|
+
? this.getStateAccount().coldAdmin
|
|
1035
|
+
: this.wallet.publicKey,
|
|
1036
|
+
state: await this.getStatePublicKey(),
|
|
1037
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1038
|
+
},
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
async updateSpotMarketMaxTokenBorrows(spotMarketIndex, maxTokenBorrowsFraction) {
|
|
1042
|
+
const updateSpotMarketMaxTokenBorrowsIx = await this.getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrowsFraction);
|
|
1043
|
+
const tx = await this.buildTransaction(updateSpotMarketMaxTokenBorrowsIx);
|
|
1044
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1045
|
+
return txSig;
|
|
1046
|
+
}
|
|
1047
|
+
async getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrowsFraction) {
|
|
1048
|
+
return this.program.instruction.updateSpotMarketMaxTokenBorrows(maxTokenBorrowsFraction, {
|
|
1049
|
+
accounts: {
|
|
1050
|
+
admin: this.isSubscribed
|
|
1051
|
+
? this.getStateAccount().coldAdmin
|
|
1052
|
+
: this.wallet.publicKey,
|
|
1053
|
+
state: await this.getStatePublicKey(),
|
|
1054
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1055
|
+
},
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
async updateSpotMarketScaleInitialAssetWeightStart(spotMarketIndex, scaleInitialAssetWeightStart) {
|
|
1059
|
+
const updateSpotMarketScaleInitialAssetWeightStartIx = await this.getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex, scaleInitialAssetWeightStart);
|
|
1060
|
+
const tx = await this.buildTransaction(updateSpotMarketScaleInitialAssetWeightStartIx);
|
|
1061
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1062
|
+
return txSig;
|
|
1063
|
+
}
|
|
1064
|
+
async getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex, scaleInitialAssetWeightStart) {
|
|
1065
|
+
return this.program.instruction.updateSpotMarketScaleInitialAssetWeightStart(scaleInitialAssetWeightStart, {
|
|
1066
|
+
accounts: {
|
|
1067
|
+
admin: this.isSubscribed
|
|
1068
|
+
? this.getStateAccount().coldAdmin
|
|
1069
|
+
: this.wallet.publicKey,
|
|
1070
|
+
state: await this.getStatePublicKey(),
|
|
1071
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1072
|
+
},
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
async updateInsuranceFundUnstakingPeriod(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
|
|
1076
|
+
const updateInsuranceFundUnstakingPeriodIx = await this.getUpdateInsuranceFundUnstakingPeriodIx(spotMarketIndex, insuranceWithdrawEscrowPeriod);
|
|
1077
|
+
const tx = await this.buildTransaction(updateInsuranceFundUnstakingPeriodIx);
|
|
1078
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1079
|
+
return txSig;
|
|
1080
|
+
}
|
|
1081
|
+
async getUpdateInsuranceFundUnstakingPeriodIx(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
|
|
1082
|
+
return await this.program.instruction.updateInsuranceFundUnstakingPeriod(insuranceWithdrawEscrowPeriod, {
|
|
1083
|
+
accounts: {
|
|
1084
|
+
admin: this.isSubscribed
|
|
1085
|
+
? this.getStateAccount().coldAdmin
|
|
1086
|
+
: this.wallet.publicKey,
|
|
1087
|
+
state: await this.getStatePublicKey(),
|
|
1088
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1089
|
+
},
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
async updatePerpMarketOracle(perpMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
|
|
1093
|
+
const updatePerpMarketOracleIx = await this.getUpdatePerpMarketOracleIx(perpMarketIndex, oracle, oracleSource, skipInvaraintCheck);
|
|
1094
|
+
const tx = await this.buildTransaction(updatePerpMarketOracleIx);
|
|
1095
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1096
|
+
return txSig;
|
|
1097
|
+
}
|
|
1098
|
+
async getUpdatePerpMarketOracleIx(perpMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
|
|
1099
|
+
return await this.program.instruction.updatePerpMarketOracle(oracle, oracleSource, skipInvaraintCheck, {
|
|
1100
|
+
accounts: {
|
|
1101
|
+
admin: this.isSubscribed
|
|
1102
|
+
? this.getStateAccount().coldAdmin
|
|
1103
|
+
: this.wallet.publicKey,
|
|
1104
|
+
state: await this.getStatePublicKey(),
|
|
1105
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1106
|
+
oracle: oracle,
|
|
1107
|
+
oldOracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
1108
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
1109
|
+
},
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
async updatePerpMarketStepSizeAndTickSize(perpMarketIndex, stepSize, tickSize) {
|
|
1113
|
+
const updatePerpMarketStepSizeAndTickSizeIx = await this.getUpdatePerpMarketStepSizeAndTickSizeIx(perpMarketIndex, stepSize, tickSize);
|
|
1114
|
+
const tx = await this.buildTransaction(updatePerpMarketStepSizeAndTickSizeIx);
|
|
1115
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1116
|
+
return txSig;
|
|
1117
|
+
}
|
|
1118
|
+
async getUpdatePerpMarketStepSizeAndTickSizeIx(perpMarketIndex, stepSize, tickSize) {
|
|
1119
|
+
return await this.program.instruction.updatePerpMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
1120
|
+
accounts: {
|
|
1121
|
+
admin: this.isSubscribed
|
|
1122
|
+
? this.getStateAccount().coldAdmin
|
|
1123
|
+
: this.wallet.publicKey,
|
|
1124
|
+
state: await this.getStatePublicKey(),
|
|
1125
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1126
|
+
},
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
async updatePerpMarketMinOrderSize(perpMarketIndex, orderSize) {
|
|
1130
|
+
const updatePerpMarketMinOrderSizeIx = await this.getUpdatePerpMarketMinOrderSizeIx(perpMarketIndex, orderSize);
|
|
1131
|
+
const tx = await this.buildTransaction(updatePerpMarketMinOrderSizeIx);
|
|
1132
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1133
|
+
return txSig;
|
|
1134
|
+
}
|
|
1135
|
+
async getUpdatePerpMarketMinOrderSizeIx(perpMarketIndex, orderSize) {
|
|
1136
|
+
return await this.program.instruction.updatePerpMarketMinOrderSize(orderSize, {
|
|
1137
|
+
accounts: {
|
|
1138
|
+
admin: this.isSubscribed
|
|
1139
|
+
? this.getStateAccount().coldAdmin
|
|
1140
|
+
: this.wallet.publicKey,
|
|
1141
|
+
state: await this.getStatePublicKey(),
|
|
1142
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1143
|
+
},
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
async updateSpotMarketStepSizeAndTickSize(spotMarketIndex, stepSize, tickSize) {
|
|
1147
|
+
const updateSpotMarketStepSizeAndTickSizeIx = await this.getUpdateSpotMarketStepSizeAndTickSizeIx(spotMarketIndex, stepSize, tickSize);
|
|
1148
|
+
const tx = await this.buildTransaction(updateSpotMarketStepSizeAndTickSizeIx);
|
|
1149
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1150
|
+
return txSig;
|
|
1151
|
+
}
|
|
1152
|
+
async getUpdateSpotMarketStepSizeAndTickSizeIx(spotMarketIndex, stepSize, tickSize) {
|
|
1153
|
+
return await this.program.instruction.updateSpotMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
1154
|
+
accounts: {
|
|
1155
|
+
admin: this.isSubscribed
|
|
1156
|
+
? this.getStateAccount().coldAdmin
|
|
1157
|
+
: this.wallet.publicKey,
|
|
1158
|
+
state: await this.getStatePublicKey(),
|
|
1159
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1160
|
+
},
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
async updateSpotMarketMinOrderSize(spotMarketIndex, orderSize) {
|
|
1164
|
+
const updateSpotMarketMinOrderSizeIx = await this.program.instruction.updateSpotMarketMinOrderSize(orderSize, {
|
|
1165
|
+
accounts: {
|
|
1166
|
+
admin: this.isSubscribed
|
|
1167
|
+
? this.getStateAccount().coldAdmin
|
|
1168
|
+
: this.wallet.publicKey,
|
|
1169
|
+
state: await this.getStatePublicKey(),
|
|
1170
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1171
|
+
},
|
|
1172
|
+
});
|
|
1173
|
+
const tx = await this.buildTransaction(updateSpotMarketMinOrderSizeIx);
|
|
1174
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1175
|
+
return txSig;
|
|
1176
|
+
}
|
|
1177
|
+
async getUpdateSpotMarketMinOrderSizeIx(spotMarketIndex, orderSize) {
|
|
1178
|
+
return await this.program.instruction.updateSpotMarketMinOrderSize(orderSize, {
|
|
1179
|
+
accounts: {
|
|
1180
|
+
admin: this.isSubscribed
|
|
1181
|
+
? this.getStateAccount().coldAdmin
|
|
1182
|
+
: this.wallet.publicKey,
|
|
1183
|
+
state: await this.getStatePublicKey(),
|
|
1184
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1185
|
+
},
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
async updatePerpMarketExpiry(perpMarketIndex, expiryTs) {
|
|
1189
|
+
const updatePerpMarketExpiryIx = await this.getUpdatePerpMarketExpiryIx(perpMarketIndex, expiryTs);
|
|
1190
|
+
const tx = await this.buildTransaction(updatePerpMarketExpiryIx);
|
|
1191
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1192
|
+
return txSig;
|
|
1193
|
+
}
|
|
1194
|
+
async getUpdatePerpMarketExpiryIx(perpMarketIndex, expiryTs) {
|
|
1195
|
+
return await this.program.instruction.updatePerpMarketExpiry(expiryTs, {
|
|
1196
|
+
accounts: {
|
|
1197
|
+
admin: this.isSubscribed
|
|
1198
|
+
? this.getStateAccount().coldAdmin
|
|
1199
|
+
: this.wallet.publicKey,
|
|
1200
|
+
state: await this.getStatePublicKey(),
|
|
1201
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1202
|
+
},
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
async updateSpotMarketOracle(spotMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
|
|
1206
|
+
const updateSpotMarketOracleIx = await this.getUpdateSpotMarketOracleIx(spotMarketIndex, oracle, oracleSource, skipInvaraintCheck);
|
|
1207
|
+
const tx = await this.buildTransaction(updateSpotMarketOracleIx);
|
|
1208
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1209
|
+
return txSig;
|
|
1210
|
+
}
|
|
1211
|
+
async getUpdateSpotMarketOracleIx(spotMarketIndex, oracle, oracleSource, skipInvaraintCheck = false) {
|
|
1212
|
+
return await this.program.instruction.updateSpotMarketOracle(oracle, oracleSource, skipInvaraintCheck, {
|
|
1213
|
+
accounts: {
|
|
1214
|
+
admin: this.isSubscribed
|
|
1215
|
+
? this.getStateAccount().coldAdmin
|
|
1216
|
+
: this.wallet.publicKey,
|
|
1217
|
+
state: await this.getStatePublicKey(),
|
|
1218
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1219
|
+
oracle: oracle,
|
|
1220
|
+
oldOracle: this.getSpotMarketAccount(spotMarketIndex).oracle,
|
|
1221
|
+
},
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
async updateSpotMarketOrdersEnabled(spotMarketIndex, ordersEnabled) {
|
|
1225
|
+
const updateSpotMarketOrdersEnabledIx = await this.getUpdateSpotMarketOrdersEnabledIx(spotMarketIndex, ordersEnabled);
|
|
1226
|
+
const tx = await this.buildTransaction(updateSpotMarketOrdersEnabledIx);
|
|
1227
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1228
|
+
return txSig;
|
|
1229
|
+
}
|
|
1230
|
+
async getUpdateSpotMarketOrdersEnabledIx(spotMarketIndex, ordersEnabled) {
|
|
1231
|
+
return await this.program.instruction.updateSpotMarketOrdersEnabled(ordersEnabled, {
|
|
1232
|
+
accounts: {
|
|
1233
|
+
admin: this.isSubscribed
|
|
1234
|
+
? this.getStateAccount().coldAdmin
|
|
1235
|
+
: this.wallet.publicKey,
|
|
1236
|
+
state: await this.getStatePublicKey(),
|
|
1237
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1238
|
+
},
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
async updateSpotMarketIfPausedOperations(spotMarketIndex, pausedOperations) {
|
|
1242
|
+
const updateSpotMarketIfStakingDisabledIx = await this.getUpdateSpotMarketIfPausedOperationsIx(spotMarketIndex, pausedOperations);
|
|
1243
|
+
const tx = await this.buildTransaction(updateSpotMarketIfStakingDisabledIx);
|
|
1244
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1245
|
+
return txSig;
|
|
1246
|
+
}
|
|
1247
|
+
async getUpdateSpotMarketIfPausedOperationsIx(spotMarketIndex, pausedOperations) {
|
|
1248
|
+
return await this.program.instruction.updateSpotMarketIfPausedOperations(pausedOperations, {
|
|
1249
|
+
accounts: {
|
|
1250
|
+
admin: this.isSubscribed
|
|
1251
|
+
? this.getStateAccount().coldAdmin
|
|
1252
|
+
: this.wallet.publicKey,
|
|
1253
|
+
state: await this.getStatePublicKey(),
|
|
1254
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1255
|
+
},
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
async updateSpotMarketExpiry(spotMarketIndex, expiryTs) {
|
|
1259
|
+
const updateSpotMarketExpiryIx = await this.getUpdateSpotMarketExpiryIx(spotMarketIndex, expiryTs);
|
|
1260
|
+
const tx = await this.buildTransaction(updateSpotMarketExpiryIx);
|
|
1261
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1262
|
+
return txSig;
|
|
1263
|
+
}
|
|
1264
|
+
async getUpdateSpotMarketExpiryIx(spotMarketIndex, expiryTs) {
|
|
1265
|
+
return await this.program.instruction.updateSpotMarketExpiry(expiryTs, {
|
|
1266
|
+
accounts: {
|
|
1267
|
+
admin: this.isSubscribed
|
|
1268
|
+
? this.getStateAccount().coldAdmin
|
|
1269
|
+
: this.wallet.publicKey,
|
|
1270
|
+
state: await this.getStatePublicKey(),
|
|
1271
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1272
|
+
},
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
async updateWhitelistMint(whitelistMint) {
|
|
1276
|
+
const updateWhitelistMintIx = await this.getUpdateWhitelistMintIx(whitelistMint);
|
|
1277
|
+
const tx = await this.buildTransaction(updateWhitelistMintIx);
|
|
1278
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1279
|
+
return txSig;
|
|
1280
|
+
}
|
|
1281
|
+
async getUpdateWhitelistMintIx(whitelistMint) {
|
|
1282
|
+
return await this.program.instruction.updateWhitelistMint(whitelistMint, {
|
|
1283
|
+
accounts: {
|
|
1284
|
+
admin: this.isSubscribed
|
|
1285
|
+
? this.getStateAccount().coldAdmin
|
|
1286
|
+
: this.wallet.publicKey,
|
|
1287
|
+
state: await this.getStatePublicKey(),
|
|
1288
|
+
},
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
async updateDiscountMint(discountMint) {
|
|
1292
|
+
const updateDiscountMintIx = await this.getUpdateDiscountMintIx(discountMint);
|
|
1293
|
+
const tx = await this.buildTransaction(updateDiscountMintIx);
|
|
1294
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1295
|
+
return txSig;
|
|
1296
|
+
}
|
|
1297
|
+
async getUpdateDiscountMintIx(discountMint) {
|
|
1298
|
+
return await this.program.instruction.updateDiscountMint(discountMint, {
|
|
1299
|
+
accounts: {
|
|
1300
|
+
admin: this.isSubscribed
|
|
1301
|
+
? this.getStateAccount().coldAdmin
|
|
1302
|
+
: this.wallet.publicKey,
|
|
1303
|
+
state: await this.getStatePublicKey(),
|
|
1304
|
+
},
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
async updateSpotMarketMarginWeights(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0) {
|
|
1308
|
+
const updateSpotMarketMarginWeightsIx = await this.getUpdateSpotMarketMarginWeightsIx(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor);
|
|
1309
|
+
const tx = await this.buildTransaction(updateSpotMarketMarginWeightsIx);
|
|
1310
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1311
|
+
return txSig;
|
|
1312
|
+
}
|
|
1313
|
+
async getUpdateSpotMarketMarginWeightsIx(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0) {
|
|
1314
|
+
return await this.program.instruction.updateSpotMarketMarginWeights(initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, {
|
|
1315
|
+
accounts: {
|
|
1316
|
+
admin: this.isSubscribed
|
|
1317
|
+
? this.getStateAccount().coldAdmin
|
|
1318
|
+
: this.wallet.publicKey,
|
|
1319
|
+
state: await this.getStatePublicKey(),
|
|
1320
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1321
|
+
},
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
async updateSpotMarketBorrowRate(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate) {
|
|
1325
|
+
const updateSpotMarketBorrowRateIx = await this.getUpdateSpotMarketBorrowRateIx(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate);
|
|
1326
|
+
const tx = await this.buildTransaction(updateSpotMarketBorrowRateIx);
|
|
1327
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1328
|
+
return txSig;
|
|
1329
|
+
}
|
|
1330
|
+
async getUpdateSpotMarketBorrowRateIx(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate) {
|
|
1331
|
+
return await this.program.instruction.updateSpotMarketBorrowRate(optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate, {
|
|
1332
|
+
accounts: {
|
|
1333
|
+
admin: this.isSubscribed
|
|
1334
|
+
? this.getStateAccount().coldAdmin
|
|
1335
|
+
: this.wallet.publicKey,
|
|
1336
|
+
state: await this.getStatePublicKey(),
|
|
1337
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1338
|
+
},
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
async updateSpotMarketAssetTier(spotMarketIndex, assetTier) {
|
|
1342
|
+
const updateSpotMarketAssetTierIx = await this.getUpdateSpotMarketAssetTierIx(spotMarketIndex, assetTier);
|
|
1343
|
+
const tx = await this.buildTransaction(updateSpotMarketAssetTierIx);
|
|
1344
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1345
|
+
return txSig;
|
|
1346
|
+
}
|
|
1347
|
+
async getUpdateSpotMarketAssetTierIx(spotMarketIndex, assetTier) {
|
|
1348
|
+
return await this.program.instruction.updateSpotMarketAssetTier(assetTier, {
|
|
1349
|
+
accounts: {
|
|
1350
|
+
admin: this.isSubscribed
|
|
1351
|
+
? this.getStateAccount().coldAdmin
|
|
1352
|
+
: this.wallet.publicKey,
|
|
1353
|
+
state: await this.getStatePublicKey(),
|
|
1354
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1355
|
+
},
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
async updateSpotMarketStatus(spotMarketIndex, marketStatus) {
|
|
1359
|
+
const updateSpotMarketStatusIx = await this.getUpdateSpotMarketStatusIx(spotMarketIndex, marketStatus);
|
|
1360
|
+
const tx = await this.buildTransaction(updateSpotMarketStatusIx);
|
|
1361
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1362
|
+
return txSig;
|
|
1363
|
+
}
|
|
1364
|
+
async getUpdateSpotMarketStatusIx(spotMarketIndex, marketStatus) {
|
|
1365
|
+
return await this.program.instruction.updateSpotMarketStatus(marketStatus, {
|
|
1366
|
+
accounts: {
|
|
1367
|
+
admin: this.isSubscribed
|
|
1368
|
+
? this.getStateAccount().coldAdmin
|
|
1369
|
+
: this.wallet.publicKey,
|
|
1370
|
+
state: await this.getStatePublicKey(),
|
|
1371
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1372
|
+
},
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
async updateSpotMarketPausedOperations(spotMarketIndex, pausedOperations) {
|
|
1376
|
+
const updateSpotMarketPausedOperationsIx = await this.getUpdateSpotMarketPausedOperationsIx(spotMarketIndex, pausedOperations);
|
|
1377
|
+
const tx = await this.buildTransaction(updateSpotMarketPausedOperationsIx);
|
|
1378
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1379
|
+
return txSig;
|
|
1380
|
+
}
|
|
1381
|
+
async getUpdateSpotMarketPausedOperationsIx(spotMarketIndex, pausedOperations) {
|
|
1382
|
+
return await this.program.instruction.updateSpotMarketPausedOperations(pausedOperations, {
|
|
1383
|
+
accounts: {
|
|
1384
|
+
admin: this.isSubscribed
|
|
1385
|
+
? this.getStateAccount().coldAdmin
|
|
1386
|
+
: this.wallet.publicKey,
|
|
1387
|
+
state: await this.getStatePublicKey(),
|
|
1388
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1389
|
+
},
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
async updatePerpMarketStatus(perpMarketIndex, marketStatus) {
|
|
1393
|
+
const updatePerpMarketStatusIx = await this.getUpdatePerpMarketStatusIx(perpMarketIndex, marketStatus);
|
|
1394
|
+
const tx = await this.buildTransaction(updatePerpMarketStatusIx);
|
|
1395
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1396
|
+
return txSig;
|
|
1397
|
+
}
|
|
1398
|
+
async getUpdatePerpMarketStatusIx(perpMarketIndex, marketStatus) {
|
|
1399
|
+
return await this.program.instruction.updatePerpMarketStatus(marketStatus, {
|
|
1400
|
+
accounts: {
|
|
1401
|
+
admin: this.isSubscribed
|
|
1402
|
+
? this.getStateAccount().coldAdmin
|
|
1403
|
+
: this.wallet.publicKey,
|
|
1404
|
+
state: await this.getStatePublicKey(),
|
|
1405
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1406
|
+
},
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
async updatePerpMarketPausedOperations(perpMarketIndex, pausedOperations) {
|
|
1410
|
+
const updatePerpMarketPausedOperationsIx = await this.getUpdatePerpMarketPausedOperationsIx(perpMarketIndex, pausedOperations);
|
|
1411
|
+
const tx = await this.buildTransaction(updatePerpMarketPausedOperationsIx);
|
|
1412
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1413
|
+
return txSig;
|
|
1414
|
+
}
|
|
1415
|
+
async getUpdatePerpMarketPausedOperationsIx(perpMarketIndex, pausedOperations) {
|
|
1416
|
+
return await this.program.instruction.updatePerpMarketPausedOperations(pausedOperations, {
|
|
1417
|
+
accounts: {
|
|
1418
|
+
admin: this.isSubscribed
|
|
1419
|
+
? this.getStateAccount().coldAdmin
|
|
1420
|
+
: this.wallet.publicKey,
|
|
1421
|
+
state: await this.getStatePublicKey(),
|
|
1422
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1423
|
+
},
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
async updatePerpMarketContractTier(perpMarketIndex, contractTier) {
|
|
1427
|
+
const updatePerpMarketContractTierIx = await this.getUpdatePerpMarketContractTierIx(perpMarketIndex, contractTier);
|
|
1428
|
+
const tx = await this.buildTransaction(updatePerpMarketContractTierIx);
|
|
1429
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1430
|
+
return txSig;
|
|
1431
|
+
}
|
|
1432
|
+
async getUpdatePerpMarketContractTierIx(perpMarketIndex, contractTier) {
|
|
1433
|
+
return await this.program.instruction.updatePerpMarketContractTier(contractTier, {
|
|
1434
|
+
accounts: {
|
|
1435
|
+
admin: this.isSubscribed
|
|
1436
|
+
? this.getStateAccount().coldAdmin
|
|
1437
|
+
: this.wallet.publicKey,
|
|
1438
|
+
state: await this.getStatePublicKey(),
|
|
1439
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1440
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
1441
|
+
},
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
async updateExchangeStatus(exchangeStatus) {
|
|
1445
|
+
const updateExchangeStatusIx = await this.getUpdateExchangeStatusIx(exchangeStatus);
|
|
1446
|
+
const tx = await this.buildTransaction(updateExchangeStatusIx);
|
|
1447
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1448
|
+
return txSig;
|
|
1449
|
+
}
|
|
1450
|
+
async getUpdateExchangeStatusIx(exchangeStatus) {
|
|
1451
|
+
return await this.program.instruction.updateExchangeStatus(exchangeStatus, {
|
|
1452
|
+
accounts: {
|
|
1453
|
+
admin: this.isSubscribed
|
|
1454
|
+
? this.getStateAccount().coldAdmin
|
|
1455
|
+
: this.wallet.publicKey,
|
|
1456
|
+
state: await this.getStatePublicKey(),
|
|
1457
|
+
},
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
async updatePerpAuctionDuration(minDuration) {
|
|
1461
|
+
const updatePerpAuctionDurationIx = await this.getUpdatePerpAuctionDurationIx(minDuration);
|
|
1462
|
+
const tx = await this.buildTransaction(updatePerpAuctionDurationIx);
|
|
1463
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1464
|
+
return txSig;
|
|
1465
|
+
}
|
|
1466
|
+
async getUpdatePerpAuctionDurationIx(minDuration) {
|
|
1467
|
+
return await this.program.instruction.updatePerpAuctionDuration(typeof minDuration === 'number' ? minDuration : minDuration.toNumber(), {
|
|
1468
|
+
accounts: {
|
|
1469
|
+
admin: this.isSubscribed
|
|
1470
|
+
? this.getStateAccount().coldAdmin
|
|
1471
|
+
: this.wallet.publicKey,
|
|
1472
|
+
state: await this.getStatePublicKey(),
|
|
1473
|
+
},
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
async updateSpotAuctionDuration(defaultAuctionDuration) {
|
|
1477
|
+
const updateSpotAuctionDurationIx = await this.getUpdateSpotAuctionDurationIx(defaultAuctionDuration);
|
|
1478
|
+
const tx = await this.buildTransaction(updateSpotAuctionDurationIx);
|
|
1479
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1480
|
+
return txSig;
|
|
1481
|
+
}
|
|
1482
|
+
async getUpdateSpotAuctionDurationIx(defaultAuctionDuration) {
|
|
1483
|
+
return await this.program.instruction.updateSpotAuctionDuration(defaultAuctionDuration, {
|
|
1484
|
+
accounts: {
|
|
1485
|
+
admin: this.isSubscribed
|
|
1486
|
+
? this.getStateAccount().coldAdmin
|
|
1487
|
+
: this.wallet.publicKey,
|
|
1488
|
+
state: await this.getStatePublicKey(),
|
|
1489
|
+
},
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
async updatePerpMarketMaxFillReserveFraction(perpMarketIndex, maxBaseAssetAmountRatio) {
|
|
1493
|
+
const updatePerpMarketMaxFillReserveFractionIx = await this.getUpdatePerpMarketMaxFillReserveFractionIx(perpMarketIndex, maxBaseAssetAmountRatio);
|
|
1494
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxFillReserveFractionIx);
|
|
1495
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1496
|
+
return txSig;
|
|
1497
|
+
}
|
|
1498
|
+
async getUpdatePerpMarketMaxFillReserveFractionIx(perpMarketIndex, maxBaseAssetAmountRatio) {
|
|
1499
|
+
return await this.program.instruction.updatePerpMarketMaxFillReserveFraction(maxBaseAssetAmountRatio, {
|
|
1500
|
+
accounts: {
|
|
1501
|
+
admin: this.isSubscribed
|
|
1502
|
+
? this.getStateAccount().coldAdmin
|
|
1503
|
+
: this.wallet.publicKey,
|
|
1504
|
+
state: await this.getStatePublicKey(),
|
|
1505
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1506
|
+
},
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
async updateMaxSlippageRatio(perpMarketIndex, maxSlippageRatio) {
|
|
1510
|
+
const updateMaxSlippageRatioIx = await this.getUpdateMaxSlippageRatioIx(perpMarketIndex, maxSlippageRatio);
|
|
1511
|
+
const tx = await this.buildTransaction(updateMaxSlippageRatioIx);
|
|
1512
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1513
|
+
return txSig;
|
|
1514
|
+
}
|
|
1515
|
+
async getUpdateMaxSlippageRatioIx(perpMarketIndex, maxSlippageRatio) {
|
|
1516
|
+
return await this.program.instruction.updateMaxSlippageRatio(maxSlippageRatio, {
|
|
1517
|
+
accounts: {
|
|
1518
|
+
admin: this.isSubscribed
|
|
1519
|
+
? this.getStateAccount().coldAdmin
|
|
1520
|
+
: this.wallet.publicKey,
|
|
1521
|
+
state: await this.getStatePublicKey(),
|
|
1522
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
1523
|
+
},
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
async updatePerpMarketUnrealizedAssetWeight(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight) {
|
|
1527
|
+
const updatePerpMarketUnrealizedAssetWeightIx = await this.getUpdatePerpMarketUnrealizedAssetWeightIx(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight);
|
|
1528
|
+
const tx = await this.buildTransaction(updatePerpMarketUnrealizedAssetWeightIx);
|
|
1529
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1530
|
+
return txSig;
|
|
1531
|
+
}
|
|
1532
|
+
async getUpdatePerpMarketUnrealizedAssetWeightIx(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight) {
|
|
1533
|
+
return await this.program.instruction.updatePerpMarketUnrealizedAssetWeight(unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight, {
|
|
1534
|
+
accounts: {
|
|
1535
|
+
admin: this.isSubscribed
|
|
1536
|
+
? this.getStateAccount().coldAdmin
|
|
1537
|
+
: this.wallet.publicKey,
|
|
1538
|
+
state: await this.getStatePublicKey(),
|
|
1539
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1540
|
+
},
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
async updatePerpMarketMaxImbalances(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
|
|
1544
|
+
const updatePerpMarketMaxImabalancesIx = await this.getUpdatePerpMarketMaxImbalancesIx(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance);
|
|
1545
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxImabalancesIx);
|
|
1546
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1547
|
+
return txSig;
|
|
1548
|
+
}
|
|
1549
|
+
async getUpdatePerpMarketMaxImbalancesIx(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
|
|
1550
|
+
return await this.program.instruction.updatePerpMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
|
|
1551
|
+
accounts: {
|
|
1552
|
+
admin: this.isSubscribed
|
|
1553
|
+
? this.getStateAccount().coldAdmin
|
|
1554
|
+
: this.wallet.publicKey,
|
|
1555
|
+
state: await this.getStatePublicKey(),
|
|
1556
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1557
|
+
},
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
async updatePerpMarketMaxOpenInterest(perpMarketIndex, maxOpenInterest) {
|
|
1561
|
+
const updatePerpMarketMaxOpenInterestIx = await this.getUpdatePerpMarketMaxOpenInterestIx(perpMarketIndex, maxOpenInterest);
|
|
1562
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxOpenInterestIx);
|
|
1563
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1564
|
+
return txSig;
|
|
1565
|
+
}
|
|
1566
|
+
async getUpdatePerpMarketMaxOpenInterestIx(perpMarketIndex, maxOpenInterest) {
|
|
1567
|
+
return await this.program.instruction.updatePerpMarketMaxOpenInterest(maxOpenInterest, {
|
|
1568
|
+
accounts: {
|
|
1569
|
+
admin: this.isSubscribed
|
|
1570
|
+
? this.getStateAccount().coldAdmin
|
|
1571
|
+
: this.wallet.publicKey,
|
|
1572
|
+
state: await this.getStatePublicKey(),
|
|
1573
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1574
|
+
},
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
async updatePerpMarketNumberOfUser(perpMarketIndex, numberOfUsers, numberOfUsersWithBase) {
|
|
1578
|
+
const updatepPerpMarketFeeAdjustmentIx = await this.getUpdatePerpMarketNumberOfUsersIx(perpMarketIndex, numberOfUsers, numberOfUsersWithBase);
|
|
1579
|
+
const tx = await this.buildTransaction(updatepPerpMarketFeeAdjustmentIx);
|
|
1580
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1581
|
+
return txSig;
|
|
1582
|
+
}
|
|
1583
|
+
async getUpdatePerpMarketNumberOfUsersIx(perpMarketIndex, numberOfUsers, numberOfUsersWithBase) {
|
|
1584
|
+
return await this.program.instruction.updatePerpMarketNumberOfUsers(numberOfUsers, numberOfUsersWithBase, {
|
|
1585
|
+
accounts: {
|
|
1586
|
+
admin: this.isSubscribed
|
|
1587
|
+
? this.getStateAccount().coldAdmin
|
|
1588
|
+
: this.wallet.publicKey,
|
|
1589
|
+
state: await this.getStatePublicKey(),
|
|
1590
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1591
|
+
},
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
async updatePerpMarketFeeAdjustment(perpMarketIndex, feeAdjustment) {
|
|
1595
|
+
const updatepPerpMarketFeeAdjustmentIx = await this.getUpdatePerpMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment);
|
|
1596
|
+
const tx = await this.buildTransaction(updatepPerpMarketFeeAdjustmentIx);
|
|
1597
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1598
|
+
return txSig;
|
|
1599
|
+
}
|
|
1600
|
+
async getUpdatePerpMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment) {
|
|
1601
|
+
return await this.program.instruction.updatePerpMarketFeeAdjustment(feeAdjustment, {
|
|
1602
|
+
accounts: {
|
|
1603
|
+
admin: this.isSubscribed
|
|
1604
|
+
? this.getStateAccount().coldAdmin
|
|
1605
|
+
: this.wallet.publicKey,
|
|
1606
|
+
state: await this.getStatePublicKey(),
|
|
1607
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1608
|
+
},
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
async updateSpotMarketFeeAdjustment(perpMarketIndex, feeAdjustment) {
|
|
1612
|
+
const updateSpotMarketFeeAdjustmentIx = await this.getUpdateSpotMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment);
|
|
1613
|
+
const tx = await this.buildTransaction(updateSpotMarketFeeAdjustmentIx);
|
|
1614
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1615
|
+
return txSig;
|
|
1616
|
+
}
|
|
1617
|
+
async getUpdateSpotMarketFeeAdjustmentIx(spotMarketIndex, feeAdjustment) {
|
|
1618
|
+
return await this.program.instruction.updateSpotMarketFeeAdjustment(feeAdjustment, {
|
|
1619
|
+
accounts: {
|
|
1620
|
+
admin: this.isSubscribed
|
|
1621
|
+
? this.getStateAccount().coldAdmin
|
|
1622
|
+
: this.wallet.publicKey,
|
|
1623
|
+
state: await this.getStatePublicKey(),
|
|
1624
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1625
|
+
},
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
async updatePerpMarketLiquidationFee(perpMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
1629
|
+
const updatePerpMarketLiquidationFeeIx = await this.getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee);
|
|
1630
|
+
const tx = await this.buildTransaction(updatePerpMarketLiquidationFeeIx);
|
|
1631
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1632
|
+
return txSig;
|
|
1633
|
+
}
|
|
1634
|
+
async getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
1635
|
+
return await this.program.instruction.updatePerpMarketLiquidationFee(liquidatorFee, ifLiquidationFee, {
|
|
1636
|
+
accounts: {
|
|
1637
|
+
admin: this.isSubscribed
|
|
1638
|
+
? this.getStateAccount().coldAdmin
|
|
1639
|
+
: this.wallet.publicKey,
|
|
1640
|
+
state: await this.getStatePublicKey(),
|
|
1641
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1642
|
+
},
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
async updateSpotMarketLiquidationFee(spotMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
1646
|
+
const updateSpotMarketLiquidationFeeIx = await this.getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee);
|
|
1647
|
+
const tx = await this.buildTransaction(updateSpotMarketLiquidationFeeIx);
|
|
1648
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1649
|
+
return txSig;
|
|
1650
|
+
}
|
|
1651
|
+
async getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
1652
|
+
return await this.program.instruction.updateSpotMarketLiquidationFee(liquidatorFee, ifLiquidationFee, {
|
|
1653
|
+
accounts: {
|
|
1654
|
+
admin: this.isSubscribed
|
|
1655
|
+
? this.getStateAccount().coldAdmin
|
|
1656
|
+
: this.wallet.publicKey,
|
|
1657
|
+
state: await this.getStatePublicKey(),
|
|
1658
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1659
|
+
},
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
async initializeProtocolIfSharesTransferConfig() {
|
|
1663
|
+
const initializeProtocolIfSharesTransferConfigIx = await this.getInitializeProtocolIfSharesTransferConfigIx();
|
|
1664
|
+
const tx = await this.buildTransaction(initializeProtocolIfSharesTransferConfigIx);
|
|
1665
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1666
|
+
return txSig;
|
|
1667
|
+
}
|
|
1668
|
+
async getInitializeProtocolIfSharesTransferConfigIx() {
|
|
1669
|
+
return await this.program.instruction.initializeProtocolIfSharesTransferConfig({
|
|
1670
|
+
accounts: {
|
|
1671
|
+
admin: this.isSubscribed
|
|
1672
|
+
? this.getStateAccount().coldAdmin
|
|
1673
|
+
: this.wallet.publicKey,
|
|
1674
|
+
state: await this.getStatePublicKey(),
|
|
1675
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1676
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1677
|
+
protocolIfSharesTransferConfig: (0, pda_1.getProtocolIfSharesTransferConfigPublicKey)(this.program.programId),
|
|
1678
|
+
},
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
async updateProtocolIfSharesTransferConfig(whitelistedSigners, maxTransferPerEpoch) {
|
|
1682
|
+
const updateProtocolIfSharesTransferConfigIx = await this.getUpdateProtocolIfSharesTransferConfigIx(whitelistedSigners, maxTransferPerEpoch);
|
|
1683
|
+
const tx = await this.buildTransaction(updateProtocolIfSharesTransferConfigIx);
|
|
1684
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1685
|
+
return txSig;
|
|
1686
|
+
}
|
|
1687
|
+
async getUpdateProtocolIfSharesTransferConfigIx(whitelistedSigners, maxTransferPerEpoch) {
|
|
1688
|
+
return await this.program.instruction.updateProtocolIfSharesTransferConfig(whitelistedSigners || null, maxTransferPerEpoch, {
|
|
1689
|
+
accounts: {
|
|
1690
|
+
admin: this.isSubscribed
|
|
1691
|
+
? this.getStateAccount().coldAdmin
|
|
1692
|
+
: this.wallet.publicKey,
|
|
1693
|
+
state: await this.getStatePublicKey(),
|
|
1694
|
+
protocolIfSharesTransferConfig: (0, pda_1.getProtocolIfSharesTransferConfigPublicKey)(this.program.programId),
|
|
1695
|
+
},
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
async transferProtocolIfSharesToRevenuePool(outMarketIndex, inMarketIndex, amount) {
|
|
1699
|
+
const transferProtocolIfSharesToRevenuePoolIx = await this.getTransferProtocolIfSharesToRevenuePoolIx(outMarketIndex, inMarketIndex, amount);
|
|
1700
|
+
const tx = await this.buildTransaction(transferProtocolIfSharesToRevenuePoolIx);
|
|
1701
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1702
|
+
return txSig;
|
|
1703
|
+
}
|
|
1704
|
+
async getTransferProtocolIfSharesToRevenuePoolIx(outMarketIndex, inMarketIndex, amount) {
|
|
1705
|
+
const remainingAccounts = await this.getRemainingAccounts({
|
|
1706
|
+
userAccounts: [],
|
|
1707
|
+
writableSpotMarketIndexes: [outMarketIndex],
|
|
1708
|
+
});
|
|
1709
|
+
return await this.program.instruction.transferProtocolIfSharesToRevenuePool(outMarketIndex, amount, {
|
|
1710
|
+
accounts: {
|
|
1711
|
+
authority: this.wallet.publicKey,
|
|
1712
|
+
state: await this.getStatePublicKey(),
|
|
1713
|
+
insuranceFundVault: await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, outMarketIndex),
|
|
1714
|
+
spotMarketVault: await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, outMarketIndex),
|
|
1715
|
+
ifRebalanceConfig: await (0, pda_1.getIfRebalanceConfigPublicKey)(this.program.programId, inMarketIndex, outMarketIndex),
|
|
1716
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
1717
|
+
driftSigner: this.getStateAccount().signer,
|
|
1718
|
+
},
|
|
1719
|
+
remainingAccounts,
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
async adminWithdrawFromInsuranceFundVault(marketIndex, amount, recipientTokenAccount, txParams) {
|
|
1723
|
+
const ix = await this.getAdminWithdrawFromInsuranceFundVaultIx(marketIndex, amount, recipientTokenAccount);
|
|
1724
|
+
const tx = await this.buildTransaction(ix, txParams);
|
|
1725
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1726
|
+
return txSig;
|
|
1727
|
+
}
|
|
1728
|
+
async getAdminWithdrawFromInsuranceFundVaultIx(marketIndex, amount, recipientTokenAccount) {
|
|
1729
|
+
const spotMarket = this.getSpotMarketAccount(marketIndex);
|
|
1730
|
+
const tokenProgramId = this.getTokenProgramForSpotMarket(spotMarket);
|
|
1731
|
+
const remainingAccounts = [];
|
|
1732
|
+
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
1733
|
+
if (this.isTransferHook(spotMarket)) {
|
|
1734
|
+
await this.addExtraAccountMetasToRemainingAccounts(spotMarket.mint, remainingAccounts);
|
|
1735
|
+
}
|
|
1736
|
+
return await this.program.instruction.adminWithdrawFromInsuranceFundVault(marketIndex, amount, {
|
|
1737
|
+
accounts: {
|
|
1738
|
+
state: await this.getStatePublicKey(),
|
|
1739
|
+
authority: this.isSubscribed
|
|
1740
|
+
? this.getStateAccount().coldAdmin
|
|
1741
|
+
: this.wallet.publicKey,
|
|
1742
|
+
spotMarket: spotMarket.pubkey,
|
|
1743
|
+
insuranceFundVault: spotMarket.insuranceFund.vault,
|
|
1744
|
+
recipientTokenAccount,
|
|
1745
|
+
tokenProgram: tokenProgramId,
|
|
1746
|
+
driftSigner: this.getSignerPublicKey(),
|
|
1747
|
+
},
|
|
1748
|
+
remainingAccounts,
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
async initializePrelaunchOracle(perpMarketIndex, price, maxPrice) {
|
|
1752
|
+
const initializePrelaunchOracleIx = await this.getInitializePrelaunchOracleIx(perpMarketIndex, price, maxPrice);
|
|
1753
|
+
const tx = await this.buildTransaction(initializePrelaunchOracleIx);
|
|
1754
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1755
|
+
return txSig;
|
|
1756
|
+
}
|
|
1757
|
+
async getInitializePrelaunchOracleIx(perpMarketIndex, price, maxPrice) {
|
|
1758
|
+
const params = {
|
|
1759
|
+
perpMarketIndex,
|
|
1760
|
+
price: price || null,
|
|
1761
|
+
maxPrice: maxPrice || null,
|
|
1762
|
+
};
|
|
1763
|
+
return await this.program.instruction.initializePrelaunchOracle(params, {
|
|
1764
|
+
accounts: {
|
|
1765
|
+
admin: this.isSubscribed
|
|
1766
|
+
? this.getStateAccount().coldAdmin
|
|
1767
|
+
: this.wallet.publicKey,
|
|
1768
|
+
state: await this.getStatePublicKey(),
|
|
1769
|
+
prelaunchOracle: await (0, pda_1.getPrelaunchOraclePublicKey)(this.program.programId, perpMarketIndex),
|
|
1770
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1771
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1772
|
+
},
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
async updatePrelaunchOracleParams(perpMarketIndex, price, maxPrice) {
|
|
1776
|
+
const updatePrelaunchOracleParamsIx = await this.getUpdatePrelaunchOracleParamsIx(perpMarketIndex, price, maxPrice);
|
|
1777
|
+
const tx = await this.buildTransaction(updatePrelaunchOracleParamsIx);
|
|
1778
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1779
|
+
return txSig;
|
|
1780
|
+
}
|
|
1781
|
+
async getUpdatePrelaunchOracleParamsIx(perpMarketIndex, price, maxPrice) {
|
|
1782
|
+
const params = {
|
|
1783
|
+
perpMarketIndex,
|
|
1784
|
+
price: price || null,
|
|
1785
|
+
maxPrice: maxPrice || null,
|
|
1786
|
+
};
|
|
1787
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1788
|
+
return await this.program.instruction.updatePrelaunchOracleParams(params, {
|
|
1789
|
+
accounts: {
|
|
1790
|
+
admin: this.isSubscribed
|
|
1791
|
+
? this.getStateAccount().coldAdmin
|
|
1792
|
+
: this.wallet.publicKey,
|
|
1793
|
+
state: await this.getStatePublicKey(),
|
|
1794
|
+
perpMarket: perpMarketPublicKey,
|
|
1795
|
+
prelaunchOracle: await (0, pda_1.getPrelaunchOraclePublicKey)(this.program.programId, perpMarketIndex),
|
|
1796
|
+
},
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
async deletePrelaunchOracle(perpMarketIndex) {
|
|
1800
|
+
const deletePrelaunchOracleIx = await this.getDeletePrelaunchOracleIx(perpMarketIndex);
|
|
1801
|
+
const tx = await this.buildTransaction(deletePrelaunchOracleIx);
|
|
1802
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1803
|
+
return txSig;
|
|
1804
|
+
}
|
|
1805
|
+
async getDeletePrelaunchOracleIx(perpMarketIndex, price, maxPrice) {
|
|
1806
|
+
const params = {
|
|
1807
|
+
perpMarketIndex,
|
|
1808
|
+
price: price || null,
|
|
1809
|
+
maxPrice: maxPrice || null,
|
|
1810
|
+
};
|
|
1811
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1812
|
+
return await this.program.instruction.deletePrelaunchOracle(params, {
|
|
1813
|
+
accounts: {
|
|
1814
|
+
admin: this.isSubscribed
|
|
1815
|
+
? this.getStateAccount().coldAdmin
|
|
1816
|
+
: this.wallet.publicKey,
|
|
1817
|
+
state: await this.getStatePublicKey(),
|
|
1818
|
+
perpMarket: perpMarketPublicKey,
|
|
1819
|
+
prelaunchOracle: await (0, pda_1.getPrelaunchOraclePublicKey)(this.program.programId, perpMarketIndex),
|
|
1820
|
+
},
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
async updatePerpMarketOracleLowRiskSlotDelayOverride(perpMarketIndex, oracleLowRiskSlotDelayOverride) {
|
|
1824
|
+
const updatePerpMarketOracleLowRiskSlotDelayOverrideIx = await this.getUpdatePerpMarketOracleLowRiskSlotDelayOverrideIx(perpMarketIndex, oracleLowRiskSlotDelayOverride);
|
|
1825
|
+
const tx = await this.buildTransaction(updatePerpMarketOracleLowRiskSlotDelayOverrideIx);
|
|
1826
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1827
|
+
return txSig;
|
|
1828
|
+
}
|
|
1829
|
+
async getUpdatePerpMarketOracleLowRiskSlotDelayOverrideIx(perpMarketIndex, oracleLowRiskSlotDelayOverride) {
|
|
1830
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1831
|
+
return await this.program.instruction.updatePerpMarketOracleLowRiskSlotDelayOverride(oracleLowRiskSlotDelayOverride, {
|
|
1832
|
+
accounts: {
|
|
1833
|
+
admin: this.useHotWalletAdmin
|
|
1834
|
+
? this.wallet.publicKey
|
|
1835
|
+
: this.getStateAccount().coldAdmin,
|
|
1836
|
+
state: await this.getStatePublicKey(),
|
|
1837
|
+
perpMarket: perpMarketPublicKey,
|
|
1838
|
+
},
|
|
1839
|
+
});
|
|
1840
|
+
}
|
|
1841
|
+
async updatePerpMarketOracleSlotDelayOverride(perpMarketIndex, oracleSlotDelay) {
|
|
1842
|
+
const updatePerpMarketOracleSlotDelayOverrideIx = await this.getUpdatePerpMarketOracleSlotDelayOverrideIx(perpMarketIndex, oracleSlotDelay);
|
|
1843
|
+
const tx = await this.buildTransaction(updatePerpMarketOracleSlotDelayOverrideIx);
|
|
1844
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1845
|
+
return txSig;
|
|
1846
|
+
}
|
|
1847
|
+
async getUpdatePerpMarketOracleSlotDelayOverrideIx(perpMarketIndex, oracleSlotDelay) {
|
|
1848
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1849
|
+
return await this.program.instruction.updatePerpMarketOracleSlotDelayOverride(oracleSlotDelay, {
|
|
1850
|
+
accounts: {
|
|
1851
|
+
admin: this.useHotWalletAdmin
|
|
1852
|
+
? this.wallet.publicKey
|
|
1853
|
+
: this.getStateAccount().coldAdmin,
|
|
1854
|
+
state: await this.getStatePublicKey(),
|
|
1855
|
+
perpMarket: perpMarketPublicKey,
|
|
1856
|
+
},
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
async updatePerpMarketAmmSpreadAdjustment(perpMarketIndex, ammSpreadAdjustment, ammInventorySpreadAdjustment, referencePriceOffset) {
|
|
1860
|
+
const updatePerpMarketAmmSpreadAdjustmentIx = await this.getUpdatePerpMarketAmmSpreadAdjustmentIx(perpMarketIndex, ammSpreadAdjustment, ammInventorySpreadAdjustment, referencePriceOffset);
|
|
1861
|
+
const tx = await this.buildTransaction(updatePerpMarketAmmSpreadAdjustmentIx);
|
|
1862
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1863
|
+
return txSig;
|
|
1864
|
+
}
|
|
1865
|
+
async getUpdatePerpMarketAmmSpreadAdjustmentIx(perpMarketIndex, ammSpreadAdjustment, ammInventorySpreadAdjustment, referencePriceOffset) {
|
|
1866
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1867
|
+
return await this.program.instruction.updatePerpMarketAmmSpreadAdjustment(ammSpreadAdjustment, ammInventorySpreadAdjustment, referencePriceOffset, {
|
|
1868
|
+
accounts: {
|
|
1869
|
+
admin: this.useHotWalletAdmin
|
|
1870
|
+
? this.wallet.publicKey
|
|
1871
|
+
: this.getStateAccount().coldAdmin,
|
|
1872
|
+
state: await this.getStatePublicKey(),
|
|
1873
|
+
perpMarket: perpMarketPublicKey,
|
|
1874
|
+
},
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
async initializeIfRebalanceConfig(params) {
|
|
1878
|
+
const initializeIfRebalanceConfigIx = await this.getInitializeIfRebalanceConfigIx(params);
|
|
1879
|
+
const tx = await this.buildTransaction(initializeIfRebalanceConfigIx);
|
|
1880
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1881
|
+
return txSig;
|
|
1882
|
+
}
|
|
1883
|
+
async getInitializeIfRebalanceConfigIx(params) {
|
|
1884
|
+
return await this.program.instruction.initializeIfRebalanceConfig(params, {
|
|
1885
|
+
accounts: {
|
|
1886
|
+
admin: this.isSubscribed
|
|
1887
|
+
? this.getStateAccount().coldAdmin
|
|
1888
|
+
: this.wallet.publicKey,
|
|
1889
|
+
state: await this.getStatePublicKey(),
|
|
1890
|
+
ifRebalanceConfig: await (0, pda_1.getIfRebalanceConfigPublicKey)(this.program.programId, params.inMarketIndex, params.outMarketIndex),
|
|
1891
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1892
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1893
|
+
},
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
async initializePythLazerOracle(feedId) {
|
|
1897
|
+
const initializePythLazerOracleIx = await this.getInitializePythLazerOracleIx(feedId);
|
|
1898
|
+
const tx = await this.buildTransaction(initializePythLazerOracleIx);
|
|
1899
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1900
|
+
return txSig;
|
|
1901
|
+
}
|
|
1902
|
+
async getInitializePythLazerOracleIx(feedId) {
|
|
1903
|
+
return await this.program.instruction.initializePythLazerOracle(feedId, {
|
|
1904
|
+
accounts: {
|
|
1905
|
+
admin: this.useHotWalletAdmin
|
|
1906
|
+
? this.wallet.publicKey
|
|
1907
|
+
: this.getStateAccount().coldAdmin,
|
|
1908
|
+
state: await this.getStatePublicKey(),
|
|
1909
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
1910
|
+
lazerOracle: (0, pda_1.getPythLazerOraclePublicKey)(this.program.programId, feedId),
|
|
1911
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1912
|
+
},
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
async adminDeposit(marketIndex, amount, depositUserAccount, adminTokenAccount) {
|
|
1916
|
+
const ix = await this.getAdminDepositIx(marketIndex, amount, depositUserAccount, adminTokenAccount);
|
|
1917
|
+
const tx = await this.buildTransaction(ix);
|
|
1918
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1919
|
+
return txSig;
|
|
1920
|
+
}
|
|
1921
|
+
async getAdminDepositIx(marketIndex, amount, depositUserAccount, adminTokenAccount) {
|
|
1922
|
+
const state = await this.getStatePublicKey();
|
|
1923
|
+
const spotMarket = this.getSpotMarketAccount(marketIndex);
|
|
1924
|
+
const remainingAccounts = this.getRemainingAccounts({
|
|
1925
|
+
userAccounts: [],
|
|
1926
|
+
writableSpotMarketIndexes: [marketIndex],
|
|
1927
|
+
});
|
|
1928
|
+
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
1929
|
+
if (this.isTransferHook(spotMarket)) {
|
|
1930
|
+
await this.addExtraAccountMetasToRemainingAccounts(spotMarket.mint, remainingAccounts);
|
|
1931
|
+
}
|
|
1932
|
+
return this.program.instruction.adminDeposit(marketIndex, amount, {
|
|
1933
|
+
remainingAccounts,
|
|
1934
|
+
accounts: {
|
|
1935
|
+
state,
|
|
1936
|
+
user: depositUserAccount,
|
|
1937
|
+
admin: this.wallet.publicKey,
|
|
1938
|
+
spotMarketVault: spotMarket.vault,
|
|
1939
|
+
adminTokenAccount: adminTokenAccount !== null && adminTokenAccount !== void 0 ? adminTokenAccount : (await this.getAssociatedTokenAccount(marketIndex)),
|
|
1940
|
+
tokenProgram: (0, pda_1.getTokenProgramForSpotMarket)(spotMarket),
|
|
1941
|
+
},
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
async zeroMMOracleFields(marketIndex) {
|
|
1945
|
+
const zeroMMOracleFieldsIx = await this.getZeroMMOracleFieldsIx(marketIndex);
|
|
1946
|
+
const tx = await this.buildTransaction(zeroMMOracleFieldsIx);
|
|
1947
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1948
|
+
return txSig;
|
|
1949
|
+
}
|
|
1950
|
+
async getZeroMMOracleFieldsIx(marketIndex) {
|
|
1951
|
+
return await this.program.instruction.zeroMmOracleFields({
|
|
1952
|
+
accounts: {
|
|
1953
|
+
admin: this.useHotWalletAdmin
|
|
1954
|
+
? this.wallet.publicKey
|
|
1955
|
+
: this.getStateAccount().coldAdmin,
|
|
1956
|
+
state: await this.getStatePublicKey(),
|
|
1957
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex),
|
|
1958
|
+
},
|
|
1959
|
+
});
|
|
1960
|
+
}
|
|
1961
|
+
async updateFeatureBitFlagsMMOracle(enable) {
|
|
1962
|
+
const updateFeatureBitFlagsMMOracleIx = await this.getUpdateFeatureBitFlagsMMOracleIx(enable);
|
|
1963
|
+
const tx = await this.buildTransaction(updateFeatureBitFlagsMMOracleIx);
|
|
1964
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1965
|
+
return txSig;
|
|
1966
|
+
}
|
|
1967
|
+
async getUpdateFeatureBitFlagsMMOracleIx(enable) {
|
|
1968
|
+
return await this.program.instruction.updateFeatureBitFlagsMmOracle(enable, {
|
|
1969
|
+
accounts: {
|
|
1970
|
+
admin: this.useHotWalletAdmin
|
|
1971
|
+
? this.wallet.publicKey
|
|
1972
|
+
: this.getStateAccount().coldAdmin,
|
|
1973
|
+
state: await this.getStatePublicKey(),
|
|
1974
|
+
},
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
async updateFeatureBitFlagsBuilderCodes(enable) {
|
|
1978
|
+
const updateFeatureBitFlagsBuilderCodesIx = await this.getUpdateFeatureBitFlagsBuilderCodesIx(enable);
|
|
1979
|
+
const tx = await this.buildTransaction(updateFeatureBitFlagsBuilderCodesIx);
|
|
1980
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1981
|
+
return txSig;
|
|
1982
|
+
}
|
|
1983
|
+
async getUpdateFeatureBitFlagsBuilderCodesIx(enable) {
|
|
1984
|
+
return this.program.instruction.updateFeatureBitFlagsBuilderCodes(enable, {
|
|
1985
|
+
accounts: {
|
|
1986
|
+
admin: this.useHotWalletAdmin
|
|
1987
|
+
? this.wallet.publicKey
|
|
1988
|
+
: this.getStateAccount().coldAdmin,
|
|
1989
|
+
state: await this.getStatePublicKey(),
|
|
1990
|
+
},
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
async updateFeatureBitFlagsBuilderReferral(enable) {
|
|
1994
|
+
const updateFeatureBitFlagsBuilderReferralIx = await this.getUpdateFeatureBitFlagsBuilderReferralIx(enable);
|
|
1995
|
+
const tx = await this.buildTransaction(updateFeatureBitFlagsBuilderReferralIx);
|
|
1996
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1997
|
+
return txSig;
|
|
1998
|
+
}
|
|
1999
|
+
async getUpdateFeatureBitFlagsBuilderReferralIx(enable) {
|
|
2000
|
+
return this.program.instruction.updateFeatureBitFlagsBuilderReferral(enable, {
|
|
2001
|
+
accounts: {
|
|
2002
|
+
admin: this.useHotWalletAdmin
|
|
2003
|
+
? this.wallet.publicKey
|
|
2004
|
+
: this.getStateAccount().coldAdmin,
|
|
2005
|
+
state: await this.getStatePublicKey(),
|
|
2006
|
+
},
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
async updateFeatureBitFlagsMedianTriggerPrice(enable) {
|
|
2010
|
+
const updateFeatureBitFlagsMedianTriggerPriceIx = await this.getUpdateFeatureBitFlagsMedianTriggerPriceIx(enable);
|
|
2011
|
+
const tx = await this.buildTransaction(updateFeatureBitFlagsMedianTriggerPriceIx);
|
|
2012
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2013
|
+
return txSig;
|
|
2014
|
+
}
|
|
2015
|
+
async getUpdateFeatureBitFlagsMedianTriggerPriceIx(enable) {
|
|
2016
|
+
return await this.program.instruction.updateFeatureBitFlagsMedianTriggerPrice(enable, {
|
|
2017
|
+
accounts: {
|
|
2018
|
+
admin: this.useHotWalletAdmin
|
|
2019
|
+
? this.wallet.publicKey
|
|
2020
|
+
: this.getStateAccount().coldAdmin,
|
|
2021
|
+
state: await this.getStatePublicKey(),
|
|
2022
|
+
},
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
async updateDelegateUserGovTokenInsuranceStake(authority, delegate) {
|
|
2026
|
+
const updateDelegateUserGovTokenInsuranceStakeIx = await this.getUpdateDelegateUserGovTokenInsuranceStakeIx(authority, delegate);
|
|
2027
|
+
const tx = await this.buildTransaction(updateDelegateUserGovTokenInsuranceStakeIx);
|
|
2028
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2029
|
+
return txSig;
|
|
2030
|
+
}
|
|
2031
|
+
async getUpdateDelegateUserGovTokenInsuranceStakeIx(authority, delegate) {
|
|
2032
|
+
const marketIndex = numericConstants_1.GOV_SPOT_MARKET_INDEX;
|
|
2033
|
+
const spotMarket = this.getSpotMarketAccount(marketIndex);
|
|
2034
|
+
const ifStakeAccountPublicKey = (0, pda_1.getInsuranceFundStakeAccountPublicKey)(this.program.programId, delegate, marketIndex);
|
|
2035
|
+
const userStatsPublicKey = (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority);
|
|
2036
|
+
const ix = this.program.instruction.getUpdateDelegateUserGovTokenInsuranceStakeIx({
|
|
2037
|
+
accounts: {
|
|
2038
|
+
state: await this.getStatePublicKey(),
|
|
2039
|
+
spotMarket: spotMarket.pubkey,
|
|
2040
|
+
insuranceFundStake: ifStakeAccountPublicKey,
|
|
2041
|
+
userStats: userStatsPublicKey,
|
|
2042
|
+
signer: this.wallet.publicKey,
|
|
2043
|
+
insuranceFundVault: spotMarket.insuranceFund.vault,
|
|
2044
|
+
},
|
|
2045
|
+
});
|
|
2046
|
+
return ix;
|
|
2047
|
+
}
|
|
2048
|
+
async depositIntoInsuranceFundStake(marketIndex, amount, userStatsPublicKey, insuranceFundStakePublicKey, userTokenAccountPublicKey, txParams) {
|
|
2049
|
+
const tx = await this.buildTransaction(await this.getDepositIntoInsuranceFundStakeIx(marketIndex, amount, userStatsPublicKey, insuranceFundStakePublicKey, userTokenAccountPublicKey), txParams);
|
|
2050
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2051
|
+
return txSig;
|
|
2052
|
+
}
|
|
2053
|
+
async getDepositIntoInsuranceFundStakeIx(marketIndex, amount, userStatsPublicKey, insuranceFundStakePublicKey, userTokenAccountPublicKey) {
|
|
2054
|
+
const spotMarket = this.getSpotMarketAccount(marketIndex);
|
|
2055
|
+
return await this.program.instruction.depositIntoInsuranceFundStake(marketIndex, amount, {
|
|
2056
|
+
accounts: {
|
|
2057
|
+
signer: this.wallet.publicKey,
|
|
2058
|
+
state: await this.getStatePublicKey(),
|
|
2059
|
+
spotMarket: spotMarket.pubkey,
|
|
2060
|
+
insuranceFundStake: insuranceFundStakePublicKey,
|
|
2061
|
+
userStats: userStatsPublicKey,
|
|
2062
|
+
spotMarketVault: spotMarket.vault,
|
|
2063
|
+
insuranceFundVault: spotMarket.insuranceFund.vault,
|
|
2064
|
+
userTokenAccount: userTokenAccountPublicKey,
|
|
2065
|
+
tokenProgram: this.getTokenProgramForSpotMarket(spotMarket),
|
|
2066
|
+
driftSigner: this.getSignerPublicKey(),
|
|
2067
|
+
},
|
|
2068
|
+
});
|
|
2069
|
+
}
|
|
2070
|
+
async updateFeatureBitFlagsSettleLpPool(enable) {
|
|
2071
|
+
const updateFeatureBitFlagsSettleLpPoolIx = await this.getUpdateFeatureBitFlagsSettleLpPoolIx(enable);
|
|
2072
|
+
const tx = await this.buildTransaction(updateFeatureBitFlagsSettleLpPoolIx);
|
|
2073
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2074
|
+
return txSig;
|
|
2075
|
+
}
|
|
2076
|
+
async getUpdateFeatureBitFlagsSettleLpPoolIx(enable) {
|
|
2077
|
+
return await this.program.instruction.updateFeatureBitFlagsSettleLpPool(enable, {
|
|
2078
|
+
accounts: {
|
|
2079
|
+
admin: this.useHotWalletAdmin
|
|
2080
|
+
? this.wallet.publicKey
|
|
2081
|
+
: this.getStateAccount().coldAdmin,
|
|
2082
|
+
state: await this.getStatePublicKey(),
|
|
2083
|
+
},
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
async updateFeatureBitFlagsSwapLpPool(enable) {
|
|
2087
|
+
const updateFeatureBitFlagsSettleLpPoolIx = await this.getUpdateFeatureBitFlagsSwapLpPoolIx(enable);
|
|
2088
|
+
const tx = await this.buildTransaction(updateFeatureBitFlagsSettleLpPoolIx);
|
|
2089
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2090
|
+
return txSig;
|
|
2091
|
+
}
|
|
2092
|
+
async getUpdateFeatureBitFlagsSwapLpPoolIx(enable) {
|
|
2093
|
+
return await this.program.instruction.updateFeatureBitFlagsSwapLpPool(enable, {
|
|
2094
|
+
accounts: {
|
|
2095
|
+
admin: this.useHotWalletAdmin
|
|
2096
|
+
? this.wallet.publicKey
|
|
2097
|
+
: this.getStateAccount().coldAdmin,
|
|
2098
|
+
state: await this.getStatePublicKey(),
|
|
2099
|
+
},
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
async updateFeatureBitFlagsMintRedeemLpPool(enable) {
|
|
2103
|
+
const updateFeatureBitFlagsSettleLpPoolIx = await this.getUpdateFeatureBitFlagsMintRedeemLpPoolIx(enable);
|
|
2104
|
+
const tx = await this.buildTransaction(updateFeatureBitFlagsSettleLpPoolIx);
|
|
2105
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2106
|
+
return txSig;
|
|
2107
|
+
}
|
|
2108
|
+
async getUpdateFeatureBitFlagsMintRedeemLpPoolIx(enable) {
|
|
2109
|
+
return await this.program.instruction.updateFeatureBitFlagsMintRedeemLpPool(enable, {
|
|
2110
|
+
accounts: {
|
|
2111
|
+
admin: this.useHotWalletAdmin
|
|
2112
|
+
? this.wallet.publicKey
|
|
2113
|
+
: this.getStateAccount().coldAdmin,
|
|
2114
|
+
state: await this.getStatePublicKey(),
|
|
2115
|
+
},
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
2118
|
+
async adminUpdateUserStatsPausedOperations(authority, pausedOperations) {
|
|
2119
|
+
const updateUserStatsPausedOperationsIx = await this.getAdminUpdateUserStatsPausedOperationsIx(authority, pausedOperations);
|
|
2120
|
+
const tx = await this.buildTransaction(updateUserStatsPausedOperationsIx);
|
|
2121
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2122
|
+
return txSig;
|
|
2123
|
+
}
|
|
2124
|
+
async getAdminUpdateUserStatsPausedOperationsIx(authority, pausedOperations) {
|
|
2125
|
+
return await this.program.instruction.adminUpdateUserStatsPausedOperations(pausedOperations, {
|
|
2126
|
+
accounts: {
|
|
2127
|
+
admin: this.useHotWalletAdmin
|
|
2128
|
+
? this.wallet.publicKey
|
|
2129
|
+
: this.getStateAccount().coldAdmin,
|
|
2130
|
+
state: await this.getStatePublicKey(),
|
|
2131
|
+
userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority),
|
|
2132
|
+
},
|
|
2133
|
+
});
|
|
2134
|
+
}
|
|
2135
|
+
async initializeLpPool(lpPoolId, minMintFee, maxAum, maxSettleQuoteAmountPerMarket, mint, whitelistMint) {
|
|
2136
|
+
const ixs = await this.getInitializeLpPoolIx(lpPoolId, minMintFee, maxAum, maxSettleQuoteAmountPerMarket, mint, whitelistMint);
|
|
2137
|
+
const tx = await this.buildTransaction(ixs);
|
|
2138
|
+
const { txSig } = await this.sendTransaction(tx, [mint]);
|
|
2139
|
+
return txSig;
|
|
2140
|
+
}
|
|
2141
|
+
async getInitializeLpPoolIx(lpPoolId, minMintFee, maxAum, maxSettleQuoteAmountPerMarket, mint, whitelistMint) {
|
|
2142
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2143
|
+
const ammConstituentMapping = (0, pda_1.getAmmConstituentMappingPublicKey)(this.program.programId, lpPool);
|
|
2144
|
+
const constituentTargetBase = (0, pda_1.getConstituentTargetBasePublicKey)(this.program.programId, lpPool);
|
|
2145
|
+
const lamports = await this.program.provider.connection.getMinimumBalanceForRentExemption(spl_token_1.MINT_SIZE);
|
|
2146
|
+
const createMintAccountIx = web3_js_1.SystemProgram.createAccount({
|
|
2147
|
+
fromPubkey: this.wallet.publicKey,
|
|
2148
|
+
newAccountPubkey: mint.publicKey,
|
|
2149
|
+
space: spl_token_1.MINT_SIZE,
|
|
2150
|
+
lamports: Math.min(0.05 * web3_js_1.LAMPORTS_PER_SOL, lamports), // should be 0.0014616 ? but bankrun returns 10 SOL
|
|
2151
|
+
programId: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2152
|
+
});
|
|
2153
|
+
const createMintIx = (0, spl_token_1.createInitializeMint2Instruction)(mint.publicKey, 6, lpPool, null, spl_token_1.TOKEN_PROGRAM_ID);
|
|
2154
|
+
return [
|
|
2155
|
+
createMintAccountIx,
|
|
2156
|
+
createMintIx,
|
|
2157
|
+
this.program.instruction.initializeLpPool(lpPoolId, minMintFee, maxAum, maxSettleQuoteAmountPerMarket, whitelistMint !== null && whitelistMint !== void 0 ? whitelistMint : web3_js_1.PublicKey.default, {
|
|
2158
|
+
accounts: {
|
|
2159
|
+
admin: this.wallet.publicKey,
|
|
2160
|
+
lpPool,
|
|
2161
|
+
lpPoolTokenVault: (0, pda_1.getLpPoolTokenVaultPublicKey)(this.program.programId, lpPool),
|
|
2162
|
+
constituentCorrelations: (0, pda_1.getConstituentCorrelationsPublicKey)(this.program.programId, lpPool),
|
|
2163
|
+
ammConstituentMapping,
|
|
2164
|
+
constituentTargetBase,
|
|
2165
|
+
mint: mint.publicKey,
|
|
2166
|
+
state: await this.getStatePublicKey(),
|
|
2167
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2168
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
2169
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
2170
|
+
},
|
|
2171
|
+
signers: [mint],
|
|
2172
|
+
}),
|
|
2173
|
+
];
|
|
2174
|
+
}
|
|
2175
|
+
async initializeConstituent(lpPoolId, initializeConstituentParams) {
|
|
2176
|
+
const ixs = await this.getInitializeConstituentIx(lpPoolId, initializeConstituentParams);
|
|
2177
|
+
const tx = await this.buildTransaction(ixs);
|
|
2178
|
+
const { txSig } = await this.sendTransaction(tx, []);
|
|
2179
|
+
return txSig;
|
|
2180
|
+
}
|
|
2181
|
+
async getInitializeConstituentIx(lpPoolId, initializeConstituentParams) {
|
|
2182
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2183
|
+
const spotMarketIndex = initializeConstituentParams.spotMarketIndex;
|
|
2184
|
+
const constituentTargetBase = (0, pda_1.getConstituentTargetBasePublicKey)(this.program.programId, lpPool);
|
|
2185
|
+
const constituent = (0, pda_1.getConstituentPublicKey)(this.program.programId, lpPool, spotMarketIndex);
|
|
2186
|
+
const spotMarketAccount = this.getSpotMarketAccount(spotMarketIndex);
|
|
2187
|
+
return [
|
|
2188
|
+
this.program.instruction.initializeConstituent(spotMarketIndex, initializeConstituentParams.decimals, initializeConstituentParams.maxWeightDeviation, initializeConstituentParams.swapFeeMin, initializeConstituentParams.swapFeeMax, initializeConstituentParams.maxBorrowTokenAmount, initializeConstituentParams.oracleStalenessThreshold, initializeConstituentParams.costToTrade, initializeConstituentParams.constituentDerivativeIndex != null
|
|
2189
|
+
? initializeConstituentParams.constituentDerivativeIndex
|
|
2190
|
+
: null, initializeConstituentParams.constituentDerivativeDepegThreshold != null
|
|
2191
|
+
? initializeConstituentParams.constituentDerivativeDepegThreshold
|
|
2192
|
+
: numericConstants_1.ZERO, initializeConstituentParams.constituentDerivativeIndex != null
|
|
2193
|
+
? initializeConstituentParams.derivativeWeight
|
|
2194
|
+
: numericConstants_1.ZERO, initializeConstituentParams.volatility != null
|
|
2195
|
+
? initializeConstituentParams.volatility
|
|
2196
|
+
: 10, initializeConstituentParams.gammaExecution != null
|
|
2197
|
+
? initializeConstituentParams.gammaExecution
|
|
2198
|
+
: 2, initializeConstituentParams.gammaInventory != null
|
|
2199
|
+
? initializeConstituentParams.gammaInventory
|
|
2200
|
+
: 2, initializeConstituentParams.xi != null
|
|
2201
|
+
? initializeConstituentParams.xi
|
|
2202
|
+
: 2, initializeConstituentParams.constituentCorrelations, {
|
|
2203
|
+
accounts: {
|
|
2204
|
+
admin: this.wallet.publicKey,
|
|
2205
|
+
lpPool,
|
|
2206
|
+
constituentTargetBase,
|
|
2207
|
+
constituent,
|
|
2208
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
2209
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
2210
|
+
state: await this.getStatePublicKey(),
|
|
2211
|
+
spotMarketMint: spotMarketAccount.mint,
|
|
2212
|
+
constituentVault: (0, pda_1.getConstituentVaultPublicKey)(this.program.programId, lpPool, spotMarketIndex),
|
|
2213
|
+
constituentCorrelations: (0, pda_1.getConstituentCorrelationsPublicKey)(this.program.programId, lpPool),
|
|
2214
|
+
spotMarket: spotMarketAccount.pubkey,
|
|
2215
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
2216
|
+
},
|
|
2217
|
+
signers: [],
|
|
2218
|
+
}),
|
|
2219
|
+
];
|
|
2220
|
+
}
|
|
2221
|
+
async updateConstituentStatus(constituent, constituentStatus) {
|
|
2222
|
+
const updateConstituentStatusIx = await this.getUpdateConstituentStatusIx(constituent, constituentStatus);
|
|
2223
|
+
const tx = await this.buildTransaction(updateConstituentStatusIx);
|
|
2224
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2225
|
+
return txSig;
|
|
2226
|
+
}
|
|
2227
|
+
async getUpdateConstituentStatusIx(constituent, constituentStatus) {
|
|
2228
|
+
return await this.program.instruction.updateConstituentStatus(constituentStatus, {
|
|
2229
|
+
accounts: {
|
|
2230
|
+
constituent,
|
|
2231
|
+
admin: this.isSubscribed
|
|
2232
|
+
? this.getStateAccount().coldAdmin
|
|
2233
|
+
: this.wallet.publicKey,
|
|
2234
|
+
state: await this.getStatePublicKey(),
|
|
2235
|
+
},
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
async updateConstituentPausedOperations(constituent, pausedOperations) {
|
|
2239
|
+
const updateConstituentPausedOperationsIx = await this.getUpdateConstituentPausedOperationsIx(constituent, pausedOperations);
|
|
2240
|
+
const tx = await this.buildTransaction(updateConstituentPausedOperationsIx);
|
|
2241
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2242
|
+
return txSig;
|
|
2243
|
+
}
|
|
2244
|
+
async getUpdateConstituentPausedOperationsIx(constituent, pausedOperations) {
|
|
2245
|
+
return await this.program.instruction.updateConstituentPausedOperations(pausedOperations, {
|
|
2246
|
+
accounts: {
|
|
2247
|
+
constituent,
|
|
2248
|
+
admin: this.useHotWalletAdmin
|
|
2249
|
+
? this.wallet.publicKey
|
|
2250
|
+
: this.getStateAccount().coldAdmin,
|
|
2251
|
+
state: await this.getStatePublicKey(),
|
|
2252
|
+
},
|
|
2253
|
+
});
|
|
2254
|
+
}
|
|
2255
|
+
async updateConstituentParams(lpPoolId, constituentPublicKey, updateConstituentParams) {
|
|
2256
|
+
const ixs = await this.getUpdateConstituentParamsIx(lpPoolId, constituentPublicKey, updateConstituentParams);
|
|
2257
|
+
const tx = await this.buildTransaction(ixs);
|
|
2258
|
+
const { txSig } = await this.sendTransaction(tx, []);
|
|
2259
|
+
return txSig;
|
|
2260
|
+
}
|
|
2261
|
+
async getUpdateConstituentParamsIx(lpPoolId, constituentPublicKey, updateConstituentParams) {
|
|
2262
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2263
|
+
return [
|
|
2264
|
+
this.program.instruction.updateConstituentParams(Object.assign({
|
|
2265
|
+
maxWeightDeviation: null,
|
|
2266
|
+
swapFeeMin: null,
|
|
2267
|
+
swapFeeMax: null,
|
|
2268
|
+
maxBorrowTokenAmount: null,
|
|
2269
|
+
oracleStalenessThreshold: null,
|
|
2270
|
+
costToTradeBps: null,
|
|
2271
|
+
stablecoinWeight: null,
|
|
2272
|
+
derivativeWeight: null,
|
|
2273
|
+
constituentDerivativeIndex: null,
|
|
2274
|
+
volatility: null,
|
|
2275
|
+
gammaExecution: null,
|
|
2276
|
+
gammaInventory: null,
|
|
2277
|
+
xi: null,
|
|
2278
|
+
}, updateConstituentParams), {
|
|
2279
|
+
accounts: {
|
|
2280
|
+
admin: this.wallet.publicKey,
|
|
2281
|
+
constituent: constituentPublicKey,
|
|
2282
|
+
state: await this.getStatePublicKey(),
|
|
2283
|
+
lpPool,
|
|
2284
|
+
constituentTargetBase: (0, pda_1.getConstituentTargetBasePublicKey)(this.program.programId, lpPool),
|
|
2285
|
+
},
|
|
2286
|
+
signers: [],
|
|
2287
|
+
}),
|
|
2288
|
+
];
|
|
2289
|
+
}
|
|
2290
|
+
async updateLpPoolParams(lpPoolId, updateLpPoolParams) {
|
|
2291
|
+
const ixs = await this.getUpdateLpPoolParamsIx(lpPoolId, updateLpPoolParams);
|
|
2292
|
+
const tx = await this.buildTransaction(ixs);
|
|
2293
|
+
const { txSig } = await this.sendTransaction(tx, []);
|
|
2294
|
+
return txSig;
|
|
2295
|
+
}
|
|
2296
|
+
async getUpdateLpPoolParamsIx(lpPoolId, updateLpPoolParams) {
|
|
2297
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2298
|
+
return [
|
|
2299
|
+
this.program.instruction.updateLpPoolParams(Object.assign({
|
|
2300
|
+
maxSettleQuoteAmount: null,
|
|
2301
|
+
volatility: null,
|
|
2302
|
+
gammaExecution: null,
|
|
2303
|
+
xi: null,
|
|
2304
|
+
whitelistMint: null,
|
|
2305
|
+
maxAum: null,
|
|
2306
|
+
}, updateLpPoolParams), {
|
|
2307
|
+
accounts: {
|
|
2308
|
+
admin: this.wallet.publicKey,
|
|
2309
|
+
state: await this.getStatePublicKey(),
|
|
2310
|
+
lpPool,
|
|
2311
|
+
},
|
|
2312
|
+
signers: [],
|
|
2313
|
+
}),
|
|
2314
|
+
];
|
|
2315
|
+
}
|
|
2316
|
+
async addAmmConstituentMappingData(lpPoolId, addAmmConstituentMappingData) {
|
|
2317
|
+
const ixs = await this.getAddAmmConstituentMappingDataIx(lpPoolId, addAmmConstituentMappingData);
|
|
2318
|
+
const tx = await this.buildTransaction(ixs);
|
|
2319
|
+
const { txSig } = await this.sendTransaction(tx, []);
|
|
2320
|
+
return txSig;
|
|
2321
|
+
}
|
|
2322
|
+
async getAddAmmConstituentMappingDataIx(lpPoolId, addAmmConstituentMappingData) {
|
|
2323
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2324
|
+
const ammConstituentMapping = (0, pda_1.getAmmConstituentMappingPublicKey)(this.program.programId, lpPool);
|
|
2325
|
+
const constituentTargetBase = (0, pda_1.getConstituentTargetBasePublicKey)(this.program.programId, lpPool);
|
|
2326
|
+
return [
|
|
2327
|
+
this.program.instruction.addAmmConstituentMappingData(addAmmConstituentMappingData, {
|
|
2328
|
+
accounts: {
|
|
2329
|
+
admin: this.wallet.publicKey,
|
|
2330
|
+
lpPool,
|
|
2331
|
+
ammConstituentMapping,
|
|
2332
|
+
constituentTargetBase,
|
|
2333
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
2334
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
2335
|
+
state: await this.getStatePublicKey(),
|
|
2336
|
+
},
|
|
2337
|
+
}),
|
|
2338
|
+
];
|
|
2339
|
+
}
|
|
2340
|
+
async updateAmmConstituentMappingData(lpPoolId, addAmmConstituentMappingData) {
|
|
2341
|
+
const ixs = await this.getUpdateAmmConstituentMappingDataIx(lpPoolId, addAmmConstituentMappingData);
|
|
2342
|
+
const tx = await this.buildTransaction(ixs);
|
|
2343
|
+
const { txSig } = await this.sendTransaction(tx, []);
|
|
2344
|
+
return txSig;
|
|
2345
|
+
}
|
|
2346
|
+
async getUpdateAmmConstituentMappingDataIx(lpPoolId, addAmmConstituentMappingData) {
|
|
2347
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2348
|
+
const ammConstituentMapping = (0, pda_1.getAmmConstituentMappingPublicKey)(this.program.programId, lpPool);
|
|
2349
|
+
return [
|
|
2350
|
+
this.program.instruction.updateAmmConstituentMappingData(addAmmConstituentMappingData, {
|
|
2351
|
+
accounts: {
|
|
2352
|
+
admin: this.wallet.publicKey,
|
|
2353
|
+
lpPool,
|
|
2354
|
+
ammConstituentMapping,
|
|
2355
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
2356
|
+
state: await this.getStatePublicKey(),
|
|
2357
|
+
},
|
|
2358
|
+
}),
|
|
2359
|
+
];
|
|
2360
|
+
}
|
|
2361
|
+
async removeAmmConstituentMappingData(lpPoolId, perpMarketIndex, constituentIndex) {
|
|
2362
|
+
const ixs = await this.getRemoveAmmConstituentMappingDataIx(lpPoolId, perpMarketIndex, constituentIndex);
|
|
2363
|
+
const tx = await this.buildTransaction(ixs);
|
|
2364
|
+
const { txSig } = await this.sendTransaction(tx, []);
|
|
2365
|
+
return txSig;
|
|
2366
|
+
}
|
|
2367
|
+
async getRemoveAmmConstituentMappingDataIx(lpPoolId, perpMarketIndex, constituentIndex) {
|
|
2368
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2369
|
+
const ammConstituentMapping = (0, pda_1.getAmmConstituentMappingPublicKey)(this.program.programId, lpPool);
|
|
2370
|
+
return [
|
|
2371
|
+
this.program.instruction.removeAmmConstituentMappingData(perpMarketIndex, constituentIndex, {
|
|
2372
|
+
accounts: {
|
|
2373
|
+
admin: this.wallet.publicKey,
|
|
2374
|
+
lpPool,
|
|
2375
|
+
ammConstituentMapping,
|
|
2376
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
2377
|
+
state: await this.getStatePublicKey(),
|
|
2378
|
+
},
|
|
2379
|
+
}),
|
|
2380
|
+
];
|
|
2381
|
+
}
|
|
2382
|
+
async updateConstituentCorrelationData(lpPoolId, index1, index2, correlation) {
|
|
2383
|
+
const ixs = await this.getUpdateConstituentCorrelationDataIx(lpPoolId, index1, index2, correlation);
|
|
2384
|
+
const tx = await this.buildTransaction(ixs);
|
|
2385
|
+
const { txSig } = await this.sendTransaction(tx, []);
|
|
2386
|
+
return txSig;
|
|
2387
|
+
}
|
|
2388
|
+
async getUpdateConstituentCorrelationDataIx(lpPoolId, index1, index2, correlation) {
|
|
2389
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2390
|
+
return [
|
|
2391
|
+
this.program.instruction.updateConstituentCorrelationData(index1, index2, correlation, {
|
|
2392
|
+
accounts: {
|
|
2393
|
+
admin: this.wallet.publicKey,
|
|
2394
|
+
lpPool,
|
|
2395
|
+
constituentCorrelations: (0, pda_1.getConstituentCorrelationsPublicKey)(this.program.programId, lpPool),
|
|
2396
|
+
state: await this.getStatePublicKey(),
|
|
2397
|
+
},
|
|
2398
|
+
}),
|
|
2399
|
+
];
|
|
2400
|
+
}
|
|
2401
|
+
/**
|
|
2402
|
+
* Get the drift begin_swap and end_swap instructions
|
|
2403
|
+
*
|
|
2404
|
+
* @param outMarketIndex the market index of the token you're buying
|
|
2405
|
+
* @param inMarketIndex the market index of the token you're selling
|
|
2406
|
+
* @param amountIn the amount of the token to sell
|
|
2407
|
+
* @param inTokenAccount the token account to move the tokens being sold (admin signer ata for lp swap)
|
|
2408
|
+
* @param outTokenAccount the token account to receive the tokens being bought (admin signer ata for lp swap)
|
|
2409
|
+
* @param limitPrice the limit price of the swap
|
|
2410
|
+
* @param reduceOnly
|
|
2411
|
+
* @param userAccountPublicKey optional, specify a custom userAccountPublicKey to use instead of getting the current user account; can be helpful if the account is being created within the current tx
|
|
2412
|
+
*/
|
|
2413
|
+
async getSwapIx({ lpPoolId, outMarketIndex, inMarketIndex, amountIn, inTokenAccount, outTokenAccount, limitPrice, reduceOnly, userAccountPublicKey, }, lpSwap) {
|
|
2414
|
+
if (!lpSwap) {
|
|
2415
|
+
return super.getSwapIx({
|
|
2416
|
+
outMarketIndex,
|
|
2417
|
+
inMarketIndex,
|
|
2418
|
+
amountIn,
|
|
2419
|
+
inTokenAccount,
|
|
2420
|
+
outTokenAccount,
|
|
2421
|
+
limitPrice,
|
|
2422
|
+
reduceOnly,
|
|
2423
|
+
userAccountPublicKey,
|
|
2424
|
+
});
|
|
2425
|
+
}
|
|
2426
|
+
const outSpotMarket = this.getSpotMarketAccount(outMarketIndex);
|
|
2427
|
+
const inSpotMarket = this.getSpotMarketAccount(inMarketIndex);
|
|
2428
|
+
const outTokenProgram = this.getTokenProgramForSpotMarket(outSpotMarket);
|
|
2429
|
+
const inTokenProgram = this.getTokenProgramForSpotMarket(inSpotMarket);
|
|
2430
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2431
|
+
const outConstituent = (0, pda_1.getConstituentPublicKey)(this.program.programId, lpPool, outMarketIndex);
|
|
2432
|
+
const inConstituent = (0, pda_1.getConstituentPublicKey)(this.program.programId, lpPool, inMarketIndex);
|
|
2433
|
+
const outConstituentTokenAccount = (0, pda_1.getConstituentVaultPublicKey)(this.program.programId, lpPool, outMarketIndex);
|
|
2434
|
+
const inConstituentTokenAccount = (0, pda_1.getConstituentVaultPublicKey)(this.program.programId, lpPool, inMarketIndex);
|
|
2435
|
+
const beginSwapIx = this.program.instruction.beginLpSwap(inMarketIndex, outMarketIndex, amountIn, {
|
|
2436
|
+
accounts: {
|
|
2437
|
+
state: await this.getStatePublicKey(),
|
|
2438
|
+
admin: this.wallet.publicKey,
|
|
2439
|
+
signerOutTokenAccount: outTokenAccount,
|
|
2440
|
+
signerInTokenAccount: inTokenAccount,
|
|
2441
|
+
constituentOutTokenAccount: outConstituentTokenAccount,
|
|
2442
|
+
constituentInTokenAccount: inConstituentTokenAccount,
|
|
2443
|
+
outConstituent,
|
|
2444
|
+
inConstituent,
|
|
2445
|
+
lpPool,
|
|
2446
|
+
instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2447
|
+
tokenProgram: inTokenProgram,
|
|
2448
|
+
},
|
|
2449
|
+
});
|
|
2450
|
+
const remainingAccounts = [];
|
|
2451
|
+
remainingAccounts.push({
|
|
2452
|
+
pubkey: outTokenProgram,
|
|
2453
|
+
isWritable: false,
|
|
2454
|
+
isSigner: false,
|
|
2455
|
+
});
|
|
2456
|
+
const endSwapIx = this.program.instruction.endLpSwap(inMarketIndex, outMarketIndex, {
|
|
2457
|
+
accounts: {
|
|
2458
|
+
state: await this.getStatePublicKey(),
|
|
2459
|
+
admin: this.wallet.publicKey,
|
|
2460
|
+
signerOutTokenAccount: outTokenAccount,
|
|
2461
|
+
signerInTokenAccount: inTokenAccount,
|
|
2462
|
+
constituentOutTokenAccount: outConstituentTokenAccount,
|
|
2463
|
+
constituentInTokenAccount: inConstituentTokenAccount,
|
|
2464
|
+
outConstituent,
|
|
2465
|
+
inConstituent,
|
|
2466
|
+
lpPool,
|
|
2467
|
+
tokenProgram: inTokenProgram,
|
|
2468
|
+
instructions: anchor.web3.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2469
|
+
},
|
|
2470
|
+
remainingAccounts,
|
|
2471
|
+
});
|
|
2472
|
+
return { beginSwapIx, endSwapIx };
|
|
2473
|
+
}
|
|
2474
|
+
async getLpJupiterSwapIxV6({ jupiterClient, outMarketIndex, inMarketIndex, amount, slippageBps, swapMode, onlyDirectRoutes, quote, lpPoolId, }) {
|
|
2475
|
+
const outMarket = this.getSpotMarketAccount(outMarketIndex);
|
|
2476
|
+
const inMarket = this.getSpotMarketAccount(inMarketIndex);
|
|
2477
|
+
if (!quote) {
|
|
2478
|
+
const fetchedQuote = await jupiterClient.getQuote({
|
|
2479
|
+
inputMint: inMarket.mint,
|
|
2480
|
+
outputMint: outMarket.mint,
|
|
2481
|
+
amount,
|
|
2482
|
+
slippageBps,
|
|
2483
|
+
swapMode,
|
|
2484
|
+
onlyDirectRoutes,
|
|
2485
|
+
});
|
|
2486
|
+
quote = fetchedQuote;
|
|
2487
|
+
}
|
|
2488
|
+
if (!quote) {
|
|
2489
|
+
throw new Error('Could not fetch swap quote. Please try again.');
|
|
2490
|
+
}
|
|
2491
|
+
const isExactOut = swapMode === 'ExactOut' || quote.swapMode === 'ExactOut';
|
|
2492
|
+
const amountIn = new anchor_1.BN(quote.inAmount);
|
|
2493
|
+
const exactOutBufferedAmountIn = amountIn.muln(1001).divn(1000); // Add 10bp buffer
|
|
2494
|
+
const transaction = await jupiterClient.getSwap({
|
|
2495
|
+
quote,
|
|
2496
|
+
userPublicKey: this.provider.wallet.publicKey,
|
|
2497
|
+
slippageBps,
|
|
2498
|
+
});
|
|
2499
|
+
const { transactionMessage, lookupTables } = await jupiterClient.getTransactionMessageAndLookupTables({
|
|
2500
|
+
transaction,
|
|
2501
|
+
});
|
|
2502
|
+
const jupiterInstructions = jupiterClient.getJupiterInstructions({
|
|
2503
|
+
transactionMessage,
|
|
2504
|
+
inputMint: inMarket.mint,
|
|
2505
|
+
outputMint: outMarket.mint,
|
|
2506
|
+
});
|
|
2507
|
+
const preInstructions = [];
|
|
2508
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(outMarket);
|
|
2509
|
+
const outAssociatedTokenAccount = await this.getAssociatedTokenAccount(outMarket.marketIndex, false, tokenProgram);
|
|
2510
|
+
const outAccountInfo = await this.connection.getAccountInfo(outAssociatedTokenAccount);
|
|
2511
|
+
if (!outAccountInfo) {
|
|
2512
|
+
preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(outAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, outMarket.mint, tokenProgram));
|
|
2513
|
+
}
|
|
2514
|
+
const inTokenProgram = this.getTokenProgramForSpotMarket(inMarket);
|
|
2515
|
+
const inAssociatedTokenAccount = await this.getAssociatedTokenAccount(inMarket.marketIndex, false, inTokenProgram);
|
|
2516
|
+
const inAccountInfo = await this.connection.getAccountInfo(inAssociatedTokenAccount);
|
|
2517
|
+
if (!inAccountInfo) {
|
|
2518
|
+
preInstructions.push(this.createAssociatedTokenAccountIdempotentInstruction(inAssociatedTokenAccount, this.provider.wallet.publicKey, this.provider.wallet.publicKey, inMarket.mint, tokenProgram));
|
|
2519
|
+
}
|
|
2520
|
+
const { beginSwapIx, endSwapIx } = await this.getSwapIx({
|
|
2521
|
+
lpPoolId,
|
|
2522
|
+
outMarketIndex,
|
|
2523
|
+
inMarketIndex,
|
|
2524
|
+
amountIn: isExactOut ? exactOutBufferedAmountIn : amountIn,
|
|
2525
|
+
inTokenAccount: inAssociatedTokenAccount,
|
|
2526
|
+
outTokenAccount: outAssociatedTokenAccount,
|
|
2527
|
+
}, true);
|
|
2528
|
+
const ixs = [
|
|
2529
|
+
...preInstructions,
|
|
2530
|
+
beginSwapIx,
|
|
2531
|
+
...jupiterInstructions,
|
|
2532
|
+
endSwapIx,
|
|
2533
|
+
];
|
|
2534
|
+
return { ixs, lookupTables };
|
|
2535
|
+
}
|
|
2536
|
+
async getDevnetLpSwapIxs(amountIn, amountOut, externalUserAuthority, externalUserInTokenAccount, externalUserOutTokenAccount, inSpotMarketIndex, outSpotMarketIndex) {
|
|
2537
|
+
const inSpotMarketAccount = this.getSpotMarketAccount(inSpotMarketIndex);
|
|
2538
|
+
const outSpotMarketAccount = this.getSpotMarketAccount(outSpotMarketIndex);
|
|
2539
|
+
const outTokenAccount = await this.getAssociatedTokenAccount(outSpotMarketAccount.marketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(outSpotMarketAccount));
|
|
2540
|
+
const inTokenAccount = await this.getAssociatedTokenAccount(inSpotMarketAccount.marketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(inSpotMarketAccount));
|
|
2541
|
+
const externalCreateInTokenAccountIx = this.createAssociatedTokenAccountIdempotentInstruction(externalUserInTokenAccount, this.wallet.publicKey, externalUserAuthority, this.getSpotMarketAccount(inSpotMarketIndex).mint);
|
|
2542
|
+
const externalCreateOutTokenAccountIx = this.createAssociatedTokenAccountIdempotentInstruction(externalUserOutTokenAccount, this.wallet.publicKey, externalUserAuthority, this.getSpotMarketAccount(outSpotMarketIndex).mint);
|
|
2543
|
+
const outTransferIx = (0, spl_token_1.createTransferCheckedInstruction)(externalUserOutTokenAccount, outSpotMarketAccount.mint, outTokenAccount, externalUserAuthority, amountOut.toNumber(), outSpotMarketAccount.decimals, undefined, (0, pda_1.getTokenProgramForSpotMarket)(outSpotMarketAccount));
|
|
2544
|
+
const inTransferIx = (0, spl_token_1.createTransferCheckedInstruction)(inTokenAccount, inSpotMarketAccount.mint, externalUserInTokenAccount, this.wallet.publicKey, amountIn.toNumber(), inSpotMarketAccount.decimals, undefined, (0, pda_1.getTokenProgramForSpotMarket)(inSpotMarketAccount));
|
|
2545
|
+
const ixs = [
|
|
2546
|
+
externalCreateInTokenAccountIx,
|
|
2547
|
+
externalCreateOutTokenAccountIx,
|
|
2548
|
+
outTransferIx,
|
|
2549
|
+
inTransferIx,
|
|
2550
|
+
];
|
|
2551
|
+
return ixs;
|
|
2552
|
+
}
|
|
2553
|
+
async getAllDevnetLpSwapIxs(lpPoolId, inMarketIndex, outMarketIndex, inAmount, minOutAmount, externalUserAuthority) {
|
|
2554
|
+
const { beginSwapIx, endSwapIx } = await this.getSwapIx({
|
|
2555
|
+
lpPoolId,
|
|
2556
|
+
inMarketIndex,
|
|
2557
|
+
outMarketIndex,
|
|
2558
|
+
amountIn: inAmount,
|
|
2559
|
+
inTokenAccount: await this.getAssociatedTokenAccount(inMarketIndex, false),
|
|
2560
|
+
outTokenAccount: await this.getAssociatedTokenAccount(outMarketIndex, false),
|
|
2561
|
+
}, true);
|
|
2562
|
+
const devnetLpSwapIxs = await this.getDevnetLpSwapIxs(inAmount, minOutAmount, externalUserAuthority, await this.getAssociatedTokenAccount(inMarketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(this.getSpotMarketAccount(inMarketIndex)), externalUserAuthority), await this.getAssociatedTokenAccount(outMarketIndex, false, (0, pda_1.getTokenProgramForSpotMarket)(this.getSpotMarketAccount(outMarketIndex)), externalUserAuthority), inMarketIndex, outMarketIndex);
|
|
2563
|
+
return [
|
|
2564
|
+
beginSwapIx,
|
|
2565
|
+
...devnetLpSwapIxs,
|
|
2566
|
+
endSwapIx,
|
|
2567
|
+
];
|
|
2568
|
+
}
|
|
2569
|
+
async depositWithdrawToProgramVault(lpPoolId, depositMarketIndex, borrowMarketIndex, amountToDeposit, amountToBorrow) {
|
|
2570
|
+
const { depositIx, withdrawIx } = await this.getDepositWithdrawToProgramVaultIxs(lpPoolId, depositMarketIndex, borrowMarketIndex, amountToDeposit, amountToBorrow);
|
|
2571
|
+
const tx = await this.buildTransaction([depositIx, withdrawIx]);
|
|
2572
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2573
|
+
return txSig;
|
|
2574
|
+
}
|
|
2575
|
+
async getDepositWithdrawToProgramVaultIxs(lpPoolId, depositMarketIndex, borrowMarketIndex, amountToDeposit, amountToBorrow) {
|
|
2576
|
+
const lpPool = (0, pda_1.getLpPoolPublicKey)(this.program.programId, lpPoolId);
|
|
2577
|
+
const depositSpotMarket = this.getSpotMarketAccount(depositMarketIndex);
|
|
2578
|
+
const withdrawSpotMarket = this.getSpotMarketAccount(borrowMarketIndex);
|
|
2579
|
+
const depositTokenProgram = this.getTokenProgramForSpotMarket(depositSpotMarket);
|
|
2580
|
+
const withdrawTokenProgram = this.getTokenProgramForSpotMarket(withdrawSpotMarket);
|
|
2581
|
+
const depositConstituent = (0, pda_1.getConstituentPublicKey)(this.program.programId, lpPool, depositMarketIndex);
|
|
2582
|
+
const withdrawConstituent = (0, pda_1.getConstituentPublicKey)(this.program.programId, lpPool, borrowMarketIndex);
|
|
2583
|
+
const depositConstituentTokenAccount = (0, pda_1.getConstituentVaultPublicKey)(this.program.programId, lpPool, depositMarketIndex);
|
|
2584
|
+
const withdrawConstituentTokenAccount = (0, pda_1.getConstituentVaultPublicKey)(this.program.programId, lpPool, borrowMarketIndex);
|
|
2585
|
+
const depositIx = this.program.instruction.depositToProgramVault(amountToDeposit, {
|
|
2586
|
+
accounts: {
|
|
2587
|
+
state: await this.getStatePublicKey(),
|
|
2588
|
+
admin: this.wallet.publicKey,
|
|
2589
|
+
constituent: depositConstituent,
|
|
2590
|
+
constituentTokenAccount: depositConstituentTokenAccount,
|
|
2591
|
+
spotMarket: depositSpotMarket.pubkey,
|
|
2592
|
+
spotMarketVault: depositSpotMarket.vault,
|
|
2593
|
+
tokenProgram: depositTokenProgram,
|
|
2594
|
+
mint: depositSpotMarket.mint,
|
|
2595
|
+
oracle: depositSpotMarket.oracle,
|
|
2596
|
+
},
|
|
2597
|
+
});
|
|
2598
|
+
const withdrawIx = this.program.instruction.withdrawFromProgramVault(amountToBorrow, {
|
|
2599
|
+
accounts: {
|
|
2600
|
+
state: await this.getStatePublicKey(),
|
|
2601
|
+
admin: this.wallet.publicKey,
|
|
2602
|
+
constituent: withdrawConstituent,
|
|
2603
|
+
constituentTokenAccount: withdrawConstituentTokenAccount,
|
|
2604
|
+
spotMarket: withdrawSpotMarket.pubkey,
|
|
2605
|
+
spotMarketVault: withdrawSpotMarket.vault,
|
|
2606
|
+
tokenProgram: withdrawTokenProgram,
|
|
2607
|
+
mint: withdrawSpotMarket.mint,
|
|
2608
|
+
driftSigner: (0, pda_1.getVelocitySignerPublicKey)(this.program.programId),
|
|
2609
|
+
oracle: withdrawSpotMarket.oracle,
|
|
2610
|
+
},
|
|
2611
|
+
});
|
|
2612
|
+
return { depositIx, withdrawIx };
|
|
2613
|
+
}
|
|
2614
|
+
async depositToProgramVault(lpPoolId, depositMarketIndex, amountToDeposit) {
|
|
2615
|
+
const depositIx = await this.getDepositToProgramVaultIx(lpPoolId, depositMarketIndex, amountToDeposit);
|
|
2616
|
+
const tx = await this.buildTransaction([depositIx]);
|
|
2617
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2618
|
+
return txSig;
|
|
2619
|
+
}
|
|
2620
|
+
async withdrawFromProgramVault(lpPoolId, borrowMarketIndex, amountToWithdraw) {
|
|
2621
|
+
const withdrawIx = await this.getWithdrawFromProgramVaultIx(lpPoolId, borrowMarketIndex, amountToWithdraw);
|
|
2622
|
+
const tx = await this.buildTransaction([withdrawIx]);
|
|
2623
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2624
|
+
return txSig;
|
|
2625
|
+
}
|
|
2626
|
+
async getDepositToProgramVaultIx(lpPoolId, depositMarketIndex, amountToDeposit) {
|
|
2627
|
+
const { depositIx } = await this.getDepositWithdrawToProgramVaultIxs(lpPoolId, depositMarketIndex, depositMarketIndex, amountToDeposit, new anchor_1.BN(0));
|
|
2628
|
+
return depositIx;
|
|
2629
|
+
}
|
|
2630
|
+
async getWithdrawFromProgramVaultIx(lpPoolId, borrowMarketIndex, amountToWithdraw) {
|
|
2631
|
+
const { withdrawIx } = await this.getDepositWithdrawToProgramVaultIxs(lpPoolId, borrowMarketIndex, borrowMarketIndex, new anchor_1.BN(0), amountToWithdraw);
|
|
2632
|
+
return withdrawIx;
|
|
2633
|
+
}
|
|
2634
|
+
async updatePerpMarketLpPoolFeeTransferScalar(marketIndex, lpFeeTransferScalar, lpExchangeFeeExcluscionScalar) {
|
|
2635
|
+
const ix = await this.getUpdatePerpMarketLpPoolFeeTransferScalarIx(marketIndex, lpFeeTransferScalar, lpExchangeFeeExcluscionScalar);
|
|
2636
|
+
const tx = await this.buildTransaction(ix);
|
|
2637
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2638
|
+
return txSig;
|
|
2639
|
+
}
|
|
2640
|
+
async getUpdatePerpMarketLpPoolFeeTransferScalarIx(marketIndex, lpFeeTransferScalar, lpExchangeFeeExcluscionScalar) {
|
|
2641
|
+
return this.program.instruction.updatePerpMarketLpPoolFeeTransferScalar(lpFeeTransferScalar !== null && lpFeeTransferScalar !== void 0 ? lpFeeTransferScalar : null, lpExchangeFeeExcluscionScalar !== null && lpExchangeFeeExcluscionScalar !== void 0 ? lpExchangeFeeExcluscionScalar : null, {
|
|
2642
|
+
accounts: {
|
|
2643
|
+
admin: this.useHotWalletAdmin
|
|
2644
|
+
? this.wallet.publicKey
|
|
2645
|
+
: this.getStateAccount().coldAdmin,
|
|
2646
|
+
state: await this.getStatePublicKey(),
|
|
2647
|
+
perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
2648
|
+
},
|
|
2649
|
+
});
|
|
2650
|
+
}
|
|
2651
|
+
async updatePerpMarketLpPoolPausedOperations(marketIndex, pausedOperations) {
|
|
2652
|
+
const ix = await this.getUpdatePerpMarketLpPoolPausedOperationsIx(marketIndex, pausedOperations);
|
|
2653
|
+
const tx = await this.buildTransaction(ix);
|
|
2654
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2655
|
+
return txSig;
|
|
2656
|
+
}
|
|
2657
|
+
async getUpdatePerpMarketLpPoolPausedOperationsIx(marketIndex, pausedOperations) {
|
|
2658
|
+
return this.program.instruction.updatePerpMarketLpPoolPausedOperations(pausedOperations, {
|
|
2659
|
+
accounts: {
|
|
2660
|
+
admin: this.useHotWalletAdmin
|
|
2661
|
+
? this.wallet.publicKey
|
|
2662
|
+
: this.getStateAccount().coldAdmin,
|
|
2663
|
+
state: await this.getStatePublicKey(),
|
|
2664
|
+
perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
2665
|
+
},
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
async mintLpWhitelistToken(lpPool, authority) {
|
|
2669
|
+
const ix = await this.getMintLpWhitelistTokenIx(lpPool, authority);
|
|
2670
|
+
const tx = await this.buildTransaction(ix);
|
|
2671
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2672
|
+
return txSig;
|
|
2673
|
+
}
|
|
2674
|
+
async getMintLpWhitelistTokenIx(lpPool, authority) {
|
|
2675
|
+
const mintAmount = 1000;
|
|
2676
|
+
const associatedTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(lpPool.whitelistMint, authority, false);
|
|
2677
|
+
const ixs = [];
|
|
2678
|
+
const createInstruction = this.createAssociatedTokenAccountIdempotentInstruction(associatedTokenAccount, this.wallet.publicKey, authority, lpPool.whitelistMint);
|
|
2679
|
+
ixs.push(createInstruction);
|
|
2680
|
+
const mintToInstruction = (0, spl_token_1.createMintToInstruction)(lpPool.whitelistMint, associatedTokenAccount, this.wallet.publicKey, mintAmount, [], spl_token_1.TOKEN_PROGRAM_ID);
|
|
2681
|
+
ixs.push(mintToInstruction);
|
|
2682
|
+
return ixs;
|
|
2683
|
+
}
|
|
2684
|
+
async updatePerpMarketConfig(marketIndex, marketConfig) {
|
|
2685
|
+
const ix = await this.getUpdatePerpMarketConfigIx(marketIndex, marketConfig);
|
|
2686
|
+
const tx = await this.buildTransaction(ix);
|
|
2687
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2688
|
+
return txSig;
|
|
2689
|
+
}
|
|
2690
|
+
async getUpdatePerpMarketConfigIx(marketIndex, marketConfig) {
|
|
2691
|
+
return this.program.instruction.updatePerpMarketConfig(marketConfig, {
|
|
2692
|
+
accounts: {
|
|
2693
|
+
admin: this.useHotWalletAdmin
|
|
2694
|
+
? this.wallet.publicKey
|
|
2695
|
+
: this.getStateAccount().coldAdmin,
|
|
2696
|
+
state: await this.getStatePublicKey(),
|
|
2697
|
+
perpMarket: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
2698
|
+
},
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2701
|
+
async transferFeeAndPnlPool(perpMarketIndexWithFeePool, perpMarketIndexWithPnlPool, amount, direction) {
|
|
2702
|
+
const transferFeeAndPnlPoolIx = await this.getTransferFeeAndPnlPoolIx(perpMarketIndexWithFeePool, perpMarketIndexWithPnlPool, amount, direction);
|
|
2703
|
+
const tx = await this.buildTransaction(transferFeeAndPnlPoolIx);
|
|
2704
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2705
|
+
return txSig;
|
|
2706
|
+
}
|
|
2707
|
+
async getTransferFeeAndPnlPoolIx(perpMarketIndexWithFeePool, perpMarketIndexWithPnlPool, amount, direction) {
|
|
2708
|
+
return await this.program.instruction.transferFeeAndPnlPool(amount, direction, {
|
|
2709
|
+
accounts: {
|
|
2710
|
+
admin: this.isSubscribed
|
|
2711
|
+
? this.getStateAccount().coldAdmin
|
|
2712
|
+
: this.wallet.publicKey,
|
|
2713
|
+
state: await this.getStatePublicKey(),
|
|
2714
|
+
perpMarketWithFeePool: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndexWithFeePool),
|
|
2715
|
+
perpMarketWithPnlPool: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndexWithPnlPool),
|
|
2716
|
+
spotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
2717
|
+
spotMarketVault: this.getQuoteSpotMarketAccount().vault,
|
|
2718
|
+
},
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
async updateSpecialUserStatus(userAccountPublicKey, status, txParams) {
|
|
2722
|
+
const ix = await this.getUpdateSpecialUserStatusIx(userAccountPublicKey, status);
|
|
2723
|
+
const tx = await this.buildTransaction(ix, txParams);
|
|
2724
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2725
|
+
return txSig;
|
|
2726
|
+
}
|
|
2727
|
+
async getUpdateSpecialUserStatusIx(userAccountPublicKey, status) {
|
|
2728
|
+
return this.program.instruction.updateSpecialUserStatus(status, {
|
|
2729
|
+
accounts: {
|
|
2730
|
+
admin: this.useHotWalletAdmin
|
|
2731
|
+
? this.wallet.publicKey
|
|
2732
|
+
: this.getStateAccount().coldAdmin,
|
|
2733
|
+
state: await this.getStatePublicKey(),
|
|
2734
|
+
user: userAccountPublicKey,
|
|
2735
|
+
},
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
// ----- Tiered admin authority -----
|
|
2739
|
+
//
|
|
2740
|
+
// `state.coldAdmin` is the root. `state.warmAdmin` is rotated by cold; each
|
|
2741
|
+
// `state.hot*` field is rotated by warm (or cold). COLD ⊇ WARM ⊇ HOT(role).
|
|
2742
|
+
// `handleInitialize` seeds `coldAdmin = warmAdmin = signer`; there is no
|
|
2743
|
+
// separate "initialize admin authority config" ix.
|
|
2744
|
+
async updateWarmAdmin(newWarmAdmin) {
|
|
2745
|
+
const ix = await this.getUpdateWarmAdminIx(newWarmAdmin);
|
|
2746
|
+
const tx = await this.buildTransaction(ix);
|
|
2747
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2748
|
+
return txSig;
|
|
2749
|
+
}
|
|
2750
|
+
async getUpdateWarmAdminIx(newWarmAdmin) {
|
|
2751
|
+
return this.program.instruction.updateWarmAdmin(newWarmAdmin, {
|
|
2752
|
+
accounts: {
|
|
2753
|
+
state: await this.getStatePublicKey(),
|
|
2754
|
+
admin: this.isSubscribed
|
|
2755
|
+
? this.getStateAccount().coldAdmin
|
|
2756
|
+
: this.wallet.publicKey,
|
|
2757
|
+
},
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2760
|
+
async updateHotAdmin(role, newPubkey) {
|
|
2761
|
+
const ix = await this.getUpdateHotAdminIx(role, newPubkey);
|
|
2762
|
+
const tx = await this.buildTransaction(ix);
|
|
2763
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2764
|
+
return txSig;
|
|
2765
|
+
}
|
|
2766
|
+
async getUpdateHotAdminIx(role, newPubkey) {
|
|
2767
|
+
return this.program.instruction.updateHotAdmin(encodeHotRole(role), newPubkey, {
|
|
2768
|
+
accounts: {
|
|
2769
|
+
state: await this.getStatePublicKey(),
|
|
2770
|
+
admin: this.wallet.publicKey,
|
|
2771
|
+
},
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
exports.AdminClient = AdminClient;
|
|
2776
|
+
/**
|
|
2777
|
+
* Hot-admin role identifier. Each role is a separate purpose-specific signer key
|
|
2778
|
+
* stored on the `AdminAuthorityConfig` PDA. Compromise of one role's key only
|
|
2779
|
+
* enables that role's instructions.
|
|
2780
|
+
*/
|
|
2781
|
+
var HotRole;
|
|
2782
|
+
(function (HotRole) {
|
|
2783
|
+
HotRole["AmmCrank"] = "ammCrank";
|
|
2784
|
+
HotRole["LpCache"] = "lpCache";
|
|
2785
|
+
HotRole["LpSwap"] = "lpSwap";
|
|
2786
|
+
HotRole["LpSettle"] = "lpSettle";
|
|
2787
|
+
HotRole["IfRebalance"] = "ifRebalance";
|
|
2788
|
+
HotRole["FeatureFlag"] = "featureFlag";
|
|
2789
|
+
HotRole["Fuel"] = "fuel";
|
|
2790
|
+
HotRole["UserFlag"] = "userFlag";
|
|
2791
|
+
HotRole["VaultDeposit"] = "vaultDeposit";
|
|
2792
|
+
HotRole["MmOracleCrank"] = "mmOracleCrank";
|
|
2793
|
+
HotRole["AmmSpreadAdjust"] = "ammSpreadAdjust";
|
|
2794
|
+
})(HotRole || (exports.HotRole = HotRole = {}));
|
|
2795
|
+
/** Anchor encodes Rust enums as `{ <variant>: {} }`. */
|
|
2796
|
+
function encodeHotRole(role) {
|
|
2797
|
+
return { [role]: {} };
|
|
2798
|
+
}
|