@drift-labs/sdk-browser 2.104.0-beta.21
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/README.md +276 -0
- package/VERSION +1 -0
- package/bun.lockb +0 -0
- package/get_events.ts +47 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.d.ts +27 -0
- package/lib/browser/accounts/basicUserAccountSubscriber.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/fetch.d.ts +6 -0
- package/lib/browser/accounts/fetch.js +30 -0
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +16 -0
- package/lib/browser/accounts/grpcAccountSubscriber.js +154 -0
- package/lib/browser/accounts/grpcDriftClientAccountSubscriber.d.ts +12 -0
- package/lib/browser/accounts/grpcDriftClientAccountSubscriber.js +98 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +30 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +171 -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/oneShotUserAccountSubscriber.d.ts +18 -0
- package/lib/browser/accounts/oneShotUserAccountSubscriber.js +48 -0
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.d.ts +69 -0
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.js +418 -0
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +29 -0
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +111 -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/testBulkAccountLoader.d.ts +4 -0
- package/lib/browser/accounts/testBulkAccountLoader.js +45 -0
- package/lib/browser/accounts/types.d.ts +168 -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 +149 -0
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +66 -0
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.js +358 -0
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +23 -0
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +69 -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 +32 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.js +120 -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/addresses/marketAddresses.d.ts +2 -0
- package/lib/browser/addresses/marketAddresses.js +15 -0
- package/lib/browser/addresses/pda.d.ts +32 -0
- package/lib/browser/addresses/pda.js +211 -0
- package/lib/browser/adminClient.d.ts +206 -0
- package/lib/browser/adminClient.js +1858 -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 +75 -0
- package/lib/browser/bankrun/bankrunConnection.js +332 -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 +60 -0
- package/lib/browser/config.js +130 -0
- package/lib/browser/constants/numericConstants.d.ts +71 -0
- package/lib/browser/constants/numericConstants.js +75 -0
- package/lib/browser/constants/perpMarkets.d.ts +19 -0
- package/lib/browser/constants/perpMarkets.js +997 -0
- package/lib/browser/constants/spotMarkets.d.ts +24 -0
- package/lib/browser/constants/spotMarkets.js +470 -0
- package/lib/browser/constants/txConstants.d.ts +1 -0
- package/lib/browser/constants/txConstants.js +4 -0
- package/lib/browser/decode/phoenix.d.ts +7 -0
- package/lib/browser/decode/phoenix.js +159 -0
- package/lib/browser/decode/user.d.ts +4 -0
- package/lib/browser/decode/user.js +339 -0
- package/lib/browser/dlob/DLOB.d.ts +186 -0
- package/lib/browser/dlob/DLOB.js +1039 -0
- package/lib/browser/dlob/DLOBNode.d.ts +68 -0
- package/lib/browser/dlob/DLOBNode.js +100 -0
- package/lib/browser/dlob/DLOBSubscriber.d.ts +54 -0
- package/lib/browser/dlob/DLOBSubscriber.js +139 -0
- package/lib/browser/dlob/NodeList.d.ts +25 -0
- package/lib/browser/dlob/NodeList.js +126 -0
- package/lib/browser/dlob/orderBookLevels.d.ts +72 -0
- package/lib/browser/dlob/orderBookLevels.js +438 -0
- package/lib/browser/dlob/types.d.ts +18 -0
- package/lib/browser/dlob/types.js +2 -0
- package/lib/browser/driftClient.d.ts +861 -0
- package/lib/browser/driftClient.js +4768 -0
- package/lib/browser/driftClientConfig.d.ts +49 -0
- package/lib/browser/driftClientConfig.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 +46 -0
- package/lib/browser/events/eventSubscriber.js +223 -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 +6 -0
- package/lib/browser/events/parse.js +106 -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 +79 -0
- package/lib/browser/events/types.js +32 -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 +457 -0
- package/lib/browser/factory/oracleClient.d.ts +5 -0
- package/lib/browser/factory/oracleClient.js +56 -0
- package/lib/browser/idl/drift.json +14440 -0
- package/lib/browser/idl/openbook.json +3854 -0
- package/lib/browser/idl/pyth_solana_receiver.json +628 -0
- package/lib/browser/idl/switchboard.json +8354 -0
- package/lib/browser/idl/switchboard_on_demand_30.json +4546 -0
- package/lib/browser/idl/token_faucet.json +142 -0
- package/lib/browser/index.d.ts +125 -0
- package/lib/browser/index.js +147 -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 +302 -0
- package/lib/browser/jupiter/jupiterClient.js +178 -0
- package/lib/browser/keypair.d.ts +2 -0
- package/lib/browser/keypair.js +28 -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 +626 -0
- package/lib/browser/math/auction.d.ts +23 -0
- package/lib/browser/math/auction.js +130 -0
- package/lib/browser/math/bankruptcy.d.ts +2 -0
- package/lib/browser/math/bankruptcy.js +31 -0
- package/lib/browser/math/conversion.d.ts +2 -0
- package/lib/browser/math/conversion.js +11 -0
- package/lib/browser/math/exchangeStatus.d.ts +6 -0
- package/lib/browser/math/exchangeStatus.js +77 -0
- package/lib/browser/math/fuel.d.ts +6 -0
- package/lib/browser/math/fuel.js +55 -0
- package/lib/browser/math/funding.d.ts +34 -0
- package/lib/browser/math/funding.js +209 -0
- package/lib/browser/math/insurance.d.ts +7 -0
- package/lib/browser/math/insurance.js +73 -0
- package/lib/browser/math/margin.d.ts +39 -0
- package/lib/browser/math/margin.js +184 -0
- package/lib/browser/math/market.d.ts +39 -0
- package/lib/browser/math/market.js +163 -0
- package/lib/browser/math/oracles.d.ts +14 -0
- package/lib/browser/math/oracles.js +134 -0
- package/lib/browser/math/orders.d.ts +23 -0
- package/lib/browser/math/orders.js +216 -0
- package/lib/browser/math/position.d.ts +70 -0
- package/lib/browser/math/position.js +225 -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 +83 -0
- package/lib/browser/math/spotBalance.js +373 -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 +78 -0
- package/lib/browser/math/state.d.ts +5 -0
- package/lib/browser/math/state.js +30 -0
- package/lib/browser/math/superStake.d.ts +167 -0
- package/lib/browser/math/superStake.js +306 -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 +117 -0
- package/lib/browser/math/trade.js +637 -0
- package/lib/browser/math/userStatus.d.ts +2 -0
- package/lib/browser/math/userStatus.js +8 -0
- package/lib/browser/math/utils.d.ts +23 -0
- package/lib/browser/math/utils.js +112 -0
- package/lib/browser/memcmp.d.ts +11 -0
- package/lib/browser/memcmp.js +99 -0
- package/lib/browser/openbook/openbookV2FulfillmentConfigMap.d.ts +10 -0
- package/lib/browser/openbook/openbookV2FulfillmentConfigMap.js +17 -0
- package/lib/browser/openbook/openbookV2Subscriber.d.ts +36 -0
- package/lib/browser/openbook/openbookV2Subscriber.js +104 -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 +4 -0
- package/lib/browser/oracles/oracleId.js +38 -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/pythPullClient.d.ts +19 -0
- package/lib/browser/oracles/pythPullClient.js +60 -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/switchboardClient.d.ts +12 -0
- package/lib/browser/oracles/switchboardClient.js +40 -0
- package/lib/browser/oracles/switchboardOnDemandClient.d.ts +12 -0
- package/lib/browser/oracles/switchboardOnDemandClient.js +32 -0
- package/lib/browser/oracles/types.d.ts +23 -0
- package/lib/browser/oracles/types.js +2 -0
- package/lib/browser/orderParams.d.ts +29 -0
- package/lib/browser/orderParams.js +44 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +42 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.js +172 -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 +66 -0
- package/lib/browser/orderSubscriber/index.d.ts +2 -0
- package/lib/browser/orderSubscriber/index.js +18 -0
- package/lib/browser/orderSubscriber/types.d.ts +34 -0
- package/lib/browser/orderSubscriber/types.js +2 -0
- package/lib/browser/phoenix/phoenixFulfillmentConfigMap.d.ts +10 -0
- package/lib/browser/phoenix/phoenixFulfillmentConfigMap.js +17 -0
- package/lib/browser/phoenix/phoenixSubscriber.d.ts +41 -0
- package/lib/browser/phoenix/phoenixSubscriber.js +152 -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/driftPriorityFeeMethod.d.ts +13 -0
- package/lib/browser/priorityFee/driftPriorityFeeMethod.js +26 -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 +11 -0
- package/lib/browser/priorityFee/index.js +27 -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 +46 -0
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +188 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +48 -0
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +88 -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 +31 -0
- package/lib/browser/priorityFee/types.js +10 -0
- package/lib/browser/serum/serumFulfillmentConfigMap.d.ts +10 -0
- package/lib/browser/serum/serumFulfillmentConfigMap.js +17 -0
- package/lib/browser/serum/serumSubscriber.d.ts +32 -0
- package/lib/browser/serum/serumSubscriber.js +107 -0
- package/lib/browser/serum/types.d.ts +13 -0
- package/lib/browser/serum/types.js +2 -0
- package/lib/browser/slot/SlotSubscriber.d.ts +27 -0
- package/lib/browser/slot/SlotSubscriber.js +71 -0
- package/lib/browser/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/browser/slot/SlothashSubscriber.js +85 -0
- package/lib/browser/testClient.d.ts +8 -0
- package/lib/browser/testClient.js +23 -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 +294 -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 +154 -0
- package/lib/browser/tx/txHandler.js +453 -0
- package/lib/browser/tx/txParamProcessor.d.ts +25 -0
- package/lib/browser/tx/txParamProcessor.js +88 -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 +2 -0
- package/lib/browser/tx/utils.js +10 -0
- package/lib/browser/tx/whileValidTxSender.d.ts +45 -0
- package/lib/browser/tx/whileValidTxSender.js +167 -0
- package/lib/browser/types.d.ts +1385 -0
- package/lib/browser/types.js +366 -0
- package/lib/browser/user.d.ts +411 -0
- package/lib/browser/user.js +2151 -0
- package/lib/browser/userConfig.d.ts +26 -0
- package/lib/browser/userConfig.js +2 -0
- package/lib/browser/userMap/PollingSubscription.d.ts +16 -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 +181 -0
- package/lib/browser/userMap/userMap.d.ts +90 -0
- package/lib/browser/userMap/userMap.js +467 -0
- package/lib/browser/userMap/userMapConfig.d.ts +39 -0
- package/lib/browser/userMap/userMapConfig.js +2 -0
- package/lib/browser/userMap/userStatsMap.d.ts +46 -0
- package/lib/browser/userMap/userStatsMap.js +165 -0
- package/lib/browser/userName.d.ts +5 -0
- package/lib/browser/userName.js +21 -0
- package/lib/browser/userStats.d.ts +22 -0
- package/lib/browser/userStats.js +91 -0
- package/lib/browser/userStatsConfig.d.ts +25 -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 +4 -0
- package/lib/browser/util/digest.js +14 -0
- package/lib/browser/util/promiseTimeout.d.ts +1 -0
- package/lib/browser/util/promiseTimeout.js +14 -0
- package/lib/browser/util/pythOracleUtils.d.ts +17 -0
- package/lib/browser/util/pythOracleUtils.js +107 -0
- package/lib/browser/util/tps.d.ts +2 -0
- package/lib/browser/util/tps.js +16 -0
- package/lib/browser/wallet.d.ts +11 -0
- package/lib/browser/wallet.js +32 -0
- package/lib/node/accounts/basicUserAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/basicUserAccountSubscriber.js +38 -0
- package/lib/node/accounts/bulkAccountLoader.d.ts +37 -0
- package/lib/node/accounts/bulkAccountLoader.js +222 -0
- package/lib/node/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/node/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/node/accounts/bulkUserSubscription.d.ts +7 -0
- package/lib/node/accounts/bulkUserSubscription.js +21 -0
- package/lib/node/accounts/fetch.d.ts +6 -0
- package/lib/node/accounts/fetch.js +30 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +16 -0
- package/lib/node/accounts/grpcAccountSubscriber.js +154 -0
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts +12 -0
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.js +98 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +10 -0
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +30 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +171 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +10 -0
- package/lib/node/accounts/grpcUserAccountSubscriber.js +28 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +10 -0
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +28 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +18 -0
- package/lib/node/accounts/oneShotUserAccountSubscriber.js +48 -0
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts +69 -0
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.js +418 -0
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +111 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +110 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/pollingOracleAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +26 -0
- package/lib/node/accounts/pollingTokenAccountSubscriber.js +78 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/pollingUserAccountSubscriber.js +102 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +94 -0
- package/lib/node/accounts/testBulkAccountLoader.d.ts +4 -0
- package/lib/node/accounts/testBulkAccountLoader.js +45 -0
- package/lib/node/accounts/types.d.ts +168 -0
- package/lib/node/accounts/types.js +16 -0
- package/lib/node/accounts/utils.d.ts +8 -0
- package/lib/node/accounts/utils.js +49 -0
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +29 -0
- package/lib/node/accounts/webSocketAccountSubscriber.js +149 -0
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +66 -0
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.js +358 -0
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +69 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.js +67 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +32 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriber.js +120 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +23 -0
- package/lib/node/accounts/webSocketUserAccountSubscriber.js +61 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +22 -0
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.js +52 -0
- package/lib/node/addresses/marketAddresses.d.ts +2 -0
- package/lib/node/addresses/marketAddresses.js +15 -0
- package/lib/node/addresses/pda.d.ts +32 -0
- package/lib/node/addresses/pda.js +211 -0
- package/lib/node/adminClient.d.ts +206 -0
- package/lib/node/adminClient.js +1858 -0
- package/lib/node/assert/assert.d.ts +1 -0
- package/lib/node/assert/assert.js +9 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +14 -0
- package/lib/node/auctionSubscriber/auctionSubscriber.js +32 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +15 -0
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +32 -0
- package/lib/node/auctionSubscriber/index.d.ts +3 -0
- package/lib/node/auctionSubscriber/index.js +19 -0
- package/lib/node/auctionSubscriber/types.d.ts +14 -0
- package/lib/node/auctionSubscriber/types.js +2 -0
- package/lib/node/bankrun/bankrunConnection.d.ts +75 -0
- package/lib/node/bankrun/bankrunConnection.js +332 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.d.ts +27 -0
- package/lib/node/blockhashSubscriber/BlockhashSubscriber.js +89 -0
- package/lib/node/blockhashSubscriber/index.d.ts +1 -0
- package/lib/node/blockhashSubscriber/index.js +17 -0
- package/lib/node/blockhashSubscriber/types.d.ts +7 -0
- package/lib/node/blockhashSubscriber/types.js +2 -0
- package/lib/node/clock/clockSubscriber.d.ts +31 -0
- package/lib/node/clock/clockSubscriber.js +80 -0
- package/lib/node/config.d.ts +60 -0
- package/lib/node/config.js +130 -0
- package/lib/node/constants/numericConstants.d.ts +71 -0
- package/lib/node/constants/numericConstants.js +75 -0
- package/lib/node/constants/perpMarkets.d.ts +19 -0
- package/lib/node/constants/perpMarkets.js +997 -0
- package/lib/node/constants/spotMarkets.d.ts +24 -0
- package/lib/node/constants/spotMarkets.js +470 -0
- package/lib/node/constants/txConstants.d.ts +1 -0
- package/lib/node/constants/txConstants.js +4 -0
- package/lib/node/decode/phoenix.d.ts +7 -0
- package/lib/node/decode/phoenix.js +159 -0
- package/lib/node/decode/user.d.ts +4 -0
- package/lib/node/decode/user.js +339 -0
- package/lib/node/dlob/DLOB.d.ts +186 -0
- package/lib/node/dlob/DLOB.js +1039 -0
- package/lib/node/dlob/DLOBNode.d.ts +68 -0
- package/lib/node/dlob/DLOBNode.js +100 -0
- package/lib/node/dlob/DLOBSubscriber.d.ts +54 -0
- package/lib/node/dlob/DLOBSubscriber.js +139 -0
- package/lib/node/dlob/NodeList.d.ts +25 -0
- package/lib/node/dlob/NodeList.js +126 -0
- package/lib/node/dlob/orderBookLevels.d.ts +72 -0
- package/lib/node/dlob/orderBookLevels.js +438 -0
- package/lib/node/dlob/types.d.ts +18 -0
- package/lib/node/dlob/types.js +2 -0
- package/lib/node/driftClient.d.ts +861 -0
- package/lib/node/driftClient.js +4768 -0
- package/lib/node/driftClientConfig.d.ts +49 -0
- package/lib/node/driftClientConfig.js +2 -0
- package/lib/node/events/eventList.d.ts +22 -0
- package/lib/node/events/eventList.js +80 -0
- package/lib/node/events/eventSubscriber.d.ts +46 -0
- package/lib/node/events/eventSubscriber.js +223 -0
- package/lib/node/events/eventsServerLogProvider.d.ts +21 -0
- package/lib/node/events/eventsServerLogProvider.js +121 -0
- package/lib/node/events/fetchLogs.d.ts +25 -0
- package/lib/node/events/fetchLogs.js +99 -0
- package/lib/node/events/parse.d.ts +6 -0
- package/lib/node/events/parse.js +106 -0
- package/lib/node/events/pollingLogProvider.d.ts +17 -0
- package/lib/node/events/pollingLogProvider.js +58 -0
- package/lib/node/events/sort.d.ts +2 -0
- package/lib/node/events/sort.js +24 -0
- package/lib/node/events/txEventCache.d.ts +24 -0
- package/lib/node/events/txEventCache.js +71 -0
- package/lib/node/events/types.d.ts +79 -0
- package/lib/node/events/types.js +32 -0
- package/lib/node/events/webSocketLogProvider.d.ts +24 -0
- package/lib/node/events/webSocketLogProvider.js +96 -0
- package/lib/node/factory/bigNum.d.ts +122 -0
- package/lib/node/factory/bigNum.js +457 -0
- package/lib/node/factory/oracleClient.d.ts +5 -0
- package/lib/node/factory/oracleClient.js +56 -0
- package/lib/node/idl/drift.json +14440 -0
- package/lib/node/idl/openbook.json +3854 -0
- package/lib/node/idl/pyth_solana_receiver.json +628 -0
- package/lib/node/idl/switchboard.json +8354 -0
- package/lib/node/idl/switchboard_on_demand_30.json +4546 -0
- package/lib/node/idl/token_faucet.json +142 -0
- package/lib/node/index.d.ts +125 -0
- package/lib/node/index.js +147 -0
- package/lib/node/isomorphic/grpc.browser.d.ts +1 -0
- package/lib/node/isomorphic/grpc.browser.js +8 -0
- package/lib/node/isomorphic/grpc.d.ts +1 -0
- package/lib/node/isomorphic/grpc.js +8 -0
- package/lib/node/jupiter/jupiterClient.d.ts +302 -0
- package/lib/node/jupiter/jupiterClient.js +178 -0
- package/lib/node/keypair.d.ts +2 -0
- package/lib/node/keypair.js +28 -0
- package/lib/node/marinade/index.d.ts +12 -0
- package/lib/node/marinade/index.js +36 -0
- package/lib/node/marinade/types.d.ts +1963 -0
- package/lib/node/marinade/types.js +1965 -0
- package/lib/node/math/amm.d.ts +98 -0
- package/lib/node/math/amm.js +626 -0
- package/lib/node/math/auction.d.ts +23 -0
- package/lib/node/math/auction.js +130 -0
- package/lib/node/math/bankruptcy.d.ts +2 -0
- package/lib/node/math/bankruptcy.js +31 -0
- package/lib/node/math/conversion.d.ts +2 -0
- package/lib/node/math/conversion.js +11 -0
- package/lib/node/math/exchangeStatus.d.ts +6 -0
- package/lib/node/math/exchangeStatus.js +77 -0
- package/lib/node/math/fuel.d.ts +6 -0
- package/lib/node/math/fuel.js +55 -0
- package/lib/node/math/funding.d.ts +34 -0
- package/lib/node/math/funding.js +209 -0
- package/lib/node/math/insurance.d.ts +7 -0
- package/lib/node/math/insurance.js +73 -0
- package/lib/node/math/margin.d.ts +39 -0
- package/lib/node/math/margin.js +184 -0
- package/lib/node/math/market.d.ts +39 -0
- package/lib/node/math/market.js +163 -0
- package/lib/node/math/oracles.d.ts +14 -0
- package/lib/node/math/oracles.js +134 -0
- package/lib/node/math/orders.d.ts +23 -0
- package/lib/node/math/orders.js +216 -0
- package/lib/node/math/position.d.ts +70 -0
- package/lib/node/math/position.js +225 -0
- package/lib/node/math/repeg.d.ts +22 -0
- package/lib/node/math/repeg.js +164 -0
- package/lib/node/math/spotBalance.d.ts +83 -0
- package/lib/node/math/spotBalance.js +373 -0
- package/lib/node/math/spotMarket.d.ts +11 -0
- package/lib/node/math/spotMarket.js +49 -0
- package/lib/node/math/spotPosition.d.ts +19 -0
- package/lib/node/math/spotPosition.js +78 -0
- package/lib/node/math/state.d.ts +5 -0
- package/lib/node/math/state.js +30 -0
- package/lib/node/math/superStake.d.ts +167 -0
- package/lib/node/math/superStake.js +306 -0
- package/lib/node/math/tiers.d.ts +4 -0
- package/lib/node/math/tiers.js +52 -0
- package/lib/node/math/trade.d.ts +117 -0
- package/lib/node/math/trade.js +637 -0
- package/lib/node/math/userStatus.d.ts +2 -0
- package/lib/node/math/userStatus.js +8 -0
- package/lib/node/math/utils.d.ts +23 -0
- package/lib/node/math/utils.js +112 -0
- package/lib/node/memcmp.d.ts +11 -0
- package/lib/node/memcmp.js +99 -0
- package/lib/node/openbook/openbookV2FulfillmentConfigMap.d.ts +10 -0
- package/lib/node/openbook/openbookV2FulfillmentConfigMap.js +17 -0
- package/lib/node/openbook/openbookV2Subscriber.d.ts +36 -0
- package/lib/node/openbook/openbookV2Subscriber.js +104 -0
- package/lib/node/oracles/oracleClientCache.d.ts +9 -0
- package/lib/node/oracles/oracleClientCache.js +19 -0
- package/lib/node/oracles/oracleId.d.ts +4 -0
- package/lib/node/oracles/oracleId.js +38 -0
- package/lib/node/oracles/prelaunchOracleClient.d.ts +12 -0
- package/lib/node/oracles/prelaunchOracleClient.js +24 -0
- package/lib/node/oracles/pythClient.d.ts +14 -0
- package/lib/node/oracles/pythClient.js +51 -0
- package/lib/node/oracles/pythLazerClient.d.ts +16 -0
- package/lib/node/oracles/pythLazerClient.js +61 -0
- package/lib/node/oracles/pythPullClient.d.ts +19 -0
- package/lib/node/oracles/pythPullClient.js +60 -0
- package/lib/node/oracles/quoteAssetOracleClient.d.ts +10 -0
- package/lib/node/oracles/quoteAssetOracleClient.js +21 -0
- package/lib/node/oracles/strictOraclePrice.d.ts +9 -0
- package/lib/node/oracles/strictOraclePrice.js +17 -0
- package/lib/node/oracles/switchboardClient.d.ts +12 -0
- package/lib/node/oracles/switchboardClient.js +40 -0
- package/lib/node/oracles/switchboardOnDemandClient.d.ts +12 -0
- package/lib/node/oracles/switchboardOnDemandClient.js +32 -0
- package/lib/node/oracles/types.d.ts +23 -0
- package/lib/node/oracles/types.js +2 -0
- package/lib/node/orderParams.d.ts +29 -0
- package/lib/node/orderParams.js +44 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +42 -0
- package/lib/node/orderSubscriber/OrderSubscriber.js +172 -0
- package/lib/node/orderSubscriber/PollingSubscription.d.ts +12 -0
- package/lib/node/orderSubscriber/PollingSubscription.js +23 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.d.ts +23 -0
- package/lib/node/orderSubscriber/WebsocketSubscription.js +67 -0
- package/lib/node/orderSubscriber/grpcSubscription.d.ts +22 -0
- package/lib/node/orderSubscriber/grpcSubscription.js +66 -0
- package/lib/node/orderSubscriber/index.d.ts +2 -0
- package/lib/node/orderSubscriber/index.js +18 -0
- package/lib/node/orderSubscriber/types.d.ts +34 -0
- package/lib/node/orderSubscriber/types.js +2 -0
- package/lib/node/phoenix/phoenixFulfillmentConfigMap.d.ts +10 -0
- package/lib/node/phoenix/phoenixFulfillmentConfigMap.js +17 -0
- package/lib/node/phoenix/phoenixSubscriber.d.ts +41 -0
- package/lib/node/phoenix/phoenixSubscriber.js +152 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.d.ts +5 -0
- package/lib/node/priorityFee/averageOverSlotsStrategy.js +16 -0
- package/lib/node/priorityFee/averageStrategy.d.ts +5 -0
- package/lib/node/priorityFee/averageStrategy.js +11 -0
- package/lib/node/priorityFee/driftPriorityFeeMethod.d.ts +13 -0
- package/lib/node/priorityFee/driftPriorityFeeMethod.js +26 -0
- package/lib/node/priorityFee/ewmaStrategy.d.ts +11 -0
- package/lib/node/priorityFee/ewmaStrategy.js +33 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.d.ts +20 -0
- package/lib/node/priorityFee/heliusPriorityFeeMethod.js +46 -0
- package/lib/node/priorityFee/index.d.ts +11 -0
- package/lib/node/priorityFee/index.js +27 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.d.ts +5 -0
- package/lib/node/priorityFee/maxOverSlotsStrategy.js +17 -0
- package/lib/node/priorityFee/maxStrategy.d.ts +7 -0
- package/lib/node/priorityFee/maxStrategy.js +9 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +46 -0
- package/lib/node/priorityFee/priorityFeeSubscriber.js +188 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +48 -0
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +88 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.d.ts +6 -0
- package/lib/node/priorityFee/solanaPriorityFeeMethod.js +21 -0
- package/lib/node/priorityFee/types.d.ts +31 -0
- package/lib/node/priorityFee/types.js +10 -0
- package/lib/node/serum/serumFulfillmentConfigMap.d.ts +10 -0
- package/lib/node/serum/serumFulfillmentConfigMap.js +17 -0
- package/lib/node/serum/serumSubscriber.d.ts +32 -0
- package/lib/node/serum/serumSubscriber.js +107 -0
- package/lib/node/serum/types.d.ts +13 -0
- package/lib/node/serum/types.js +2 -0
- package/lib/node/slot/SlotSubscriber.d.ts +27 -0
- package/lib/node/slot/SlotSubscriber.js +71 -0
- package/lib/node/slot/SlothashSubscriber.d.ts +26 -0
- package/lib/node/slot/SlothashSubscriber.js +85 -0
- package/lib/node/testClient.d.ts +8 -0
- package/lib/node/testClient.js +23 -0
- package/lib/node/token/index.d.ts +5 -0
- package/lib/node/token/index.js +15 -0
- package/lib/node/tokenFaucet.d.ts +41 -0
- package/lib/node/tokenFaucet.js +188 -0
- package/lib/node/tx/baseTxSender.d.ts +59 -0
- package/lib/node/tx/baseTxSender.js +294 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.d.ts +8 -0
- package/lib/node/tx/blockhashFetcher/baseBlockhashFetcher.js +13 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.d.ts +28 -0
- package/lib/node/tx/blockhashFetcher/cachedBlockhashFetcher.js +73 -0
- package/lib/node/tx/blockhashFetcher/types.d.ts +4 -0
- package/lib/node/tx/blockhashFetcher/types.js +2 -0
- package/lib/node/tx/fastSingleTxSender.d.ts +41 -0
- package/lib/node/tx/fastSingleTxSender.js +86 -0
- package/lib/node/tx/forwardOnlyTxSender.d.ts +37 -0
- package/lib/node/tx/forwardOnlyTxSender.js +92 -0
- package/lib/node/tx/priorityFeeCalculator.d.ts +44 -0
- package/lib/node/tx/priorityFeeCalculator.js +85 -0
- package/lib/node/tx/reportTransactionError.d.ts +20 -0
- package/lib/node/tx/reportTransactionError.js +103 -0
- package/lib/node/tx/retryTxSender.d.ts +37 -0
- package/lib/node/tx/retryTxSender.js +86 -0
- package/lib/node/tx/txHandler.d.ts +154 -0
- package/lib/node/tx/txHandler.js +453 -0
- package/lib/node/tx/txParamProcessor.d.ts +25 -0
- package/lib/node/tx/txParamProcessor.js +88 -0
- package/lib/node/tx/types.d.ts +29 -0
- package/lib/node/tx/types.js +20 -0
- package/lib/node/tx/utils.d.ts +2 -0
- package/lib/node/tx/utils.js +10 -0
- package/lib/node/tx/whileValidTxSender.d.ts +45 -0
- package/lib/node/tx/whileValidTxSender.js +167 -0
- package/lib/node/types.d.ts +1385 -0
- package/lib/node/types.js +366 -0
- package/lib/node/user.d.ts +411 -0
- package/lib/node/user.js +2151 -0
- package/lib/node/userConfig.d.ts +26 -0
- package/lib/node/userConfig.js +2 -0
- package/lib/node/userMap/PollingSubscription.d.ts +16 -0
- package/lib/node/userMap/PollingSubscription.js +30 -0
- package/lib/node/userMap/WebsocketSubscription.d.ts +27 -0
- package/lib/node/userMap/WebsocketSubscription.js +45 -0
- package/lib/node/userMap/grpcSubscription.d.ts +27 -0
- package/lib/node/userMap/grpcSubscription.js +44 -0
- package/lib/node/userMap/referrerMap.d.ts +45 -0
- package/lib/node/userMap/referrerMap.js +181 -0
- package/lib/node/userMap/userMap.d.ts +90 -0
- package/lib/node/userMap/userMap.js +467 -0
- package/lib/node/userMap/userMapConfig.d.ts +39 -0
- package/lib/node/userMap/userMapConfig.js +2 -0
- package/lib/node/userMap/userStatsMap.d.ts +46 -0
- package/lib/node/userMap/userStatsMap.js +165 -0
- package/lib/node/userName.d.ts +5 -0
- package/lib/node/userName.js +21 -0
- package/lib/node/userStats.d.ts +22 -0
- package/lib/node/userStats.js +91 -0
- package/lib/node/userStatsConfig.d.ts +25 -0
- package/lib/node/userStatsConfig.js +2 -0
- package/lib/node/util/TransactionConfirmationManager.d.ts +16 -0
- package/lib/node/util/TransactionConfirmationManager.js +174 -0
- package/lib/node/util/chainClock.d.ts +17 -0
- package/lib/node/util/chainClock.js +29 -0
- package/lib/node/util/computeUnits.d.ts +8 -0
- package/lib/node/util/computeUnits.js +48 -0
- package/lib/node/util/digest.d.ts +4 -0
- package/lib/node/util/digest.js +14 -0
- package/lib/node/util/promiseTimeout.d.ts +1 -0
- package/lib/node/util/promiseTimeout.js +14 -0
- package/lib/node/util/pythOracleUtils.d.ts +17 -0
- package/lib/node/util/pythOracleUtils.js +107 -0
- package/lib/node/util/tps.d.ts +2 -0
- package/lib/node/util/tps.js +16 -0
- package/lib/node/wallet.d.ts +11 -0
- package/lib/node/wallet.js +32 -0
- package/package.json +92 -0
- package/scripts/postbuild.js +95 -0
- package/scripts/updateVersion.js +28 -0
- package/src/accounts/basicUserAccountSubscriber.ts +59 -0
- package/src/accounts/bulkAccountLoader.ts +294 -0
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +33 -0
- package/src/accounts/fetch.ts +66 -0
- package/src/accounts/grpcAccountSubscriber.ts +160 -0
- package/src/accounts/grpcDriftClientAccountSubscriber.ts +203 -0
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +56 -0
- package/src/accounts/grpcProgramAccountSubscriber.ts +190 -0
- package/src/accounts/grpcUserAccountSubscriber.ts +48 -0
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +50 -0
- package/src/accounts/oneShotUserAccountSubscriber.ts +68 -0
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +644 -0
- package/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +189 -0
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +185 -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/testBulkAccountLoader.ts +53 -0
- package/src/accounts/types.ts +245 -0
- package/src/accounts/utils.ts +62 -0
- package/src/accounts/webSocketAccountSubscriber.ts +205 -0
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +621 -0
- package/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +131 -0
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +129 -0
- package/src/accounts/webSocketProgramAccountSubscriber.ts +182 -0
- package/src/accounts/webSocketUserAccountSubscriber.ts +104 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +98 -0
- package/src/addresses/marketAddresses.ts +17 -0
- package/src/addresses/pda.ts +355 -0
- package/src/adminClient.ts +4030 -0
- package/src/assert/assert.ts +5 -0
- package/src/auctionSubscriber/auctionSubscriber.ts +66 -0
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +70 -0
- package/src/auctionSubscriber/index.ts +3 -0
- package/src/auctionSubscriber/types.ts +20 -0
- package/src/bankrun/bankrunConnection.ts +534 -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 +212 -0
- package/src/constants/numericConstants.ts +113 -0
- package/src/constants/perpMarkets.ts +1084 -0
- package/src/constants/spotMarkets.ts +565 -0
- package/src/constants/txConstants.ts +1 -0
- package/src/decode/phoenix.ts +207 -0
- package/src/decode/user.ts +368 -0
- package/src/dlob/DLOB.ts +1897 -0
- package/src/dlob/DLOBNode.ts +197 -0
- package/src/dlob/DLOBSubscriber.ts +201 -0
- package/src/dlob/NodeList.ts +173 -0
- package/src/dlob/orderBookLevels.ts +643 -0
- package/src/dlob/types.ts +22 -0
- package/src/driftClient.ts +9032 -0
- package/src/driftClientConfig.ts +60 -0
- package/src/events/eventList.ts +97 -0
- package/src/events/eventSubscriber.ts +364 -0
- package/src/events/eventsServerLogProvider.ts +152 -0
- package/src/events/fetchLogs.ts +169 -0
- package/src/events/parse.ts +133 -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 +185 -0
- package/src/events/webSocketLogProvider.ts +121 -0
- package/src/factory/bigNum.ts +660 -0
- package/src/factory/oracleClient.ts +72 -0
- package/src/idl/drift.json +14440 -0
- package/src/idl/openbook.json +3854 -0
- package/src/idl/pyth.json +142 -0
- package/src/idl/pyth_solana_receiver.json +628 -0
- package/src/idl/switchboard.json +8354 -0
- package/src/idl/switchboard_on_demand_30.json +4546 -0
- package/src/idl/token_faucet.json +142 -0
- package/src/index.ts +127 -0
- package/src/isomorphic/README.md +19 -0
- package/src/isomorphic/grpc.browser.ts +4 -0
- package/src/isomorphic/grpc.node.ts +23 -0
- package/src/isomorphic/grpc.ts +1 -0
- package/src/jupiter/jupiterClient.ts +510 -0
- package/src/keypair.ts +24 -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 +1162 -0
- package/src/math/auction.ts +173 -0
- package/src/math/bankruptcy.ts +34 -0
- package/src/math/conversion.ts +13 -0
- package/src/math/exchangeStatus.ts +121 -0
- package/src/math/fuel.ts +70 -0
- package/src/math/funding.ts +342 -0
- package/src/math/insurance.ts +110 -0
- package/src/math/margin.ts +340 -0
- package/src/math/market.ts +336 -0
- package/src/math/oracles.ts +228 -0
- package/src/math/orders.ts +343 -0
- package/src/math/position.ts +324 -0
- package/src/math/repeg.ts +214 -0
- package/src/math/spotBalance.ts +630 -0
- package/src/math/spotMarket.ts +82 -0
- package/src/math/spotPosition.ts +184 -0
- package/src/math/state.ts +29 -0
- package/src/math/superStake.ts +525 -0
- package/src/math/tiers.ts +44 -0
- package/src/math/trade.ts +993 -0
- package/src/math/userStatus.ts +5 -0
- package/src/math/utils.ts +120 -0
- package/src/memcmp.ts +94 -0
- package/src/openbook/openbookV2FulfillmentConfigMap.ts +29 -0
- package/src/openbook/openbookV2Subscriber.ts +165 -0
- package/src/oracles/oracleClientCache.ts +25 -0
- package/src/oracles/oracleId.ts +28 -0
- package/src/oracles/prelaunchOracleClient.ts +37 -0
- package/src/oracles/pythClient.ts +85 -0
- package/src/oracles/pythLazerClient.ts +102 -0
- package/src/oracles/pythPullClient.ts +111 -0
- package/src/oracles/quoteAssetOracleClient.ts +25 -0
- package/src/oracles/strictOraclePrice.ts +19 -0
- package/src/oracles/switchboardClient.ts +77 -0
- package/src/oracles/switchboardOnDemandClient.ts +56 -0
- package/src/oracles/types.ts +23 -0
- package/src/orderParams.ts +79 -0
- package/src/orderSubscriber/OrderSubscriber.ts +249 -0
- package/src/orderSubscriber/PollingSubscription.ts +39 -0
- package/src/orderSubscriber/WebsocketSubscription.ts +119 -0
- package/src/orderSubscriber/grpcSubscription.ts +121 -0
- package/src/orderSubscriber/index.ts +2 -0
- package/src/orderSubscriber/types.ts +54 -0
- package/src/phoenix/phoenixFulfillmentConfigMap.ts +26 -0
- package/src/phoenix/phoenixSubscriber.ts +235 -0
- package/src/priorityFee/averageOverSlotsStrategy.ts +16 -0
- package/src/priorityFee/averageStrategy.ts +12 -0
- package/src/priorityFee/driftPriorityFeeMethod.ts +42 -0
- package/src/priorityFee/ewmaStrategy.ts +41 -0
- package/src/priorityFee/heliusPriorityFeeMethod.ts +57 -0
- package/src/priorityFee/index.ts +11 -0
- package/src/priorityFee/maxOverSlotsStrategy.ts +17 -0
- package/src/priorityFee/maxStrategy.ts +7 -0
- package/src/priorityFee/priorityFeeSubscriber.ts +251 -0
- package/src/priorityFee/priorityFeeSubscriberMap.ts +112 -0
- package/src/priorityFee/solanaPriorityFeeMethod.ts +34 -0
- package/src/priorityFee/types.ts +60 -0
- package/src/serum/serumFulfillmentConfigMap.ts +26 -0
- package/src/serum/serumSubscriber.ts +169 -0
- package/src/serum/types.ts +17 -0
- package/src/slot/SlotSubscriber.ts +101 -0
- package/src/slot/SlothashSubscriber.ts +126 -0
- package/src/testClient.ts +41 -0
- package/src/token/index.ts +13 -0
- package/src/tokenFaucet.ts +269 -0
- package/src/tx/baseTxSender.ts +477 -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 +737 -0
- package/src/tx/txParamProcessor.ts +155 -0
- package/src/tx/types.ts +71 -0
- package/src/tx/utils.ts +11 -0
- package/src/tx/whileValidTxSender.ts +265 -0
- package/src/types.ts +1386 -0
- package/src/user.ts +4054 -0
- package/src/userConfig.ts +32 -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/userMap.ts +654 -0
- package/src/userMap/userMapConfig.ts +63 -0
- package/src/userMap/userStatsMap.ts +218 -0
- package/src/userName.ts +21 -0
- package/src/userStats.ts +174 -0
- package/src/userStatsConfig.ts +31 -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 +11 -0
- package/src/util/promiseTimeout.ts +14 -0
- package/src/util/pythOracleUtils.ts +136 -0
- package/src/util/tps.ts +27 -0
- package/src/wallet.ts +43 -0
- package/tests/amm/test.ts +2092 -0
- package/tests/auctions/test.ts +81 -0
- package/tests/bn/test.ts +341 -0
- package/tests/ci/idl.ts +101 -0
- package/tests/ci/verifyConstants.ts +278 -0
- package/tests/decode/phoenix.ts +71 -0
- package/tests/decode/test.ts +266 -0
- package/tests/decode/userAccountBufferStrings.ts +102 -0
- package/tests/dlob/helpers.ts +749 -0
- package/tests/dlob/test.ts +6623 -0
- package/tests/insurance/test.ts +40 -0
- package/tests/spot/test.ts +226 -0
- package/tests/subscriber/openbook.ts +62 -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/helpers.ts +92 -0
- package/tests/user/test.ts +517 -0
- package/tsconfig.browser.json +13 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,4030 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PublicKey,
|
|
3
|
+
SystemProgram,
|
|
4
|
+
SYSVAR_RENT_PUBKEY,
|
|
5
|
+
TransactionInstruction,
|
|
6
|
+
TransactionSignature,
|
|
7
|
+
} from '@solana/web3.js';
|
|
8
|
+
import {
|
|
9
|
+
FeeStructure,
|
|
10
|
+
OracleGuardRails,
|
|
11
|
+
OracleSource,
|
|
12
|
+
ExchangeStatus,
|
|
13
|
+
MarketStatus,
|
|
14
|
+
ContractTier,
|
|
15
|
+
AssetTier,
|
|
16
|
+
SpotFulfillmentConfigStatus,
|
|
17
|
+
} from './types';
|
|
18
|
+
import { DEFAULT_MARKET_NAME, encodeName } from './userName';
|
|
19
|
+
import { BN } from '@coral-xyz/anchor';
|
|
20
|
+
import * as anchor from '@coral-xyz/anchor';
|
|
21
|
+
import {
|
|
22
|
+
getDriftStateAccountPublicKeyAndNonce,
|
|
23
|
+
getSpotMarketPublicKey,
|
|
24
|
+
getSpotMarketVaultPublicKey,
|
|
25
|
+
getPerpMarketPublicKey,
|
|
26
|
+
getInsuranceFundVaultPublicKey,
|
|
27
|
+
getSerumOpenOrdersPublicKey,
|
|
28
|
+
getSerumFulfillmentConfigPublicKey,
|
|
29
|
+
getPhoenixFulfillmentConfigPublicKey,
|
|
30
|
+
getProtocolIfSharesTransferConfigPublicKey,
|
|
31
|
+
getPrelaunchOraclePublicKey,
|
|
32
|
+
getOpenbookV2FulfillmentConfigPublicKey,
|
|
33
|
+
getPythPullOraclePublicKey,
|
|
34
|
+
getUserStatsAccountPublicKey,
|
|
35
|
+
getHighLeverageModeConfigPublicKey,
|
|
36
|
+
getPythLazerOraclePublicKey,
|
|
37
|
+
} from './addresses/pda';
|
|
38
|
+
import { squareRootBN } from './math/utils';
|
|
39
|
+
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
40
|
+
import { DriftClient } from './driftClient';
|
|
41
|
+
import {
|
|
42
|
+
PEG_PRECISION,
|
|
43
|
+
QUOTE_SPOT_MARKET_INDEX,
|
|
44
|
+
ZERO,
|
|
45
|
+
ONE,
|
|
46
|
+
BASE_PRECISION,
|
|
47
|
+
PRICE_PRECISION,
|
|
48
|
+
} from './constants/numericConstants';
|
|
49
|
+
import { calculateTargetPriceTrade } from './math/trade';
|
|
50
|
+
import { calculateAmmReservesAfterSwap, getSwapDirection } from './math/amm';
|
|
51
|
+
import { PROGRAM_ID as PHOENIX_PROGRAM_ID } from '@ellipsis-labs/phoenix-sdk';
|
|
52
|
+
import { DRIFT_ORACLE_RECEIVER_ID } from './config';
|
|
53
|
+
import { getFeedIdUint8Array } from './util/pythOracleUtils';
|
|
54
|
+
|
|
55
|
+
const OPENBOOK_PROGRAM_ID = new PublicKey(
|
|
56
|
+
'opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb'
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export class AdminClient extends DriftClient {
|
|
60
|
+
public async initialize(
|
|
61
|
+
usdcMint: PublicKey,
|
|
62
|
+
_adminControlsPrices: boolean
|
|
63
|
+
): Promise<[TransactionSignature]> {
|
|
64
|
+
const stateAccountRPCResponse = await this.connection.getParsedAccountInfo(
|
|
65
|
+
await this.getStatePublicKey()
|
|
66
|
+
);
|
|
67
|
+
if (stateAccountRPCResponse.value !== null) {
|
|
68
|
+
throw new Error('Clearing house already initialized');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const [driftStatePublicKey] = await getDriftStateAccountPublicKeyAndNonce(
|
|
72
|
+
this.program.programId
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const initializeIx = await this.program.instruction.initialize({
|
|
76
|
+
accounts: {
|
|
77
|
+
admin: this.isSubscribed
|
|
78
|
+
? this.getStateAccount().admin
|
|
79
|
+
: this.wallet.publicKey,
|
|
80
|
+
state: driftStatePublicKey,
|
|
81
|
+
quoteAssetMint: usdcMint,
|
|
82
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
83
|
+
driftSigner: this.getSignerPublicKey(),
|
|
84
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
85
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
90
|
+
|
|
91
|
+
const { txSig } = await super.sendTransaction(tx, [], this.opts);
|
|
92
|
+
|
|
93
|
+
return [txSig];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public async initializeSpotMarket(
|
|
97
|
+
mint: PublicKey,
|
|
98
|
+
optimalUtilization: number,
|
|
99
|
+
optimalRate: number,
|
|
100
|
+
maxRate: number,
|
|
101
|
+
oracle: PublicKey,
|
|
102
|
+
oracleSource: OracleSource,
|
|
103
|
+
initialAssetWeight: number,
|
|
104
|
+
maintenanceAssetWeight: number,
|
|
105
|
+
initialLiabilityWeight: number,
|
|
106
|
+
maintenanceLiabilityWeight: number,
|
|
107
|
+
imfFactor = 0,
|
|
108
|
+
liquidatorFee = 0,
|
|
109
|
+
ifLiquidationFee = 0,
|
|
110
|
+
activeStatus = true,
|
|
111
|
+
assetTier = AssetTier.COLLATERAL,
|
|
112
|
+
scaleInitialAssetWeightStart = ZERO,
|
|
113
|
+
withdrawGuardThreshold = ZERO,
|
|
114
|
+
orderTickSize = ONE,
|
|
115
|
+
orderStepSize = ONE,
|
|
116
|
+
ifTotalFactor = 0,
|
|
117
|
+
name = DEFAULT_MARKET_NAME,
|
|
118
|
+
marketIndex?: number
|
|
119
|
+
): Promise<TransactionSignature> {
|
|
120
|
+
const spotMarketIndex =
|
|
121
|
+
marketIndex ?? this.getStateAccount().numberOfSpotMarkets;
|
|
122
|
+
|
|
123
|
+
const initializeIx = await this.getInitializeSpotMarketIx(
|
|
124
|
+
mint,
|
|
125
|
+
optimalUtilization,
|
|
126
|
+
optimalRate,
|
|
127
|
+
maxRate,
|
|
128
|
+
oracle,
|
|
129
|
+
oracleSource,
|
|
130
|
+
initialAssetWeight,
|
|
131
|
+
maintenanceAssetWeight,
|
|
132
|
+
initialLiabilityWeight,
|
|
133
|
+
maintenanceLiabilityWeight,
|
|
134
|
+
imfFactor,
|
|
135
|
+
liquidatorFee,
|
|
136
|
+
ifLiquidationFee,
|
|
137
|
+
activeStatus,
|
|
138
|
+
assetTier,
|
|
139
|
+
scaleInitialAssetWeightStart,
|
|
140
|
+
withdrawGuardThreshold,
|
|
141
|
+
orderTickSize,
|
|
142
|
+
orderStepSize,
|
|
143
|
+
ifTotalFactor,
|
|
144
|
+
name,
|
|
145
|
+
marketIndex
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
149
|
+
|
|
150
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
151
|
+
|
|
152
|
+
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
153
|
+
await this.accountSubscriber.addOracle({
|
|
154
|
+
source: oracleSource,
|
|
155
|
+
publicKey: oracle,
|
|
156
|
+
});
|
|
157
|
+
await this.accountSubscriber.setSpotOracleMap();
|
|
158
|
+
|
|
159
|
+
return txSig;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public async getInitializeSpotMarketIx(
|
|
163
|
+
mint: PublicKey,
|
|
164
|
+
optimalUtilization: number,
|
|
165
|
+
optimalRate: number,
|
|
166
|
+
maxRate: number,
|
|
167
|
+
oracle: PublicKey,
|
|
168
|
+
oracleSource: OracleSource,
|
|
169
|
+
initialAssetWeight: number,
|
|
170
|
+
maintenanceAssetWeight: number,
|
|
171
|
+
initialLiabilityWeight: number,
|
|
172
|
+
maintenanceLiabilityWeight: number,
|
|
173
|
+
imfFactor = 0,
|
|
174
|
+
liquidatorFee = 0,
|
|
175
|
+
ifLiquidationFee = 0,
|
|
176
|
+
activeStatus = true,
|
|
177
|
+
assetTier = AssetTier.COLLATERAL,
|
|
178
|
+
scaleInitialAssetWeightStart = ZERO,
|
|
179
|
+
withdrawGuardThreshold = ZERO,
|
|
180
|
+
orderTickSize = ONE,
|
|
181
|
+
orderStepSize = ONE,
|
|
182
|
+
ifTotalFactor = 0,
|
|
183
|
+
name = DEFAULT_MARKET_NAME,
|
|
184
|
+
marketIndex?: number
|
|
185
|
+
): Promise<TransactionInstruction> {
|
|
186
|
+
const spotMarketIndex =
|
|
187
|
+
marketIndex ?? this.getStateAccount().numberOfSpotMarkets;
|
|
188
|
+
const spotMarket = await getSpotMarketPublicKey(
|
|
189
|
+
this.program.programId,
|
|
190
|
+
spotMarketIndex
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const spotMarketVault = await getSpotMarketVaultPublicKey(
|
|
194
|
+
this.program.programId,
|
|
195
|
+
spotMarketIndex
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const insuranceFundVault = await getInsuranceFundVaultPublicKey(
|
|
199
|
+
this.program.programId,
|
|
200
|
+
spotMarketIndex
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const tokenProgram = (await this.connection.getAccountInfo(mint)).owner;
|
|
204
|
+
|
|
205
|
+
const nameBuffer = encodeName(name);
|
|
206
|
+
const initializeIx = await this.program.instruction.initializeSpotMarket(
|
|
207
|
+
optimalUtilization,
|
|
208
|
+
optimalRate,
|
|
209
|
+
maxRate,
|
|
210
|
+
oracleSource,
|
|
211
|
+
initialAssetWeight,
|
|
212
|
+
maintenanceAssetWeight,
|
|
213
|
+
initialLiabilityWeight,
|
|
214
|
+
maintenanceLiabilityWeight,
|
|
215
|
+
imfFactor,
|
|
216
|
+
liquidatorFee,
|
|
217
|
+
ifLiquidationFee,
|
|
218
|
+
activeStatus,
|
|
219
|
+
assetTier,
|
|
220
|
+
scaleInitialAssetWeightStart,
|
|
221
|
+
withdrawGuardThreshold,
|
|
222
|
+
orderTickSize,
|
|
223
|
+
orderStepSize,
|
|
224
|
+
ifTotalFactor,
|
|
225
|
+
nameBuffer,
|
|
226
|
+
{
|
|
227
|
+
accounts: {
|
|
228
|
+
admin: this.isSubscribed
|
|
229
|
+
? this.getStateAccount().admin
|
|
230
|
+
: this.wallet.publicKey,
|
|
231
|
+
state: await this.getStatePublicKey(),
|
|
232
|
+
spotMarket,
|
|
233
|
+
spotMarketVault,
|
|
234
|
+
insuranceFundVault,
|
|
235
|
+
driftSigner: this.getSignerPublicKey(),
|
|
236
|
+
spotMarketMint: mint,
|
|
237
|
+
oracle,
|
|
238
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
239
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
240
|
+
tokenProgram,
|
|
241
|
+
},
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
return initializeIx;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public async deleteInitializedSpotMarket(
|
|
249
|
+
marketIndex: number
|
|
250
|
+
): Promise<TransactionSignature> {
|
|
251
|
+
const deleteInitializeMarketIx =
|
|
252
|
+
await this.getDeleteInitializedSpotMarketIx(marketIndex);
|
|
253
|
+
|
|
254
|
+
const tx = await this.buildTransaction(deleteInitializeMarketIx);
|
|
255
|
+
|
|
256
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
257
|
+
|
|
258
|
+
return txSig;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
public async getDeleteInitializedSpotMarketIx(
|
|
262
|
+
marketIndex: number
|
|
263
|
+
): Promise<TransactionInstruction> {
|
|
264
|
+
const spotMarketPublicKey = await getSpotMarketPublicKey(
|
|
265
|
+
this.program.programId,
|
|
266
|
+
marketIndex
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
const spotMarketVaultPublicKey = await getSpotMarketVaultPublicKey(
|
|
270
|
+
this.program.programId,
|
|
271
|
+
marketIndex
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
const insuranceFundVaultPublicKey = await getInsuranceFundVaultPublicKey(
|
|
275
|
+
this.program.programId,
|
|
276
|
+
marketIndex
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
return await this.program.instruction.deleteInitializedSpotMarket(
|
|
280
|
+
marketIndex,
|
|
281
|
+
{
|
|
282
|
+
accounts: {
|
|
283
|
+
state: await this.getStatePublicKey(),
|
|
284
|
+
admin: this.isSubscribed
|
|
285
|
+
? this.getStateAccount().admin
|
|
286
|
+
: this.wallet.publicKey,
|
|
287
|
+
spotMarket: spotMarketPublicKey,
|
|
288
|
+
spotMarketVault: spotMarketVaultPublicKey,
|
|
289
|
+
insuranceFundVault: insuranceFundVaultPublicKey,
|
|
290
|
+
driftSigner: this.getSignerPublicKey(),
|
|
291
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
292
|
+
},
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
public async initializeSerumFulfillmentConfig(
|
|
298
|
+
marketIndex: number,
|
|
299
|
+
serumMarket: PublicKey,
|
|
300
|
+
serumProgram: PublicKey
|
|
301
|
+
): Promise<TransactionSignature> {
|
|
302
|
+
const initializeIx = await this.getInitializeSerumFulfillmentConfigIx(
|
|
303
|
+
marketIndex,
|
|
304
|
+
serumMarket,
|
|
305
|
+
serumProgram
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
309
|
+
|
|
310
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
311
|
+
|
|
312
|
+
return txSig;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
public async getInitializeSerumFulfillmentConfigIx(
|
|
316
|
+
marketIndex: number,
|
|
317
|
+
serumMarket: PublicKey,
|
|
318
|
+
serumProgram: PublicKey
|
|
319
|
+
): Promise<TransactionInstruction> {
|
|
320
|
+
const serumOpenOrders = getSerumOpenOrdersPublicKey(
|
|
321
|
+
this.program.programId,
|
|
322
|
+
serumMarket
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
const serumFulfillmentConfig = getSerumFulfillmentConfigPublicKey(
|
|
326
|
+
this.program.programId,
|
|
327
|
+
serumMarket
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
return await this.program.instruction.initializeSerumFulfillmentConfig(
|
|
331
|
+
marketIndex,
|
|
332
|
+
{
|
|
333
|
+
accounts: {
|
|
334
|
+
admin: this.isSubscribed
|
|
335
|
+
? this.getStateAccount().admin
|
|
336
|
+
: this.wallet.publicKey,
|
|
337
|
+
state: await this.getStatePublicKey(),
|
|
338
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
339
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
340
|
+
driftSigner: this.getSignerPublicKey(),
|
|
341
|
+
serumProgram,
|
|
342
|
+
serumMarket,
|
|
343
|
+
serumOpenOrders,
|
|
344
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
345
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
346
|
+
serumFulfillmentConfig,
|
|
347
|
+
},
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
public async initializePhoenixFulfillmentConfig(
|
|
353
|
+
marketIndex: number,
|
|
354
|
+
phoenixMarket: PublicKey
|
|
355
|
+
): Promise<TransactionSignature> {
|
|
356
|
+
const initializeIx = await this.getInitializePhoenixFulfillmentConfigIx(
|
|
357
|
+
marketIndex,
|
|
358
|
+
phoenixMarket
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
362
|
+
|
|
363
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
364
|
+
|
|
365
|
+
return txSig;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
public async getInitializePhoenixFulfillmentConfigIx(
|
|
369
|
+
marketIndex: number,
|
|
370
|
+
phoenixMarket: PublicKey
|
|
371
|
+
): Promise<TransactionInstruction> {
|
|
372
|
+
const phoenixFulfillmentConfig = getPhoenixFulfillmentConfigPublicKey(
|
|
373
|
+
this.program.programId,
|
|
374
|
+
phoenixMarket
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
return await this.program.instruction.initializePhoenixFulfillmentConfig(
|
|
378
|
+
marketIndex,
|
|
379
|
+
{
|
|
380
|
+
accounts: {
|
|
381
|
+
admin: this.isSubscribed
|
|
382
|
+
? this.getStateAccount().admin
|
|
383
|
+
: this.wallet.publicKey,
|
|
384
|
+
state: await this.getStatePublicKey(),
|
|
385
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
386
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
387
|
+
driftSigner: this.getSignerPublicKey(),
|
|
388
|
+
phoenixMarket: phoenixMarket,
|
|
389
|
+
phoenixProgram: PHOENIX_PROGRAM_ID,
|
|
390
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
391
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
392
|
+
phoenixFulfillmentConfig,
|
|
393
|
+
},
|
|
394
|
+
}
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
public async initializeOpenbookV2FulfillmentConfig(
|
|
399
|
+
marketIndex: number,
|
|
400
|
+
openbookMarket: PublicKey
|
|
401
|
+
): Promise<TransactionSignature> {
|
|
402
|
+
const initializeIx = await this.getInitializeOpenbookV2FulfillmentConfigIx(
|
|
403
|
+
marketIndex,
|
|
404
|
+
openbookMarket
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
408
|
+
|
|
409
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
410
|
+
|
|
411
|
+
return txSig;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
public async getInitializeOpenbookV2FulfillmentConfigIx(
|
|
415
|
+
marketIndex: number,
|
|
416
|
+
openbookMarket: PublicKey
|
|
417
|
+
): Promise<TransactionInstruction> {
|
|
418
|
+
const openbookFulfillmentConfig = getOpenbookV2FulfillmentConfigPublicKey(
|
|
419
|
+
this.program.programId,
|
|
420
|
+
openbookMarket
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
return this.program.instruction.initializeOpenbookV2FulfillmentConfig(
|
|
424
|
+
marketIndex,
|
|
425
|
+
{
|
|
426
|
+
accounts: {
|
|
427
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
428
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
429
|
+
state: await this.getStatePublicKey(),
|
|
430
|
+
openbookV2Program: OPENBOOK_PROGRAM_ID,
|
|
431
|
+
openbookV2Market: openbookMarket,
|
|
432
|
+
driftSigner: this.getSignerPublicKey(),
|
|
433
|
+
openbookV2FulfillmentConfig: openbookFulfillmentConfig,
|
|
434
|
+
admin: this.isSubscribed
|
|
435
|
+
? this.getStateAccount().admin
|
|
436
|
+
: this.wallet.publicKey,
|
|
437
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
438
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
439
|
+
},
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
public async initializePerpMarket(
|
|
445
|
+
marketIndex: number,
|
|
446
|
+
priceOracle: PublicKey,
|
|
447
|
+
baseAssetReserve: BN,
|
|
448
|
+
quoteAssetReserve: BN,
|
|
449
|
+
periodicity: BN,
|
|
450
|
+
pegMultiplier: BN = PEG_PRECISION,
|
|
451
|
+
oracleSource: OracleSource = OracleSource.PYTH,
|
|
452
|
+
contractTier: ContractTier = ContractTier.SPECULATIVE,
|
|
453
|
+
marginRatioInitial = 2000,
|
|
454
|
+
marginRatioMaintenance = 500,
|
|
455
|
+
liquidatorFee = 0,
|
|
456
|
+
ifLiquidatorFee = 10000,
|
|
457
|
+
imfFactor = 0,
|
|
458
|
+
activeStatus = true,
|
|
459
|
+
baseSpread = 0,
|
|
460
|
+
maxSpread = 142500,
|
|
461
|
+
maxOpenInterest = ZERO,
|
|
462
|
+
maxRevenueWithdrawPerPeriod = ZERO,
|
|
463
|
+
quoteMaxInsurance = ZERO,
|
|
464
|
+
orderStepSize = BASE_PRECISION.divn(10000),
|
|
465
|
+
orderTickSize = PRICE_PRECISION.divn(100000),
|
|
466
|
+
minOrderSize = BASE_PRECISION.divn(10000),
|
|
467
|
+
concentrationCoefScale = ONE,
|
|
468
|
+
curveUpdateIntensity = 0,
|
|
469
|
+
ammJitIntensity = 0,
|
|
470
|
+
name = DEFAULT_MARKET_NAME
|
|
471
|
+
): Promise<TransactionSignature> {
|
|
472
|
+
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
473
|
+
|
|
474
|
+
const initializeMarketIx = await this.getInitializePerpMarketIx(
|
|
475
|
+
marketIndex,
|
|
476
|
+
priceOracle,
|
|
477
|
+
baseAssetReserve,
|
|
478
|
+
quoteAssetReserve,
|
|
479
|
+
periodicity,
|
|
480
|
+
pegMultiplier,
|
|
481
|
+
oracleSource,
|
|
482
|
+
contractTier,
|
|
483
|
+
marginRatioInitial,
|
|
484
|
+
marginRatioMaintenance,
|
|
485
|
+
liquidatorFee,
|
|
486
|
+
ifLiquidatorFee,
|
|
487
|
+
imfFactor,
|
|
488
|
+
activeStatus,
|
|
489
|
+
baseSpread,
|
|
490
|
+
maxSpread,
|
|
491
|
+
maxOpenInterest,
|
|
492
|
+
maxRevenueWithdrawPerPeriod,
|
|
493
|
+
quoteMaxInsurance,
|
|
494
|
+
orderStepSize,
|
|
495
|
+
orderTickSize,
|
|
496
|
+
minOrderSize,
|
|
497
|
+
concentrationCoefScale,
|
|
498
|
+
curveUpdateIntensity,
|
|
499
|
+
ammJitIntensity,
|
|
500
|
+
name
|
|
501
|
+
);
|
|
502
|
+
const tx = await this.buildTransaction(initializeMarketIx);
|
|
503
|
+
|
|
504
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
505
|
+
|
|
506
|
+
while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
|
|
507
|
+
await this.fetchAccounts();
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
await this.accountSubscriber.addPerpMarket(marketIndex);
|
|
511
|
+
await this.accountSubscriber.addOracle({
|
|
512
|
+
source: oracleSource,
|
|
513
|
+
publicKey: priceOracle,
|
|
514
|
+
});
|
|
515
|
+
await this.accountSubscriber.setPerpOracleMap();
|
|
516
|
+
|
|
517
|
+
return txSig;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
public async getInitializePerpMarketIx(
|
|
521
|
+
marketIndex: number,
|
|
522
|
+
priceOracle: PublicKey,
|
|
523
|
+
baseAssetReserve: BN,
|
|
524
|
+
quoteAssetReserve: BN,
|
|
525
|
+
periodicity: BN,
|
|
526
|
+
pegMultiplier: BN = PEG_PRECISION,
|
|
527
|
+
oracleSource: OracleSource = OracleSource.PYTH,
|
|
528
|
+
contractTier: ContractTier = ContractTier.SPECULATIVE,
|
|
529
|
+
marginRatioInitial = 2000,
|
|
530
|
+
marginRatioMaintenance = 500,
|
|
531
|
+
liquidatorFee = 0,
|
|
532
|
+
ifLiquidatorFee = 10000,
|
|
533
|
+
imfFactor = 0,
|
|
534
|
+
activeStatus = true,
|
|
535
|
+
baseSpread = 0,
|
|
536
|
+
maxSpread = 142500,
|
|
537
|
+
maxOpenInterest = ZERO,
|
|
538
|
+
maxRevenueWithdrawPerPeriod = ZERO,
|
|
539
|
+
quoteMaxInsurance = ZERO,
|
|
540
|
+
orderStepSize = BASE_PRECISION.divn(10000),
|
|
541
|
+
orderTickSize = PRICE_PRECISION.divn(100000),
|
|
542
|
+
minOrderSize = BASE_PRECISION.divn(10000),
|
|
543
|
+
concentrationCoefScale = ONE,
|
|
544
|
+
curveUpdateIntensity = 0,
|
|
545
|
+
ammJitIntensity = 0,
|
|
546
|
+
name = DEFAULT_MARKET_NAME
|
|
547
|
+
): Promise<TransactionInstruction> {
|
|
548
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
549
|
+
this.program.programId,
|
|
550
|
+
marketIndex
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
const nameBuffer = encodeName(name);
|
|
554
|
+
return await this.program.instruction.initializePerpMarket(
|
|
555
|
+
marketIndex,
|
|
556
|
+
baseAssetReserve,
|
|
557
|
+
quoteAssetReserve,
|
|
558
|
+
periodicity,
|
|
559
|
+
pegMultiplier,
|
|
560
|
+
oracleSource,
|
|
561
|
+
contractTier,
|
|
562
|
+
marginRatioInitial,
|
|
563
|
+
marginRatioMaintenance,
|
|
564
|
+
liquidatorFee,
|
|
565
|
+
ifLiquidatorFee,
|
|
566
|
+
imfFactor,
|
|
567
|
+
activeStatus,
|
|
568
|
+
baseSpread,
|
|
569
|
+
maxSpread,
|
|
570
|
+
maxOpenInterest,
|
|
571
|
+
maxRevenueWithdrawPerPeriod,
|
|
572
|
+
quoteMaxInsurance,
|
|
573
|
+
orderStepSize,
|
|
574
|
+
orderTickSize,
|
|
575
|
+
minOrderSize,
|
|
576
|
+
concentrationCoefScale,
|
|
577
|
+
curveUpdateIntensity,
|
|
578
|
+
ammJitIntensity,
|
|
579
|
+
nameBuffer,
|
|
580
|
+
{
|
|
581
|
+
accounts: {
|
|
582
|
+
state: await this.getStatePublicKey(),
|
|
583
|
+
admin: this.isSubscribed
|
|
584
|
+
? this.getStateAccount().admin
|
|
585
|
+
: this.wallet.publicKey,
|
|
586
|
+
oracle: priceOracle,
|
|
587
|
+
perpMarket: perpMarketPublicKey,
|
|
588
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
589
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
590
|
+
},
|
|
591
|
+
}
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
public async initializePredictionMarket(
|
|
596
|
+
perpMarketIndex: number
|
|
597
|
+
): Promise<TransactionSignature> {
|
|
598
|
+
const updatePerpMarketConcentrationCoefIx =
|
|
599
|
+
await this.getInitializePredictionMarketIx(perpMarketIndex);
|
|
600
|
+
|
|
601
|
+
const tx = await this.buildTransaction(updatePerpMarketConcentrationCoefIx);
|
|
602
|
+
|
|
603
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
604
|
+
|
|
605
|
+
return txSig;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
public async getInitializePredictionMarketIx(
|
|
609
|
+
perpMarketIndex: number
|
|
610
|
+
): Promise<TransactionInstruction> {
|
|
611
|
+
return await this.program.instruction.initializePredictionMarket({
|
|
612
|
+
accounts: {
|
|
613
|
+
state: await this.getStatePublicKey(),
|
|
614
|
+
admin: this.isSubscribed
|
|
615
|
+
? this.getStateAccount().admin
|
|
616
|
+
: this.wallet.publicKey,
|
|
617
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
618
|
+
this.program.programId,
|
|
619
|
+
perpMarketIndex
|
|
620
|
+
),
|
|
621
|
+
},
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
public async deleteInitializedPerpMarket(
|
|
626
|
+
marketIndex: number
|
|
627
|
+
): Promise<TransactionSignature> {
|
|
628
|
+
const deleteInitializeMarketIx =
|
|
629
|
+
await this.getDeleteInitializedPerpMarketIx(marketIndex);
|
|
630
|
+
|
|
631
|
+
const tx = await this.buildTransaction(deleteInitializeMarketIx);
|
|
632
|
+
|
|
633
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
634
|
+
|
|
635
|
+
return txSig;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
public async getDeleteInitializedPerpMarketIx(
|
|
639
|
+
marketIndex: number
|
|
640
|
+
): Promise<TransactionInstruction> {
|
|
641
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
642
|
+
this.program.programId,
|
|
643
|
+
marketIndex
|
|
644
|
+
);
|
|
645
|
+
|
|
646
|
+
return await this.program.instruction.deleteInitializedPerpMarket(
|
|
647
|
+
marketIndex,
|
|
648
|
+
{
|
|
649
|
+
accounts: {
|
|
650
|
+
state: await this.getStatePublicKey(),
|
|
651
|
+
admin: this.isSubscribed
|
|
652
|
+
? this.getStateAccount().admin
|
|
653
|
+
: this.wallet.publicKey,
|
|
654
|
+
perpMarket: perpMarketPublicKey,
|
|
655
|
+
},
|
|
656
|
+
}
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
public async moveAmmPrice(
|
|
661
|
+
perpMarketIndex: number,
|
|
662
|
+
baseAssetReserve: BN,
|
|
663
|
+
quoteAssetReserve: BN,
|
|
664
|
+
sqrtK?: BN
|
|
665
|
+
): Promise<TransactionSignature> {
|
|
666
|
+
const moveAmmPriceIx = await this.getMoveAmmPriceIx(
|
|
667
|
+
perpMarketIndex,
|
|
668
|
+
baseAssetReserve,
|
|
669
|
+
quoteAssetReserve,
|
|
670
|
+
sqrtK
|
|
671
|
+
);
|
|
672
|
+
|
|
673
|
+
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
674
|
+
|
|
675
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
676
|
+
|
|
677
|
+
return txSig;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
public async getMoveAmmPriceIx(
|
|
681
|
+
perpMarketIndex: number,
|
|
682
|
+
baseAssetReserve: BN,
|
|
683
|
+
quoteAssetReserve: BN,
|
|
684
|
+
sqrtK?: BN
|
|
685
|
+
): Promise<TransactionInstruction> {
|
|
686
|
+
const marketPublicKey = await getPerpMarketPublicKey(
|
|
687
|
+
this.program.programId,
|
|
688
|
+
perpMarketIndex
|
|
689
|
+
);
|
|
690
|
+
|
|
691
|
+
if (sqrtK == undefined) {
|
|
692
|
+
sqrtK = squareRootBN(baseAssetReserve.mul(quoteAssetReserve));
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
return await this.program.instruction.moveAmmPrice(
|
|
696
|
+
baseAssetReserve,
|
|
697
|
+
quoteAssetReserve,
|
|
698
|
+
sqrtK,
|
|
699
|
+
{
|
|
700
|
+
accounts: {
|
|
701
|
+
state: await this.getStatePublicKey(),
|
|
702
|
+
admin: this.isSubscribed
|
|
703
|
+
? this.getStateAccount().admin
|
|
704
|
+
: this.wallet.publicKey,
|
|
705
|
+
perpMarket: marketPublicKey,
|
|
706
|
+
},
|
|
707
|
+
}
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
public async updateK(
|
|
712
|
+
perpMarketIndex: number,
|
|
713
|
+
sqrtK: BN
|
|
714
|
+
): Promise<TransactionSignature> {
|
|
715
|
+
const updateKIx = await this.getUpdateKIx(perpMarketIndex, sqrtK);
|
|
716
|
+
|
|
717
|
+
const tx = await this.buildTransaction(updateKIx);
|
|
718
|
+
|
|
719
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
720
|
+
|
|
721
|
+
return txSig;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
public async getUpdateKIx(
|
|
725
|
+
perpMarketIndex: number,
|
|
726
|
+
sqrtK: BN
|
|
727
|
+
): Promise<TransactionInstruction> {
|
|
728
|
+
return await this.program.instruction.updateK(sqrtK, {
|
|
729
|
+
accounts: {
|
|
730
|
+
state: await this.getStatePublicKey(),
|
|
731
|
+
admin: this.isSubscribed
|
|
732
|
+
? this.getStateAccount().admin
|
|
733
|
+
: this.wallet.publicKey,
|
|
734
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
735
|
+
this.program.programId,
|
|
736
|
+
perpMarketIndex
|
|
737
|
+
),
|
|
738
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
739
|
+
},
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
public async recenterPerpMarketAmm(
|
|
744
|
+
perpMarketIndex: number,
|
|
745
|
+
pegMultiplier: BN,
|
|
746
|
+
sqrtK: BN
|
|
747
|
+
): Promise<TransactionSignature> {
|
|
748
|
+
const recenterPerpMarketAmmIx = await this.getRecenterPerpMarketAmmIx(
|
|
749
|
+
perpMarketIndex,
|
|
750
|
+
pegMultiplier,
|
|
751
|
+
sqrtK
|
|
752
|
+
);
|
|
753
|
+
|
|
754
|
+
const tx = await this.buildTransaction(recenterPerpMarketAmmIx);
|
|
755
|
+
|
|
756
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
757
|
+
|
|
758
|
+
return txSig;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
public async getRecenterPerpMarketAmmIx(
|
|
762
|
+
perpMarketIndex: number,
|
|
763
|
+
pegMultiplier: BN,
|
|
764
|
+
sqrtK: BN
|
|
765
|
+
): Promise<TransactionInstruction> {
|
|
766
|
+
const marketPublicKey = await getPerpMarketPublicKey(
|
|
767
|
+
this.program.programId,
|
|
768
|
+
perpMarketIndex
|
|
769
|
+
);
|
|
770
|
+
|
|
771
|
+
return await this.program.instruction.recenterPerpMarketAmm(
|
|
772
|
+
pegMultiplier,
|
|
773
|
+
sqrtK,
|
|
774
|
+
{
|
|
775
|
+
accounts: {
|
|
776
|
+
state: await this.getStatePublicKey(),
|
|
777
|
+
admin: this.isSubscribed
|
|
778
|
+
? this.getStateAccount().admin
|
|
779
|
+
: this.wallet.publicKey,
|
|
780
|
+
perpMarket: marketPublicKey,
|
|
781
|
+
},
|
|
782
|
+
}
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
public async updatePerpMarketConcentrationScale(
|
|
787
|
+
perpMarketIndex: number,
|
|
788
|
+
concentrationScale: BN
|
|
789
|
+
): Promise<TransactionSignature> {
|
|
790
|
+
const updatePerpMarketConcentrationCoefIx =
|
|
791
|
+
await this.getUpdatePerpMarketConcentrationScaleIx(
|
|
792
|
+
perpMarketIndex,
|
|
793
|
+
concentrationScale
|
|
794
|
+
);
|
|
795
|
+
|
|
796
|
+
const tx = await this.buildTransaction(updatePerpMarketConcentrationCoefIx);
|
|
797
|
+
|
|
798
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
799
|
+
|
|
800
|
+
return txSig;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
public async getUpdatePerpMarketConcentrationScaleIx(
|
|
804
|
+
perpMarketIndex: number,
|
|
805
|
+
concentrationScale: BN
|
|
806
|
+
): Promise<TransactionInstruction> {
|
|
807
|
+
return await this.program.instruction.updatePerpMarketConcentrationCoef(
|
|
808
|
+
concentrationScale,
|
|
809
|
+
{
|
|
810
|
+
accounts: {
|
|
811
|
+
state: await this.getStatePublicKey(),
|
|
812
|
+
admin: this.isSubscribed
|
|
813
|
+
? this.getStateAccount().admin
|
|
814
|
+
: this.wallet.publicKey,
|
|
815
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
816
|
+
this.program.programId,
|
|
817
|
+
perpMarketIndex
|
|
818
|
+
),
|
|
819
|
+
},
|
|
820
|
+
}
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
public async moveAmmToPrice(
|
|
825
|
+
perpMarketIndex: number,
|
|
826
|
+
targetPrice: BN
|
|
827
|
+
): Promise<TransactionSignature> {
|
|
828
|
+
const moveAmmPriceIx = await this.getMoveAmmToPriceIx(
|
|
829
|
+
perpMarketIndex,
|
|
830
|
+
targetPrice
|
|
831
|
+
);
|
|
832
|
+
|
|
833
|
+
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
834
|
+
|
|
835
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
836
|
+
|
|
837
|
+
return txSig;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
public async getMoveAmmToPriceIx(
|
|
841
|
+
perpMarketIndex: number,
|
|
842
|
+
targetPrice: BN
|
|
843
|
+
): Promise<TransactionInstruction> {
|
|
844
|
+
const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
|
|
845
|
+
|
|
846
|
+
const [direction, tradeSize, _] = calculateTargetPriceTrade(
|
|
847
|
+
perpMarket,
|
|
848
|
+
targetPrice,
|
|
849
|
+
new BN(1000),
|
|
850
|
+
'quote',
|
|
851
|
+
undefined //todo
|
|
852
|
+
);
|
|
853
|
+
|
|
854
|
+
const [newQuoteAssetAmount, newBaseAssetAmount] =
|
|
855
|
+
calculateAmmReservesAfterSwap(
|
|
856
|
+
perpMarket.amm,
|
|
857
|
+
'quote',
|
|
858
|
+
tradeSize,
|
|
859
|
+
getSwapDirection('quote', direction)
|
|
860
|
+
);
|
|
861
|
+
|
|
862
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
863
|
+
this.program.programId,
|
|
864
|
+
perpMarketIndex
|
|
865
|
+
);
|
|
866
|
+
|
|
867
|
+
return await this.program.instruction.moveAmmPrice(
|
|
868
|
+
newBaseAssetAmount,
|
|
869
|
+
newQuoteAssetAmount,
|
|
870
|
+
perpMarket.amm.sqrtK,
|
|
871
|
+
{
|
|
872
|
+
accounts: {
|
|
873
|
+
state: await this.getStatePublicKey(),
|
|
874
|
+
admin: this.isSubscribed
|
|
875
|
+
? this.getStateAccount().admin
|
|
876
|
+
: this.wallet.publicKey,
|
|
877
|
+
perpMarket: perpMarketPublicKey,
|
|
878
|
+
},
|
|
879
|
+
}
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
public async repegAmmCurve(
|
|
884
|
+
newPeg: BN,
|
|
885
|
+
perpMarketIndex: number
|
|
886
|
+
): Promise<TransactionSignature> {
|
|
887
|
+
const repegAmmCurveIx = await this.getRepegAmmCurveIx(
|
|
888
|
+
newPeg,
|
|
889
|
+
perpMarketIndex
|
|
890
|
+
);
|
|
891
|
+
|
|
892
|
+
const tx = await this.buildTransaction(repegAmmCurveIx);
|
|
893
|
+
|
|
894
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
895
|
+
|
|
896
|
+
return txSig;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
public async getRepegAmmCurveIx(
|
|
900
|
+
newPeg: BN,
|
|
901
|
+
perpMarketIndex: number
|
|
902
|
+
): Promise<TransactionInstruction> {
|
|
903
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
904
|
+
this.program.programId,
|
|
905
|
+
perpMarketIndex
|
|
906
|
+
);
|
|
907
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
908
|
+
|
|
909
|
+
return await this.program.instruction.repegAmmCurve(newPeg, {
|
|
910
|
+
accounts: {
|
|
911
|
+
state: await this.getStatePublicKey(),
|
|
912
|
+
admin: this.isSubscribed
|
|
913
|
+
? this.getStateAccount().admin
|
|
914
|
+
: this.wallet.publicKey,
|
|
915
|
+
oracle: ammData.oracle,
|
|
916
|
+
perpMarket: perpMarketPublicKey,
|
|
917
|
+
},
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
public async updatePerpMarketAmmOracleTwap(
|
|
922
|
+
perpMarketIndex: number
|
|
923
|
+
): Promise<TransactionSignature> {
|
|
924
|
+
const updatePerpMarketAmmOracleTwapIx =
|
|
925
|
+
await this.getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
926
|
+
|
|
927
|
+
const tx = await this.buildTransaction(updatePerpMarketAmmOracleTwapIx);
|
|
928
|
+
|
|
929
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
930
|
+
|
|
931
|
+
return txSig;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
public async getUpdatePerpMarketAmmOracleTwapIx(
|
|
935
|
+
perpMarketIndex: number
|
|
936
|
+
): Promise<TransactionInstruction> {
|
|
937
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
938
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
939
|
+
this.program.programId,
|
|
940
|
+
perpMarketIndex
|
|
941
|
+
);
|
|
942
|
+
|
|
943
|
+
return await this.program.instruction.updatePerpMarketAmmOracleTwap({
|
|
944
|
+
accounts: {
|
|
945
|
+
state: await this.getStatePublicKey(),
|
|
946
|
+
admin: this.isSubscribed
|
|
947
|
+
? this.getStateAccount().admin
|
|
948
|
+
: this.wallet.publicKey,
|
|
949
|
+
oracle: ammData.oracle,
|
|
950
|
+
perpMarket: perpMarketPublicKey,
|
|
951
|
+
},
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
public async resetPerpMarketAmmOracleTwap(
|
|
956
|
+
perpMarketIndex: number
|
|
957
|
+
): Promise<TransactionSignature> {
|
|
958
|
+
const resetPerpMarketAmmOracleTwapIx =
|
|
959
|
+
await this.getResetPerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
960
|
+
|
|
961
|
+
const tx = await this.buildTransaction(resetPerpMarketAmmOracleTwapIx);
|
|
962
|
+
|
|
963
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
964
|
+
|
|
965
|
+
return txSig;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
public async getResetPerpMarketAmmOracleTwapIx(
|
|
969
|
+
perpMarketIndex: number
|
|
970
|
+
): Promise<TransactionInstruction> {
|
|
971
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
972
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
973
|
+
this.program.programId,
|
|
974
|
+
perpMarketIndex
|
|
975
|
+
);
|
|
976
|
+
|
|
977
|
+
return await this.program.instruction.resetPerpMarketAmmOracleTwap({
|
|
978
|
+
accounts: {
|
|
979
|
+
state: await this.getStatePublicKey(),
|
|
980
|
+
admin: this.isSubscribed
|
|
981
|
+
? this.getStateAccount().admin
|
|
982
|
+
: this.wallet.publicKey,
|
|
983
|
+
oracle: ammData.oracle,
|
|
984
|
+
perpMarket: perpMarketPublicKey,
|
|
985
|
+
},
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
public async depositIntoPerpMarketFeePool(
|
|
990
|
+
perpMarketIndex: number,
|
|
991
|
+
amount: BN,
|
|
992
|
+
sourceVault: PublicKey
|
|
993
|
+
): Promise<TransactionSignature> {
|
|
994
|
+
const depositIntoPerpMarketFeePoolIx =
|
|
995
|
+
await this.getDepositIntoPerpMarketFeePoolIx(
|
|
996
|
+
perpMarketIndex,
|
|
997
|
+
amount,
|
|
998
|
+
sourceVault
|
|
999
|
+
);
|
|
1000
|
+
|
|
1001
|
+
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
1002
|
+
|
|
1003
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1004
|
+
|
|
1005
|
+
return txSig;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
public async getDepositIntoPerpMarketFeePoolIx(
|
|
1009
|
+
perpMarketIndex: number,
|
|
1010
|
+
amount: BN,
|
|
1011
|
+
sourceVault: PublicKey
|
|
1012
|
+
): Promise<TransactionInstruction> {
|
|
1013
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
1014
|
+
|
|
1015
|
+
return await this.program.instruction.depositIntoPerpMarketFeePool(amount, {
|
|
1016
|
+
accounts: {
|
|
1017
|
+
admin: this.isSubscribed
|
|
1018
|
+
? this.getStateAccount().admin
|
|
1019
|
+
: this.wallet.publicKey,
|
|
1020
|
+
state: await this.getStatePublicKey(),
|
|
1021
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1022
|
+
this.program.programId,
|
|
1023
|
+
perpMarketIndex
|
|
1024
|
+
),
|
|
1025
|
+
sourceVault,
|
|
1026
|
+
driftSigner: this.getSignerPublicKey(),
|
|
1027
|
+
quoteSpotMarket: spotMarket.pubkey,
|
|
1028
|
+
spotMarketVault: spotMarket.vault,
|
|
1029
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1030
|
+
},
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
public async depositIntoSpotMarketVault(
|
|
1035
|
+
spotMarketIndex: number,
|
|
1036
|
+
amount: BN,
|
|
1037
|
+
sourceVault: PublicKey
|
|
1038
|
+
): Promise<TransactionSignature> {
|
|
1039
|
+
const depositIntoPerpMarketFeePoolIx =
|
|
1040
|
+
await this.getDepositIntoSpotMarketVaultIx(
|
|
1041
|
+
spotMarketIndex,
|
|
1042
|
+
amount,
|
|
1043
|
+
sourceVault
|
|
1044
|
+
);
|
|
1045
|
+
|
|
1046
|
+
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
1047
|
+
|
|
1048
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1049
|
+
|
|
1050
|
+
return txSig;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
public async getDepositIntoSpotMarketVaultIx(
|
|
1054
|
+
spotMarketIndex: number,
|
|
1055
|
+
amount: BN,
|
|
1056
|
+
sourceVault: PublicKey
|
|
1057
|
+
): Promise<TransactionInstruction> {
|
|
1058
|
+
const spotMarket = this.getSpotMarketAccount(spotMarketIndex);
|
|
1059
|
+
|
|
1060
|
+
const remainingAccounts = [];
|
|
1061
|
+
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
1062
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
1063
|
+
return await this.program.instruction.depositIntoSpotMarketVault(amount, {
|
|
1064
|
+
accounts: {
|
|
1065
|
+
admin: this.wallet.publicKey,
|
|
1066
|
+
state: await this.getStatePublicKey(),
|
|
1067
|
+
sourceVault,
|
|
1068
|
+
spotMarket: spotMarket.pubkey,
|
|
1069
|
+
spotMarketVault: spotMarket.vault,
|
|
1070
|
+
tokenProgram,
|
|
1071
|
+
},
|
|
1072
|
+
remainingAccounts,
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
public async updateAdmin(admin: PublicKey): Promise<TransactionSignature> {
|
|
1077
|
+
const updateAdminIx = await this.getUpdateAdminIx(admin);
|
|
1078
|
+
|
|
1079
|
+
const tx = await this.buildTransaction(updateAdminIx);
|
|
1080
|
+
|
|
1081
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1082
|
+
|
|
1083
|
+
return txSig;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
public async getUpdateAdminIx(
|
|
1087
|
+
admin: PublicKey
|
|
1088
|
+
): Promise<TransactionInstruction> {
|
|
1089
|
+
return await this.program.instruction.updateAdmin(admin, {
|
|
1090
|
+
accounts: {
|
|
1091
|
+
admin: this.isSubscribed
|
|
1092
|
+
? this.getStateAccount().admin
|
|
1093
|
+
: this.wallet.publicKey,
|
|
1094
|
+
state: await this.getStatePublicKey(),
|
|
1095
|
+
},
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
public async updatePerpMarketCurveUpdateIntensity(
|
|
1100
|
+
perpMarketIndex: number,
|
|
1101
|
+
curveUpdateIntensity: number
|
|
1102
|
+
): Promise<TransactionSignature> {
|
|
1103
|
+
const updatePerpMarketCurveUpdateIntensityIx =
|
|
1104
|
+
await this.getUpdatePerpMarketCurveUpdateIntensityIx(
|
|
1105
|
+
perpMarketIndex,
|
|
1106
|
+
curveUpdateIntensity
|
|
1107
|
+
);
|
|
1108
|
+
|
|
1109
|
+
const tx = await this.buildTransaction(
|
|
1110
|
+
updatePerpMarketCurveUpdateIntensityIx
|
|
1111
|
+
);
|
|
1112
|
+
|
|
1113
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1114
|
+
|
|
1115
|
+
return txSig;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
public async getUpdatePerpMarketCurveUpdateIntensityIx(
|
|
1119
|
+
perpMarketIndex: number,
|
|
1120
|
+
curveUpdateIntensity: number
|
|
1121
|
+
): Promise<TransactionInstruction> {
|
|
1122
|
+
return await this.program.instruction.updatePerpMarketCurveUpdateIntensity(
|
|
1123
|
+
curveUpdateIntensity,
|
|
1124
|
+
{
|
|
1125
|
+
accounts: {
|
|
1126
|
+
admin: this.isSubscribed
|
|
1127
|
+
? this.getStateAccount().admin
|
|
1128
|
+
: this.wallet.publicKey,
|
|
1129
|
+
state: await this.getStatePublicKey(),
|
|
1130
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1131
|
+
this.program.programId,
|
|
1132
|
+
perpMarketIndex
|
|
1133
|
+
),
|
|
1134
|
+
},
|
|
1135
|
+
}
|
|
1136
|
+
);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
public async updatePerpMarketTargetBaseAssetAmountPerLp(
|
|
1140
|
+
perpMarketIndex: number,
|
|
1141
|
+
targetBaseAssetAmountPerLP: number
|
|
1142
|
+
): Promise<TransactionSignature> {
|
|
1143
|
+
const updatePerpMarketTargetBaseAssetAmountPerLpIx =
|
|
1144
|
+
await this.getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(
|
|
1145
|
+
perpMarketIndex,
|
|
1146
|
+
targetBaseAssetAmountPerLP
|
|
1147
|
+
);
|
|
1148
|
+
|
|
1149
|
+
const tx = await this.buildTransaction(
|
|
1150
|
+
updatePerpMarketTargetBaseAssetAmountPerLpIx
|
|
1151
|
+
);
|
|
1152
|
+
|
|
1153
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1154
|
+
|
|
1155
|
+
return txSig;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
public async updatePerpMarketAmmSummaryStats(
|
|
1159
|
+
perpMarketIndex: number,
|
|
1160
|
+
updateAmmSummaryStats?: boolean,
|
|
1161
|
+
quoteAssetAmountWithUnsettledLp?: BN,
|
|
1162
|
+
netUnsettledFundingPnl?: BN
|
|
1163
|
+
): Promise<TransactionSignature> {
|
|
1164
|
+
const updatePerpMarketMarginRatioIx =
|
|
1165
|
+
await this.getUpdatePerpMarketAmmSummaryStatsIx(
|
|
1166
|
+
perpMarketIndex,
|
|
1167
|
+
updateAmmSummaryStats,
|
|
1168
|
+
quoteAssetAmountWithUnsettledLp,
|
|
1169
|
+
netUnsettledFundingPnl
|
|
1170
|
+
);
|
|
1171
|
+
|
|
1172
|
+
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
1173
|
+
|
|
1174
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1175
|
+
|
|
1176
|
+
return txSig;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
public async getUpdatePerpMarketAmmSummaryStatsIx(
|
|
1180
|
+
perpMarketIndex: number,
|
|
1181
|
+
updateAmmSummaryStats?: boolean,
|
|
1182
|
+
quoteAssetAmountWithUnsettledLp?: BN,
|
|
1183
|
+
netUnsettledFundingPnl?: BN
|
|
1184
|
+
): Promise<TransactionInstruction> {
|
|
1185
|
+
return await this.program.instruction.updatePerpMarketAmmSummaryStats(
|
|
1186
|
+
{
|
|
1187
|
+
updateAmmSummaryStats: updateAmmSummaryStats ?? null,
|
|
1188
|
+
quoteAssetAmountWithUnsettledLp:
|
|
1189
|
+
quoteAssetAmountWithUnsettledLp ?? null,
|
|
1190
|
+
netUnsettledFundingPnl: netUnsettledFundingPnl ?? null,
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
accounts: {
|
|
1194
|
+
admin: this.wallet.publicKey,
|
|
1195
|
+
state: await this.getStatePublicKey(),
|
|
1196
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1197
|
+
this.program.programId,
|
|
1198
|
+
perpMarketIndex
|
|
1199
|
+
),
|
|
1200
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1201
|
+
this.program.programId,
|
|
1202
|
+
QUOTE_SPOT_MARKET_INDEX
|
|
1203
|
+
),
|
|
1204
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
1205
|
+
},
|
|
1206
|
+
}
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
public async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(
|
|
1211
|
+
perpMarketIndex: number,
|
|
1212
|
+
targetBaseAssetAmountPerLP: number
|
|
1213
|
+
): Promise<TransactionInstruction> {
|
|
1214
|
+
return await this.program.instruction.updatePerpMarketTargetBaseAssetAmountPerLp(
|
|
1215
|
+
targetBaseAssetAmountPerLP,
|
|
1216
|
+
{
|
|
1217
|
+
accounts: {
|
|
1218
|
+
admin: this.isSubscribed
|
|
1219
|
+
? this.getStateAccount().admin
|
|
1220
|
+
: this.wallet.publicKey,
|
|
1221
|
+
state: await this.getStatePublicKey(),
|
|
1222
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1223
|
+
this.program.programId,
|
|
1224
|
+
perpMarketIndex
|
|
1225
|
+
),
|
|
1226
|
+
},
|
|
1227
|
+
}
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
public async updatePerpMarketMarginRatio(
|
|
1232
|
+
perpMarketIndex: number,
|
|
1233
|
+
marginRatioInitial: number,
|
|
1234
|
+
marginRatioMaintenance: number
|
|
1235
|
+
): Promise<TransactionSignature> {
|
|
1236
|
+
const updatePerpMarketMarginRatioIx =
|
|
1237
|
+
await this.getUpdatePerpMarketMarginRatioIx(
|
|
1238
|
+
perpMarketIndex,
|
|
1239
|
+
marginRatioInitial,
|
|
1240
|
+
marginRatioMaintenance
|
|
1241
|
+
);
|
|
1242
|
+
|
|
1243
|
+
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
1244
|
+
|
|
1245
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1246
|
+
|
|
1247
|
+
return txSig;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
public async getUpdatePerpMarketMarginRatioIx(
|
|
1251
|
+
perpMarketIndex: number,
|
|
1252
|
+
marginRatioInitial: number,
|
|
1253
|
+
marginRatioMaintenance: number
|
|
1254
|
+
): Promise<TransactionInstruction> {
|
|
1255
|
+
return await this.program.instruction.updatePerpMarketMarginRatio(
|
|
1256
|
+
marginRatioInitial,
|
|
1257
|
+
marginRatioMaintenance,
|
|
1258
|
+
{
|
|
1259
|
+
accounts: {
|
|
1260
|
+
admin: this.isSubscribed
|
|
1261
|
+
? this.getStateAccount().admin
|
|
1262
|
+
: this.wallet.publicKey,
|
|
1263
|
+
state: await this.getStatePublicKey(),
|
|
1264
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1265
|
+
this.program.programId,
|
|
1266
|
+
perpMarketIndex
|
|
1267
|
+
),
|
|
1268
|
+
},
|
|
1269
|
+
}
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
public async updatePerpMarketHighLeverageMarginRatio(
|
|
1274
|
+
perpMarketIndex: number,
|
|
1275
|
+
marginRatioInitial: number,
|
|
1276
|
+
marginRatioMaintenance: number
|
|
1277
|
+
): Promise<TransactionSignature> {
|
|
1278
|
+
const updatePerpMarketHighLeverageMarginRatioIx =
|
|
1279
|
+
await this.getUpdatePerpMarketHighLeverageMarginRatioIx(
|
|
1280
|
+
perpMarketIndex,
|
|
1281
|
+
marginRatioInitial,
|
|
1282
|
+
marginRatioMaintenance
|
|
1283
|
+
);
|
|
1284
|
+
|
|
1285
|
+
const tx = await this.buildTransaction(
|
|
1286
|
+
updatePerpMarketHighLeverageMarginRatioIx
|
|
1287
|
+
);
|
|
1288
|
+
|
|
1289
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1290
|
+
|
|
1291
|
+
return txSig;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
public async getUpdatePerpMarketHighLeverageMarginRatioIx(
|
|
1295
|
+
perpMarketIndex: number,
|
|
1296
|
+
marginRatioInitial: number,
|
|
1297
|
+
marginRatioMaintenance: number
|
|
1298
|
+
): Promise<TransactionInstruction> {
|
|
1299
|
+
return await this.program.instruction.updatePerpMarketHighLeverageMarginRatio(
|
|
1300
|
+
marginRatioInitial,
|
|
1301
|
+
marginRatioMaintenance,
|
|
1302
|
+
{
|
|
1303
|
+
accounts: {
|
|
1304
|
+
admin: this.isSubscribed
|
|
1305
|
+
? this.getStateAccount().admin
|
|
1306
|
+
: this.wallet.publicKey,
|
|
1307
|
+
state: await this.getStatePublicKey(),
|
|
1308
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1309
|
+
this.program.programId,
|
|
1310
|
+
perpMarketIndex
|
|
1311
|
+
),
|
|
1312
|
+
},
|
|
1313
|
+
}
|
|
1314
|
+
);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
public async updatePerpMarketImfFactor(
|
|
1318
|
+
perpMarketIndex: number,
|
|
1319
|
+
imfFactor: number,
|
|
1320
|
+
unrealizedPnlImfFactor: number
|
|
1321
|
+
): Promise<TransactionSignature> {
|
|
1322
|
+
const updatePerpMarketImfFactorIx =
|
|
1323
|
+
await this.getUpdatePerpMarketImfFactorIx(
|
|
1324
|
+
perpMarketIndex,
|
|
1325
|
+
imfFactor,
|
|
1326
|
+
unrealizedPnlImfFactor
|
|
1327
|
+
);
|
|
1328
|
+
|
|
1329
|
+
const tx = await this.buildTransaction(updatePerpMarketImfFactorIx);
|
|
1330
|
+
|
|
1331
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1332
|
+
|
|
1333
|
+
return txSig;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
public async getUpdatePerpMarketImfFactorIx(
|
|
1337
|
+
perpMarketIndex: number,
|
|
1338
|
+
imfFactor: number,
|
|
1339
|
+
unrealizedPnlImfFactor: number
|
|
1340
|
+
): Promise<TransactionInstruction> {
|
|
1341
|
+
return await this.program.instruction.updatePerpMarketImfFactor(
|
|
1342
|
+
imfFactor,
|
|
1343
|
+
unrealizedPnlImfFactor,
|
|
1344
|
+
{
|
|
1345
|
+
accounts: {
|
|
1346
|
+
admin: this.isSubscribed
|
|
1347
|
+
? this.getStateAccount().admin
|
|
1348
|
+
: this.wallet.publicKey,
|
|
1349
|
+
state: await this.getStatePublicKey(),
|
|
1350
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1351
|
+
this.program.programId,
|
|
1352
|
+
perpMarketIndex
|
|
1353
|
+
),
|
|
1354
|
+
},
|
|
1355
|
+
}
|
|
1356
|
+
);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
public async updatePerpMarketBaseSpread(
|
|
1360
|
+
perpMarketIndex: number,
|
|
1361
|
+
baseSpread: number
|
|
1362
|
+
): Promise<TransactionSignature> {
|
|
1363
|
+
const updatePerpMarketBaseSpreadIx =
|
|
1364
|
+
await this.getUpdatePerpMarketBaseSpreadIx(perpMarketIndex, baseSpread);
|
|
1365
|
+
|
|
1366
|
+
const tx = await this.buildTransaction(updatePerpMarketBaseSpreadIx);
|
|
1367
|
+
|
|
1368
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1369
|
+
|
|
1370
|
+
return txSig;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
public async getUpdatePerpMarketBaseSpreadIx(
|
|
1374
|
+
perpMarketIndex: number,
|
|
1375
|
+
baseSpread: number
|
|
1376
|
+
): Promise<TransactionInstruction> {
|
|
1377
|
+
return await this.program.instruction.updatePerpMarketBaseSpread(
|
|
1378
|
+
baseSpread,
|
|
1379
|
+
{
|
|
1380
|
+
accounts: {
|
|
1381
|
+
admin: this.isSubscribed
|
|
1382
|
+
? this.getStateAccount().admin
|
|
1383
|
+
: this.wallet.publicKey,
|
|
1384
|
+
state: await this.getStatePublicKey(),
|
|
1385
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1386
|
+
this.program.programId,
|
|
1387
|
+
perpMarketIndex
|
|
1388
|
+
),
|
|
1389
|
+
},
|
|
1390
|
+
}
|
|
1391
|
+
);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
public async updateAmmJitIntensity(
|
|
1395
|
+
perpMarketIndex: number,
|
|
1396
|
+
ammJitIntensity: number
|
|
1397
|
+
): Promise<TransactionSignature> {
|
|
1398
|
+
const updateAmmJitIntensityIx = await this.getUpdateAmmJitIntensityIx(
|
|
1399
|
+
perpMarketIndex,
|
|
1400
|
+
ammJitIntensity
|
|
1401
|
+
);
|
|
1402
|
+
|
|
1403
|
+
const tx = await this.buildTransaction(updateAmmJitIntensityIx);
|
|
1404
|
+
|
|
1405
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1406
|
+
|
|
1407
|
+
return txSig;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
public async getUpdateAmmJitIntensityIx(
|
|
1411
|
+
perpMarketIndex: number,
|
|
1412
|
+
ammJitIntensity: number
|
|
1413
|
+
): Promise<TransactionInstruction> {
|
|
1414
|
+
return await this.program.instruction.updateAmmJitIntensity(
|
|
1415
|
+
ammJitIntensity,
|
|
1416
|
+
{
|
|
1417
|
+
accounts: {
|
|
1418
|
+
admin: this.isSubscribed
|
|
1419
|
+
? this.getStateAccount().admin
|
|
1420
|
+
: this.wallet.publicKey,
|
|
1421
|
+
state: await this.getStatePublicKey(),
|
|
1422
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1423
|
+
this.program.programId,
|
|
1424
|
+
perpMarketIndex
|
|
1425
|
+
),
|
|
1426
|
+
},
|
|
1427
|
+
}
|
|
1428
|
+
);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
public async updatePerpMarketName(
|
|
1432
|
+
perpMarketIndex: number,
|
|
1433
|
+
name: string
|
|
1434
|
+
): Promise<TransactionSignature> {
|
|
1435
|
+
const updatePerpMarketNameIx = await this.getUpdatePerpMarketNameIx(
|
|
1436
|
+
perpMarketIndex,
|
|
1437
|
+
name
|
|
1438
|
+
);
|
|
1439
|
+
|
|
1440
|
+
const tx = await this.buildTransaction(updatePerpMarketNameIx);
|
|
1441
|
+
|
|
1442
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1443
|
+
|
|
1444
|
+
return txSig;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
public async getUpdatePerpMarketNameIx(
|
|
1448
|
+
perpMarketIndex: number,
|
|
1449
|
+
name: string
|
|
1450
|
+
): Promise<TransactionInstruction> {
|
|
1451
|
+
const nameBuffer = encodeName(name);
|
|
1452
|
+
return await this.program.instruction.updatePerpMarketName(nameBuffer, {
|
|
1453
|
+
accounts: {
|
|
1454
|
+
admin: this.isSubscribed
|
|
1455
|
+
? this.getStateAccount().admin
|
|
1456
|
+
: this.wallet.publicKey,
|
|
1457
|
+
state: await this.getStatePublicKey(),
|
|
1458
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
1459
|
+
this.program.programId,
|
|
1460
|
+
perpMarketIndex
|
|
1461
|
+
),
|
|
1462
|
+
},
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
public async updateSpotMarketName(
|
|
1467
|
+
spotMarketIndex: number,
|
|
1468
|
+
name: string
|
|
1469
|
+
): Promise<TransactionSignature> {
|
|
1470
|
+
const updateSpotMarketNameIx = await this.getUpdateSpotMarketNameIx(
|
|
1471
|
+
spotMarketIndex,
|
|
1472
|
+
name
|
|
1473
|
+
);
|
|
1474
|
+
|
|
1475
|
+
const tx = await this.buildTransaction(updateSpotMarketNameIx);
|
|
1476
|
+
|
|
1477
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1478
|
+
|
|
1479
|
+
return txSig;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
public async getUpdateSpotMarketNameIx(
|
|
1483
|
+
spotMarketIndex: number,
|
|
1484
|
+
name: string
|
|
1485
|
+
): Promise<TransactionInstruction> {
|
|
1486
|
+
const nameBuffer = encodeName(name);
|
|
1487
|
+
return await this.program.instruction.updateSpotMarketName(nameBuffer, {
|
|
1488
|
+
accounts: {
|
|
1489
|
+
admin: this.isSubscribed
|
|
1490
|
+
? this.getStateAccount().admin
|
|
1491
|
+
: this.wallet.publicKey,
|
|
1492
|
+
state: await this.getStatePublicKey(),
|
|
1493
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1494
|
+
this.program.programId,
|
|
1495
|
+
spotMarketIndex
|
|
1496
|
+
),
|
|
1497
|
+
},
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
public async updateSpotMarketPoolId(
|
|
1502
|
+
spotMarketIndex: number,
|
|
1503
|
+
poolId: number
|
|
1504
|
+
): Promise<TransactionSignature> {
|
|
1505
|
+
const updateSpotMarketPoolIdIx = await this.getUpdateSpotMarketPoolIdIx(
|
|
1506
|
+
spotMarketIndex,
|
|
1507
|
+
poolId
|
|
1508
|
+
);
|
|
1509
|
+
|
|
1510
|
+
const tx = await this.buildTransaction(updateSpotMarketPoolIdIx);
|
|
1511
|
+
|
|
1512
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1513
|
+
|
|
1514
|
+
return txSig;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
public async getUpdateSpotMarketPoolIdIx(
|
|
1518
|
+
spotMarketIndex: number,
|
|
1519
|
+
poolId: number
|
|
1520
|
+
): Promise<TransactionInstruction> {
|
|
1521
|
+
return await this.program.instruction.updateSpotMarketPoolId(poolId, {
|
|
1522
|
+
accounts: {
|
|
1523
|
+
admin: this.isSubscribed
|
|
1524
|
+
? this.getStateAccount().admin
|
|
1525
|
+
: this.wallet.publicKey,
|
|
1526
|
+
state: await this.getStatePublicKey(),
|
|
1527
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1528
|
+
this.program.programId,
|
|
1529
|
+
spotMarketIndex
|
|
1530
|
+
),
|
|
1531
|
+
},
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
public async updatePerpMarketPerLpBase(
|
|
1536
|
+
perpMarketIndex: number,
|
|
1537
|
+
perLpBase: number
|
|
1538
|
+
): Promise<TransactionSignature> {
|
|
1539
|
+
const updatePerpMarketPerLpBaseIx =
|
|
1540
|
+
await this.getUpdatePerpMarketPerLpBaseIx(perpMarketIndex, perLpBase);
|
|
1541
|
+
|
|
1542
|
+
const tx = await this.buildTransaction(updatePerpMarketPerLpBaseIx);
|
|
1543
|
+
|
|
1544
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1545
|
+
|
|
1546
|
+
return txSig;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
public async getUpdatePerpMarketPerLpBaseIx(
|
|
1550
|
+
perpMarketIndex: number,
|
|
1551
|
+
perLpBase: number
|
|
1552
|
+
): Promise<TransactionInstruction> {
|
|
1553
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1554
|
+
this.program.programId,
|
|
1555
|
+
perpMarketIndex
|
|
1556
|
+
);
|
|
1557
|
+
|
|
1558
|
+
return await this.program.instruction.updatePerpMarketPerLpBase(perLpBase, {
|
|
1559
|
+
accounts: {
|
|
1560
|
+
admin: this.isSubscribed
|
|
1561
|
+
? this.getStateAccount().admin
|
|
1562
|
+
: this.wallet.publicKey,
|
|
1563
|
+
state: await this.getStatePublicKey(),
|
|
1564
|
+
perpMarket: perpMarketPublicKey,
|
|
1565
|
+
},
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
public async updatePerpMarketMaxSpread(
|
|
1570
|
+
perpMarketIndex: number,
|
|
1571
|
+
maxSpread: number
|
|
1572
|
+
): Promise<TransactionSignature> {
|
|
1573
|
+
const updatePerpMarketMaxSpreadIx =
|
|
1574
|
+
await this.getUpdatePerpMarketMaxSpreadIx(perpMarketIndex, maxSpread);
|
|
1575
|
+
|
|
1576
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxSpreadIx);
|
|
1577
|
+
|
|
1578
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1579
|
+
|
|
1580
|
+
return txSig;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
public async getUpdatePerpMarketMaxSpreadIx(
|
|
1584
|
+
perpMarketIndex: number,
|
|
1585
|
+
maxSpread: number
|
|
1586
|
+
): Promise<TransactionInstruction> {
|
|
1587
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1588
|
+
this.program.programId,
|
|
1589
|
+
perpMarketIndex
|
|
1590
|
+
);
|
|
1591
|
+
|
|
1592
|
+
return await this.program.instruction.updatePerpMarketMaxSpread(maxSpread, {
|
|
1593
|
+
accounts: {
|
|
1594
|
+
admin: this.isSubscribed
|
|
1595
|
+
? this.getStateAccount().admin
|
|
1596
|
+
: this.wallet.publicKey,
|
|
1597
|
+
state: await this.getStatePublicKey(),
|
|
1598
|
+
perpMarket: perpMarketPublicKey,
|
|
1599
|
+
},
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
public async updatePerpFeeStructure(
|
|
1604
|
+
feeStructure: FeeStructure
|
|
1605
|
+
): Promise<TransactionSignature> {
|
|
1606
|
+
const updatePerpFeeStructureIx = await this.getUpdatePerpFeeStructureIx(
|
|
1607
|
+
feeStructure
|
|
1608
|
+
);
|
|
1609
|
+
|
|
1610
|
+
const tx = await this.buildTransaction(updatePerpFeeStructureIx);
|
|
1611
|
+
|
|
1612
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1613
|
+
|
|
1614
|
+
return txSig;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
public async getUpdatePerpFeeStructureIx(
|
|
1618
|
+
feeStructure: FeeStructure
|
|
1619
|
+
): Promise<TransactionInstruction> {
|
|
1620
|
+
return this.program.instruction.updatePerpFeeStructure(feeStructure, {
|
|
1621
|
+
accounts: {
|
|
1622
|
+
admin: this.isSubscribed
|
|
1623
|
+
? this.getStateAccount().admin
|
|
1624
|
+
: this.wallet.publicKey,
|
|
1625
|
+
state: await this.getStatePublicKey(),
|
|
1626
|
+
},
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
public async updateSpotFeeStructure(
|
|
1631
|
+
feeStructure: FeeStructure
|
|
1632
|
+
): Promise<TransactionSignature> {
|
|
1633
|
+
const updateSpotFeeStructureIx = await this.getUpdateSpotFeeStructureIx(
|
|
1634
|
+
feeStructure
|
|
1635
|
+
);
|
|
1636
|
+
|
|
1637
|
+
const tx = await this.buildTransaction(updateSpotFeeStructureIx);
|
|
1638
|
+
|
|
1639
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1640
|
+
|
|
1641
|
+
return txSig;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
public async getUpdateSpotFeeStructureIx(
|
|
1645
|
+
feeStructure: FeeStructure
|
|
1646
|
+
): Promise<TransactionInstruction> {
|
|
1647
|
+
return await this.program.instruction.updateSpotFeeStructure(feeStructure, {
|
|
1648
|
+
accounts: {
|
|
1649
|
+
admin: this.isSubscribed
|
|
1650
|
+
? this.getStateAccount().admin
|
|
1651
|
+
: this.wallet.publicKey,
|
|
1652
|
+
state: await this.getStatePublicKey(),
|
|
1653
|
+
},
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
public async updateInitialPctToLiquidate(
|
|
1658
|
+
initialPctToLiquidate: number
|
|
1659
|
+
): Promise<TransactionSignature> {
|
|
1660
|
+
const updateInitialPctToLiquidateIx =
|
|
1661
|
+
await this.getUpdateInitialPctToLiquidateIx(initialPctToLiquidate);
|
|
1662
|
+
|
|
1663
|
+
const tx = await this.buildTransaction(updateInitialPctToLiquidateIx);
|
|
1664
|
+
|
|
1665
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1666
|
+
|
|
1667
|
+
return txSig;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
public async getUpdateInitialPctToLiquidateIx(
|
|
1671
|
+
initialPctToLiquidate: number
|
|
1672
|
+
): Promise<TransactionInstruction> {
|
|
1673
|
+
return await this.program.instruction.updateInitialPctToLiquidate(
|
|
1674
|
+
initialPctToLiquidate,
|
|
1675
|
+
{
|
|
1676
|
+
accounts: {
|
|
1677
|
+
admin: this.isSubscribed
|
|
1678
|
+
? this.getStateAccount().admin
|
|
1679
|
+
: this.wallet.publicKey,
|
|
1680
|
+
state: await this.getStatePublicKey(),
|
|
1681
|
+
},
|
|
1682
|
+
}
|
|
1683
|
+
);
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
public async updateLiquidationDuration(
|
|
1687
|
+
liquidationDuration: number
|
|
1688
|
+
): Promise<TransactionSignature> {
|
|
1689
|
+
const updateLiquidationDurationIx =
|
|
1690
|
+
await this.getUpdateLiquidationDurationIx(liquidationDuration);
|
|
1691
|
+
|
|
1692
|
+
const tx = await this.buildTransaction(updateLiquidationDurationIx);
|
|
1693
|
+
|
|
1694
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1695
|
+
|
|
1696
|
+
return txSig;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
public async getUpdateLiquidationDurationIx(
|
|
1700
|
+
liquidationDuration: number
|
|
1701
|
+
): Promise<TransactionInstruction> {
|
|
1702
|
+
return await this.program.instruction.updateLiquidationDuration(
|
|
1703
|
+
liquidationDuration,
|
|
1704
|
+
{
|
|
1705
|
+
accounts: {
|
|
1706
|
+
admin: this.isSubscribed
|
|
1707
|
+
? this.getStateAccount().admin
|
|
1708
|
+
: this.wallet.publicKey,
|
|
1709
|
+
state: await this.getStatePublicKey(),
|
|
1710
|
+
},
|
|
1711
|
+
}
|
|
1712
|
+
);
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
public async updateLiquidationMarginBufferRatio(
|
|
1716
|
+
updateLiquidationMarginBufferRatio: number
|
|
1717
|
+
): Promise<TransactionSignature> {
|
|
1718
|
+
const updateLiquidationMarginBufferRatioIx =
|
|
1719
|
+
await this.getUpdateLiquidationMarginBufferRatioIx(
|
|
1720
|
+
updateLiquidationMarginBufferRatio
|
|
1721
|
+
);
|
|
1722
|
+
|
|
1723
|
+
const tx = await this.buildTransaction(
|
|
1724
|
+
updateLiquidationMarginBufferRatioIx
|
|
1725
|
+
);
|
|
1726
|
+
|
|
1727
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1728
|
+
|
|
1729
|
+
return txSig;
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
public async getUpdateLiquidationMarginBufferRatioIx(
|
|
1733
|
+
updateLiquidationMarginBufferRatio: number
|
|
1734
|
+
): Promise<TransactionInstruction> {
|
|
1735
|
+
return await this.program.instruction.updateLiquidationMarginBufferRatio(
|
|
1736
|
+
updateLiquidationMarginBufferRatio,
|
|
1737
|
+
{
|
|
1738
|
+
accounts: {
|
|
1739
|
+
admin: this.isSubscribed
|
|
1740
|
+
? this.getStateAccount().admin
|
|
1741
|
+
: this.wallet.publicKey,
|
|
1742
|
+
state: await this.getStatePublicKey(),
|
|
1743
|
+
},
|
|
1744
|
+
}
|
|
1745
|
+
);
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
public async updateOracleGuardRails(
|
|
1749
|
+
oracleGuardRails: OracleGuardRails
|
|
1750
|
+
): Promise<TransactionSignature> {
|
|
1751
|
+
const updateOracleGuardRailsIx = await this.getUpdateOracleGuardRailsIx(
|
|
1752
|
+
oracleGuardRails
|
|
1753
|
+
);
|
|
1754
|
+
|
|
1755
|
+
const tx = await this.buildTransaction(updateOracleGuardRailsIx);
|
|
1756
|
+
|
|
1757
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1758
|
+
|
|
1759
|
+
return txSig;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
public async getUpdateOracleGuardRailsIx(
|
|
1763
|
+
oracleGuardRails: OracleGuardRails
|
|
1764
|
+
): Promise<TransactionInstruction> {
|
|
1765
|
+
return await this.program.instruction.updateOracleGuardRails(
|
|
1766
|
+
oracleGuardRails,
|
|
1767
|
+
{
|
|
1768
|
+
accounts: {
|
|
1769
|
+
admin: this.isSubscribed
|
|
1770
|
+
? this.getStateAccount().admin
|
|
1771
|
+
: this.wallet.publicKey,
|
|
1772
|
+
state: await this.getStatePublicKey(),
|
|
1773
|
+
},
|
|
1774
|
+
}
|
|
1775
|
+
);
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
public async updateStateSettlementDuration(
|
|
1779
|
+
settlementDuration: number
|
|
1780
|
+
): Promise<TransactionSignature> {
|
|
1781
|
+
const updateStateSettlementDurationIx =
|
|
1782
|
+
await this.getUpdateStateSettlementDurationIx(settlementDuration);
|
|
1783
|
+
|
|
1784
|
+
const tx = await this.buildTransaction(updateStateSettlementDurationIx);
|
|
1785
|
+
|
|
1786
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1787
|
+
|
|
1788
|
+
return txSig;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
public async getUpdateStateSettlementDurationIx(
|
|
1792
|
+
settlementDuration: number
|
|
1793
|
+
): Promise<TransactionInstruction> {
|
|
1794
|
+
return await this.program.instruction.updateStateSettlementDuration(
|
|
1795
|
+
settlementDuration,
|
|
1796
|
+
{
|
|
1797
|
+
accounts: {
|
|
1798
|
+
admin: this.isSubscribed
|
|
1799
|
+
? this.getStateAccount().admin
|
|
1800
|
+
: this.wallet.publicKey,
|
|
1801
|
+
state: await this.getStatePublicKey(),
|
|
1802
|
+
},
|
|
1803
|
+
}
|
|
1804
|
+
);
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
public async updateStateMaxNumberOfSubAccounts(
|
|
1808
|
+
maxNumberOfSubAccounts: number
|
|
1809
|
+
): Promise<TransactionSignature> {
|
|
1810
|
+
const updateStateMaxNumberOfSubAccountsIx =
|
|
1811
|
+
await this.getUpdateStateMaxNumberOfSubAccountsIx(maxNumberOfSubAccounts);
|
|
1812
|
+
|
|
1813
|
+
const tx = await this.buildTransaction(updateStateMaxNumberOfSubAccountsIx);
|
|
1814
|
+
|
|
1815
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1816
|
+
|
|
1817
|
+
return txSig;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
public async getUpdateStateMaxNumberOfSubAccountsIx(
|
|
1821
|
+
maxNumberOfSubAccounts: number
|
|
1822
|
+
): Promise<TransactionInstruction> {
|
|
1823
|
+
return await this.program.instruction.updateStateMaxNumberOfSubAccounts(
|
|
1824
|
+
maxNumberOfSubAccounts,
|
|
1825
|
+
{
|
|
1826
|
+
accounts: {
|
|
1827
|
+
admin: this.isSubscribed
|
|
1828
|
+
? this.getStateAccount().admin
|
|
1829
|
+
: this.wallet.publicKey,
|
|
1830
|
+
state: await this.getStatePublicKey(),
|
|
1831
|
+
},
|
|
1832
|
+
}
|
|
1833
|
+
);
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
public async updateStateMaxInitializeUserFee(
|
|
1837
|
+
maxInitializeUserFee: number
|
|
1838
|
+
): Promise<TransactionSignature> {
|
|
1839
|
+
const updateStateMaxInitializeUserFeeIx =
|
|
1840
|
+
await this.getUpdateStateMaxInitializeUserFeeIx(maxInitializeUserFee);
|
|
1841
|
+
|
|
1842
|
+
const tx = await this.buildTransaction(updateStateMaxInitializeUserFeeIx);
|
|
1843
|
+
|
|
1844
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1845
|
+
|
|
1846
|
+
return txSig;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
public async getUpdateStateMaxInitializeUserFeeIx(
|
|
1850
|
+
maxInitializeUserFee: number
|
|
1851
|
+
): Promise<TransactionInstruction> {
|
|
1852
|
+
return await this.program.instruction.updateStateMaxInitializeUserFee(
|
|
1853
|
+
maxInitializeUserFee,
|
|
1854
|
+
{
|
|
1855
|
+
accounts: {
|
|
1856
|
+
admin: this.isSubscribed
|
|
1857
|
+
? this.getStateAccount().admin
|
|
1858
|
+
: this.wallet.publicKey,
|
|
1859
|
+
state: await this.getStatePublicKey(),
|
|
1860
|
+
},
|
|
1861
|
+
}
|
|
1862
|
+
);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
public async updateWithdrawGuardThreshold(
|
|
1866
|
+
spotMarketIndex: number,
|
|
1867
|
+
withdrawGuardThreshold: BN
|
|
1868
|
+
): Promise<TransactionSignature> {
|
|
1869
|
+
const updateWithdrawGuardThresholdIx =
|
|
1870
|
+
await this.getUpdateWithdrawGuardThresholdIx(
|
|
1871
|
+
spotMarketIndex,
|
|
1872
|
+
withdrawGuardThreshold
|
|
1873
|
+
);
|
|
1874
|
+
|
|
1875
|
+
const tx = await this.buildTransaction(updateWithdrawGuardThresholdIx);
|
|
1876
|
+
|
|
1877
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1878
|
+
|
|
1879
|
+
return txSig;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
public async getUpdateWithdrawGuardThresholdIx(
|
|
1883
|
+
spotMarketIndex: number,
|
|
1884
|
+
withdrawGuardThreshold: BN
|
|
1885
|
+
): Promise<TransactionInstruction> {
|
|
1886
|
+
return await this.program.instruction.updateWithdrawGuardThreshold(
|
|
1887
|
+
withdrawGuardThreshold,
|
|
1888
|
+
{
|
|
1889
|
+
accounts: {
|
|
1890
|
+
admin: this.isSubscribed
|
|
1891
|
+
? this.getStateAccount().admin
|
|
1892
|
+
: this.wallet.publicKey,
|
|
1893
|
+
state: await this.getStatePublicKey(),
|
|
1894
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1895
|
+
this.program.programId,
|
|
1896
|
+
spotMarketIndex
|
|
1897
|
+
),
|
|
1898
|
+
},
|
|
1899
|
+
}
|
|
1900
|
+
);
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
public async updateSpotMarketIfFactor(
|
|
1904
|
+
spotMarketIndex: number,
|
|
1905
|
+
userIfFactor: BN,
|
|
1906
|
+
totalIfFactor: BN
|
|
1907
|
+
): Promise<TransactionSignature> {
|
|
1908
|
+
const updateSpotMarketIfFactorIx = await this.getUpdateSpotMarketIfFactorIx(
|
|
1909
|
+
spotMarketIndex,
|
|
1910
|
+
userIfFactor,
|
|
1911
|
+
totalIfFactor
|
|
1912
|
+
);
|
|
1913
|
+
|
|
1914
|
+
const tx = await this.buildTransaction(updateSpotMarketIfFactorIx);
|
|
1915
|
+
|
|
1916
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1917
|
+
|
|
1918
|
+
return txSig;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
public async getUpdateSpotMarketIfFactorIx(
|
|
1922
|
+
spotMarketIndex: number,
|
|
1923
|
+
userIfFactor: BN,
|
|
1924
|
+
totalIfFactor: BN
|
|
1925
|
+
): Promise<TransactionInstruction> {
|
|
1926
|
+
return await this.program.instruction.updateSpotMarketIfFactor(
|
|
1927
|
+
spotMarketIndex,
|
|
1928
|
+
userIfFactor,
|
|
1929
|
+
totalIfFactor,
|
|
1930
|
+
{
|
|
1931
|
+
accounts: {
|
|
1932
|
+
admin: this.isSubscribed
|
|
1933
|
+
? this.getStateAccount().admin
|
|
1934
|
+
: this.wallet.publicKey,
|
|
1935
|
+
state: await this.getStatePublicKey(),
|
|
1936
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1937
|
+
this.program.programId,
|
|
1938
|
+
spotMarketIndex
|
|
1939
|
+
),
|
|
1940
|
+
},
|
|
1941
|
+
}
|
|
1942
|
+
);
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
public async updateSpotMarketRevenueSettlePeriod(
|
|
1946
|
+
spotMarketIndex: number,
|
|
1947
|
+
revenueSettlePeriod: BN
|
|
1948
|
+
): Promise<TransactionSignature> {
|
|
1949
|
+
const updateSpotMarketRevenueSettlePeriodIx =
|
|
1950
|
+
await this.getUpdateSpotMarketRevenueSettlePeriodIx(
|
|
1951
|
+
spotMarketIndex,
|
|
1952
|
+
revenueSettlePeriod
|
|
1953
|
+
);
|
|
1954
|
+
|
|
1955
|
+
const tx = await this.buildTransaction(
|
|
1956
|
+
updateSpotMarketRevenueSettlePeriodIx
|
|
1957
|
+
);
|
|
1958
|
+
|
|
1959
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1960
|
+
|
|
1961
|
+
return txSig;
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
public async getUpdateSpotMarketRevenueSettlePeriodIx(
|
|
1965
|
+
spotMarketIndex: number,
|
|
1966
|
+
revenueSettlePeriod: BN
|
|
1967
|
+
): Promise<TransactionInstruction> {
|
|
1968
|
+
return await this.program.instruction.updateSpotMarketRevenueSettlePeriod(
|
|
1969
|
+
revenueSettlePeriod,
|
|
1970
|
+
{
|
|
1971
|
+
accounts: {
|
|
1972
|
+
admin: this.isSubscribed
|
|
1973
|
+
? this.getStateAccount().admin
|
|
1974
|
+
: this.wallet.publicKey,
|
|
1975
|
+
state: await this.getStatePublicKey(),
|
|
1976
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
1977
|
+
this.program.programId,
|
|
1978
|
+
spotMarketIndex
|
|
1979
|
+
),
|
|
1980
|
+
},
|
|
1981
|
+
}
|
|
1982
|
+
);
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
public async updateSpotMarketMaxTokenDeposits(
|
|
1986
|
+
spotMarketIndex: number,
|
|
1987
|
+
maxTokenDeposits: BN
|
|
1988
|
+
): Promise<TransactionSignature> {
|
|
1989
|
+
const updateSpotMarketMaxTokenDepositsIx =
|
|
1990
|
+
await this.getUpdateSpotMarketMaxTokenDepositsIx(
|
|
1991
|
+
spotMarketIndex,
|
|
1992
|
+
maxTokenDeposits
|
|
1993
|
+
);
|
|
1994
|
+
|
|
1995
|
+
const tx = await this.buildTransaction(updateSpotMarketMaxTokenDepositsIx);
|
|
1996
|
+
|
|
1997
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1998
|
+
|
|
1999
|
+
return txSig;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
public async getUpdateSpotMarketMaxTokenDepositsIx(
|
|
2003
|
+
spotMarketIndex: number,
|
|
2004
|
+
maxTokenDeposits: BN
|
|
2005
|
+
): Promise<TransactionInstruction> {
|
|
2006
|
+
return this.program.instruction.updateSpotMarketMaxTokenDeposits(
|
|
2007
|
+
maxTokenDeposits,
|
|
2008
|
+
{
|
|
2009
|
+
accounts: {
|
|
2010
|
+
admin: this.isSubscribed
|
|
2011
|
+
? this.getStateAccount().admin
|
|
2012
|
+
: this.wallet.publicKey,
|
|
2013
|
+
state: await this.getStatePublicKey(),
|
|
2014
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2015
|
+
this.program.programId,
|
|
2016
|
+
spotMarketIndex
|
|
2017
|
+
),
|
|
2018
|
+
},
|
|
2019
|
+
}
|
|
2020
|
+
);
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
public async updateSpotMarketMaxTokenBorrows(
|
|
2024
|
+
spotMarketIndex: number,
|
|
2025
|
+
maxTokenBorrowsFraction: number
|
|
2026
|
+
): Promise<TransactionSignature> {
|
|
2027
|
+
const updateSpotMarketMaxTokenBorrowsIx =
|
|
2028
|
+
await this.getUpdateSpotMarketMaxTokenBorrowsIx(
|
|
2029
|
+
spotMarketIndex,
|
|
2030
|
+
maxTokenBorrowsFraction
|
|
2031
|
+
);
|
|
2032
|
+
|
|
2033
|
+
const tx = await this.buildTransaction(updateSpotMarketMaxTokenBorrowsIx);
|
|
2034
|
+
|
|
2035
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2036
|
+
|
|
2037
|
+
return txSig;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
public async getUpdateSpotMarketMaxTokenBorrowsIx(
|
|
2041
|
+
spotMarketIndex: number,
|
|
2042
|
+
maxTokenBorrowsFraction: number
|
|
2043
|
+
): Promise<TransactionInstruction> {
|
|
2044
|
+
return this.program.instruction.updateSpotMarketMaxTokenBorrows(
|
|
2045
|
+
maxTokenBorrowsFraction,
|
|
2046
|
+
{
|
|
2047
|
+
accounts: {
|
|
2048
|
+
admin: this.isSubscribed
|
|
2049
|
+
? this.getStateAccount().admin
|
|
2050
|
+
: this.wallet.publicKey,
|
|
2051
|
+
state: await this.getStatePublicKey(),
|
|
2052
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2053
|
+
this.program.programId,
|
|
2054
|
+
spotMarketIndex
|
|
2055
|
+
),
|
|
2056
|
+
},
|
|
2057
|
+
}
|
|
2058
|
+
);
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
public async updateSpotMarketScaleInitialAssetWeightStart(
|
|
2062
|
+
spotMarketIndex: number,
|
|
2063
|
+
scaleInitialAssetWeightStart: BN
|
|
2064
|
+
): Promise<TransactionSignature> {
|
|
2065
|
+
const updateSpotMarketScaleInitialAssetWeightStartIx =
|
|
2066
|
+
await this.getUpdateSpotMarketScaleInitialAssetWeightStartIx(
|
|
2067
|
+
spotMarketIndex,
|
|
2068
|
+
scaleInitialAssetWeightStart
|
|
2069
|
+
);
|
|
2070
|
+
|
|
2071
|
+
const tx = await this.buildTransaction(
|
|
2072
|
+
updateSpotMarketScaleInitialAssetWeightStartIx
|
|
2073
|
+
);
|
|
2074
|
+
|
|
2075
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2076
|
+
|
|
2077
|
+
return txSig;
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
public async getUpdateSpotMarketScaleInitialAssetWeightStartIx(
|
|
2081
|
+
spotMarketIndex: number,
|
|
2082
|
+
scaleInitialAssetWeightStart: BN
|
|
2083
|
+
): Promise<TransactionInstruction> {
|
|
2084
|
+
return this.program.instruction.updateSpotMarketScaleInitialAssetWeightStart(
|
|
2085
|
+
scaleInitialAssetWeightStart,
|
|
2086
|
+
{
|
|
2087
|
+
accounts: {
|
|
2088
|
+
admin: this.isSubscribed
|
|
2089
|
+
? this.getStateAccount().admin
|
|
2090
|
+
: this.wallet.publicKey,
|
|
2091
|
+
state: await this.getStatePublicKey(),
|
|
2092
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2093
|
+
this.program.programId,
|
|
2094
|
+
spotMarketIndex
|
|
2095
|
+
),
|
|
2096
|
+
},
|
|
2097
|
+
}
|
|
2098
|
+
);
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
public async updateInsuranceFundUnstakingPeriod(
|
|
2102
|
+
spotMarketIndex: number,
|
|
2103
|
+
insuranceWithdrawEscrowPeriod: BN
|
|
2104
|
+
): Promise<TransactionSignature> {
|
|
2105
|
+
const updateInsuranceFundUnstakingPeriodIx =
|
|
2106
|
+
await this.getUpdateInsuranceFundUnstakingPeriodIx(
|
|
2107
|
+
spotMarketIndex,
|
|
2108
|
+
insuranceWithdrawEscrowPeriod
|
|
2109
|
+
);
|
|
2110
|
+
|
|
2111
|
+
const tx = await this.buildTransaction(
|
|
2112
|
+
updateInsuranceFundUnstakingPeriodIx
|
|
2113
|
+
);
|
|
2114
|
+
|
|
2115
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2116
|
+
|
|
2117
|
+
return txSig;
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
public async getUpdateInsuranceFundUnstakingPeriodIx(
|
|
2121
|
+
spotMarketIndex: number,
|
|
2122
|
+
insuranceWithdrawEscrowPeriod: BN
|
|
2123
|
+
): Promise<TransactionInstruction> {
|
|
2124
|
+
return await this.program.instruction.updateInsuranceFundUnstakingPeriod(
|
|
2125
|
+
insuranceWithdrawEscrowPeriod,
|
|
2126
|
+
{
|
|
2127
|
+
accounts: {
|
|
2128
|
+
admin: this.isSubscribed
|
|
2129
|
+
? this.getStateAccount().admin
|
|
2130
|
+
: this.wallet.publicKey,
|
|
2131
|
+
state: await this.getStatePublicKey(),
|
|
2132
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2133
|
+
this.program.programId,
|
|
2134
|
+
spotMarketIndex
|
|
2135
|
+
),
|
|
2136
|
+
},
|
|
2137
|
+
}
|
|
2138
|
+
);
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
public async updateLpCooldownTime(
|
|
2142
|
+
cooldownTime: BN
|
|
2143
|
+
): Promise<TransactionSignature> {
|
|
2144
|
+
const updateLpCooldownTimeIx = await this.getUpdateLpCooldownTimeIx(
|
|
2145
|
+
cooldownTime
|
|
2146
|
+
);
|
|
2147
|
+
|
|
2148
|
+
const tx = await this.buildTransaction(updateLpCooldownTimeIx);
|
|
2149
|
+
|
|
2150
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2151
|
+
|
|
2152
|
+
return txSig;
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
public async getUpdateLpCooldownTimeIx(
|
|
2156
|
+
cooldownTime: BN
|
|
2157
|
+
): Promise<TransactionInstruction> {
|
|
2158
|
+
return await this.program.instruction.updateLpCooldownTime(cooldownTime, {
|
|
2159
|
+
accounts: {
|
|
2160
|
+
admin: this.isSubscribed
|
|
2161
|
+
? this.getStateAccount().admin
|
|
2162
|
+
: this.wallet.publicKey,
|
|
2163
|
+
state: await this.getStatePublicKey(),
|
|
2164
|
+
},
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
public async updatePerpMarketOracle(
|
|
2169
|
+
perpMarketIndex: number,
|
|
2170
|
+
oracle: PublicKey,
|
|
2171
|
+
oracleSource: OracleSource
|
|
2172
|
+
): Promise<TransactionSignature> {
|
|
2173
|
+
const updatePerpMarketOracleIx = await this.getUpdatePerpMarketOracleIx(
|
|
2174
|
+
perpMarketIndex,
|
|
2175
|
+
oracle,
|
|
2176
|
+
oracleSource
|
|
2177
|
+
);
|
|
2178
|
+
|
|
2179
|
+
const tx = await this.buildTransaction(updatePerpMarketOracleIx);
|
|
2180
|
+
|
|
2181
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2182
|
+
|
|
2183
|
+
return txSig;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
public async getUpdatePerpMarketOracleIx(
|
|
2187
|
+
perpMarketIndex: number,
|
|
2188
|
+
oracle: PublicKey,
|
|
2189
|
+
oracleSource: OracleSource
|
|
2190
|
+
): Promise<TransactionInstruction> {
|
|
2191
|
+
return await this.program.instruction.updatePerpMarketOracle(
|
|
2192
|
+
oracle,
|
|
2193
|
+
oracleSource,
|
|
2194
|
+
{
|
|
2195
|
+
accounts: {
|
|
2196
|
+
admin: this.isSubscribed
|
|
2197
|
+
? this.getStateAccount().admin
|
|
2198
|
+
: this.wallet.publicKey,
|
|
2199
|
+
state: await this.getStatePublicKey(),
|
|
2200
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2201
|
+
this.program.programId,
|
|
2202
|
+
perpMarketIndex
|
|
2203
|
+
),
|
|
2204
|
+
oracle: oracle,
|
|
2205
|
+
},
|
|
2206
|
+
}
|
|
2207
|
+
);
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
public async updatePerpMarketStepSizeAndTickSize(
|
|
2211
|
+
perpMarketIndex: number,
|
|
2212
|
+
stepSize: BN,
|
|
2213
|
+
tickSize: BN
|
|
2214
|
+
): Promise<TransactionSignature> {
|
|
2215
|
+
const updatePerpMarketStepSizeAndTickSizeIx =
|
|
2216
|
+
await this.getUpdatePerpMarketStepSizeAndTickSizeIx(
|
|
2217
|
+
perpMarketIndex,
|
|
2218
|
+
stepSize,
|
|
2219
|
+
tickSize
|
|
2220
|
+
);
|
|
2221
|
+
|
|
2222
|
+
const tx = await this.buildTransaction(
|
|
2223
|
+
updatePerpMarketStepSizeAndTickSizeIx
|
|
2224
|
+
);
|
|
2225
|
+
|
|
2226
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2227
|
+
|
|
2228
|
+
return txSig;
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
public async getUpdatePerpMarketStepSizeAndTickSizeIx(
|
|
2232
|
+
perpMarketIndex: number,
|
|
2233
|
+
stepSize: BN,
|
|
2234
|
+
tickSize: BN
|
|
2235
|
+
): Promise<TransactionInstruction> {
|
|
2236
|
+
return await this.program.instruction.updatePerpMarketStepSizeAndTickSize(
|
|
2237
|
+
stepSize,
|
|
2238
|
+
tickSize,
|
|
2239
|
+
{
|
|
2240
|
+
accounts: {
|
|
2241
|
+
admin: this.isSubscribed
|
|
2242
|
+
? this.getStateAccount().admin
|
|
2243
|
+
: this.wallet.publicKey,
|
|
2244
|
+
state: await this.getStatePublicKey(),
|
|
2245
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2246
|
+
this.program.programId,
|
|
2247
|
+
perpMarketIndex
|
|
2248
|
+
),
|
|
2249
|
+
},
|
|
2250
|
+
}
|
|
2251
|
+
);
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
public async updatePerpMarketMinOrderSize(
|
|
2255
|
+
perpMarketIndex: number,
|
|
2256
|
+
orderSize: BN
|
|
2257
|
+
): Promise<TransactionSignature> {
|
|
2258
|
+
const updatePerpMarketMinOrderSizeIx =
|
|
2259
|
+
await this.getUpdatePerpMarketMinOrderSizeIx(perpMarketIndex, orderSize);
|
|
2260
|
+
|
|
2261
|
+
const tx = await this.buildTransaction(updatePerpMarketMinOrderSizeIx);
|
|
2262
|
+
|
|
2263
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2264
|
+
|
|
2265
|
+
return txSig;
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
public async getUpdatePerpMarketMinOrderSizeIx(
|
|
2269
|
+
perpMarketIndex: number,
|
|
2270
|
+
orderSize: BN
|
|
2271
|
+
): Promise<TransactionInstruction> {
|
|
2272
|
+
return await this.program.instruction.updatePerpMarketMinOrderSize(
|
|
2273
|
+
orderSize,
|
|
2274
|
+
{
|
|
2275
|
+
accounts: {
|
|
2276
|
+
admin: this.isSubscribed
|
|
2277
|
+
? this.getStateAccount().admin
|
|
2278
|
+
: this.wallet.publicKey,
|
|
2279
|
+
state: await this.getStatePublicKey(),
|
|
2280
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2281
|
+
this.program.programId,
|
|
2282
|
+
perpMarketIndex
|
|
2283
|
+
),
|
|
2284
|
+
},
|
|
2285
|
+
}
|
|
2286
|
+
);
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
public async updateSpotMarketStepSizeAndTickSize(
|
|
2290
|
+
spotMarketIndex: number,
|
|
2291
|
+
stepSize: BN,
|
|
2292
|
+
tickSize: BN
|
|
2293
|
+
): Promise<TransactionSignature> {
|
|
2294
|
+
const updateSpotMarketStepSizeAndTickSizeIx =
|
|
2295
|
+
await this.getUpdateSpotMarketStepSizeAndTickSizeIx(
|
|
2296
|
+
spotMarketIndex,
|
|
2297
|
+
stepSize,
|
|
2298
|
+
tickSize
|
|
2299
|
+
);
|
|
2300
|
+
|
|
2301
|
+
const tx = await this.buildTransaction(
|
|
2302
|
+
updateSpotMarketStepSizeAndTickSizeIx
|
|
2303
|
+
);
|
|
2304
|
+
|
|
2305
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2306
|
+
|
|
2307
|
+
return txSig;
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
public async getUpdateSpotMarketStepSizeAndTickSizeIx(
|
|
2311
|
+
spotMarketIndex: number,
|
|
2312
|
+
stepSize: BN,
|
|
2313
|
+
tickSize: BN
|
|
2314
|
+
): Promise<TransactionInstruction> {
|
|
2315
|
+
return await this.program.instruction.updateSpotMarketStepSizeAndTickSize(
|
|
2316
|
+
stepSize,
|
|
2317
|
+
tickSize,
|
|
2318
|
+
{
|
|
2319
|
+
accounts: {
|
|
2320
|
+
admin: this.isSubscribed
|
|
2321
|
+
? this.getStateAccount().admin
|
|
2322
|
+
: this.wallet.publicKey,
|
|
2323
|
+
state: await this.getStatePublicKey(),
|
|
2324
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2325
|
+
this.program.programId,
|
|
2326
|
+
spotMarketIndex
|
|
2327
|
+
),
|
|
2328
|
+
},
|
|
2329
|
+
}
|
|
2330
|
+
);
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
public async updateSpotMarketMinOrderSize(
|
|
2334
|
+
spotMarketIndex: number,
|
|
2335
|
+
orderSize: BN
|
|
2336
|
+
): Promise<TransactionSignature> {
|
|
2337
|
+
const updateSpotMarketMinOrderSizeIx =
|
|
2338
|
+
await this.program.instruction.updateSpotMarketMinOrderSize(orderSize, {
|
|
2339
|
+
accounts: {
|
|
2340
|
+
admin: this.isSubscribed
|
|
2341
|
+
? this.getStateAccount().admin
|
|
2342
|
+
: this.wallet.publicKey,
|
|
2343
|
+
state: await this.getStatePublicKey(),
|
|
2344
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2345
|
+
this.program.programId,
|
|
2346
|
+
spotMarketIndex
|
|
2347
|
+
),
|
|
2348
|
+
},
|
|
2349
|
+
});
|
|
2350
|
+
|
|
2351
|
+
const tx = await this.buildTransaction(updateSpotMarketMinOrderSizeIx);
|
|
2352
|
+
|
|
2353
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2354
|
+
|
|
2355
|
+
return txSig;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
public async getUpdateSpotMarketMinOrderSizeIx(
|
|
2359
|
+
spotMarketIndex: number,
|
|
2360
|
+
orderSize: BN
|
|
2361
|
+
): Promise<TransactionInstruction> {
|
|
2362
|
+
return await this.program.instruction.updateSpotMarketMinOrderSize(
|
|
2363
|
+
orderSize,
|
|
2364
|
+
{
|
|
2365
|
+
accounts: {
|
|
2366
|
+
admin: this.isSubscribed
|
|
2367
|
+
? this.getStateAccount().admin
|
|
2368
|
+
: this.wallet.publicKey,
|
|
2369
|
+
state: await this.getStatePublicKey(),
|
|
2370
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2371
|
+
this.program.programId,
|
|
2372
|
+
spotMarketIndex
|
|
2373
|
+
),
|
|
2374
|
+
},
|
|
2375
|
+
}
|
|
2376
|
+
);
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
public async updatePerpMarketExpiry(
|
|
2380
|
+
perpMarketIndex: number,
|
|
2381
|
+
expiryTs: BN
|
|
2382
|
+
): Promise<TransactionSignature> {
|
|
2383
|
+
const updatePerpMarketExpiryIx = await this.getUpdatePerpMarketExpiryIx(
|
|
2384
|
+
perpMarketIndex,
|
|
2385
|
+
expiryTs
|
|
2386
|
+
);
|
|
2387
|
+
const tx = await this.buildTransaction(updatePerpMarketExpiryIx);
|
|
2388
|
+
|
|
2389
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2390
|
+
|
|
2391
|
+
return txSig;
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
public async getUpdatePerpMarketExpiryIx(
|
|
2395
|
+
perpMarketIndex: number,
|
|
2396
|
+
expiryTs: BN
|
|
2397
|
+
): Promise<TransactionInstruction> {
|
|
2398
|
+
return await this.program.instruction.updatePerpMarketExpiry(expiryTs, {
|
|
2399
|
+
accounts: {
|
|
2400
|
+
admin: this.isSubscribed
|
|
2401
|
+
? this.getStateAccount().admin
|
|
2402
|
+
: this.wallet.publicKey,
|
|
2403
|
+
state: await this.getStatePublicKey(),
|
|
2404
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2405
|
+
this.program.programId,
|
|
2406
|
+
perpMarketIndex
|
|
2407
|
+
),
|
|
2408
|
+
},
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
public async updateSpotMarketOracle(
|
|
2413
|
+
spotMarketIndex: number,
|
|
2414
|
+
oracle: PublicKey,
|
|
2415
|
+
oracleSource: OracleSource
|
|
2416
|
+
): Promise<TransactionSignature> {
|
|
2417
|
+
const updateSpotMarketOracleIx = await this.getUpdateSpotMarketOracleIx(
|
|
2418
|
+
spotMarketIndex,
|
|
2419
|
+
oracle,
|
|
2420
|
+
oracleSource
|
|
2421
|
+
);
|
|
2422
|
+
|
|
2423
|
+
const tx = await this.buildTransaction(updateSpotMarketOracleIx);
|
|
2424
|
+
|
|
2425
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2426
|
+
|
|
2427
|
+
return txSig;
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
public async getUpdateSpotMarketOracleIx(
|
|
2431
|
+
spotMarketIndex: number,
|
|
2432
|
+
oracle: PublicKey,
|
|
2433
|
+
oracleSource: OracleSource
|
|
2434
|
+
): Promise<TransactionInstruction> {
|
|
2435
|
+
return await this.program.instruction.updateSpotMarketOracle(
|
|
2436
|
+
oracle,
|
|
2437
|
+
oracleSource,
|
|
2438
|
+
{
|
|
2439
|
+
accounts: {
|
|
2440
|
+
admin: this.isSubscribed
|
|
2441
|
+
? this.getStateAccount().admin
|
|
2442
|
+
: this.wallet.publicKey,
|
|
2443
|
+
state: await this.getStatePublicKey(),
|
|
2444
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2445
|
+
this.program.programId,
|
|
2446
|
+
spotMarketIndex
|
|
2447
|
+
),
|
|
2448
|
+
oracle: oracle,
|
|
2449
|
+
},
|
|
2450
|
+
}
|
|
2451
|
+
);
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
public async updateSpotMarketOrdersEnabled(
|
|
2455
|
+
spotMarketIndex: number,
|
|
2456
|
+
ordersEnabled: boolean
|
|
2457
|
+
): Promise<TransactionSignature> {
|
|
2458
|
+
const updateSpotMarketOrdersEnabledIx =
|
|
2459
|
+
await this.getUpdateSpotMarketOrdersEnabledIx(
|
|
2460
|
+
spotMarketIndex,
|
|
2461
|
+
ordersEnabled
|
|
2462
|
+
);
|
|
2463
|
+
|
|
2464
|
+
const tx = await this.buildTransaction(updateSpotMarketOrdersEnabledIx);
|
|
2465
|
+
|
|
2466
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2467
|
+
|
|
2468
|
+
return txSig;
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
public async getUpdateSpotMarketOrdersEnabledIx(
|
|
2472
|
+
spotMarketIndex: number,
|
|
2473
|
+
ordersEnabled: boolean
|
|
2474
|
+
): Promise<TransactionInstruction> {
|
|
2475
|
+
return await this.program.instruction.updateSpotMarketOrdersEnabled(
|
|
2476
|
+
ordersEnabled,
|
|
2477
|
+
{
|
|
2478
|
+
accounts: {
|
|
2479
|
+
admin: this.isSubscribed
|
|
2480
|
+
? this.getStateAccount().admin
|
|
2481
|
+
: this.wallet.publicKey,
|
|
2482
|
+
state: await this.getStatePublicKey(),
|
|
2483
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2484
|
+
this.program.programId,
|
|
2485
|
+
spotMarketIndex
|
|
2486
|
+
),
|
|
2487
|
+
},
|
|
2488
|
+
}
|
|
2489
|
+
);
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
public async updateSpotMarketIfPausedOperations(
|
|
2493
|
+
spotMarketIndex: number,
|
|
2494
|
+
pausedOperations: number
|
|
2495
|
+
): Promise<TransactionSignature> {
|
|
2496
|
+
const updateSpotMarketIfStakingDisabledIx =
|
|
2497
|
+
await this.getUpdateSpotMarketIfPausedOperationsIx(
|
|
2498
|
+
spotMarketIndex,
|
|
2499
|
+
pausedOperations
|
|
2500
|
+
);
|
|
2501
|
+
|
|
2502
|
+
const tx = await this.buildTransaction(updateSpotMarketIfStakingDisabledIx);
|
|
2503
|
+
|
|
2504
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2505
|
+
|
|
2506
|
+
return txSig;
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
public async getUpdateSpotMarketIfPausedOperationsIx(
|
|
2510
|
+
spotMarketIndex: number,
|
|
2511
|
+
pausedOperations: number
|
|
2512
|
+
): Promise<TransactionInstruction> {
|
|
2513
|
+
return await this.program.instruction.updateSpotMarketIfPausedOperations(
|
|
2514
|
+
pausedOperations,
|
|
2515
|
+
{
|
|
2516
|
+
accounts: {
|
|
2517
|
+
admin: this.isSubscribed
|
|
2518
|
+
? this.getStateAccount().admin
|
|
2519
|
+
: this.wallet.publicKey,
|
|
2520
|
+
state: await this.getStatePublicKey(),
|
|
2521
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2522
|
+
this.program.programId,
|
|
2523
|
+
spotMarketIndex
|
|
2524
|
+
),
|
|
2525
|
+
},
|
|
2526
|
+
}
|
|
2527
|
+
);
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
public async updateSerumFulfillmentConfigStatus(
|
|
2531
|
+
serumFulfillmentConfig: PublicKey,
|
|
2532
|
+
status: SpotFulfillmentConfigStatus
|
|
2533
|
+
): Promise<TransactionSignature> {
|
|
2534
|
+
const updateSerumFulfillmentConfigStatusIx =
|
|
2535
|
+
await this.getUpdateSerumFulfillmentConfigStatusIx(
|
|
2536
|
+
serumFulfillmentConfig,
|
|
2537
|
+
status
|
|
2538
|
+
);
|
|
2539
|
+
|
|
2540
|
+
const tx = await this.buildTransaction(
|
|
2541
|
+
updateSerumFulfillmentConfigStatusIx
|
|
2542
|
+
);
|
|
2543
|
+
|
|
2544
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2545
|
+
|
|
2546
|
+
return txSig;
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
public async getUpdateSerumFulfillmentConfigStatusIx(
|
|
2550
|
+
serumFulfillmentConfig: PublicKey,
|
|
2551
|
+
status: SpotFulfillmentConfigStatus
|
|
2552
|
+
): Promise<TransactionInstruction> {
|
|
2553
|
+
return await this.program.instruction.updateSerumFulfillmentConfigStatus(
|
|
2554
|
+
status,
|
|
2555
|
+
{
|
|
2556
|
+
accounts: {
|
|
2557
|
+
admin: this.isSubscribed
|
|
2558
|
+
? this.getStateAccount().admin
|
|
2559
|
+
: this.wallet.publicKey,
|
|
2560
|
+
state: await this.getStatePublicKey(),
|
|
2561
|
+
serumFulfillmentConfig,
|
|
2562
|
+
},
|
|
2563
|
+
}
|
|
2564
|
+
);
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
public async updatePhoenixFulfillmentConfigStatus(
|
|
2568
|
+
phoenixFulfillmentConfig: PublicKey,
|
|
2569
|
+
status: SpotFulfillmentConfigStatus
|
|
2570
|
+
): Promise<TransactionSignature> {
|
|
2571
|
+
const updatePhoenixFulfillmentConfigStatusIx =
|
|
2572
|
+
await this.program.instruction.phoenixFulfillmentConfigStatus(status, {
|
|
2573
|
+
accounts: {
|
|
2574
|
+
admin: this.isSubscribed
|
|
2575
|
+
? this.getStateAccount().admin
|
|
2576
|
+
: this.wallet.publicKey,
|
|
2577
|
+
state: await this.getStatePublicKey(),
|
|
2578
|
+
phoenixFulfillmentConfig,
|
|
2579
|
+
},
|
|
2580
|
+
});
|
|
2581
|
+
|
|
2582
|
+
const tx = await this.buildTransaction(
|
|
2583
|
+
updatePhoenixFulfillmentConfigStatusIx
|
|
2584
|
+
);
|
|
2585
|
+
|
|
2586
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2587
|
+
|
|
2588
|
+
return txSig;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
public async getUpdatePhoenixFulfillmentConfigStatusIx(
|
|
2592
|
+
phoenixFulfillmentConfig: PublicKey,
|
|
2593
|
+
status: SpotFulfillmentConfigStatus
|
|
2594
|
+
): Promise<TransactionInstruction> {
|
|
2595
|
+
return await this.program.instruction.phoenixFulfillmentConfigStatus(
|
|
2596
|
+
status,
|
|
2597
|
+
{
|
|
2598
|
+
accounts: {
|
|
2599
|
+
admin: this.isSubscribed
|
|
2600
|
+
? this.getStateAccount().admin
|
|
2601
|
+
: this.wallet.publicKey,
|
|
2602
|
+
state: await this.getStatePublicKey(),
|
|
2603
|
+
phoenixFulfillmentConfig,
|
|
2604
|
+
},
|
|
2605
|
+
}
|
|
2606
|
+
);
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
public async updateSpotMarketExpiry(
|
|
2610
|
+
spotMarketIndex: number,
|
|
2611
|
+
expiryTs: BN
|
|
2612
|
+
): Promise<TransactionSignature> {
|
|
2613
|
+
const updateSpotMarketExpiryIx = await this.getUpdateSpotMarketExpiryIx(
|
|
2614
|
+
spotMarketIndex,
|
|
2615
|
+
expiryTs
|
|
2616
|
+
);
|
|
2617
|
+
|
|
2618
|
+
const tx = await this.buildTransaction(updateSpotMarketExpiryIx);
|
|
2619
|
+
|
|
2620
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2621
|
+
|
|
2622
|
+
return txSig;
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
public async getUpdateSpotMarketExpiryIx(
|
|
2626
|
+
spotMarketIndex: number,
|
|
2627
|
+
expiryTs: BN
|
|
2628
|
+
): Promise<TransactionInstruction> {
|
|
2629
|
+
return await this.program.instruction.updateSpotMarketExpiry(expiryTs, {
|
|
2630
|
+
accounts: {
|
|
2631
|
+
admin: this.isSubscribed
|
|
2632
|
+
? this.getStateAccount().admin
|
|
2633
|
+
: this.wallet.publicKey,
|
|
2634
|
+
state: await this.getStatePublicKey(),
|
|
2635
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2636
|
+
this.program.programId,
|
|
2637
|
+
spotMarketIndex
|
|
2638
|
+
),
|
|
2639
|
+
},
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
public async updateWhitelistMint(
|
|
2644
|
+
whitelistMint?: PublicKey
|
|
2645
|
+
): Promise<TransactionSignature> {
|
|
2646
|
+
const updateWhitelistMintIx = await this.getUpdateWhitelistMintIx(
|
|
2647
|
+
whitelistMint
|
|
2648
|
+
);
|
|
2649
|
+
|
|
2650
|
+
const tx = await this.buildTransaction(updateWhitelistMintIx);
|
|
2651
|
+
|
|
2652
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2653
|
+
|
|
2654
|
+
return txSig;
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
public async getUpdateWhitelistMintIx(
|
|
2658
|
+
whitelistMint?: PublicKey
|
|
2659
|
+
): Promise<TransactionInstruction> {
|
|
2660
|
+
return await this.program.instruction.updateWhitelistMint(whitelistMint, {
|
|
2661
|
+
accounts: {
|
|
2662
|
+
admin: this.isSubscribed
|
|
2663
|
+
? this.getStateAccount().admin
|
|
2664
|
+
: this.wallet.publicKey,
|
|
2665
|
+
state: await this.getStatePublicKey(),
|
|
2666
|
+
},
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
public async updateDiscountMint(
|
|
2671
|
+
discountMint: PublicKey
|
|
2672
|
+
): Promise<TransactionSignature> {
|
|
2673
|
+
const updateDiscountMintIx = await this.getUpdateDiscountMintIx(
|
|
2674
|
+
discountMint
|
|
2675
|
+
);
|
|
2676
|
+
|
|
2677
|
+
const tx = await this.buildTransaction(updateDiscountMintIx);
|
|
2678
|
+
|
|
2679
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2680
|
+
|
|
2681
|
+
return txSig;
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
public async getUpdateDiscountMintIx(
|
|
2685
|
+
discountMint: PublicKey
|
|
2686
|
+
): Promise<TransactionInstruction> {
|
|
2687
|
+
return await this.program.instruction.updateDiscountMint(discountMint, {
|
|
2688
|
+
accounts: {
|
|
2689
|
+
admin: this.isSubscribed
|
|
2690
|
+
? this.getStateAccount().admin
|
|
2691
|
+
: this.wallet.publicKey,
|
|
2692
|
+
state: await this.getStatePublicKey(),
|
|
2693
|
+
},
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
public async updateSpotMarketMarginWeights(
|
|
2698
|
+
spotMarketIndex: number,
|
|
2699
|
+
initialAssetWeight: number,
|
|
2700
|
+
maintenanceAssetWeight: number,
|
|
2701
|
+
initialLiabilityWeight: number,
|
|
2702
|
+
maintenanceLiabilityWeight: number,
|
|
2703
|
+
imfFactor = 0
|
|
2704
|
+
): Promise<TransactionSignature> {
|
|
2705
|
+
const updateSpotMarketMarginWeightsIx =
|
|
2706
|
+
await this.getUpdateSpotMarketMarginWeightsIx(
|
|
2707
|
+
spotMarketIndex,
|
|
2708
|
+
initialAssetWeight,
|
|
2709
|
+
maintenanceAssetWeight,
|
|
2710
|
+
initialLiabilityWeight,
|
|
2711
|
+
maintenanceLiabilityWeight,
|
|
2712
|
+
imfFactor
|
|
2713
|
+
);
|
|
2714
|
+
|
|
2715
|
+
const tx = await this.buildTransaction(updateSpotMarketMarginWeightsIx);
|
|
2716
|
+
|
|
2717
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2718
|
+
|
|
2719
|
+
return txSig;
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
public async getUpdateSpotMarketMarginWeightsIx(
|
|
2723
|
+
spotMarketIndex: number,
|
|
2724
|
+
initialAssetWeight: number,
|
|
2725
|
+
maintenanceAssetWeight: number,
|
|
2726
|
+
initialLiabilityWeight: number,
|
|
2727
|
+
maintenanceLiabilityWeight: number,
|
|
2728
|
+
imfFactor = 0
|
|
2729
|
+
): Promise<TransactionInstruction> {
|
|
2730
|
+
return await this.program.instruction.updateSpotMarketMarginWeights(
|
|
2731
|
+
initialAssetWeight,
|
|
2732
|
+
maintenanceAssetWeight,
|
|
2733
|
+
initialLiabilityWeight,
|
|
2734
|
+
maintenanceLiabilityWeight,
|
|
2735
|
+
imfFactor,
|
|
2736
|
+
{
|
|
2737
|
+
accounts: {
|
|
2738
|
+
admin: this.isSubscribed
|
|
2739
|
+
? this.getStateAccount().admin
|
|
2740
|
+
: this.wallet.publicKey,
|
|
2741
|
+
state: await this.getStatePublicKey(),
|
|
2742
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2743
|
+
this.program.programId,
|
|
2744
|
+
spotMarketIndex
|
|
2745
|
+
),
|
|
2746
|
+
},
|
|
2747
|
+
}
|
|
2748
|
+
);
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
public async updateSpotMarketBorrowRate(
|
|
2752
|
+
spotMarketIndex: number,
|
|
2753
|
+
optimalUtilization: number,
|
|
2754
|
+
optimalBorrowRate: number,
|
|
2755
|
+
optimalMaxRate: number,
|
|
2756
|
+
minBorrowRate?: number | undefined
|
|
2757
|
+
): Promise<TransactionSignature> {
|
|
2758
|
+
const updateSpotMarketBorrowRateIx =
|
|
2759
|
+
await this.getUpdateSpotMarketBorrowRateIx(
|
|
2760
|
+
spotMarketIndex,
|
|
2761
|
+
optimalUtilization,
|
|
2762
|
+
optimalBorrowRate,
|
|
2763
|
+
optimalMaxRate,
|
|
2764
|
+
minBorrowRate
|
|
2765
|
+
);
|
|
2766
|
+
|
|
2767
|
+
const tx = await this.buildTransaction(updateSpotMarketBorrowRateIx);
|
|
2768
|
+
|
|
2769
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2770
|
+
|
|
2771
|
+
return txSig;
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
public async getUpdateSpotMarketBorrowRateIx(
|
|
2775
|
+
spotMarketIndex: number,
|
|
2776
|
+
optimalUtilization: number,
|
|
2777
|
+
optimalBorrowRate: number,
|
|
2778
|
+
optimalMaxRate: number,
|
|
2779
|
+
minBorrowRate?: number | undefined
|
|
2780
|
+
): Promise<TransactionInstruction> {
|
|
2781
|
+
return await this.program.instruction.updateSpotMarketBorrowRate(
|
|
2782
|
+
optimalUtilization,
|
|
2783
|
+
optimalBorrowRate,
|
|
2784
|
+
optimalMaxRate,
|
|
2785
|
+
minBorrowRate,
|
|
2786
|
+
{
|
|
2787
|
+
accounts: {
|
|
2788
|
+
admin: this.isSubscribed
|
|
2789
|
+
? this.getStateAccount().admin
|
|
2790
|
+
: this.wallet.publicKey,
|
|
2791
|
+
state: await this.getStatePublicKey(),
|
|
2792
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2793
|
+
this.program.programId,
|
|
2794
|
+
spotMarketIndex
|
|
2795
|
+
),
|
|
2796
|
+
},
|
|
2797
|
+
}
|
|
2798
|
+
);
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
public async updateSpotMarketAssetTier(
|
|
2802
|
+
spotMarketIndex: number,
|
|
2803
|
+
assetTier: AssetTier
|
|
2804
|
+
): Promise<TransactionSignature> {
|
|
2805
|
+
const updateSpotMarketAssetTierIx =
|
|
2806
|
+
await this.getUpdateSpotMarketAssetTierIx(spotMarketIndex, assetTier);
|
|
2807
|
+
|
|
2808
|
+
const tx = await this.buildTransaction(updateSpotMarketAssetTierIx);
|
|
2809
|
+
|
|
2810
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2811
|
+
|
|
2812
|
+
return txSig;
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
public async getUpdateSpotMarketAssetTierIx(
|
|
2816
|
+
spotMarketIndex: number,
|
|
2817
|
+
assetTier: AssetTier
|
|
2818
|
+
): Promise<TransactionInstruction> {
|
|
2819
|
+
return await this.program.instruction.updateSpotMarketAssetTier(assetTier, {
|
|
2820
|
+
accounts: {
|
|
2821
|
+
admin: this.isSubscribed
|
|
2822
|
+
? this.getStateAccount().admin
|
|
2823
|
+
: this.wallet.publicKey,
|
|
2824
|
+
state: await this.getStatePublicKey(),
|
|
2825
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2826
|
+
this.program.programId,
|
|
2827
|
+
spotMarketIndex
|
|
2828
|
+
),
|
|
2829
|
+
},
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
public async updateSpotMarketStatus(
|
|
2834
|
+
spotMarketIndex: number,
|
|
2835
|
+
marketStatus: MarketStatus
|
|
2836
|
+
): Promise<TransactionSignature> {
|
|
2837
|
+
const updateSpotMarketStatusIx = await this.getUpdateSpotMarketStatusIx(
|
|
2838
|
+
spotMarketIndex,
|
|
2839
|
+
marketStatus
|
|
2840
|
+
);
|
|
2841
|
+
|
|
2842
|
+
const tx = await this.buildTransaction(updateSpotMarketStatusIx);
|
|
2843
|
+
|
|
2844
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2845
|
+
|
|
2846
|
+
return txSig;
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
public async getUpdateSpotMarketStatusIx(
|
|
2850
|
+
spotMarketIndex: number,
|
|
2851
|
+
marketStatus: MarketStatus
|
|
2852
|
+
): Promise<TransactionInstruction> {
|
|
2853
|
+
return await this.program.instruction.updateSpotMarketStatus(marketStatus, {
|
|
2854
|
+
accounts: {
|
|
2855
|
+
admin: this.isSubscribed
|
|
2856
|
+
? this.getStateAccount().admin
|
|
2857
|
+
: this.wallet.publicKey,
|
|
2858
|
+
state: await this.getStatePublicKey(),
|
|
2859
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2860
|
+
this.program.programId,
|
|
2861
|
+
spotMarketIndex
|
|
2862
|
+
),
|
|
2863
|
+
},
|
|
2864
|
+
});
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2867
|
+
public async updateSpotMarketPausedOperations(
|
|
2868
|
+
spotMarketIndex: number,
|
|
2869
|
+
pausedOperations: number
|
|
2870
|
+
): Promise<TransactionSignature> {
|
|
2871
|
+
const updateSpotMarketPausedOperationsIx =
|
|
2872
|
+
await this.getUpdateSpotMarketPausedOperationsIx(
|
|
2873
|
+
spotMarketIndex,
|
|
2874
|
+
pausedOperations
|
|
2875
|
+
);
|
|
2876
|
+
|
|
2877
|
+
const tx = await this.buildTransaction(updateSpotMarketPausedOperationsIx);
|
|
2878
|
+
|
|
2879
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2880
|
+
|
|
2881
|
+
return txSig;
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
public async getUpdateSpotMarketPausedOperationsIx(
|
|
2885
|
+
spotMarketIndex: number,
|
|
2886
|
+
pausedOperations: number
|
|
2887
|
+
): Promise<TransactionInstruction> {
|
|
2888
|
+
return await this.program.instruction.updateSpotMarketPausedOperations(
|
|
2889
|
+
pausedOperations,
|
|
2890
|
+
{
|
|
2891
|
+
accounts: {
|
|
2892
|
+
admin: this.isSubscribed
|
|
2893
|
+
? this.getStateAccount().admin
|
|
2894
|
+
: this.wallet.publicKey,
|
|
2895
|
+
state: await this.getStatePublicKey(),
|
|
2896
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
2897
|
+
this.program.programId,
|
|
2898
|
+
spotMarketIndex
|
|
2899
|
+
),
|
|
2900
|
+
},
|
|
2901
|
+
}
|
|
2902
|
+
);
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
public async updatePerpMarketStatus(
|
|
2906
|
+
perpMarketIndex: number,
|
|
2907
|
+
marketStatus: MarketStatus
|
|
2908
|
+
): Promise<TransactionSignature> {
|
|
2909
|
+
const updatePerpMarketStatusIx = await this.getUpdatePerpMarketStatusIx(
|
|
2910
|
+
perpMarketIndex,
|
|
2911
|
+
marketStatus
|
|
2912
|
+
);
|
|
2913
|
+
|
|
2914
|
+
const tx = await this.buildTransaction(updatePerpMarketStatusIx);
|
|
2915
|
+
|
|
2916
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2917
|
+
|
|
2918
|
+
return txSig;
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
public async getUpdatePerpMarketStatusIx(
|
|
2922
|
+
perpMarketIndex: number,
|
|
2923
|
+
marketStatus: MarketStatus
|
|
2924
|
+
): Promise<TransactionInstruction> {
|
|
2925
|
+
return await this.program.instruction.updatePerpMarketStatus(marketStatus, {
|
|
2926
|
+
accounts: {
|
|
2927
|
+
admin: this.isSubscribed
|
|
2928
|
+
? this.getStateAccount().admin
|
|
2929
|
+
: this.wallet.publicKey,
|
|
2930
|
+
state: await this.getStatePublicKey(),
|
|
2931
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2932
|
+
this.program.programId,
|
|
2933
|
+
perpMarketIndex
|
|
2934
|
+
),
|
|
2935
|
+
},
|
|
2936
|
+
});
|
|
2937
|
+
}
|
|
2938
|
+
|
|
2939
|
+
public async updatePerpMarketPausedOperations(
|
|
2940
|
+
perpMarketIndex: number,
|
|
2941
|
+
pausedOperations: number
|
|
2942
|
+
): Promise<TransactionSignature> {
|
|
2943
|
+
const updatePerpMarketPausedOperationsIx =
|
|
2944
|
+
await this.getUpdatePerpMarketPausedOperationsIx(
|
|
2945
|
+
perpMarketIndex,
|
|
2946
|
+
pausedOperations
|
|
2947
|
+
);
|
|
2948
|
+
|
|
2949
|
+
const tx = await this.buildTransaction(updatePerpMarketPausedOperationsIx);
|
|
2950
|
+
|
|
2951
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2952
|
+
|
|
2953
|
+
return txSig;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
public async getUpdatePerpMarketPausedOperationsIx(
|
|
2957
|
+
perpMarketIndex: number,
|
|
2958
|
+
pausedOperations: number
|
|
2959
|
+
): Promise<TransactionInstruction> {
|
|
2960
|
+
return await this.program.instruction.updatePerpMarketPausedOperations(
|
|
2961
|
+
pausedOperations,
|
|
2962
|
+
{
|
|
2963
|
+
accounts: {
|
|
2964
|
+
admin: this.isSubscribed
|
|
2965
|
+
? this.getStateAccount().admin
|
|
2966
|
+
: this.wallet.publicKey,
|
|
2967
|
+
state: await this.getStatePublicKey(),
|
|
2968
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
2969
|
+
this.program.programId,
|
|
2970
|
+
perpMarketIndex
|
|
2971
|
+
),
|
|
2972
|
+
},
|
|
2973
|
+
}
|
|
2974
|
+
);
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
public async updatePerpMarketContractTier(
|
|
2978
|
+
perpMarketIndex: number,
|
|
2979
|
+
contractTier: ContractTier
|
|
2980
|
+
): Promise<TransactionSignature> {
|
|
2981
|
+
const updatePerpMarketContractTierIx =
|
|
2982
|
+
await this.getUpdatePerpMarketContractTierIx(
|
|
2983
|
+
perpMarketIndex,
|
|
2984
|
+
contractTier
|
|
2985
|
+
);
|
|
2986
|
+
|
|
2987
|
+
const tx = await this.buildTransaction(updatePerpMarketContractTierIx);
|
|
2988
|
+
|
|
2989
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2990
|
+
|
|
2991
|
+
return txSig;
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
public async getUpdatePerpMarketContractTierIx(
|
|
2995
|
+
perpMarketIndex: number,
|
|
2996
|
+
contractTier: ContractTier
|
|
2997
|
+
): Promise<TransactionInstruction> {
|
|
2998
|
+
return await this.program.instruction.updatePerpMarketContractTier(
|
|
2999
|
+
contractTier,
|
|
3000
|
+
{
|
|
3001
|
+
accounts: {
|
|
3002
|
+
admin: this.isSubscribed
|
|
3003
|
+
? this.getStateAccount().admin
|
|
3004
|
+
: this.wallet.publicKey,
|
|
3005
|
+
state: await this.getStatePublicKey(),
|
|
3006
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3007
|
+
this.program.programId,
|
|
3008
|
+
perpMarketIndex
|
|
3009
|
+
),
|
|
3010
|
+
},
|
|
3011
|
+
}
|
|
3012
|
+
);
|
|
3013
|
+
}
|
|
3014
|
+
|
|
3015
|
+
public async updateExchangeStatus(
|
|
3016
|
+
exchangeStatus: ExchangeStatus
|
|
3017
|
+
): Promise<TransactionSignature> {
|
|
3018
|
+
const updateExchangeStatusIx = await this.getUpdateExchangeStatusIx(
|
|
3019
|
+
exchangeStatus
|
|
3020
|
+
);
|
|
3021
|
+
|
|
3022
|
+
const tx = await this.buildTransaction(updateExchangeStatusIx);
|
|
3023
|
+
|
|
3024
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3025
|
+
|
|
3026
|
+
return txSig;
|
|
3027
|
+
}
|
|
3028
|
+
|
|
3029
|
+
public async getUpdateExchangeStatusIx(
|
|
3030
|
+
exchangeStatus: ExchangeStatus
|
|
3031
|
+
): Promise<TransactionInstruction> {
|
|
3032
|
+
return await this.program.instruction.updateExchangeStatus(exchangeStatus, {
|
|
3033
|
+
accounts: {
|
|
3034
|
+
admin: this.isSubscribed
|
|
3035
|
+
? this.getStateAccount().admin
|
|
3036
|
+
: this.wallet.publicKey,
|
|
3037
|
+
state: await this.getStatePublicKey(),
|
|
3038
|
+
},
|
|
3039
|
+
});
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
public async updatePerpAuctionDuration(
|
|
3043
|
+
minDuration: BN | number
|
|
3044
|
+
): Promise<TransactionSignature> {
|
|
3045
|
+
const updatePerpAuctionDurationIx =
|
|
3046
|
+
await this.getUpdatePerpAuctionDurationIx(minDuration);
|
|
3047
|
+
|
|
3048
|
+
const tx = await this.buildTransaction(updatePerpAuctionDurationIx);
|
|
3049
|
+
|
|
3050
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3051
|
+
|
|
3052
|
+
return txSig;
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
public async getUpdatePerpAuctionDurationIx(
|
|
3056
|
+
minDuration: BN | number
|
|
3057
|
+
): Promise<TransactionInstruction> {
|
|
3058
|
+
return await this.program.instruction.updatePerpAuctionDuration(
|
|
3059
|
+
typeof minDuration === 'number' ? minDuration : minDuration.toNumber(),
|
|
3060
|
+
{
|
|
3061
|
+
accounts: {
|
|
3062
|
+
admin: this.isSubscribed
|
|
3063
|
+
? this.getStateAccount().admin
|
|
3064
|
+
: this.wallet.publicKey,
|
|
3065
|
+
state: await this.getStatePublicKey(),
|
|
3066
|
+
},
|
|
3067
|
+
}
|
|
3068
|
+
);
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
public async updateSpotAuctionDuration(
|
|
3072
|
+
defaultAuctionDuration: number
|
|
3073
|
+
): Promise<TransactionSignature> {
|
|
3074
|
+
const updateSpotAuctionDurationIx =
|
|
3075
|
+
await this.getUpdateSpotAuctionDurationIx(defaultAuctionDuration);
|
|
3076
|
+
|
|
3077
|
+
const tx = await this.buildTransaction(updateSpotAuctionDurationIx);
|
|
3078
|
+
|
|
3079
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3080
|
+
|
|
3081
|
+
return txSig;
|
|
3082
|
+
}
|
|
3083
|
+
|
|
3084
|
+
public async getUpdateSpotAuctionDurationIx(
|
|
3085
|
+
defaultAuctionDuration: number
|
|
3086
|
+
): Promise<TransactionInstruction> {
|
|
3087
|
+
return await this.program.instruction.updateSpotAuctionDuration(
|
|
3088
|
+
defaultAuctionDuration,
|
|
3089
|
+
{
|
|
3090
|
+
accounts: {
|
|
3091
|
+
admin: this.isSubscribed
|
|
3092
|
+
? this.getStateAccount().admin
|
|
3093
|
+
: this.wallet.publicKey,
|
|
3094
|
+
state: await this.getStatePublicKey(),
|
|
3095
|
+
},
|
|
3096
|
+
}
|
|
3097
|
+
);
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3100
|
+
public async updatePerpMarketMaxFillReserveFraction(
|
|
3101
|
+
perpMarketIndex: number,
|
|
3102
|
+
maxBaseAssetAmountRatio: number
|
|
3103
|
+
): Promise<TransactionSignature> {
|
|
3104
|
+
const updatePerpMarketMaxFillReserveFractionIx =
|
|
3105
|
+
await this.getUpdatePerpMarketMaxFillReserveFractionIx(
|
|
3106
|
+
perpMarketIndex,
|
|
3107
|
+
maxBaseAssetAmountRatio
|
|
3108
|
+
);
|
|
3109
|
+
|
|
3110
|
+
const tx = await this.buildTransaction(
|
|
3111
|
+
updatePerpMarketMaxFillReserveFractionIx
|
|
3112
|
+
);
|
|
3113
|
+
|
|
3114
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3115
|
+
|
|
3116
|
+
return txSig;
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
public async getUpdatePerpMarketMaxFillReserveFractionIx(
|
|
3120
|
+
perpMarketIndex: number,
|
|
3121
|
+
maxBaseAssetAmountRatio: number
|
|
3122
|
+
): Promise<TransactionInstruction> {
|
|
3123
|
+
return await this.program.instruction.updatePerpMarketMaxFillReserveFraction(
|
|
3124
|
+
maxBaseAssetAmountRatio,
|
|
3125
|
+
{
|
|
3126
|
+
accounts: {
|
|
3127
|
+
admin: this.isSubscribed
|
|
3128
|
+
? this.getStateAccount().admin
|
|
3129
|
+
: this.wallet.publicKey,
|
|
3130
|
+
state: await this.getStatePublicKey(),
|
|
3131
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3132
|
+
this.program.programId,
|
|
3133
|
+
perpMarketIndex
|
|
3134
|
+
),
|
|
3135
|
+
},
|
|
3136
|
+
}
|
|
3137
|
+
);
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
public async updateMaxSlippageRatio(
|
|
3141
|
+
perpMarketIndex: number,
|
|
3142
|
+
maxSlippageRatio: number
|
|
3143
|
+
): Promise<TransactionSignature> {
|
|
3144
|
+
const updateMaxSlippageRatioIx = await this.getUpdateMaxSlippageRatioIx(
|
|
3145
|
+
perpMarketIndex,
|
|
3146
|
+
maxSlippageRatio
|
|
3147
|
+
);
|
|
3148
|
+
|
|
3149
|
+
const tx = await this.buildTransaction(updateMaxSlippageRatioIx);
|
|
3150
|
+
|
|
3151
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3152
|
+
|
|
3153
|
+
return txSig;
|
|
3154
|
+
}
|
|
3155
|
+
|
|
3156
|
+
public async getUpdateMaxSlippageRatioIx(
|
|
3157
|
+
perpMarketIndex: number,
|
|
3158
|
+
maxSlippageRatio: number
|
|
3159
|
+
): Promise<TransactionInstruction> {
|
|
3160
|
+
return await this.program.instruction.updateMaxSlippageRatio(
|
|
3161
|
+
maxSlippageRatio,
|
|
3162
|
+
{
|
|
3163
|
+
accounts: {
|
|
3164
|
+
admin: this.isSubscribed
|
|
3165
|
+
? this.getStateAccount().admin
|
|
3166
|
+
: this.wallet.publicKey,
|
|
3167
|
+
state: await this.getStatePublicKey(),
|
|
3168
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
3169
|
+
},
|
|
3170
|
+
}
|
|
3171
|
+
);
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
public async updatePerpMarketUnrealizedAssetWeight(
|
|
3175
|
+
perpMarketIndex: number,
|
|
3176
|
+
unrealizedInitialAssetWeight: number,
|
|
3177
|
+
unrealizedMaintenanceAssetWeight: number
|
|
3178
|
+
): Promise<TransactionSignature> {
|
|
3179
|
+
const updatePerpMarketUnrealizedAssetWeightIx =
|
|
3180
|
+
await this.getUpdatePerpMarketUnrealizedAssetWeightIx(
|
|
3181
|
+
perpMarketIndex,
|
|
3182
|
+
unrealizedInitialAssetWeight,
|
|
3183
|
+
unrealizedMaintenanceAssetWeight
|
|
3184
|
+
);
|
|
3185
|
+
|
|
3186
|
+
const tx = await this.buildTransaction(
|
|
3187
|
+
updatePerpMarketUnrealizedAssetWeightIx
|
|
3188
|
+
);
|
|
3189
|
+
|
|
3190
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3191
|
+
|
|
3192
|
+
return txSig;
|
|
3193
|
+
}
|
|
3194
|
+
|
|
3195
|
+
public async getUpdatePerpMarketUnrealizedAssetWeightIx(
|
|
3196
|
+
perpMarketIndex: number,
|
|
3197
|
+
unrealizedInitialAssetWeight: number,
|
|
3198
|
+
unrealizedMaintenanceAssetWeight: number
|
|
3199
|
+
): Promise<TransactionInstruction> {
|
|
3200
|
+
return await this.program.instruction.updatePerpMarketUnrealizedAssetWeight(
|
|
3201
|
+
unrealizedInitialAssetWeight,
|
|
3202
|
+
unrealizedMaintenanceAssetWeight,
|
|
3203
|
+
{
|
|
3204
|
+
accounts: {
|
|
3205
|
+
admin: this.isSubscribed
|
|
3206
|
+
? this.getStateAccount().admin
|
|
3207
|
+
: this.wallet.publicKey,
|
|
3208
|
+
state: await this.getStatePublicKey(),
|
|
3209
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3210
|
+
this.program.programId,
|
|
3211
|
+
perpMarketIndex
|
|
3212
|
+
),
|
|
3213
|
+
},
|
|
3214
|
+
}
|
|
3215
|
+
);
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
public async updatePerpMarketMaxImbalances(
|
|
3219
|
+
perpMarketIndex: number,
|
|
3220
|
+
unrealizedMaxImbalance: BN,
|
|
3221
|
+
maxRevenueWithdrawPerPeriod: BN,
|
|
3222
|
+
quoteMaxInsurance: BN
|
|
3223
|
+
): Promise<TransactionSignature> {
|
|
3224
|
+
const updatePerpMarketMaxImabalancesIx =
|
|
3225
|
+
await this.getUpdatePerpMarketMaxImbalancesIx(
|
|
3226
|
+
perpMarketIndex,
|
|
3227
|
+
unrealizedMaxImbalance,
|
|
3228
|
+
maxRevenueWithdrawPerPeriod,
|
|
3229
|
+
quoteMaxInsurance
|
|
3230
|
+
);
|
|
3231
|
+
|
|
3232
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxImabalancesIx);
|
|
3233
|
+
|
|
3234
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3235
|
+
|
|
3236
|
+
return txSig;
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
public async getUpdatePerpMarketMaxImbalancesIx(
|
|
3240
|
+
perpMarketIndex: number,
|
|
3241
|
+
unrealizedMaxImbalance: BN,
|
|
3242
|
+
maxRevenueWithdrawPerPeriod: BN,
|
|
3243
|
+
quoteMaxInsurance: BN
|
|
3244
|
+
): Promise<TransactionInstruction> {
|
|
3245
|
+
return await this.program.instruction.updatePerpMarketMaxImbalances(
|
|
3246
|
+
unrealizedMaxImbalance,
|
|
3247
|
+
maxRevenueWithdrawPerPeriod,
|
|
3248
|
+
quoteMaxInsurance,
|
|
3249
|
+
{
|
|
3250
|
+
accounts: {
|
|
3251
|
+
admin: this.isSubscribed
|
|
3252
|
+
? this.getStateAccount().admin
|
|
3253
|
+
: this.wallet.publicKey,
|
|
3254
|
+
state: await this.getStatePublicKey(),
|
|
3255
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3256
|
+
this.program.programId,
|
|
3257
|
+
perpMarketIndex
|
|
3258
|
+
),
|
|
3259
|
+
},
|
|
3260
|
+
}
|
|
3261
|
+
);
|
|
3262
|
+
}
|
|
3263
|
+
|
|
3264
|
+
public async updatePerpMarketMaxOpenInterest(
|
|
3265
|
+
perpMarketIndex: number,
|
|
3266
|
+
maxOpenInterest: BN
|
|
3267
|
+
): Promise<TransactionSignature> {
|
|
3268
|
+
const updatePerpMarketMaxOpenInterestIx =
|
|
3269
|
+
await this.getUpdatePerpMarketMaxOpenInterestIx(
|
|
3270
|
+
perpMarketIndex,
|
|
3271
|
+
maxOpenInterest
|
|
3272
|
+
);
|
|
3273
|
+
|
|
3274
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxOpenInterestIx);
|
|
3275
|
+
|
|
3276
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3277
|
+
|
|
3278
|
+
return txSig;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
public async getUpdatePerpMarketMaxOpenInterestIx(
|
|
3282
|
+
perpMarketIndex: number,
|
|
3283
|
+
maxOpenInterest: BN
|
|
3284
|
+
): Promise<TransactionInstruction> {
|
|
3285
|
+
return await this.program.instruction.updatePerpMarketMaxOpenInterest(
|
|
3286
|
+
maxOpenInterest,
|
|
3287
|
+
{
|
|
3288
|
+
accounts: {
|
|
3289
|
+
admin: this.isSubscribed
|
|
3290
|
+
? this.getStateAccount().admin
|
|
3291
|
+
: this.wallet.publicKey,
|
|
3292
|
+
state: await this.getStatePublicKey(),
|
|
3293
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3294
|
+
this.program.programId,
|
|
3295
|
+
perpMarketIndex
|
|
3296
|
+
),
|
|
3297
|
+
},
|
|
3298
|
+
}
|
|
3299
|
+
);
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3302
|
+
public async updatePerpMarketNumberOfUser(
|
|
3303
|
+
perpMarketIndex: number,
|
|
3304
|
+
numberOfUsers?: number,
|
|
3305
|
+
numberOfUsersWithBase?: number
|
|
3306
|
+
): Promise<TransactionSignature> {
|
|
3307
|
+
const updatepPerpMarketFeeAdjustmentIx =
|
|
3308
|
+
await this.getUpdatePerpMarketNumberOfUsersIx(
|
|
3309
|
+
perpMarketIndex,
|
|
3310
|
+
numberOfUsers,
|
|
3311
|
+
numberOfUsersWithBase
|
|
3312
|
+
);
|
|
3313
|
+
|
|
3314
|
+
const tx = await this.buildTransaction(updatepPerpMarketFeeAdjustmentIx);
|
|
3315
|
+
|
|
3316
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3317
|
+
|
|
3318
|
+
return txSig;
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
public async getUpdatePerpMarketNumberOfUsersIx(
|
|
3322
|
+
perpMarketIndex: number,
|
|
3323
|
+
numberOfUsers?: number,
|
|
3324
|
+
numberOfUsersWithBase?: number
|
|
3325
|
+
): Promise<TransactionInstruction> {
|
|
3326
|
+
return await this.program.instruction.updatePerpMarketNumberOfUsers(
|
|
3327
|
+
numberOfUsers,
|
|
3328
|
+
numberOfUsersWithBase,
|
|
3329
|
+
{
|
|
3330
|
+
accounts: {
|
|
3331
|
+
admin: this.isSubscribed
|
|
3332
|
+
? this.getStateAccount().admin
|
|
3333
|
+
: this.wallet.publicKey,
|
|
3334
|
+
state: await this.getStatePublicKey(),
|
|
3335
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3336
|
+
this.program.programId,
|
|
3337
|
+
perpMarketIndex
|
|
3338
|
+
),
|
|
3339
|
+
},
|
|
3340
|
+
}
|
|
3341
|
+
);
|
|
3342
|
+
}
|
|
3343
|
+
|
|
3344
|
+
public async updatePerpMarketFeeAdjustment(
|
|
3345
|
+
perpMarketIndex: number,
|
|
3346
|
+
feeAdjustment: number
|
|
3347
|
+
): Promise<TransactionSignature> {
|
|
3348
|
+
const updatepPerpMarketFeeAdjustmentIx =
|
|
3349
|
+
await this.getUpdatePerpMarketFeeAdjustmentIx(
|
|
3350
|
+
perpMarketIndex,
|
|
3351
|
+
feeAdjustment
|
|
3352
|
+
);
|
|
3353
|
+
|
|
3354
|
+
const tx = await this.buildTransaction(updatepPerpMarketFeeAdjustmentIx);
|
|
3355
|
+
|
|
3356
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3357
|
+
|
|
3358
|
+
return txSig;
|
|
3359
|
+
}
|
|
3360
|
+
|
|
3361
|
+
public async getUpdatePerpMarketFeeAdjustmentIx(
|
|
3362
|
+
perpMarketIndex: number,
|
|
3363
|
+
feeAdjustment: number
|
|
3364
|
+
): Promise<TransactionInstruction> {
|
|
3365
|
+
return await this.program.instruction.updatePerpMarketFeeAdjustment(
|
|
3366
|
+
feeAdjustment,
|
|
3367
|
+
{
|
|
3368
|
+
accounts: {
|
|
3369
|
+
admin: this.isSubscribed
|
|
3370
|
+
? this.getStateAccount().admin
|
|
3371
|
+
: this.wallet.publicKey,
|
|
3372
|
+
state: await this.getStatePublicKey(),
|
|
3373
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3374
|
+
this.program.programId,
|
|
3375
|
+
perpMarketIndex
|
|
3376
|
+
),
|
|
3377
|
+
},
|
|
3378
|
+
}
|
|
3379
|
+
);
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
public async updateSpotMarketFeeAdjustment(
|
|
3383
|
+
perpMarketIndex: number,
|
|
3384
|
+
feeAdjustment: number
|
|
3385
|
+
): Promise<TransactionSignature> {
|
|
3386
|
+
const updateSpotMarketFeeAdjustmentIx =
|
|
3387
|
+
await this.getUpdateSpotMarketFeeAdjustmentIx(
|
|
3388
|
+
perpMarketIndex,
|
|
3389
|
+
feeAdjustment
|
|
3390
|
+
);
|
|
3391
|
+
|
|
3392
|
+
const tx = await this.buildTransaction(updateSpotMarketFeeAdjustmentIx);
|
|
3393
|
+
|
|
3394
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3395
|
+
|
|
3396
|
+
return txSig;
|
|
3397
|
+
}
|
|
3398
|
+
|
|
3399
|
+
public async getUpdateSpotMarketFeeAdjustmentIx(
|
|
3400
|
+
spotMarketIndex: number,
|
|
3401
|
+
feeAdjustment: number
|
|
3402
|
+
): Promise<TransactionInstruction> {
|
|
3403
|
+
return await this.program.instruction.updateSpotMarketFeeAdjustment(
|
|
3404
|
+
feeAdjustment,
|
|
3405
|
+
{
|
|
3406
|
+
accounts: {
|
|
3407
|
+
admin: this.isSubscribed
|
|
3408
|
+
? this.getStateAccount().admin
|
|
3409
|
+
: this.wallet.publicKey,
|
|
3410
|
+
state: await this.getStatePublicKey(),
|
|
3411
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
3412
|
+
this.program.programId,
|
|
3413
|
+
spotMarketIndex
|
|
3414
|
+
),
|
|
3415
|
+
},
|
|
3416
|
+
}
|
|
3417
|
+
);
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
public async updateSerumVault(
|
|
3421
|
+
srmVault: PublicKey
|
|
3422
|
+
): Promise<TransactionSignature> {
|
|
3423
|
+
const updateSerumVaultIx = await this.getUpdateSerumVaultIx(srmVault);
|
|
3424
|
+
|
|
3425
|
+
const tx = await this.buildTransaction(updateSerumVaultIx);
|
|
3426
|
+
|
|
3427
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3428
|
+
|
|
3429
|
+
return txSig;
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3432
|
+
public async getUpdateSerumVaultIx(
|
|
3433
|
+
srmVault: PublicKey
|
|
3434
|
+
): Promise<TransactionInstruction> {
|
|
3435
|
+
return await this.program.instruction.updateSerumVault(srmVault, {
|
|
3436
|
+
accounts: {
|
|
3437
|
+
admin: this.isSubscribed
|
|
3438
|
+
? this.getStateAccount().admin
|
|
3439
|
+
: this.wallet.publicKey,
|
|
3440
|
+
state: await this.getStatePublicKey(),
|
|
3441
|
+
srmVault: srmVault,
|
|
3442
|
+
},
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3446
|
+
public async updatePerpMarketLiquidationFee(
|
|
3447
|
+
perpMarketIndex: number,
|
|
3448
|
+
liquidatorFee: number,
|
|
3449
|
+
ifLiquidationFee: number
|
|
3450
|
+
): Promise<TransactionSignature> {
|
|
3451
|
+
const updatePerpMarketLiquidationFeeIx =
|
|
3452
|
+
await this.getUpdatePerpMarketLiquidationFeeIx(
|
|
3453
|
+
perpMarketIndex,
|
|
3454
|
+
liquidatorFee,
|
|
3455
|
+
ifLiquidationFee
|
|
3456
|
+
);
|
|
3457
|
+
|
|
3458
|
+
const tx = await this.buildTransaction(updatePerpMarketLiquidationFeeIx);
|
|
3459
|
+
|
|
3460
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3461
|
+
|
|
3462
|
+
return txSig;
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
public async getUpdatePerpMarketLiquidationFeeIx(
|
|
3466
|
+
perpMarketIndex: number,
|
|
3467
|
+
liquidatorFee: number,
|
|
3468
|
+
ifLiquidationFee: number
|
|
3469
|
+
): Promise<TransactionInstruction> {
|
|
3470
|
+
return await this.program.instruction.updatePerpMarketLiquidationFee(
|
|
3471
|
+
liquidatorFee,
|
|
3472
|
+
ifLiquidationFee,
|
|
3473
|
+
{
|
|
3474
|
+
accounts: {
|
|
3475
|
+
admin: this.isSubscribed
|
|
3476
|
+
? this.getStateAccount().admin
|
|
3477
|
+
: this.wallet.publicKey,
|
|
3478
|
+
state: await this.getStatePublicKey(),
|
|
3479
|
+
perpMarket: await getPerpMarketPublicKey(
|
|
3480
|
+
this.program.programId,
|
|
3481
|
+
perpMarketIndex
|
|
3482
|
+
),
|
|
3483
|
+
},
|
|
3484
|
+
}
|
|
3485
|
+
);
|
|
3486
|
+
}
|
|
3487
|
+
|
|
3488
|
+
public async updateSpotMarketLiquidationFee(
|
|
3489
|
+
spotMarketIndex: number,
|
|
3490
|
+
liquidatorFee: number,
|
|
3491
|
+
ifLiquidationFee: number
|
|
3492
|
+
): Promise<TransactionSignature> {
|
|
3493
|
+
const updateSpotMarketLiquidationFeeIx =
|
|
3494
|
+
await this.getUpdateSpotMarketLiquidationFeeIx(
|
|
3495
|
+
spotMarketIndex,
|
|
3496
|
+
liquidatorFee,
|
|
3497
|
+
ifLiquidationFee
|
|
3498
|
+
);
|
|
3499
|
+
|
|
3500
|
+
const tx = await this.buildTransaction(updateSpotMarketLiquidationFeeIx);
|
|
3501
|
+
|
|
3502
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3503
|
+
|
|
3504
|
+
return txSig;
|
|
3505
|
+
}
|
|
3506
|
+
|
|
3507
|
+
public async getUpdateSpotMarketLiquidationFeeIx(
|
|
3508
|
+
spotMarketIndex: number,
|
|
3509
|
+
liquidatorFee: number,
|
|
3510
|
+
ifLiquidationFee: number
|
|
3511
|
+
): Promise<TransactionInstruction> {
|
|
3512
|
+
return await this.program.instruction.updateSpotMarketLiquidationFee(
|
|
3513
|
+
liquidatorFee,
|
|
3514
|
+
ifLiquidationFee,
|
|
3515
|
+
{
|
|
3516
|
+
accounts: {
|
|
3517
|
+
admin: this.isSubscribed
|
|
3518
|
+
? this.getStateAccount().admin
|
|
3519
|
+
: this.wallet.publicKey,
|
|
3520
|
+
state: await this.getStatePublicKey(),
|
|
3521
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
3522
|
+
this.program.programId,
|
|
3523
|
+
spotMarketIndex
|
|
3524
|
+
),
|
|
3525
|
+
},
|
|
3526
|
+
}
|
|
3527
|
+
);
|
|
3528
|
+
}
|
|
3529
|
+
|
|
3530
|
+
public async initializeProtocolIfSharesTransferConfig(): Promise<TransactionSignature> {
|
|
3531
|
+
const initializeProtocolIfSharesTransferConfigIx =
|
|
3532
|
+
await this.getInitializeProtocolIfSharesTransferConfigIx();
|
|
3533
|
+
|
|
3534
|
+
const tx = await this.buildTransaction(
|
|
3535
|
+
initializeProtocolIfSharesTransferConfigIx
|
|
3536
|
+
);
|
|
3537
|
+
|
|
3538
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3539
|
+
|
|
3540
|
+
return txSig;
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3543
|
+
public async getInitializeProtocolIfSharesTransferConfigIx(): Promise<TransactionInstruction> {
|
|
3544
|
+
return await this.program.instruction.initializeProtocolIfSharesTransferConfig(
|
|
3545
|
+
{
|
|
3546
|
+
accounts: {
|
|
3547
|
+
admin: this.isSubscribed
|
|
3548
|
+
? this.getStateAccount().admin
|
|
3549
|
+
: this.wallet.publicKey,
|
|
3550
|
+
state: await this.getStatePublicKey(),
|
|
3551
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
3552
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
3553
|
+
protocolIfSharesTransferConfig:
|
|
3554
|
+
getProtocolIfSharesTransferConfigPublicKey(this.program.programId),
|
|
3555
|
+
},
|
|
3556
|
+
}
|
|
3557
|
+
);
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
public async updateProtocolIfSharesTransferConfig(
|
|
3561
|
+
whitelistedSigners?: PublicKey[],
|
|
3562
|
+
maxTransferPerEpoch?: BN
|
|
3563
|
+
): Promise<TransactionSignature> {
|
|
3564
|
+
const updateProtocolIfSharesTransferConfigIx =
|
|
3565
|
+
await this.getUpdateProtocolIfSharesTransferConfigIx(
|
|
3566
|
+
whitelistedSigners,
|
|
3567
|
+
maxTransferPerEpoch
|
|
3568
|
+
);
|
|
3569
|
+
|
|
3570
|
+
const tx = await this.buildTransaction(
|
|
3571
|
+
updateProtocolIfSharesTransferConfigIx
|
|
3572
|
+
);
|
|
3573
|
+
|
|
3574
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3575
|
+
|
|
3576
|
+
return txSig;
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
public async getUpdateProtocolIfSharesTransferConfigIx(
|
|
3580
|
+
whitelistedSigners?: PublicKey[],
|
|
3581
|
+
maxTransferPerEpoch?: BN
|
|
3582
|
+
): Promise<TransactionInstruction> {
|
|
3583
|
+
return await this.program.instruction.updateProtocolIfSharesTransferConfig(
|
|
3584
|
+
whitelistedSigners || null,
|
|
3585
|
+
maxTransferPerEpoch,
|
|
3586
|
+
{
|
|
3587
|
+
accounts: {
|
|
3588
|
+
admin: this.isSubscribed
|
|
3589
|
+
? this.getStateAccount().admin
|
|
3590
|
+
: this.wallet.publicKey,
|
|
3591
|
+
state: await this.getStatePublicKey(),
|
|
3592
|
+
protocolIfSharesTransferConfig:
|
|
3593
|
+
getProtocolIfSharesTransferConfigPublicKey(this.program.programId),
|
|
3594
|
+
},
|
|
3595
|
+
}
|
|
3596
|
+
);
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
public async initializePrelaunchOracle(
|
|
3600
|
+
perpMarketIndex: number,
|
|
3601
|
+
price?: BN,
|
|
3602
|
+
maxPrice?: BN
|
|
3603
|
+
): Promise<TransactionSignature> {
|
|
3604
|
+
const initializePrelaunchOracleIx =
|
|
3605
|
+
await this.getInitializePrelaunchOracleIx(
|
|
3606
|
+
perpMarketIndex,
|
|
3607
|
+
price,
|
|
3608
|
+
maxPrice
|
|
3609
|
+
);
|
|
3610
|
+
|
|
3611
|
+
const tx = await this.buildTransaction(initializePrelaunchOracleIx);
|
|
3612
|
+
|
|
3613
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3614
|
+
|
|
3615
|
+
return txSig;
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3618
|
+
public async getInitializePrelaunchOracleIx(
|
|
3619
|
+
perpMarketIndex: number,
|
|
3620
|
+
price?: BN,
|
|
3621
|
+
maxPrice?: BN
|
|
3622
|
+
): Promise<TransactionInstruction> {
|
|
3623
|
+
const params = {
|
|
3624
|
+
perpMarketIndex,
|
|
3625
|
+
price: price || null,
|
|
3626
|
+
maxPrice: maxPrice || null,
|
|
3627
|
+
};
|
|
3628
|
+
|
|
3629
|
+
return await this.program.instruction.initializePrelaunchOracle(params, {
|
|
3630
|
+
accounts: {
|
|
3631
|
+
admin: this.isSubscribed
|
|
3632
|
+
? this.getStateAccount().admin
|
|
3633
|
+
: this.wallet.publicKey,
|
|
3634
|
+
state: await this.getStatePublicKey(),
|
|
3635
|
+
prelaunchOracle: await getPrelaunchOraclePublicKey(
|
|
3636
|
+
this.program.programId,
|
|
3637
|
+
perpMarketIndex
|
|
3638
|
+
),
|
|
3639
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
3640
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
3641
|
+
},
|
|
3642
|
+
});
|
|
3643
|
+
}
|
|
3644
|
+
|
|
3645
|
+
public async updatePrelaunchOracleParams(
|
|
3646
|
+
perpMarketIndex: number,
|
|
3647
|
+
price?: BN,
|
|
3648
|
+
maxPrice?: BN
|
|
3649
|
+
): Promise<TransactionSignature> {
|
|
3650
|
+
const updatePrelaunchOracleParamsIx =
|
|
3651
|
+
await this.getUpdatePrelaunchOracleParamsIx(
|
|
3652
|
+
perpMarketIndex,
|
|
3653
|
+
price,
|
|
3654
|
+
maxPrice
|
|
3655
|
+
);
|
|
3656
|
+
|
|
3657
|
+
const tx = await this.buildTransaction(updatePrelaunchOracleParamsIx);
|
|
3658
|
+
|
|
3659
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3660
|
+
|
|
3661
|
+
return txSig;
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
public async getUpdatePrelaunchOracleParamsIx(
|
|
3665
|
+
perpMarketIndex: number,
|
|
3666
|
+
price?: BN,
|
|
3667
|
+
maxPrice?: BN
|
|
3668
|
+
): Promise<TransactionInstruction> {
|
|
3669
|
+
const params = {
|
|
3670
|
+
perpMarketIndex,
|
|
3671
|
+
price: price || null,
|
|
3672
|
+
maxPrice: maxPrice || null,
|
|
3673
|
+
};
|
|
3674
|
+
|
|
3675
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
3676
|
+
this.program.programId,
|
|
3677
|
+
perpMarketIndex
|
|
3678
|
+
);
|
|
3679
|
+
|
|
3680
|
+
return await this.program.instruction.updatePrelaunchOracleParams(params, {
|
|
3681
|
+
accounts: {
|
|
3682
|
+
admin: this.isSubscribed
|
|
3683
|
+
? this.getStateAccount().admin
|
|
3684
|
+
: this.wallet.publicKey,
|
|
3685
|
+
state: await this.getStatePublicKey(),
|
|
3686
|
+
perpMarket: perpMarketPublicKey,
|
|
3687
|
+
prelaunchOracle: await getPrelaunchOraclePublicKey(
|
|
3688
|
+
this.program.programId,
|
|
3689
|
+
perpMarketIndex
|
|
3690
|
+
),
|
|
3691
|
+
},
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
|
|
3695
|
+
public async deletePrelaunchOracle(
|
|
3696
|
+
perpMarketIndex: number
|
|
3697
|
+
): Promise<TransactionSignature> {
|
|
3698
|
+
const deletePrelaunchOracleIx = await this.getDeletePrelaunchOracleIx(
|
|
3699
|
+
perpMarketIndex
|
|
3700
|
+
);
|
|
3701
|
+
|
|
3702
|
+
const tx = await this.buildTransaction(deletePrelaunchOracleIx);
|
|
3703
|
+
|
|
3704
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3705
|
+
|
|
3706
|
+
return txSig;
|
|
3707
|
+
}
|
|
3708
|
+
|
|
3709
|
+
public async getDeletePrelaunchOracleIx(
|
|
3710
|
+
perpMarketIndex: number,
|
|
3711
|
+
price?: BN,
|
|
3712
|
+
maxPrice?: BN
|
|
3713
|
+
): Promise<TransactionInstruction> {
|
|
3714
|
+
const params = {
|
|
3715
|
+
perpMarketIndex,
|
|
3716
|
+
price: price || null,
|
|
3717
|
+
maxPrice: maxPrice || null,
|
|
3718
|
+
};
|
|
3719
|
+
|
|
3720
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
3721
|
+
this.program.programId,
|
|
3722
|
+
perpMarketIndex
|
|
3723
|
+
);
|
|
3724
|
+
|
|
3725
|
+
return await this.program.instruction.deletePrelaunchOracle(params, {
|
|
3726
|
+
accounts: {
|
|
3727
|
+
admin: this.isSubscribed
|
|
3728
|
+
? this.getStateAccount().admin
|
|
3729
|
+
: this.wallet.publicKey,
|
|
3730
|
+
state: await this.getStatePublicKey(),
|
|
3731
|
+
perpMarket: perpMarketPublicKey,
|
|
3732
|
+
prelaunchOracle: await getPrelaunchOraclePublicKey(
|
|
3733
|
+
this.program.programId,
|
|
3734
|
+
perpMarketIndex
|
|
3735
|
+
),
|
|
3736
|
+
},
|
|
3737
|
+
});
|
|
3738
|
+
}
|
|
3739
|
+
|
|
3740
|
+
public async updateSpotMarketFuel(
|
|
3741
|
+
spotMarketIndex: number,
|
|
3742
|
+
fuelBoostDeposits?: number,
|
|
3743
|
+
fuelBoostBorrows?: number,
|
|
3744
|
+
fuelBoostTaker?: number,
|
|
3745
|
+
fuelBoostMaker?: number,
|
|
3746
|
+
fuelBoostInsurance?: number
|
|
3747
|
+
): Promise<TransactionSignature> {
|
|
3748
|
+
const updateSpotMarketFuelIx = await this.getUpdateSpotMarketFuelIx(
|
|
3749
|
+
spotMarketIndex,
|
|
3750
|
+
fuelBoostDeposits || null,
|
|
3751
|
+
fuelBoostBorrows || null,
|
|
3752
|
+
fuelBoostTaker || null,
|
|
3753
|
+
fuelBoostMaker || null,
|
|
3754
|
+
fuelBoostInsurance || null
|
|
3755
|
+
);
|
|
3756
|
+
|
|
3757
|
+
const tx = await this.buildTransaction(updateSpotMarketFuelIx);
|
|
3758
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3759
|
+
|
|
3760
|
+
return txSig;
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
public async getUpdateSpotMarketFuelIx(
|
|
3764
|
+
spotMarketIndex: number,
|
|
3765
|
+
fuelBoostDeposits?: number,
|
|
3766
|
+
fuelBoostBorrows?: number,
|
|
3767
|
+
fuelBoostTaker?: number,
|
|
3768
|
+
fuelBoostMaker?: number,
|
|
3769
|
+
fuelBoostInsurance?: number
|
|
3770
|
+
): Promise<TransactionInstruction> {
|
|
3771
|
+
const spotMarketPublicKey = await getSpotMarketPublicKey(
|
|
3772
|
+
this.program.programId,
|
|
3773
|
+
spotMarketIndex
|
|
3774
|
+
);
|
|
3775
|
+
|
|
3776
|
+
return await this.program.instruction.updateSpotMarketFuel(
|
|
3777
|
+
fuelBoostDeposits || null,
|
|
3778
|
+
fuelBoostBorrows || null,
|
|
3779
|
+
fuelBoostTaker || null,
|
|
3780
|
+
fuelBoostMaker || null,
|
|
3781
|
+
fuelBoostInsurance || null,
|
|
3782
|
+
{
|
|
3783
|
+
accounts: {
|
|
3784
|
+
admin: this.isSubscribed
|
|
3785
|
+
? this.getStateAccount().admin
|
|
3786
|
+
: this.wallet.publicKey,
|
|
3787
|
+
state: await this.getStatePublicKey(),
|
|
3788
|
+
spotMarket: spotMarketPublicKey,
|
|
3789
|
+
},
|
|
3790
|
+
}
|
|
3791
|
+
);
|
|
3792
|
+
}
|
|
3793
|
+
|
|
3794
|
+
public async updatePerpMarketFuel(
|
|
3795
|
+
perpMarketIndex: number,
|
|
3796
|
+
fuelBoostTaker?: number,
|
|
3797
|
+
fuelBoostMaker?: number,
|
|
3798
|
+
fuelBoostPosition?: number
|
|
3799
|
+
): Promise<TransactionSignature> {
|
|
3800
|
+
const updatePerpMarketFuelIx = await this.getUpdatePerpMarketFuelIx(
|
|
3801
|
+
perpMarketIndex,
|
|
3802
|
+
fuelBoostTaker || null,
|
|
3803
|
+
fuelBoostMaker || null,
|
|
3804
|
+
fuelBoostPosition || null
|
|
3805
|
+
);
|
|
3806
|
+
|
|
3807
|
+
const tx = await this.buildTransaction(updatePerpMarketFuelIx);
|
|
3808
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3809
|
+
|
|
3810
|
+
return txSig;
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
public async getUpdatePerpMarketFuelIx(
|
|
3814
|
+
perpMarketIndex: number,
|
|
3815
|
+
fuelBoostTaker?: number,
|
|
3816
|
+
fuelBoostMaker?: number,
|
|
3817
|
+
fuelBoostPosition?: number
|
|
3818
|
+
): Promise<TransactionInstruction> {
|
|
3819
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
3820
|
+
this.program.programId,
|
|
3821
|
+
perpMarketIndex
|
|
3822
|
+
);
|
|
3823
|
+
|
|
3824
|
+
return await this.program.instruction.updatePerpMarketFuel(
|
|
3825
|
+
fuelBoostTaker || null,
|
|
3826
|
+
fuelBoostMaker || null,
|
|
3827
|
+
fuelBoostPosition || null,
|
|
3828
|
+
{
|
|
3829
|
+
accounts: {
|
|
3830
|
+
admin: this.isSubscribed
|
|
3831
|
+
? this.getStateAccount().admin
|
|
3832
|
+
: this.wallet.publicKey,
|
|
3833
|
+
state: await this.getStatePublicKey(),
|
|
3834
|
+
perpMarket: perpMarketPublicKey,
|
|
3835
|
+
},
|
|
3836
|
+
}
|
|
3837
|
+
);
|
|
3838
|
+
}
|
|
3839
|
+
|
|
3840
|
+
public async initUserFuel(
|
|
3841
|
+
user: PublicKey,
|
|
3842
|
+
authority: PublicKey,
|
|
3843
|
+
fuelBonusDeposits?: number,
|
|
3844
|
+
fuelBonusBorrows?: number,
|
|
3845
|
+
fuelBonusTaker?: number,
|
|
3846
|
+
fuelBonusMaker?: number,
|
|
3847
|
+
fuelBonusInsurance?: number
|
|
3848
|
+
): Promise<TransactionSignature> {
|
|
3849
|
+
const updatePerpMarketFuelIx = await this.getInitUserFuelIx(
|
|
3850
|
+
user,
|
|
3851
|
+
authority,
|
|
3852
|
+
fuelBonusDeposits,
|
|
3853
|
+
fuelBonusBorrows,
|
|
3854
|
+
fuelBonusTaker,
|
|
3855
|
+
fuelBonusMaker,
|
|
3856
|
+
fuelBonusInsurance
|
|
3857
|
+
);
|
|
3858
|
+
|
|
3859
|
+
const tx = await this.buildTransaction(updatePerpMarketFuelIx);
|
|
3860
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3861
|
+
|
|
3862
|
+
return txSig;
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
public async getInitUserFuelIx(
|
|
3866
|
+
user: PublicKey,
|
|
3867
|
+
authority: PublicKey,
|
|
3868
|
+
fuelBonusDeposits?: number,
|
|
3869
|
+
fuelBonusBorrows?: number,
|
|
3870
|
+
fuelBonusTaker?: number,
|
|
3871
|
+
fuelBonusMaker?: number,
|
|
3872
|
+
fuelBonusInsurance?: number
|
|
3873
|
+
): Promise<TransactionInstruction> {
|
|
3874
|
+
const userStats = await getUserStatsAccountPublicKey(
|
|
3875
|
+
this.program.programId,
|
|
3876
|
+
authority
|
|
3877
|
+
);
|
|
3878
|
+
|
|
3879
|
+
return await this.program.instruction.initUserFuel(
|
|
3880
|
+
fuelBonusDeposits || null,
|
|
3881
|
+
fuelBonusBorrows || null,
|
|
3882
|
+
fuelBonusTaker || null,
|
|
3883
|
+
fuelBonusMaker || null,
|
|
3884
|
+
fuelBonusInsurance || null,
|
|
3885
|
+
{
|
|
3886
|
+
accounts: {
|
|
3887
|
+
admin: this.wallet.publicKey,
|
|
3888
|
+
state: await this.getStatePublicKey(),
|
|
3889
|
+
user,
|
|
3890
|
+
userStats,
|
|
3891
|
+
},
|
|
3892
|
+
}
|
|
3893
|
+
);
|
|
3894
|
+
}
|
|
3895
|
+
|
|
3896
|
+
public async initializePythPullOracle(
|
|
3897
|
+
feedId: string,
|
|
3898
|
+
isAdmin = false
|
|
3899
|
+
): Promise<TransactionSignature> {
|
|
3900
|
+
const initializePythPullOracleIx = await this.getInitializePythPullOracleIx(
|
|
3901
|
+
feedId,
|
|
3902
|
+
isAdmin
|
|
3903
|
+
);
|
|
3904
|
+
const tx = await this.buildTransaction(initializePythPullOracleIx);
|
|
3905
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3906
|
+
|
|
3907
|
+
return txSig;
|
|
3908
|
+
}
|
|
3909
|
+
|
|
3910
|
+
public async getInitializePythPullOracleIx(
|
|
3911
|
+
feedId: string,
|
|
3912
|
+
isAdmin = false
|
|
3913
|
+
): Promise<TransactionInstruction> {
|
|
3914
|
+
const feedIdBuffer = getFeedIdUint8Array(feedId);
|
|
3915
|
+
return await this.program.instruction.initializePythPullOracle(
|
|
3916
|
+
feedIdBuffer,
|
|
3917
|
+
{
|
|
3918
|
+
accounts: {
|
|
3919
|
+
admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey,
|
|
3920
|
+
state: await this.getStatePublicKey(),
|
|
3921
|
+
systemProgram: SystemProgram.programId,
|
|
3922
|
+
priceFeed: getPythPullOraclePublicKey(
|
|
3923
|
+
this.program.programId,
|
|
3924
|
+
feedIdBuffer
|
|
3925
|
+
),
|
|
3926
|
+
pythSolanaReceiver: DRIFT_ORACLE_RECEIVER_ID,
|
|
3927
|
+
},
|
|
3928
|
+
}
|
|
3929
|
+
);
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3932
|
+
public async initializePythLazerOracle(
|
|
3933
|
+
feedId: number,
|
|
3934
|
+
isAdmin = false
|
|
3935
|
+
): Promise<TransactionSignature> {
|
|
3936
|
+
const initializePythPullOracleIx =
|
|
3937
|
+
await this.getInitializePythLazerOracleIx(feedId, isAdmin);
|
|
3938
|
+
const tx = await this.buildTransaction(initializePythPullOracleIx);
|
|
3939
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3940
|
+
|
|
3941
|
+
return txSig;
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
public async getInitializePythLazerOracleIx(
|
|
3945
|
+
feedId: number,
|
|
3946
|
+
isAdmin = false
|
|
3947
|
+
): Promise<TransactionInstruction> {
|
|
3948
|
+
return await this.program.instruction.initializePythLazerOracle(feedId, {
|
|
3949
|
+
accounts: {
|
|
3950
|
+
admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey,
|
|
3951
|
+
state: await this.getStatePublicKey(),
|
|
3952
|
+
systemProgram: SystemProgram.programId,
|
|
3953
|
+
lazerOracle: getPythLazerOraclePublicKey(
|
|
3954
|
+
this.program.programId,
|
|
3955
|
+
feedId
|
|
3956
|
+
),
|
|
3957
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
3958
|
+
},
|
|
3959
|
+
});
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3962
|
+
public async initializeHighLeverageModeConfig(
|
|
3963
|
+
maxUsers: number
|
|
3964
|
+
): Promise<TransactionSignature> {
|
|
3965
|
+
const initializeHighLeverageModeConfigIx =
|
|
3966
|
+
await this.getInitializeHighLeverageModeConfigIx(maxUsers);
|
|
3967
|
+
|
|
3968
|
+
const tx = await this.buildTransaction(initializeHighLeverageModeConfigIx);
|
|
3969
|
+
|
|
3970
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
3971
|
+
|
|
3972
|
+
return txSig;
|
|
3973
|
+
}
|
|
3974
|
+
|
|
3975
|
+
public async getInitializeHighLeverageModeConfigIx(
|
|
3976
|
+
maxUsers: number
|
|
3977
|
+
): Promise<TransactionInstruction> {
|
|
3978
|
+
return await this.program.instruction.initializeHighLeverageModeConfig(
|
|
3979
|
+
maxUsers,
|
|
3980
|
+
{
|
|
3981
|
+
accounts: {
|
|
3982
|
+
admin: this.isSubscribed
|
|
3983
|
+
? this.getStateAccount().admin
|
|
3984
|
+
: this.wallet.publicKey,
|
|
3985
|
+
state: await this.getStatePublicKey(),
|
|
3986
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
3987
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
3988
|
+
highLeverageModeConfig: getHighLeverageModeConfigPublicKey(
|
|
3989
|
+
this.program.programId
|
|
3990
|
+
),
|
|
3991
|
+
},
|
|
3992
|
+
}
|
|
3993
|
+
);
|
|
3994
|
+
}
|
|
3995
|
+
|
|
3996
|
+
public async updateUpdateHighLeverageModeConfig(
|
|
3997
|
+
maxUsers: number,
|
|
3998
|
+
reduceOnly: boolean
|
|
3999
|
+
): Promise<TransactionSignature> {
|
|
4000
|
+
const updateHighLeverageModeConfigIx =
|
|
4001
|
+
await this.getUpdateHighLeverageModeConfigIx(maxUsers, reduceOnly);
|
|
4002
|
+
|
|
4003
|
+
const tx = await this.buildTransaction(updateHighLeverageModeConfigIx);
|
|
4004
|
+
|
|
4005
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
4006
|
+
|
|
4007
|
+
return txSig;
|
|
4008
|
+
}
|
|
4009
|
+
|
|
4010
|
+
public async getUpdateHighLeverageModeConfigIx(
|
|
4011
|
+
maxUsers: number,
|
|
4012
|
+
reduceOnly: boolean
|
|
4013
|
+
): Promise<TransactionInstruction> {
|
|
4014
|
+
return await this.program.instruction.updateHighLeverageModeConfig(
|
|
4015
|
+
maxUsers,
|
|
4016
|
+
reduceOnly,
|
|
4017
|
+
{
|
|
4018
|
+
accounts: {
|
|
4019
|
+
admin: this.isSubscribed
|
|
4020
|
+
? this.getStateAccount().admin
|
|
4021
|
+
: this.wallet.publicKey,
|
|
4022
|
+
state: await this.getStatePublicKey(),
|
|
4023
|
+
highLeverageModeConfig: getHighLeverageModeConfigPublicKey(
|
|
4024
|
+
this.program.programId
|
|
4025
|
+
),
|
|
4026
|
+
},
|
|
4027
|
+
}
|
|
4028
|
+
);
|
|
4029
|
+
}
|
|
4030
|
+
}
|