@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,1858 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.AdminClient = void 0;
|
|
27
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
28
|
+
const types_1 = require("./types");
|
|
29
|
+
const userName_1 = require("./userName");
|
|
30
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
31
|
+
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
32
|
+
const pda_1 = require("./addresses/pda");
|
|
33
|
+
const utils_1 = require("./math/utils");
|
|
34
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
35
|
+
const driftClient_1 = require("./driftClient");
|
|
36
|
+
const numericConstants_1 = require("./constants/numericConstants");
|
|
37
|
+
const trade_1 = require("./math/trade");
|
|
38
|
+
const amm_1 = require("./math/amm");
|
|
39
|
+
const phoenix_sdk_1 = require("@ellipsis-labs/phoenix-sdk");
|
|
40
|
+
const config_1 = require("./config");
|
|
41
|
+
const pythOracleUtils_1 = require("./util/pythOracleUtils");
|
|
42
|
+
const OPENBOOK_PROGRAM_ID = new web3_js_1.PublicKey('opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb');
|
|
43
|
+
class AdminClient extends driftClient_1.DriftClient {
|
|
44
|
+
async initialize(usdcMint, _adminControlsPrices) {
|
|
45
|
+
const stateAccountRPCResponse = await this.connection.getParsedAccountInfo(await this.getStatePublicKey());
|
|
46
|
+
if (stateAccountRPCResponse.value !== null) {
|
|
47
|
+
throw new Error('Clearing house already initialized');
|
|
48
|
+
}
|
|
49
|
+
const [driftStatePublicKey] = await (0, pda_1.getDriftStateAccountPublicKeyAndNonce)(this.program.programId);
|
|
50
|
+
const initializeIx = await this.program.instruction.initialize({
|
|
51
|
+
accounts: {
|
|
52
|
+
admin: this.isSubscribed
|
|
53
|
+
? this.getStateAccount().admin
|
|
54
|
+
: this.wallet.publicKey,
|
|
55
|
+
state: driftStatePublicKey,
|
|
56
|
+
quoteAssetMint: usdcMint,
|
|
57
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
58
|
+
driftSigner: this.getSignerPublicKey(),
|
|
59
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
60
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
64
|
+
const { txSig } = await super.sendTransaction(tx, [], this.opts);
|
|
65
|
+
return [txSig];
|
|
66
|
+
}
|
|
67
|
+
async initializeSpotMarket(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0, liquidatorFee = 0, ifLiquidationFee = 0, activeStatus = true, assetTier = types_1.AssetTier.COLLATERAL, scaleInitialAssetWeightStart = numericConstants_1.ZERO, withdrawGuardThreshold = numericConstants_1.ZERO, orderTickSize = numericConstants_1.ONE, orderStepSize = numericConstants_1.ONE, ifTotalFactor = 0, name = userName_1.DEFAULT_MARKET_NAME, marketIndex) {
|
|
68
|
+
const spotMarketIndex = marketIndex !== null && marketIndex !== void 0 ? marketIndex : this.getStateAccount().numberOfSpotMarkets;
|
|
69
|
+
const initializeIx = await this.getInitializeSpotMarketIx(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, ifLiquidationFee, activeStatus, assetTier, scaleInitialAssetWeightStart, withdrawGuardThreshold, orderTickSize, orderStepSize, ifTotalFactor, name, marketIndex);
|
|
70
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
71
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
72
|
+
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
73
|
+
await this.accountSubscriber.addOracle({
|
|
74
|
+
source: oracleSource,
|
|
75
|
+
publicKey: oracle,
|
|
76
|
+
});
|
|
77
|
+
await this.accountSubscriber.setSpotOracleMap();
|
|
78
|
+
return txSig;
|
|
79
|
+
}
|
|
80
|
+
async getInitializeSpotMarketIx(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0, liquidatorFee = 0, ifLiquidationFee = 0, activeStatus = true, assetTier = types_1.AssetTier.COLLATERAL, scaleInitialAssetWeightStart = numericConstants_1.ZERO, withdrawGuardThreshold = numericConstants_1.ZERO, orderTickSize = numericConstants_1.ONE, orderStepSize = numericConstants_1.ONE, ifTotalFactor = 0, name = userName_1.DEFAULT_MARKET_NAME, marketIndex) {
|
|
81
|
+
const spotMarketIndex = marketIndex !== null && marketIndex !== void 0 ? marketIndex : this.getStateAccount().numberOfSpotMarkets;
|
|
82
|
+
const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
|
|
83
|
+
const spotMarketVault = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, spotMarketIndex);
|
|
84
|
+
const insuranceFundVault = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, spotMarketIndex);
|
|
85
|
+
const tokenProgram = (await this.connection.getAccountInfo(mint)).owner;
|
|
86
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
87
|
+
const initializeIx = await this.program.instruction.initializeSpotMarket(optimalUtilization, optimalRate, maxRate, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, ifLiquidationFee, activeStatus, assetTier, scaleInitialAssetWeightStart, withdrawGuardThreshold, orderTickSize, orderStepSize, ifTotalFactor, nameBuffer, {
|
|
88
|
+
accounts: {
|
|
89
|
+
admin: this.isSubscribed
|
|
90
|
+
? this.getStateAccount().admin
|
|
91
|
+
: this.wallet.publicKey,
|
|
92
|
+
state: await this.getStatePublicKey(),
|
|
93
|
+
spotMarket,
|
|
94
|
+
spotMarketVault,
|
|
95
|
+
insuranceFundVault,
|
|
96
|
+
driftSigner: this.getSignerPublicKey(),
|
|
97
|
+
spotMarketMint: mint,
|
|
98
|
+
oracle,
|
|
99
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
100
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
101
|
+
tokenProgram,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
return initializeIx;
|
|
105
|
+
}
|
|
106
|
+
async deleteInitializedSpotMarket(marketIndex) {
|
|
107
|
+
const deleteInitializeMarketIx = await this.getDeleteInitializedSpotMarketIx(marketIndex);
|
|
108
|
+
const tx = await this.buildTransaction(deleteInitializeMarketIx);
|
|
109
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
110
|
+
return txSig;
|
|
111
|
+
}
|
|
112
|
+
async getDeleteInitializedSpotMarketIx(marketIndex) {
|
|
113
|
+
const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
|
|
114
|
+
const spotMarketVaultPublicKey = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, marketIndex);
|
|
115
|
+
const insuranceFundVaultPublicKey = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, marketIndex);
|
|
116
|
+
return await this.program.instruction.deleteInitializedSpotMarket(marketIndex, {
|
|
117
|
+
accounts: {
|
|
118
|
+
state: await this.getStatePublicKey(),
|
|
119
|
+
admin: this.isSubscribed
|
|
120
|
+
? this.getStateAccount().admin
|
|
121
|
+
: this.wallet.publicKey,
|
|
122
|
+
spotMarket: spotMarketPublicKey,
|
|
123
|
+
spotMarketVault: spotMarketVaultPublicKey,
|
|
124
|
+
insuranceFundVault: insuranceFundVaultPublicKey,
|
|
125
|
+
driftSigner: this.getSignerPublicKey(),
|
|
126
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async initializeSerumFulfillmentConfig(marketIndex, serumMarket, serumProgram) {
|
|
131
|
+
const initializeIx = await this.getInitializeSerumFulfillmentConfigIx(marketIndex, serumMarket, serumProgram);
|
|
132
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
133
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
134
|
+
return txSig;
|
|
135
|
+
}
|
|
136
|
+
async getInitializeSerumFulfillmentConfigIx(marketIndex, serumMarket, serumProgram) {
|
|
137
|
+
const serumOpenOrders = (0, pda_1.getSerumOpenOrdersPublicKey)(this.program.programId, serumMarket);
|
|
138
|
+
const serumFulfillmentConfig = (0, pda_1.getSerumFulfillmentConfigPublicKey)(this.program.programId, serumMarket);
|
|
139
|
+
return await this.program.instruction.initializeSerumFulfillmentConfig(marketIndex, {
|
|
140
|
+
accounts: {
|
|
141
|
+
admin: this.isSubscribed
|
|
142
|
+
? this.getStateAccount().admin
|
|
143
|
+
: this.wallet.publicKey,
|
|
144
|
+
state: await this.getStatePublicKey(),
|
|
145
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
146
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
147
|
+
driftSigner: this.getSignerPublicKey(),
|
|
148
|
+
serumProgram,
|
|
149
|
+
serumMarket,
|
|
150
|
+
serumOpenOrders,
|
|
151
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
152
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
153
|
+
serumFulfillmentConfig,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async initializePhoenixFulfillmentConfig(marketIndex, phoenixMarket) {
|
|
158
|
+
const initializeIx = await this.getInitializePhoenixFulfillmentConfigIx(marketIndex, phoenixMarket);
|
|
159
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
160
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
161
|
+
return txSig;
|
|
162
|
+
}
|
|
163
|
+
async getInitializePhoenixFulfillmentConfigIx(marketIndex, phoenixMarket) {
|
|
164
|
+
const phoenixFulfillmentConfig = (0, pda_1.getPhoenixFulfillmentConfigPublicKey)(this.program.programId, phoenixMarket);
|
|
165
|
+
return await this.program.instruction.initializePhoenixFulfillmentConfig(marketIndex, {
|
|
166
|
+
accounts: {
|
|
167
|
+
admin: this.isSubscribed
|
|
168
|
+
? this.getStateAccount().admin
|
|
169
|
+
: this.wallet.publicKey,
|
|
170
|
+
state: await this.getStatePublicKey(),
|
|
171
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
172
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
173
|
+
driftSigner: this.getSignerPublicKey(),
|
|
174
|
+
phoenixMarket: phoenixMarket,
|
|
175
|
+
phoenixProgram: phoenix_sdk_1.PROGRAM_ID,
|
|
176
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
177
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
178
|
+
phoenixFulfillmentConfig,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async initializeOpenbookV2FulfillmentConfig(marketIndex, openbookMarket) {
|
|
183
|
+
const initializeIx = await this.getInitializeOpenbookV2FulfillmentConfigIx(marketIndex, openbookMarket);
|
|
184
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
185
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
186
|
+
return txSig;
|
|
187
|
+
}
|
|
188
|
+
async getInitializeOpenbookV2FulfillmentConfigIx(marketIndex, openbookMarket) {
|
|
189
|
+
const openbookFulfillmentConfig = (0, pda_1.getOpenbookV2FulfillmentConfigPublicKey)(this.program.programId, openbookMarket);
|
|
190
|
+
return this.program.instruction.initializeOpenbookV2FulfillmentConfig(marketIndex, {
|
|
191
|
+
accounts: {
|
|
192
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
193
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
194
|
+
state: await this.getStatePublicKey(),
|
|
195
|
+
openbookV2Program: OPENBOOK_PROGRAM_ID,
|
|
196
|
+
openbookV2Market: openbookMarket,
|
|
197
|
+
driftSigner: this.getSignerPublicKey(),
|
|
198
|
+
openbookV2FulfillmentConfig: openbookFulfillmentConfig,
|
|
199
|
+
admin: this.isSubscribed
|
|
200
|
+
? this.getStateAccount().admin
|
|
201
|
+
: this.wallet.publicKey,
|
|
202
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
203
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
async initializePerpMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME) {
|
|
208
|
+
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
209
|
+
const initializeMarketIx = await this.getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name);
|
|
210
|
+
const tx = await this.buildTransaction(initializeMarketIx);
|
|
211
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
212
|
+
while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
|
|
213
|
+
await this.fetchAccounts();
|
|
214
|
+
}
|
|
215
|
+
await this.accountSubscriber.addPerpMarket(marketIndex);
|
|
216
|
+
await this.accountSubscriber.addOracle({
|
|
217
|
+
source: oracleSource,
|
|
218
|
+
publicKey: priceOracle,
|
|
219
|
+
});
|
|
220
|
+
await this.accountSubscriber.setPerpOracleMap();
|
|
221
|
+
return txSig;
|
|
222
|
+
}
|
|
223
|
+
async getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME) {
|
|
224
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
225
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
226
|
+
return await this.program.instruction.initializePerpMarket(marketIndex, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, nameBuffer, {
|
|
227
|
+
accounts: {
|
|
228
|
+
state: await this.getStatePublicKey(),
|
|
229
|
+
admin: this.isSubscribed
|
|
230
|
+
? this.getStateAccount().admin
|
|
231
|
+
: this.wallet.publicKey,
|
|
232
|
+
oracle: priceOracle,
|
|
233
|
+
perpMarket: perpMarketPublicKey,
|
|
234
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
235
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
async initializePredictionMarket(perpMarketIndex) {
|
|
240
|
+
const updatePerpMarketConcentrationCoefIx = await this.getInitializePredictionMarketIx(perpMarketIndex);
|
|
241
|
+
const tx = await this.buildTransaction(updatePerpMarketConcentrationCoefIx);
|
|
242
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
243
|
+
return txSig;
|
|
244
|
+
}
|
|
245
|
+
async getInitializePredictionMarketIx(perpMarketIndex) {
|
|
246
|
+
return await this.program.instruction.initializePredictionMarket({
|
|
247
|
+
accounts: {
|
|
248
|
+
state: await this.getStatePublicKey(),
|
|
249
|
+
admin: this.isSubscribed
|
|
250
|
+
? this.getStateAccount().admin
|
|
251
|
+
: this.wallet.publicKey,
|
|
252
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
async deleteInitializedPerpMarket(marketIndex) {
|
|
257
|
+
const deleteInitializeMarketIx = await this.getDeleteInitializedPerpMarketIx(marketIndex);
|
|
258
|
+
const tx = await this.buildTransaction(deleteInitializeMarketIx);
|
|
259
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
260
|
+
return txSig;
|
|
261
|
+
}
|
|
262
|
+
async getDeleteInitializedPerpMarketIx(marketIndex) {
|
|
263
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
264
|
+
return await this.program.instruction.deleteInitializedPerpMarket(marketIndex, {
|
|
265
|
+
accounts: {
|
|
266
|
+
state: await this.getStatePublicKey(),
|
|
267
|
+
admin: this.isSubscribed
|
|
268
|
+
? this.getStateAccount().admin
|
|
269
|
+
: this.wallet.publicKey,
|
|
270
|
+
perpMarket: perpMarketPublicKey,
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
async moveAmmPrice(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
|
|
275
|
+
const moveAmmPriceIx = await this.getMoveAmmPriceIx(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK);
|
|
276
|
+
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
277
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
278
|
+
return txSig;
|
|
279
|
+
}
|
|
280
|
+
async getMoveAmmPriceIx(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
|
|
281
|
+
const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
282
|
+
if (sqrtK == undefined) {
|
|
283
|
+
sqrtK = (0, utils_1.squareRootBN)(baseAssetReserve.mul(quoteAssetReserve));
|
|
284
|
+
}
|
|
285
|
+
return await this.program.instruction.moveAmmPrice(baseAssetReserve, quoteAssetReserve, sqrtK, {
|
|
286
|
+
accounts: {
|
|
287
|
+
state: await this.getStatePublicKey(),
|
|
288
|
+
admin: this.isSubscribed
|
|
289
|
+
? this.getStateAccount().admin
|
|
290
|
+
: this.wallet.publicKey,
|
|
291
|
+
perpMarket: marketPublicKey,
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
async updateK(perpMarketIndex, sqrtK) {
|
|
296
|
+
const updateKIx = await this.getUpdateKIx(perpMarketIndex, sqrtK);
|
|
297
|
+
const tx = await this.buildTransaction(updateKIx);
|
|
298
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
299
|
+
return txSig;
|
|
300
|
+
}
|
|
301
|
+
async getUpdateKIx(perpMarketIndex, sqrtK) {
|
|
302
|
+
return await this.program.instruction.updateK(sqrtK, {
|
|
303
|
+
accounts: {
|
|
304
|
+
state: await this.getStatePublicKey(),
|
|
305
|
+
admin: this.isSubscribed
|
|
306
|
+
? this.getStateAccount().admin
|
|
307
|
+
: this.wallet.publicKey,
|
|
308
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
309
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
async recenterPerpMarketAmm(perpMarketIndex, pegMultiplier, sqrtK) {
|
|
314
|
+
const recenterPerpMarketAmmIx = await this.getRecenterPerpMarketAmmIx(perpMarketIndex, pegMultiplier, sqrtK);
|
|
315
|
+
const tx = await this.buildTransaction(recenterPerpMarketAmmIx);
|
|
316
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
317
|
+
return txSig;
|
|
318
|
+
}
|
|
319
|
+
async getRecenterPerpMarketAmmIx(perpMarketIndex, pegMultiplier, sqrtK) {
|
|
320
|
+
const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
321
|
+
return await this.program.instruction.recenterPerpMarketAmm(pegMultiplier, sqrtK, {
|
|
322
|
+
accounts: {
|
|
323
|
+
state: await this.getStatePublicKey(),
|
|
324
|
+
admin: this.isSubscribed
|
|
325
|
+
? this.getStateAccount().admin
|
|
326
|
+
: this.wallet.publicKey,
|
|
327
|
+
perpMarket: marketPublicKey,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
async updatePerpMarketConcentrationScale(perpMarketIndex, concentrationScale) {
|
|
332
|
+
const updatePerpMarketConcentrationCoefIx = await this.getUpdatePerpMarketConcentrationScaleIx(perpMarketIndex, concentrationScale);
|
|
333
|
+
const tx = await this.buildTransaction(updatePerpMarketConcentrationCoefIx);
|
|
334
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
335
|
+
return txSig;
|
|
336
|
+
}
|
|
337
|
+
async getUpdatePerpMarketConcentrationScaleIx(perpMarketIndex, concentrationScale) {
|
|
338
|
+
return await this.program.instruction.updatePerpMarketConcentrationCoef(concentrationScale, {
|
|
339
|
+
accounts: {
|
|
340
|
+
state: await this.getStatePublicKey(),
|
|
341
|
+
admin: this.isSubscribed
|
|
342
|
+
? this.getStateAccount().admin
|
|
343
|
+
: this.wallet.publicKey,
|
|
344
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
async moveAmmToPrice(perpMarketIndex, targetPrice) {
|
|
349
|
+
const moveAmmPriceIx = await this.getMoveAmmToPriceIx(perpMarketIndex, targetPrice);
|
|
350
|
+
const tx = await this.buildTransaction(moveAmmPriceIx);
|
|
351
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
352
|
+
return txSig;
|
|
353
|
+
}
|
|
354
|
+
async getMoveAmmToPriceIx(perpMarketIndex, targetPrice) {
|
|
355
|
+
const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
|
|
356
|
+
const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(perpMarket, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
|
|
357
|
+
);
|
|
358
|
+
const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(perpMarket.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
|
|
359
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
360
|
+
return await this.program.instruction.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, perpMarket.amm.sqrtK, {
|
|
361
|
+
accounts: {
|
|
362
|
+
state: await this.getStatePublicKey(),
|
|
363
|
+
admin: this.isSubscribed
|
|
364
|
+
? this.getStateAccount().admin
|
|
365
|
+
: this.wallet.publicKey,
|
|
366
|
+
perpMarket: perpMarketPublicKey,
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
async repegAmmCurve(newPeg, perpMarketIndex) {
|
|
371
|
+
const repegAmmCurveIx = await this.getRepegAmmCurveIx(newPeg, perpMarketIndex);
|
|
372
|
+
const tx = await this.buildTransaction(repegAmmCurveIx);
|
|
373
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
374
|
+
return txSig;
|
|
375
|
+
}
|
|
376
|
+
async getRepegAmmCurveIx(newPeg, perpMarketIndex) {
|
|
377
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
378
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
379
|
+
return await this.program.instruction.repegAmmCurve(newPeg, {
|
|
380
|
+
accounts: {
|
|
381
|
+
state: await this.getStatePublicKey(),
|
|
382
|
+
admin: this.isSubscribed
|
|
383
|
+
? this.getStateAccount().admin
|
|
384
|
+
: this.wallet.publicKey,
|
|
385
|
+
oracle: ammData.oracle,
|
|
386
|
+
perpMarket: perpMarketPublicKey,
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
async updatePerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
391
|
+
const updatePerpMarketAmmOracleTwapIx = await this.getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
392
|
+
const tx = await this.buildTransaction(updatePerpMarketAmmOracleTwapIx);
|
|
393
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
394
|
+
return txSig;
|
|
395
|
+
}
|
|
396
|
+
async getUpdatePerpMarketAmmOracleTwapIx(perpMarketIndex) {
|
|
397
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
398
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
399
|
+
return await this.program.instruction.updatePerpMarketAmmOracleTwap({
|
|
400
|
+
accounts: {
|
|
401
|
+
state: await this.getStatePublicKey(),
|
|
402
|
+
admin: this.isSubscribed
|
|
403
|
+
? this.getStateAccount().admin
|
|
404
|
+
: this.wallet.publicKey,
|
|
405
|
+
oracle: ammData.oracle,
|
|
406
|
+
perpMarket: perpMarketPublicKey,
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
async resetPerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
411
|
+
const resetPerpMarketAmmOracleTwapIx = await this.getResetPerpMarketAmmOracleTwapIx(perpMarketIndex);
|
|
412
|
+
const tx = await this.buildTransaction(resetPerpMarketAmmOracleTwapIx);
|
|
413
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
414
|
+
return txSig;
|
|
415
|
+
}
|
|
416
|
+
async getResetPerpMarketAmmOracleTwapIx(perpMarketIndex) {
|
|
417
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
418
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
419
|
+
return await this.program.instruction.resetPerpMarketAmmOracleTwap({
|
|
420
|
+
accounts: {
|
|
421
|
+
state: await this.getStatePublicKey(),
|
|
422
|
+
admin: this.isSubscribed
|
|
423
|
+
? this.getStateAccount().admin
|
|
424
|
+
: this.wallet.publicKey,
|
|
425
|
+
oracle: ammData.oracle,
|
|
426
|
+
perpMarket: perpMarketPublicKey,
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
async depositIntoPerpMarketFeePool(perpMarketIndex, amount, sourceVault) {
|
|
431
|
+
const depositIntoPerpMarketFeePoolIx = await this.getDepositIntoPerpMarketFeePoolIx(perpMarketIndex, amount, sourceVault);
|
|
432
|
+
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
433
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
434
|
+
return txSig;
|
|
435
|
+
}
|
|
436
|
+
async getDepositIntoPerpMarketFeePoolIx(perpMarketIndex, amount, sourceVault) {
|
|
437
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
438
|
+
return await this.program.instruction.depositIntoPerpMarketFeePool(amount, {
|
|
439
|
+
accounts: {
|
|
440
|
+
admin: this.isSubscribed
|
|
441
|
+
? this.getStateAccount().admin
|
|
442
|
+
: this.wallet.publicKey,
|
|
443
|
+
state: await this.getStatePublicKey(),
|
|
444
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
445
|
+
sourceVault,
|
|
446
|
+
driftSigner: this.getSignerPublicKey(),
|
|
447
|
+
quoteSpotMarket: spotMarket.pubkey,
|
|
448
|
+
spotMarketVault: spotMarket.vault,
|
|
449
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
450
|
+
},
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
async depositIntoSpotMarketVault(spotMarketIndex, amount, sourceVault) {
|
|
454
|
+
const depositIntoPerpMarketFeePoolIx = await this.getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault);
|
|
455
|
+
const tx = await this.buildTransaction(depositIntoPerpMarketFeePoolIx);
|
|
456
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
457
|
+
return txSig;
|
|
458
|
+
}
|
|
459
|
+
async getDepositIntoSpotMarketVaultIx(spotMarketIndex, amount, sourceVault) {
|
|
460
|
+
const spotMarket = this.getSpotMarketAccount(spotMarketIndex);
|
|
461
|
+
const remainingAccounts = [];
|
|
462
|
+
this.addTokenMintToRemainingAccounts(spotMarket, remainingAccounts);
|
|
463
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
464
|
+
return await this.program.instruction.depositIntoSpotMarketVault(amount, {
|
|
465
|
+
accounts: {
|
|
466
|
+
admin: this.wallet.publicKey,
|
|
467
|
+
state: await this.getStatePublicKey(),
|
|
468
|
+
sourceVault,
|
|
469
|
+
spotMarket: spotMarket.pubkey,
|
|
470
|
+
spotMarketVault: spotMarket.vault,
|
|
471
|
+
tokenProgram,
|
|
472
|
+
},
|
|
473
|
+
remainingAccounts,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
async updateAdmin(admin) {
|
|
477
|
+
const updateAdminIx = await this.getUpdateAdminIx(admin);
|
|
478
|
+
const tx = await this.buildTransaction(updateAdminIx);
|
|
479
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
480
|
+
return txSig;
|
|
481
|
+
}
|
|
482
|
+
async getUpdateAdminIx(admin) {
|
|
483
|
+
return await this.program.instruction.updateAdmin(admin, {
|
|
484
|
+
accounts: {
|
|
485
|
+
admin: this.isSubscribed
|
|
486
|
+
? this.getStateAccount().admin
|
|
487
|
+
: this.wallet.publicKey,
|
|
488
|
+
state: await this.getStatePublicKey(),
|
|
489
|
+
},
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
async updatePerpMarketCurveUpdateIntensity(perpMarketIndex, curveUpdateIntensity) {
|
|
493
|
+
const updatePerpMarketCurveUpdateIntensityIx = await this.getUpdatePerpMarketCurveUpdateIntensityIx(perpMarketIndex, curveUpdateIntensity);
|
|
494
|
+
const tx = await this.buildTransaction(updatePerpMarketCurveUpdateIntensityIx);
|
|
495
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
496
|
+
return txSig;
|
|
497
|
+
}
|
|
498
|
+
async getUpdatePerpMarketCurveUpdateIntensityIx(perpMarketIndex, curveUpdateIntensity) {
|
|
499
|
+
return await this.program.instruction.updatePerpMarketCurveUpdateIntensity(curveUpdateIntensity, {
|
|
500
|
+
accounts: {
|
|
501
|
+
admin: this.isSubscribed
|
|
502
|
+
? this.getStateAccount().admin
|
|
503
|
+
: this.wallet.publicKey,
|
|
504
|
+
state: await this.getStatePublicKey(),
|
|
505
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
506
|
+
},
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
async updatePerpMarketTargetBaseAssetAmountPerLp(perpMarketIndex, targetBaseAssetAmountPerLP) {
|
|
510
|
+
const updatePerpMarketTargetBaseAssetAmountPerLpIx = await this.getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex, targetBaseAssetAmountPerLP);
|
|
511
|
+
const tx = await this.buildTransaction(updatePerpMarketTargetBaseAssetAmountPerLpIx);
|
|
512
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
513
|
+
return txSig;
|
|
514
|
+
}
|
|
515
|
+
async updatePerpMarketAmmSummaryStats(perpMarketIndex, updateAmmSummaryStats, quoteAssetAmountWithUnsettledLp, netUnsettledFundingPnl) {
|
|
516
|
+
const updatePerpMarketMarginRatioIx = await this.getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, quoteAssetAmountWithUnsettledLp, netUnsettledFundingPnl);
|
|
517
|
+
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
518
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
519
|
+
return txSig;
|
|
520
|
+
}
|
|
521
|
+
async getUpdatePerpMarketAmmSummaryStatsIx(perpMarketIndex, updateAmmSummaryStats, quoteAssetAmountWithUnsettledLp, netUnsettledFundingPnl) {
|
|
522
|
+
return await this.program.instruction.updatePerpMarketAmmSummaryStats({
|
|
523
|
+
updateAmmSummaryStats: updateAmmSummaryStats !== null && updateAmmSummaryStats !== void 0 ? updateAmmSummaryStats : null,
|
|
524
|
+
quoteAssetAmountWithUnsettledLp: quoteAssetAmountWithUnsettledLp !== null && quoteAssetAmountWithUnsettledLp !== void 0 ? quoteAssetAmountWithUnsettledLp : null,
|
|
525
|
+
netUnsettledFundingPnl: netUnsettledFundingPnl !== null && netUnsettledFundingPnl !== void 0 ? netUnsettledFundingPnl : null,
|
|
526
|
+
}, {
|
|
527
|
+
accounts: {
|
|
528
|
+
admin: this.wallet.publicKey,
|
|
529
|
+
state: await this.getStatePublicKey(),
|
|
530
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
531
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, numericConstants_1.QUOTE_SPOT_MARKET_INDEX),
|
|
532
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
533
|
+
},
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx(perpMarketIndex, targetBaseAssetAmountPerLP) {
|
|
537
|
+
return await this.program.instruction.updatePerpMarketTargetBaseAssetAmountPerLp(targetBaseAssetAmountPerLP, {
|
|
538
|
+
accounts: {
|
|
539
|
+
admin: this.isSubscribed
|
|
540
|
+
? this.getStateAccount().admin
|
|
541
|
+
: this.wallet.publicKey,
|
|
542
|
+
state: await this.getStatePublicKey(),
|
|
543
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
544
|
+
},
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
async updatePerpMarketMarginRatio(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
548
|
+
const updatePerpMarketMarginRatioIx = await this.getUpdatePerpMarketMarginRatioIx(perpMarketIndex, marginRatioInitial, marginRatioMaintenance);
|
|
549
|
+
const tx = await this.buildTransaction(updatePerpMarketMarginRatioIx);
|
|
550
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
551
|
+
return txSig;
|
|
552
|
+
}
|
|
553
|
+
async getUpdatePerpMarketMarginRatioIx(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
554
|
+
return await this.program.instruction.updatePerpMarketMarginRatio(marginRatioInitial, marginRatioMaintenance, {
|
|
555
|
+
accounts: {
|
|
556
|
+
admin: this.isSubscribed
|
|
557
|
+
? this.getStateAccount().admin
|
|
558
|
+
: this.wallet.publicKey,
|
|
559
|
+
state: await this.getStatePublicKey(),
|
|
560
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
async updatePerpMarketHighLeverageMarginRatio(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
565
|
+
const updatePerpMarketHighLeverageMarginRatioIx = await this.getUpdatePerpMarketHighLeverageMarginRatioIx(perpMarketIndex, marginRatioInitial, marginRatioMaintenance);
|
|
566
|
+
const tx = await this.buildTransaction(updatePerpMarketHighLeverageMarginRatioIx);
|
|
567
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
568
|
+
return txSig;
|
|
569
|
+
}
|
|
570
|
+
async getUpdatePerpMarketHighLeverageMarginRatioIx(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
571
|
+
return await this.program.instruction.updatePerpMarketHighLeverageMarginRatio(marginRatioInitial, marginRatioMaintenance, {
|
|
572
|
+
accounts: {
|
|
573
|
+
admin: this.isSubscribed
|
|
574
|
+
? this.getStateAccount().admin
|
|
575
|
+
: this.wallet.publicKey,
|
|
576
|
+
state: await this.getStatePublicKey(),
|
|
577
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
578
|
+
},
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
async updatePerpMarketImfFactor(perpMarketIndex, imfFactor, unrealizedPnlImfFactor) {
|
|
582
|
+
const updatePerpMarketImfFactorIx = await this.getUpdatePerpMarketImfFactorIx(perpMarketIndex, imfFactor, unrealizedPnlImfFactor);
|
|
583
|
+
const tx = await this.buildTransaction(updatePerpMarketImfFactorIx);
|
|
584
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
585
|
+
return txSig;
|
|
586
|
+
}
|
|
587
|
+
async getUpdatePerpMarketImfFactorIx(perpMarketIndex, imfFactor, unrealizedPnlImfFactor) {
|
|
588
|
+
return await this.program.instruction.updatePerpMarketImfFactor(imfFactor, unrealizedPnlImfFactor, {
|
|
589
|
+
accounts: {
|
|
590
|
+
admin: this.isSubscribed
|
|
591
|
+
? this.getStateAccount().admin
|
|
592
|
+
: this.wallet.publicKey,
|
|
593
|
+
state: await this.getStatePublicKey(),
|
|
594
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
595
|
+
},
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
async updatePerpMarketBaseSpread(perpMarketIndex, baseSpread) {
|
|
599
|
+
const updatePerpMarketBaseSpreadIx = await this.getUpdatePerpMarketBaseSpreadIx(perpMarketIndex, baseSpread);
|
|
600
|
+
const tx = await this.buildTransaction(updatePerpMarketBaseSpreadIx);
|
|
601
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
602
|
+
return txSig;
|
|
603
|
+
}
|
|
604
|
+
async getUpdatePerpMarketBaseSpreadIx(perpMarketIndex, baseSpread) {
|
|
605
|
+
return await this.program.instruction.updatePerpMarketBaseSpread(baseSpread, {
|
|
606
|
+
accounts: {
|
|
607
|
+
admin: this.isSubscribed
|
|
608
|
+
? this.getStateAccount().admin
|
|
609
|
+
: this.wallet.publicKey,
|
|
610
|
+
state: await this.getStatePublicKey(),
|
|
611
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
612
|
+
},
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
async updateAmmJitIntensity(perpMarketIndex, ammJitIntensity) {
|
|
616
|
+
const updateAmmJitIntensityIx = await this.getUpdateAmmJitIntensityIx(perpMarketIndex, ammJitIntensity);
|
|
617
|
+
const tx = await this.buildTransaction(updateAmmJitIntensityIx);
|
|
618
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
619
|
+
return txSig;
|
|
620
|
+
}
|
|
621
|
+
async getUpdateAmmJitIntensityIx(perpMarketIndex, ammJitIntensity) {
|
|
622
|
+
return await this.program.instruction.updateAmmJitIntensity(ammJitIntensity, {
|
|
623
|
+
accounts: {
|
|
624
|
+
admin: this.isSubscribed
|
|
625
|
+
? this.getStateAccount().admin
|
|
626
|
+
: this.wallet.publicKey,
|
|
627
|
+
state: await this.getStatePublicKey(),
|
|
628
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
629
|
+
},
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
async updatePerpMarketName(perpMarketIndex, name) {
|
|
633
|
+
const updatePerpMarketNameIx = await this.getUpdatePerpMarketNameIx(perpMarketIndex, name);
|
|
634
|
+
const tx = await this.buildTransaction(updatePerpMarketNameIx);
|
|
635
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
636
|
+
return txSig;
|
|
637
|
+
}
|
|
638
|
+
async getUpdatePerpMarketNameIx(perpMarketIndex, name) {
|
|
639
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
640
|
+
return await this.program.instruction.updatePerpMarketName(nameBuffer, {
|
|
641
|
+
accounts: {
|
|
642
|
+
admin: this.isSubscribed
|
|
643
|
+
? this.getStateAccount().admin
|
|
644
|
+
: this.wallet.publicKey,
|
|
645
|
+
state: await this.getStatePublicKey(),
|
|
646
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
async updateSpotMarketName(spotMarketIndex, name) {
|
|
651
|
+
const updateSpotMarketNameIx = await this.getUpdateSpotMarketNameIx(spotMarketIndex, name);
|
|
652
|
+
const tx = await this.buildTransaction(updateSpotMarketNameIx);
|
|
653
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
654
|
+
return txSig;
|
|
655
|
+
}
|
|
656
|
+
async getUpdateSpotMarketNameIx(spotMarketIndex, name) {
|
|
657
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
658
|
+
return await this.program.instruction.updateSpotMarketName(nameBuffer, {
|
|
659
|
+
accounts: {
|
|
660
|
+
admin: this.isSubscribed
|
|
661
|
+
? this.getStateAccount().admin
|
|
662
|
+
: this.wallet.publicKey,
|
|
663
|
+
state: await this.getStatePublicKey(),
|
|
664
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
665
|
+
},
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
async updateSpotMarketPoolId(spotMarketIndex, poolId) {
|
|
669
|
+
const updateSpotMarketPoolIdIx = await this.getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId);
|
|
670
|
+
const tx = await this.buildTransaction(updateSpotMarketPoolIdIx);
|
|
671
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
672
|
+
return txSig;
|
|
673
|
+
}
|
|
674
|
+
async getUpdateSpotMarketPoolIdIx(spotMarketIndex, poolId) {
|
|
675
|
+
return await this.program.instruction.updateSpotMarketPoolId(poolId, {
|
|
676
|
+
accounts: {
|
|
677
|
+
admin: this.isSubscribed
|
|
678
|
+
? this.getStateAccount().admin
|
|
679
|
+
: this.wallet.publicKey,
|
|
680
|
+
state: await this.getStatePublicKey(),
|
|
681
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
async updatePerpMarketPerLpBase(perpMarketIndex, perLpBase) {
|
|
686
|
+
const updatePerpMarketPerLpBaseIx = await this.getUpdatePerpMarketPerLpBaseIx(perpMarketIndex, perLpBase);
|
|
687
|
+
const tx = await this.buildTransaction(updatePerpMarketPerLpBaseIx);
|
|
688
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
689
|
+
return txSig;
|
|
690
|
+
}
|
|
691
|
+
async getUpdatePerpMarketPerLpBaseIx(perpMarketIndex, perLpBase) {
|
|
692
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
693
|
+
return await this.program.instruction.updatePerpMarketPerLpBase(perLpBase, {
|
|
694
|
+
accounts: {
|
|
695
|
+
admin: this.isSubscribed
|
|
696
|
+
? this.getStateAccount().admin
|
|
697
|
+
: this.wallet.publicKey,
|
|
698
|
+
state: await this.getStatePublicKey(),
|
|
699
|
+
perpMarket: perpMarketPublicKey,
|
|
700
|
+
},
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
async updatePerpMarketMaxSpread(perpMarketIndex, maxSpread) {
|
|
704
|
+
const updatePerpMarketMaxSpreadIx = await this.getUpdatePerpMarketMaxSpreadIx(perpMarketIndex, maxSpread);
|
|
705
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxSpreadIx);
|
|
706
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
707
|
+
return txSig;
|
|
708
|
+
}
|
|
709
|
+
async getUpdatePerpMarketMaxSpreadIx(perpMarketIndex, maxSpread) {
|
|
710
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
711
|
+
return await this.program.instruction.updatePerpMarketMaxSpread(maxSpread, {
|
|
712
|
+
accounts: {
|
|
713
|
+
admin: this.isSubscribed
|
|
714
|
+
? this.getStateAccount().admin
|
|
715
|
+
: this.wallet.publicKey,
|
|
716
|
+
state: await this.getStatePublicKey(),
|
|
717
|
+
perpMarket: perpMarketPublicKey,
|
|
718
|
+
},
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
async updatePerpFeeStructure(feeStructure) {
|
|
722
|
+
const updatePerpFeeStructureIx = await this.getUpdatePerpFeeStructureIx(feeStructure);
|
|
723
|
+
const tx = await this.buildTransaction(updatePerpFeeStructureIx);
|
|
724
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
725
|
+
return txSig;
|
|
726
|
+
}
|
|
727
|
+
async getUpdatePerpFeeStructureIx(feeStructure) {
|
|
728
|
+
return this.program.instruction.updatePerpFeeStructure(feeStructure, {
|
|
729
|
+
accounts: {
|
|
730
|
+
admin: this.isSubscribed
|
|
731
|
+
? this.getStateAccount().admin
|
|
732
|
+
: this.wallet.publicKey,
|
|
733
|
+
state: await this.getStatePublicKey(),
|
|
734
|
+
},
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
async updateSpotFeeStructure(feeStructure) {
|
|
738
|
+
const updateSpotFeeStructureIx = await this.getUpdateSpotFeeStructureIx(feeStructure);
|
|
739
|
+
const tx = await this.buildTransaction(updateSpotFeeStructureIx);
|
|
740
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
741
|
+
return txSig;
|
|
742
|
+
}
|
|
743
|
+
async getUpdateSpotFeeStructureIx(feeStructure) {
|
|
744
|
+
return await this.program.instruction.updateSpotFeeStructure(feeStructure, {
|
|
745
|
+
accounts: {
|
|
746
|
+
admin: this.isSubscribed
|
|
747
|
+
? this.getStateAccount().admin
|
|
748
|
+
: this.wallet.publicKey,
|
|
749
|
+
state: await this.getStatePublicKey(),
|
|
750
|
+
},
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
async updateInitialPctToLiquidate(initialPctToLiquidate) {
|
|
754
|
+
const updateInitialPctToLiquidateIx = await this.getUpdateInitialPctToLiquidateIx(initialPctToLiquidate);
|
|
755
|
+
const tx = await this.buildTransaction(updateInitialPctToLiquidateIx);
|
|
756
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
757
|
+
return txSig;
|
|
758
|
+
}
|
|
759
|
+
async getUpdateInitialPctToLiquidateIx(initialPctToLiquidate) {
|
|
760
|
+
return await this.program.instruction.updateInitialPctToLiquidate(initialPctToLiquidate, {
|
|
761
|
+
accounts: {
|
|
762
|
+
admin: this.isSubscribed
|
|
763
|
+
? this.getStateAccount().admin
|
|
764
|
+
: this.wallet.publicKey,
|
|
765
|
+
state: await this.getStatePublicKey(),
|
|
766
|
+
},
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
async updateLiquidationDuration(liquidationDuration) {
|
|
770
|
+
const updateLiquidationDurationIx = await this.getUpdateLiquidationDurationIx(liquidationDuration);
|
|
771
|
+
const tx = await this.buildTransaction(updateLiquidationDurationIx);
|
|
772
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
773
|
+
return txSig;
|
|
774
|
+
}
|
|
775
|
+
async getUpdateLiquidationDurationIx(liquidationDuration) {
|
|
776
|
+
return await this.program.instruction.updateLiquidationDuration(liquidationDuration, {
|
|
777
|
+
accounts: {
|
|
778
|
+
admin: this.isSubscribed
|
|
779
|
+
? this.getStateAccount().admin
|
|
780
|
+
: this.wallet.publicKey,
|
|
781
|
+
state: await this.getStatePublicKey(),
|
|
782
|
+
},
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
async updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio) {
|
|
786
|
+
const updateLiquidationMarginBufferRatioIx = await this.getUpdateLiquidationMarginBufferRatioIx(updateLiquidationMarginBufferRatio);
|
|
787
|
+
const tx = await this.buildTransaction(updateLiquidationMarginBufferRatioIx);
|
|
788
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
789
|
+
return txSig;
|
|
790
|
+
}
|
|
791
|
+
async getUpdateLiquidationMarginBufferRatioIx(updateLiquidationMarginBufferRatio) {
|
|
792
|
+
return await this.program.instruction.updateLiquidationMarginBufferRatio(updateLiquidationMarginBufferRatio, {
|
|
793
|
+
accounts: {
|
|
794
|
+
admin: this.isSubscribed
|
|
795
|
+
? this.getStateAccount().admin
|
|
796
|
+
: this.wallet.publicKey,
|
|
797
|
+
state: await this.getStatePublicKey(),
|
|
798
|
+
},
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
async updateOracleGuardRails(oracleGuardRails) {
|
|
802
|
+
const updateOracleGuardRailsIx = await this.getUpdateOracleGuardRailsIx(oracleGuardRails);
|
|
803
|
+
const tx = await this.buildTransaction(updateOracleGuardRailsIx);
|
|
804
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
805
|
+
return txSig;
|
|
806
|
+
}
|
|
807
|
+
async getUpdateOracleGuardRailsIx(oracleGuardRails) {
|
|
808
|
+
return await this.program.instruction.updateOracleGuardRails(oracleGuardRails, {
|
|
809
|
+
accounts: {
|
|
810
|
+
admin: this.isSubscribed
|
|
811
|
+
? this.getStateAccount().admin
|
|
812
|
+
: this.wallet.publicKey,
|
|
813
|
+
state: await this.getStatePublicKey(),
|
|
814
|
+
},
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
async updateStateSettlementDuration(settlementDuration) {
|
|
818
|
+
const updateStateSettlementDurationIx = await this.getUpdateStateSettlementDurationIx(settlementDuration);
|
|
819
|
+
const tx = await this.buildTransaction(updateStateSettlementDurationIx);
|
|
820
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
821
|
+
return txSig;
|
|
822
|
+
}
|
|
823
|
+
async getUpdateStateSettlementDurationIx(settlementDuration) {
|
|
824
|
+
return await this.program.instruction.updateStateSettlementDuration(settlementDuration, {
|
|
825
|
+
accounts: {
|
|
826
|
+
admin: this.isSubscribed
|
|
827
|
+
? this.getStateAccount().admin
|
|
828
|
+
: this.wallet.publicKey,
|
|
829
|
+
state: await this.getStatePublicKey(),
|
|
830
|
+
},
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
async updateStateMaxNumberOfSubAccounts(maxNumberOfSubAccounts) {
|
|
834
|
+
const updateStateMaxNumberOfSubAccountsIx = await this.getUpdateStateMaxNumberOfSubAccountsIx(maxNumberOfSubAccounts);
|
|
835
|
+
const tx = await this.buildTransaction(updateStateMaxNumberOfSubAccountsIx);
|
|
836
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
837
|
+
return txSig;
|
|
838
|
+
}
|
|
839
|
+
async getUpdateStateMaxNumberOfSubAccountsIx(maxNumberOfSubAccounts) {
|
|
840
|
+
return await this.program.instruction.updateStateMaxNumberOfSubAccounts(maxNumberOfSubAccounts, {
|
|
841
|
+
accounts: {
|
|
842
|
+
admin: this.isSubscribed
|
|
843
|
+
? this.getStateAccount().admin
|
|
844
|
+
: this.wallet.publicKey,
|
|
845
|
+
state: await this.getStatePublicKey(),
|
|
846
|
+
},
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
async updateStateMaxInitializeUserFee(maxInitializeUserFee) {
|
|
850
|
+
const updateStateMaxInitializeUserFeeIx = await this.getUpdateStateMaxInitializeUserFeeIx(maxInitializeUserFee);
|
|
851
|
+
const tx = await this.buildTransaction(updateStateMaxInitializeUserFeeIx);
|
|
852
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
853
|
+
return txSig;
|
|
854
|
+
}
|
|
855
|
+
async getUpdateStateMaxInitializeUserFeeIx(maxInitializeUserFee) {
|
|
856
|
+
return await this.program.instruction.updateStateMaxInitializeUserFee(maxInitializeUserFee, {
|
|
857
|
+
accounts: {
|
|
858
|
+
admin: this.isSubscribed
|
|
859
|
+
? this.getStateAccount().admin
|
|
860
|
+
: this.wallet.publicKey,
|
|
861
|
+
state: await this.getStatePublicKey(),
|
|
862
|
+
},
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
async updateWithdrawGuardThreshold(spotMarketIndex, withdrawGuardThreshold) {
|
|
866
|
+
const updateWithdrawGuardThresholdIx = await this.getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold);
|
|
867
|
+
const tx = await this.buildTransaction(updateWithdrawGuardThresholdIx);
|
|
868
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
869
|
+
return txSig;
|
|
870
|
+
}
|
|
871
|
+
async getUpdateWithdrawGuardThresholdIx(spotMarketIndex, withdrawGuardThreshold) {
|
|
872
|
+
return await this.program.instruction.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
|
|
873
|
+
accounts: {
|
|
874
|
+
admin: this.isSubscribed
|
|
875
|
+
? this.getStateAccount().admin
|
|
876
|
+
: this.wallet.publicKey,
|
|
877
|
+
state: await this.getStatePublicKey(),
|
|
878
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
879
|
+
},
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
async updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor) {
|
|
883
|
+
const updateSpotMarketIfFactorIx = await this.getUpdateSpotMarketIfFactorIx(spotMarketIndex, userIfFactor, totalIfFactor);
|
|
884
|
+
const tx = await this.buildTransaction(updateSpotMarketIfFactorIx);
|
|
885
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
886
|
+
return txSig;
|
|
887
|
+
}
|
|
888
|
+
async getUpdateSpotMarketIfFactorIx(spotMarketIndex, userIfFactor, totalIfFactor) {
|
|
889
|
+
return await this.program.instruction.updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor, {
|
|
890
|
+
accounts: {
|
|
891
|
+
admin: this.isSubscribed
|
|
892
|
+
? this.getStateAccount().admin
|
|
893
|
+
: this.wallet.publicKey,
|
|
894
|
+
state: await this.getStatePublicKey(),
|
|
895
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
896
|
+
},
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
async updateSpotMarketRevenueSettlePeriod(spotMarketIndex, revenueSettlePeriod) {
|
|
900
|
+
const updateSpotMarketRevenueSettlePeriodIx = await this.getUpdateSpotMarketRevenueSettlePeriodIx(spotMarketIndex, revenueSettlePeriod);
|
|
901
|
+
const tx = await this.buildTransaction(updateSpotMarketRevenueSettlePeriodIx);
|
|
902
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
903
|
+
return txSig;
|
|
904
|
+
}
|
|
905
|
+
async getUpdateSpotMarketRevenueSettlePeriodIx(spotMarketIndex, revenueSettlePeriod) {
|
|
906
|
+
return await this.program.instruction.updateSpotMarketRevenueSettlePeriod(revenueSettlePeriod, {
|
|
907
|
+
accounts: {
|
|
908
|
+
admin: this.isSubscribed
|
|
909
|
+
? this.getStateAccount().admin
|
|
910
|
+
: this.wallet.publicKey,
|
|
911
|
+
state: await this.getStatePublicKey(),
|
|
912
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
913
|
+
},
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
async updateSpotMarketMaxTokenDeposits(spotMarketIndex, maxTokenDeposits) {
|
|
917
|
+
const updateSpotMarketMaxTokenDepositsIx = await this.getUpdateSpotMarketMaxTokenDepositsIx(spotMarketIndex, maxTokenDeposits);
|
|
918
|
+
const tx = await this.buildTransaction(updateSpotMarketMaxTokenDepositsIx);
|
|
919
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
920
|
+
return txSig;
|
|
921
|
+
}
|
|
922
|
+
async getUpdateSpotMarketMaxTokenDepositsIx(spotMarketIndex, maxTokenDeposits) {
|
|
923
|
+
return this.program.instruction.updateSpotMarketMaxTokenDeposits(maxTokenDeposits, {
|
|
924
|
+
accounts: {
|
|
925
|
+
admin: this.isSubscribed
|
|
926
|
+
? this.getStateAccount().admin
|
|
927
|
+
: this.wallet.publicKey,
|
|
928
|
+
state: await this.getStatePublicKey(),
|
|
929
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
930
|
+
},
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
async updateSpotMarketMaxTokenBorrows(spotMarketIndex, maxTokenBorrowsFraction) {
|
|
934
|
+
const updateSpotMarketMaxTokenBorrowsIx = await this.getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrowsFraction);
|
|
935
|
+
const tx = await this.buildTransaction(updateSpotMarketMaxTokenBorrowsIx);
|
|
936
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
937
|
+
return txSig;
|
|
938
|
+
}
|
|
939
|
+
async getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrowsFraction) {
|
|
940
|
+
return this.program.instruction.updateSpotMarketMaxTokenBorrows(maxTokenBorrowsFraction, {
|
|
941
|
+
accounts: {
|
|
942
|
+
admin: this.isSubscribed
|
|
943
|
+
? this.getStateAccount().admin
|
|
944
|
+
: this.wallet.publicKey,
|
|
945
|
+
state: await this.getStatePublicKey(),
|
|
946
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
947
|
+
},
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
async updateSpotMarketScaleInitialAssetWeightStart(spotMarketIndex, scaleInitialAssetWeightStart) {
|
|
951
|
+
const updateSpotMarketScaleInitialAssetWeightStartIx = await this.getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex, scaleInitialAssetWeightStart);
|
|
952
|
+
const tx = await this.buildTransaction(updateSpotMarketScaleInitialAssetWeightStartIx);
|
|
953
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
954
|
+
return txSig;
|
|
955
|
+
}
|
|
956
|
+
async getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex, scaleInitialAssetWeightStart) {
|
|
957
|
+
return this.program.instruction.updateSpotMarketScaleInitialAssetWeightStart(scaleInitialAssetWeightStart, {
|
|
958
|
+
accounts: {
|
|
959
|
+
admin: this.isSubscribed
|
|
960
|
+
? this.getStateAccount().admin
|
|
961
|
+
: this.wallet.publicKey,
|
|
962
|
+
state: await this.getStatePublicKey(),
|
|
963
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
964
|
+
},
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
async updateInsuranceFundUnstakingPeriod(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
|
|
968
|
+
const updateInsuranceFundUnstakingPeriodIx = await this.getUpdateInsuranceFundUnstakingPeriodIx(spotMarketIndex, insuranceWithdrawEscrowPeriod);
|
|
969
|
+
const tx = await this.buildTransaction(updateInsuranceFundUnstakingPeriodIx);
|
|
970
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
971
|
+
return txSig;
|
|
972
|
+
}
|
|
973
|
+
async getUpdateInsuranceFundUnstakingPeriodIx(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
|
|
974
|
+
return await this.program.instruction.updateInsuranceFundUnstakingPeriod(insuranceWithdrawEscrowPeriod, {
|
|
975
|
+
accounts: {
|
|
976
|
+
admin: this.isSubscribed
|
|
977
|
+
? this.getStateAccount().admin
|
|
978
|
+
: this.wallet.publicKey,
|
|
979
|
+
state: await this.getStatePublicKey(),
|
|
980
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
981
|
+
},
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
async updateLpCooldownTime(cooldownTime) {
|
|
985
|
+
const updateLpCooldownTimeIx = await this.getUpdateLpCooldownTimeIx(cooldownTime);
|
|
986
|
+
const tx = await this.buildTransaction(updateLpCooldownTimeIx);
|
|
987
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
988
|
+
return txSig;
|
|
989
|
+
}
|
|
990
|
+
async getUpdateLpCooldownTimeIx(cooldownTime) {
|
|
991
|
+
return await this.program.instruction.updateLpCooldownTime(cooldownTime, {
|
|
992
|
+
accounts: {
|
|
993
|
+
admin: this.isSubscribed
|
|
994
|
+
? this.getStateAccount().admin
|
|
995
|
+
: this.wallet.publicKey,
|
|
996
|
+
state: await this.getStatePublicKey(),
|
|
997
|
+
},
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
async updatePerpMarketOracle(perpMarketIndex, oracle, oracleSource) {
|
|
1001
|
+
const updatePerpMarketOracleIx = await this.getUpdatePerpMarketOracleIx(perpMarketIndex, oracle, oracleSource);
|
|
1002
|
+
const tx = await this.buildTransaction(updatePerpMarketOracleIx);
|
|
1003
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1004
|
+
return txSig;
|
|
1005
|
+
}
|
|
1006
|
+
async getUpdatePerpMarketOracleIx(perpMarketIndex, oracle, oracleSource) {
|
|
1007
|
+
return await this.program.instruction.updatePerpMarketOracle(oracle, oracleSource, {
|
|
1008
|
+
accounts: {
|
|
1009
|
+
admin: this.isSubscribed
|
|
1010
|
+
? this.getStateAccount().admin
|
|
1011
|
+
: this.wallet.publicKey,
|
|
1012
|
+
state: await this.getStatePublicKey(),
|
|
1013
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1014
|
+
oracle: oracle,
|
|
1015
|
+
},
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
async updatePerpMarketStepSizeAndTickSize(perpMarketIndex, stepSize, tickSize) {
|
|
1019
|
+
const updatePerpMarketStepSizeAndTickSizeIx = await this.getUpdatePerpMarketStepSizeAndTickSizeIx(perpMarketIndex, stepSize, tickSize);
|
|
1020
|
+
const tx = await this.buildTransaction(updatePerpMarketStepSizeAndTickSizeIx);
|
|
1021
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1022
|
+
return txSig;
|
|
1023
|
+
}
|
|
1024
|
+
async getUpdatePerpMarketStepSizeAndTickSizeIx(perpMarketIndex, stepSize, tickSize) {
|
|
1025
|
+
return await this.program.instruction.updatePerpMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
1026
|
+
accounts: {
|
|
1027
|
+
admin: this.isSubscribed
|
|
1028
|
+
? this.getStateAccount().admin
|
|
1029
|
+
: this.wallet.publicKey,
|
|
1030
|
+
state: await this.getStatePublicKey(),
|
|
1031
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1032
|
+
},
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
async updatePerpMarketMinOrderSize(perpMarketIndex, orderSize) {
|
|
1036
|
+
const updatePerpMarketMinOrderSizeIx = await this.getUpdatePerpMarketMinOrderSizeIx(perpMarketIndex, orderSize);
|
|
1037
|
+
const tx = await this.buildTransaction(updatePerpMarketMinOrderSizeIx);
|
|
1038
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1039
|
+
return txSig;
|
|
1040
|
+
}
|
|
1041
|
+
async getUpdatePerpMarketMinOrderSizeIx(perpMarketIndex, orderSize) {
|
|
1042
|
+
return await this.program.instruction.updatePerpMarketMinOrderSize(orderSize, {
|
|
1043
|
+
accounts: {
|
|
1044
|
+
admin: this.isSubscribed
|
|
1045
|
+
? this.getStateAccount().admin
|
|
1046
|
+
: this.wallet.publicKey,
|
|
1047
|
+
state: await this.getStatePublicKey(),
|
|
1048
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1049
|
+
},
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
async updateSpotMarketStepSizeAndTickSize(spotMarketIndex, stepSize, tickSize) {
|
|
1053
|
+
const updateSpotMarketStepSizeAndTickSizeIx = await this.getUpdateSpotMarketStepSizeAndTickSizeIx(spotMarketIndex, stepSize, tickSize);
|
|
1054
|
+
const tx = await this.buildTransaction(updateSpotMarketStepSizeAndTickSizeIx);
|
|
1055
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1056
|
+
return txSig;
|
|
1057
|
+
}
|
|
1058
|
+
async getUpdateSpotMarketStepSizeAndTickSizeIx(spotMarketIndex, stepSize, tickSize) {
|
|
1059
|
+
return await this.program.instruction.updateSpotMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
1060
|
+
accounts: {
|
|
1061
|
+
admin: this.isSubscribed
|
|
1062
|
+
? this.getStateAccount().admin
|
|
1063
|
+
: this.wallet.publicKey,
|
|
1064
|
+
state: await this.getStatePublicKey(),
|
|
1065
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1066
|
+
},
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
async updateSpotMarketMinOrderSize(spotMarketIndex, orderSize) {
|
|
1070
|
+
const updateSpotMarketMinOrderSizeIx = await this.program.instruction.updateSpotMarketMinOrderSize(orderSize, {
|
|
1071
|
+
accounts: {
|
|
1072
|
+
admin: this.isSubscribed
|
|
1073
|
+
? this.getStateAccount().admin
|
|
1074
|
+
: this.wallet.publicKey,
|
|
1075
|
+
state: await this.getStatePublicKey(),
|
|
1076
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1077
|
+
},
|
|
1078
|
+
});
|
|
1079
|
+
const tx = await this.buildTransaction(updateSpotMarketMinOrderSizeIx);
|
|
1080
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1081
|
+
return txSig;
|
|
1082
|
+
}
|
|
1083
|
+
async getUpdateSpotMarketMinOrderSizeIx(spotMarketIndex, orderSize) {
|
|
1084
|
+
return await this.program.instruction.updateSpotMarketMinOrderSize(orderSize, {
|
|
1085
|
+
accounts: {
|
|
1086
|
+
admin: this.isSubscribed
|
|
1087
|
+
? this.getStateAccount().admin
|
|
1088
|
+
: this.wallet.publicKey,
|
|
1089
|
+
state: await this.getStatePublicKey(),
|
|
1090
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1091
|
+
},
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
async updatePerpMarketExpiry(perpMarketIndex, expiryTs) {
|
|
1095
|
+
const updatePerpMarketExpiryIx = await this.getUpdatePerpMarketExpiryIx(perpMarketIndex, expiryTs);
|
|
1096
|
+
const tx = await this.buildTransaction(updatePerpMarketExpiryIx);
|
|
1097
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1098
|
+
return txSig;
|
|
1099
|
+
}
|
|
1100
|
+
async getUpdatePerpMarketExpiryIx(perpMarketIndex, expiryTs) {
|
|
1101
|
+
return await this.program.instruction.updatePerpMarketExpiry(expiryTs, {
|
|
1102
|
+
accounts: {
|
|
1103
|
+
admin: this.isSubscribed
|
|
1104
|
+
? this.getStateAccount().admin
|
|
1105
|
+
: this.wallet.publicKey,
|
|
1106
|
+
state: await this.getStatePublicKey(),
|
|
1107
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1108
|
+
},
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
async updateSpotMarketOracle(spotMarketIndex, oracle, oracleSource) {
|
|
1112
|
+
const updateSpotMarketOracleIx = await this.getUpdateSpotMarketOracleIx(spotMarketIndex, oracle, oracleSource);
|
|
1113
|
+
const tx = await this.buildTransaction(updateSpotMarketOracleIx);
|
|
1114
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1115
|
+
return txSig;
|
|
1116
|
+
}
|
|
1117
|
+
async getUpdateSpotMarketOracleIx(spotMarketIndex, oracle, oracleSource) {
|
|
1118
|
+
return await this.program.instruction.updateSpotMarketOracle(oracle, oracleSource, {
|
|
1119
|
+
accounts: {
|
|
1120
|
+
admin: this.isSubscribed
|
|
1121
|
+
? this.getStateAccount().admin
|
|
1122
|
+
: this.wallet.publicKey,
|
|
1123
|
+
state: await this.getStatePublicKey(),
|
|
1124
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1125
|
+
oracle: oracle,
|
|
1126
|
+
},
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
async updateSpotMarketOrdersEnabled(spotMarketIndex, ordersEnabled) {
|
|
1130
|
+
const updateSpotMarketOrdersEnabledIx = await this.getUpdateSpotMarketOrdersEnabledIx(spotMarketIndex, ordersEnabled);
|
|
1131
|
+
const tx = await this.buildTransaction(updateSpotMarketOrdersEnabledIx);
|
|
1132
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1133
|
+
return txSig;
|
|
1134
|
+
}
|
|
1135
|
+
async getUpdateSpotMarketOrdersEnabledIx(spotMarketIndex, ordersEnabled) {
|
|
1136
|
+
return await this.program.instruction.updateSpotMarketOrdersEnabled(ordersEnabled, {
|
|
1137
|
+
accounts: {
|
|
1138
|
+
admin: this.isSubscribed
|
|
1139
|
+
? this.getStateAccount().admin
|
|
1140
|
+
: this.wallet.publicKey,
|
|
1141
|
+
state: await this.getStatePublicKey(),
|
|
1142
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1143
|
+
},
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
async updateSpotMarketIfPausedOperations(spotMarketIndex, pausedOperations) {
|
|
1147
|
+
const updateSpotMarketIfStakingDisabledIx = await this.getUpdateSpotMarketIfPausedOperationsIx(spotMarketIndex, pausedOperations);
|
|
1148
|
+
const tx = await this.buildTransaction(updateSpotMarketIfStakingDisabledIx);
|
|
1149
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1150
|
+
return txSig;
|
|
1151
|
+
}
|
|
1152
|
+
async getUpdateSpotMarketIfPausedOperationsIx(spotMarketIndex, pausedOperations) {
|
|
1153
|
+
return await this.program.instruction.updateSpotMarketIfPausedOperations(pausedOperations, {
|
|
1154
|
+
accounts: {
|
|
1155
|
+
admin: this.isSubscribed
|
|
1156
|
+
? this.getStateAccount().admin
|
|
1157
|
+
: this.wallet.publicKey,
|
|
1158
|
+
state: await this.getStatePublicKey(),
|
|
1159
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1160
|
+
},
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
async updateSerumFulfillmentConfigStatus(serumFulfillmentConfig, status) {
|
|
1164
|
+
const updateSerumFulfillmentConfigStatusIx = await this.getUpdateSerumFulfillmentConfigStatusIx(serumFulfillmentConfig, status);
|
|
1165
|
+
const tx = await this.buildTransaction(updateSerumFulfillmentConfigStatusIx);
|
|
1166
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1167
|
+
return txSig;
|
|
1168
|
+
}
|
|
1169
|
+
async getUpdateSerumFulfillmentConfigStatusIx(serumFulfillmentConfig, status) {
|
|
1170
|
+
return await this.program.instruction.updateSerumFulfillmentConfigStatus(status, {
|
|
1171
|
+
accounts: {
|
|
1172
|
+
admin: this.isSubscribed
|
|
1173
|
+
? this.getStateAccount().admin
|
|
1174
|
+
: this.wallet.publicKey,
|
|
1175
|
+
state: await this.getStatePublicKey(),
|
|
1176
|
+
serumFulfillmentConfig,
|
|
1177
|
+
},
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
async updatePhoenixFulfillmentConfigStatus(phoenixFulfillmentConfig, status) {
|
|
1181
|
+
const updatePhoenixFulfillmentConfigStatusIx = await this.program.instruction.phoenixFulfillmentConfigStatus(status, {
|
|
1182
|
+
accounts: {
|
|
1183
|
+
admin: this.isSubscribed
|
|
1184
|
+
? this.getStateAccount().admin
|
|
1185
|
+
: this.wallet.publicKey,
|
|
1186
|
+
state: await this.getStatePublicKey(),
|
|
1187
|
+
phoenixFulfillmentConfig,
|
|
1188
|
+
},
|
|
1189
|
+
});
|
|
1190
|
+
const tx = await this.buildTransaction(updatePhoenixFulfillmentConfigStatusIx);
|
|
1191
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1192
|
+
return txSig;
|
|
1193
|
+
}
|
|
1194
|
+
async getUpdatePhoenixFulfillmentConfigStatusIx(phoenixFulfillmentConfig, status) {
|
|
1195
|
+
return await this.program.instruction.phoenixFulfillmentConfigStatus(status, {
|
|
1196
|
+
accounts: {
|
|
1197
|
+
admin: this.isSubscribed
|
|
1198
|
+
? this.getStateAccount().admin
|
|
1199
|
+
: this.wallet.publicKey,
|
|
1200
|
+
state: await this.getStatePublicKey(),
|
|
1201
|
+
phoenixFulfillmentConfig,
|
|
1202
|
+
},
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
async updateSpotMarketExpiry(spotMarketIndex, expiryTs) {
|
|
1206
|
+
const updateSpotMarketExpiryIx = await this.getUpdateSpotMarketExpiryIx(spotMarketIndex, expiryTs);
|
|
1207
|
+
const tx = await this.buildTransaction(updateSpotMarketExpiryIx);
|
|
1208
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1209
|
+
return txSig;
|
|
1210
|
+
}
|
|
1211
|
+
async getUpdateSpotMarketExpiryIx(spotMarketIndex, expiryTs) {
|
|
1212
|
+
return await this.program.instruction.updateSpotMarketExpiry(expiryTs, {
|
|
1213
|
+
accounts: {
|
|
1214
|
+
admin: this.isSubscribed
|
|
1215
|
+
? this.getStateAccount().admin
|
|
1216
|
+
: this.wallet.publicKey,
|
|
1217
|
+
state: await this.getStatePublicKey(),
|
|
1218
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1219
|
+
},
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
async updateWhitelistMint(whitelistMint) {
|
|
1223
|
+
const updateWhitelistMintIx = await this.getUpdateWhitelistMintIx(whitelistMint);
|
|
1224
|
+
const tx = await this.buildTransaction(updateWhitelistMintIx);
|
|
1225
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1226
|
+
return txSig;
|
|
1227
|
+
}
|
|
1228
|
+
async getUpdateWhitelistMintIx(whitelistMint) {
|
|
1229
|
+
return await this.program.instruction.updateWhitelistMint(whitelistMint, {
|
|
1230
|
+
accounts: {
|
|
1231
|
+
admin: this.isSubscribed
|
|
1232
|
+
? this.getStateAccount().admin
|
|
1233
|
+
: this.wallet.publicKey,
|
|
1234
|
+
state: await this.getStatePublicKey(),
|
|
1235
|
+
},
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
async updateDiscountMint(discountMint) {
|
|
1239
|
+
const updateDiscountMintIx = await this.getUpdateDiscountMintIx(discountMint);
|
|
1240
|
+
const tx = await this.buildTransaction(updateDiscountMintIx);
|
|
1241
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1242
|
+
return txSig;
|
|
1243
|
+
}
|
|
1244
|
+
async getUpdateDiscountMintIx(discountMint) {
|
|
1245
|
+
return await this.program.instruction.updateDiscountMint(discountMint, {
|
|
1246
|
+
accounts: {
|
|
1247
|
+
admin: this.isSubscribed
|
|
1248
|
+
? this.getStateAccount().admin
|
|
1249
|
+
: this.wallet.publicKey,
|
|
1250
|
+
state: await this.getStatePublicKey(),
|
|
1251
|
+
},
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
async updateSpotMarketMarginWeights(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0) {
|
|
1255
|
+
const updateSpotMarketMarginWeightsIx = await this.getUpdateSpotMarketMarginWeightsIx(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor);
|
|
1256
|
+
const tx = await this.buildTransaction(updateSpotMarketMarginWeightsIx);
|
|
1257
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1258
|
+
return txSig;
|
|
1259
|
+
}
|
|
1260
|
+
async getUpdateSpotMarketMarginWeightsIx(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0) {
|
|
1261
|
+
return await this.program.instruction.updateSpotMarketMarginWeights(initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, {
|
|
1262
|
+
accounts: {
|
|
1263
|
+
admin: this.isSubscribed
|
|
1264
|
+
? this.getStateAccount().admin
|
|
1265
|
+
: this.wallet.publicKey,
|
|
1266
|
+
state: await this.getStatePublicKey(),
|
|
1267
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1268
|
+
},
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
async updateSpotMarketBorrowRate(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate) {
|
|
1272
|
+
const updateSpotMarketBorrowRateIx = await this.getUpdateSpotMarketBorrowRateIx(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate);
|
|
1273
|
+
const tx = await this.buildTransaction(updateSpotMarketBorrowRateIx);
|
|
1274
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1275
|
+
return txSig;
|
|
1276
|
+
}
|
|
1277
|
+
async getUpdateSpotMarketBorrowRateIx(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate) {
|
|
1278
|
+
return await this.program.instruction.updateSpotMarketBorrowRate(optimalUtilization, optimalBorrowRate, optimalMaxRate, minBorrowRate, {
|
|
1279
|
+
accounts: {
|
|
1280
|
+
admin: this.isSubscribed
|
|
1281
|
+
? this.getStateAccount().admin
|
|
1282
|
+
: this.wallet.publicKey,
|
|
1283
|
+
state: await this.getStatePublicKey(),
|
|
1284
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1285
|
+
},
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
async updateSpotMarketAssetTier(spotMarketIndex, assetTier) {
|
|
1289
|
+
const updateSpotMarketAssetTierIx = await this.getUpdateSpotMarketAssetTierIx(spotMarketIndex, assetTier);
|
|
1290
|
+
const tx = await this.buildTransaction(updateSpotMarketAssetTierIx);
|
|
1291
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1292
|
+
return txSig;
|
|
1293
|
+
}
|
|
1294
|
+
async getUpdateSpotMarketAssetTierIx(spotMarketIndex, assetTier) {
|
|
1295
|
+
return await this.program.instruction.updateSpotMarketAssetTier(assetTier, {
|
|
1296
|
+
accounts: {
|
|
1297
|
+
admin: this.isSubscribed
|
|
1298
|
+
? this.getStateAccount().admin
|
|
1299
|
+
: this.wallet.publicKey,
|
|
1300
|
+
state: await this.getStatePublicKey(),
|
|
1301
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1302
|
+
},
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
async updateSpotMarketStatus(spotMarketIndex, marketStatus) {
|
|
1306
|
+
const updateSpotMarketStatusIx = await this.getUpdateSpotMarketStatusIx(spotMarketIndex, marketStatus);
|
|
1307
|
+
const tx = await this.buildTransaction(updateSpotMarketStatusIx);
|
|
1308
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1309
|
+
return txSig;
|
|
1310
|
+
}
|
|
1311
|
+
async getUpdateSpotMarketStatusIx(spotMarketIndex, marketStatus) {
|
|
1312
|
+
return await this.program.instruction.updateSpotMarketStatus(marketStatus, {
|
|
1313
|
+
accounts: {
|
|
1314
|
+
admin: this.isSubscribed
|
|
1315
|
+
? this.getStateAccount().admin
|
|
1316
|
+
: this.wallet.publicKey,
|
|
1317
|
+
state: await this.getStatePublicKey(),
|
|
1318
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1319
|
+
},
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
async updateSpotMarketPausedOperations(spotMarketIndex, pausedOperations) {
|
|
1323
|
+
const updateSpotMarketPausedOperationsIx = await this.getUpdateSpotMarketPausedOperationsIx(spotMarketIndex, pausedOperations);
|
|
1324
|
+
const tx = await this.buildTransaction(updateSpotMarketPausedOperationsIx);
|
|
1325
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1326
|
+
return txSig;
|
|
1327
|
+
}
|
|
1328
|
+
async getUpdateSpotMarketPausedOperationsIx(spotMarketIndex, pausedOperations) {
|
|
1329
|
+
return await this.program.instruction.updateSpotMarketPausedOperations(pausedOperations, {
|
|
1330
|
+
accounts: {
|
|
1331
|
+
admin: this.isSubscribed
|
|
1332
|
+
? this.getStateAccount().admin
|
|
1333
|
+
: this.wallet.publicKey,
|
|
1334
|
+
state: await this.getStatePublicKey(),
|
|
1335
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1336
|
+
},
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
async updatePerpMarketStatus(perpMarketIndex, marketStatus) {
|
|
1340
|
+
const updatePerpMarketStatusIx = await this.getUpdatePerpMarketStatusIx(perpMarketIndex, marketStatus);
|
|
1341
|
+
const tx = await this.buildTransaction(updatePerpMarketStatusIx);
|
|
1342
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1343
|
+
return txSig;
|
|
1344
|
+
}
|
|
1345
|
+
async getUpdatePerpMarketStatusIx(perpMarketIndex, marketStatus) {
|
|
1346
|
+
return await this.program.instruction.updatePerpMarketStatus(marketStatus, {
|
|
1347
|
+
accounts: {
|
|
1348
|
+
admin: this.isSubscribed
|
|
1349
|
+
? this.getStateAccount().admin
|
|
1350
|
+
: this.wallet.publicKey,
|
|
1351
|
+
state: await this.getStatePublicKey(),
|
|
1352
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1353
|
+
},
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
async updatePerpMarketPausedOperations(perpMarketIndex, pausedOperations) {
|
|
1357
|
+
const updatePerpMarketPausedOperationsIx = await this.getUpdatePerpMarketPausedOperationsIx(perpMarketIndex, pausedOperations);
|
|
1358
|
+
const tx = await this.buildTransaction(updatePerpMarketPausedOperationsIx);
|
|
1359
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1360
|
+
return txSig;
|
|
1361
|
+
}
|
|
1362
|
+
async getUpdatePerpMarketPausedOperationsIx(perpMarketIndex, pausedOperations) {
|
|
1363
|
+
return await this.program.instruction.updatePerpMarketPausedOperations(pausedOperations, {
|
|
1364
|
+
accounts: {
|
|
1365
|
+
admin: this.isSubscribed
|
|
1366
|
+
? this.getStateAccount().admin
|
|
1367
|
+
: this.wallet.publicKey,
|
|
1368
|
+
state: await this.getStatePublicKey(),
|
|
1369
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1370
|
+
},
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
async updatePerpMarketContractTier(perpMarketIndex, contractTier) {
|
|
1374
|
+
const updatePerpMarketContractTierIx = await this.getUpdatePerpMarketContractTierIx(perpMarketIndex, contractTier);
|
|
1375
|
+
const tx = await this.buildTransaction(updatePerpMarketContractTierIx);
|
|
1376
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1377
|
+
return txSig;
|
|
1378
|
+
}
|
|
1379
|
+
async getUpdatePerpMarketContractTierIx(perpMarketIndex, contractTier) {
|
|
1380
|
+
return await this.program.instruction.updatePerpMarketContractTier(contractTier, {
|
|
1381
|
+
accounts: {
|
|
1382
|
+
admin: this.isSubscribed
|
|
1383
|
+
? this.getStateAccount().admin
|
|
1384
|
+
: this.wallet.publicKey,
|
|
1385
|
+
state: await this.getStatePublicKey(),
|
|
1386
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1387
|
+
},
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
async updateExchangeStatus(exchangeStatus) {
|
|
1391
|
+
const updateExchangeStatusIx = await this.getUpdateExchangeStatusIx(exchangeStatus);
|
|
1392
|
+
const tx = await this.buildTransaction(updateExchangeStatusIx);
|
|
1393
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1394
|
+
return txSig;
|
|
1395
|
+
}
|
|
1396
|
+
async getUpdateExchangeStatusIx(exchangeStatus) {
|
|
1397
|
+
return await this.program.instruction.updateExchangeStatus(exchangeStatus, {
|
|
1398
|
+
accounts: {
|
|
1399
|
+
admin: this.isSubscribed
|
|
1400
|
+
? this.getStateAccount().admin
|
|
1401
|
+
: this.wallet.publicKey,
|
|
1402
|
+
state: await this.getStatePublicKey(),
|
|
1403
|
+
},
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
async updatePerpAuctionDuration(minDuration) {
|
|
1407
|
+
const updatePerpAuctionDurationIx = await this.getUpdatePerpAuctionDurationIx(minDuration);
|
|
1408
|
+
const tx = await this.buildTransaction(updatePerpAuctionDurationIx);
|
|
1409
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1410
|
+
return txSig;
|
|
1411
|
+
}
|
|
1412
|
+
async getUpdatePerpAuctionDurationIx(minDuration) {
|
|
1413
|
+
return await this.program.instruction.updatePerpAuctionDuration(typeof minDuration === 'number' ? minDuration : minDuration.toNumber(), {
|
|
1414
|
+
accounts: {
|
|
1415
|
+
admin: this.isSubscribed
|
|
1416
|
+
? this.getStateAccount().admin
|
|
1417
|
+
: this.wallet.publicKey,
|
|
1418
|
+
state: await this.getStatePublicKey(),
|
|
1419
|
+
},
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
async updateSpotAuctionDuration(defaultAuctionDuration) {
|
|
1423
|
+
const updateSpotAuctionDurationIx = await this.getUpdateSpotAuctionDurationIx(defaultAuctionDuration);
|
|
1424
|
+
const tx = await this.buildTransaction(updateSpotAuctionDurationIx);
|
|
1425
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1426
|
+
return txSig;
|
|
1427
|
+
}
|
|
1428
|
+
async getUpdateSpotAuctionDurationIx(defaultAuctionDuration) {
|
|
1429
|
+
return await this.program.instruction.updateSpotAuctionDuration(defaultAuctionDuration, {
|
|
1430
|
+
accounts: {
|
|
1431
|
+
admin: this.isSubscribed
|
|
1432
|
+
? this.getStateAccount().admin
|
|
1433
|
+
: this.wallet.publicKey,
|
|
1434
|
+
state: await this.getStatePublicKey(),
|
|
1435
|
+
},
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
async updatePerpMarketMaxFillReserveFraction(perpMarketIndex, maxBaseAssetAmountRatio) {
|
|
1439
|
+
const updatePerpMarketMaxFillReserveFractionIx = await this.getUpdatePerpMarketMaxFillReserveFractionIx(perpMarketIndex, maxBaseAssetAmountRatio);
|
|
1440
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxFillReserveFractionIx);
|
|
1441
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1442
|
+
return txSig;
|
|
1443
|
+
}
|
|
1444
|
+
async getUpdatePerpMarketMaxFillReserveFractionIx(perpMarketIndex, maxBaseAssetAmountRatio) {
|
|
1445
|
+
return await this.program.instruction.updatePerpMarketMaxFillReserveFraction(maxBaseAssetAmountRatio, {
|
|
1446
|
+
accounts: {
|
|
1447
|
+
admin: this.isSubscribed
|
|
1448
|
+
? this.getStateAccount().admin
|
|
1449
|
+
: this.wallet.publicKey,
|
|
1450
|
+
state: await this.getStatePublicKey(),
|
|
1451
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1452
|
+
},
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
async updateMaxSlippageRatio(perpMarketIndex, maxSlippageRatio) {
|
|
1456
|
+
const updateMaxSlippageRatioIx = await this.getUpdateMaxSlippageRatioIx(perpMarketIndex, maxSlippageRatio);
|
|
1457
|
+
const tx = await this.buildTransaction(updateMaxSlippageRatioIx);
|
|
1458
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1459
|
+
return txSig;
|
|
1460
|
+
}
|
|
1461
|
+
async getUpdateMaxSlippageRatioIx(perpMarketIndex, maxSlippageRatio) {
|
|
1462
|
+
return await this.program.instruction.updateMaxSlippageRatio(maxSlippageRatio, {
|
|
1463
|
+
accounts: {
|
|
1464
|
+
admin: this.isSubscribed
|
|
1465
|
+
? this.getStateAccount().admin
|
|
1466
|
+
: this.wallet.publicKey,
|
|
1467
|
+
state: await this.getStatePublicKey(),
|
|
1468
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
1469
|
+
},
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
async updatePerpMarketUnrealizedAssetWeight(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight) {
|
|
1473
|
+
const updatePerpMarketUnrealizedAssetWeightIx = await this.getUpdatePerpMarketUnrealizedAssetWeightIx(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight);
|
|
1474
|
+
const tx = await this.buildTransaction(updatePerpMarketUnrealizedAssetWeightIx);
|
|
1475
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1476
|
+
return txSig;
|
|
1477
|
+
}
|
|
1478
|
+
async getUpdatePerpMarketUnrealizedAssetWeightIx(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight) {
|
|
1479
|
+
return await this.program.instruction.updatePerpMarketUnrealizedAssetWeight(unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight, {
|
|
1480
|
+
accounts: {
|
|
1481
|
+
admin: this.isSubscribed
|
|
1482
|
+
? this.getStateAccount().admin
|
|
1483
|
+
: this.wallet.publicKey,
|
|
1484
|
+
state: await this.getStatePublicKey(),
|
|
1485
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1486
|
+
},
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
async updatePerpMarketMaxImbalances(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
|
|
1490
|
+
const updatePerpMarketMaxImabalancesIx = await this.getUpdatePerpMarketMaxImbalancesIx(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance);
|
|
1491
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxImabalancesIx);
|
|
1492
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1493
|
+
return txSig;
|
|
1494
|
+
}
|
|
1495
|
+
async getUpdatePerpMarketMaxImbalancesIx(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
|
|
1496
|
+
return await this.program.instruction.updatePerpMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
|
|
1497
|
+
accounts: {
|
|
1498
|
+
admin: this.isSubscribed
|
|
1499
|
+
? this.getStateAccount().admin
|
|
1500
|
+
: this.wallet.publicKey,
|
|
1501
|
+
state: await this.getStatePublicKey(),
|
|
1502
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1503
|
+
},
|
|
1504
|
+
});
|
|
1505
|
+
}
|
|
1506
|
+
async updatePerpMarketMaxOpenInterest(perpMarketIndex, maxOpenInterest) {
|
|
1507
|
+
const updatePerpMarketMaxOpenInterestIx = await this.getUpdatePerpMarketMaxOpenInterestIx(perpMarketIndex, maxOpenInterest);
|
|
1508
|
+
const tx = await this.buildTransaction(updatePerpMarketMaxOpenInterestIx);
|
|
1509
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1510
|
+
return txSig;
|
|
1511
|
+
}
|
|
1512
|
+
async getUpdatePerpMarketMaxOpenInterestIx(perpMarketIndex, maxOpenInterest) {
|
|
1513
|
+
return await this.program.instruction.updatePerpMarketMaxOpenInterest(maxOpenInterest, {
|
|
1514
|
+
accounts: {
|
|
1515
|
+
admin: this.isSubscribed
|
|
1516
|
+
? this.getStateAccount().admin
|
|
1517
|
+
: this.wallet.publicKey,
|
|
1518
|
+
state: await this.getStatePublicKey(),
|
|
1519
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1520
|
+
},
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
async updatePerpMarketNumberOfUser(perpMarketIndex, numberOfUsers, numberOfUsersWithBase) {
|
|
1524
|
+
const updatepPerpMarketFeeAdjustmentIx = await this.getUpdatePerpMarketNumberOfUsersIx(perpMarketIndex, numberOfUsers, numberOfUsersWithBase);
|
|
1525
|
+
const tx = await this.buildTransaction(updatepPerpMarketFeeAdjustmentIx);
|
|
1526
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1527
|
+
return txSig;
|
|
1528
|
+
}
|
|
1529
|
+
async getUpdatePerpMarketNumberOfUsersIx(perpMarketIndex, numberOfUsers, numberOfUsersWithBase) {
|
|
1530
|
+
return await this.program.instruction.updatePerpMarketNumberOfUsers(numberOfUsers, numberOfUsersWithBase, {
|
|
1531
|
+
accounts: {
|
|
1532
|
+
admin: this.isSubscribed
|
|
1533
|
+
? this.getStateAccount().admin
|
|
1534
|
+
: this.wallet.publicKey,
|
|
1535
|
+
state: await this.getStatePublicKey(),
|
|
1536
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1537
|
+
},
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
async updatePerpMarketFeeAdjustment(perpMarketIndex, feeAdjustment) {
|
|
1541
|
+
const updatepPerpMarketFeeAdjustmentIx = await this.getUpdatePerpMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment);
|
|
1542
|
+
const tx = await this.buildTransaction(updatepPerpMarketFeeAdjustmentIx);
|
|
1543
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1544
|
+
return txSig;
|
|
1545
|
+
}
|
|
1546
|
+
async getUpdatePerpMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment) {
|
|
1547
|
+
return await this.program.instruction.updatePerpMarketFeeAdjustment(feeAdjustment, {
|
|
1548
|
+
accounts: {
|
|
1549
|
+
admin: this.isSubscribed
|
|
1550
|
+
? this.getStateAccount().admin
|
|
1551
|
+
: this.wallet.publicKey,
|
|
1552
|
+
state: await this.getStatePublicKey(),
|
|
1553
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1554
|
+
},
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
async updateSpotMarketFeeAdjustment(perpMarketIndex, feeAdjustment) {
|
|
1558
|
+
const updateSpotMarketFeeAdjustmentIx = await this.getUpdateSpotMarketFeeAdjustmentIx(perpMarketIndex, feeAdjustment);
|
|
1559
|
+
const tx = await this.buildTransaction(updateSpotMarketFeeAdjustmentIx);
|
|
1560
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1561
|
+
return txSig;
|
|
1562
|
+
}
|
|
1563
|
+
async getUpdateSpotMarketFeeAdjustmentIx(spotMarketIndex, feeAdjustment) {
|
|
1564
|
+
return await this.program.instruction.updateSpotMarketFeeAdjustment(feeAdjustment, {
|
|
1565
|
+
accounts: {
|
|
1566
|
+
admin: this.isSubscribed
|
|
1567
|
+
? this.getStateAccount().admin
|
|
1568
|
+
: this.wallet.publicKey,
|
|
1569
|
+
state: await this.getStatePublicKey(),
|
|
1570
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1571
|
+
},
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
async updateSerumVault(srmVault) {
|
|
1575
|
+
const updateSerumVaultIx = await this.getUpdateSerumVaultIx(srmVault);
|
|
1576
|
+
const tx = await this.buildTransaction(updateSerumVaultIx);
|
|
1577
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1578
|
+
return txSig;
|
|
1579
|
+
}
|
|
1580
|
+
async getUpdateSerumVaultIx(srmVault) {
|
|
1581
|
+
return await this.program.instruction.updateSerumVault(srmVault, {
|
|
1582
|
+
accounts: {
|
|
1583
|
+
admin: this.isSubscribed
|
|
1584
|
+
? this.getStateAccount().admin
|
|
1585
|
+
: this.wallet.publicKey,
|
|
1586
|
+
state: await this.getStatePublicKey(),
|
|
1587
|
+
srmVault: srmVault,
|
|
1588
|
+
},
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
async updatePerpMarketLiquidationFee(perpMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
1592
|
+
const updatePerpMarketLiquidationFeeIx = await this.getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee);
|
|
1593
|
+
const tx = await this.buildTransaction(updatePerpMarketLiquidationFeeIx);
|
|
1594
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1595
|
+
return txSig;
|
|
1596
|
+
}
|
|
1597
|
+
async getUpdatePerpMarketLiquidationFeeIx(perpMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
1598
|
+
return await this.program.instruction.updatePerpMarketLiquidationFee(liquidatorFee, ifLiquidationFee, {
|
|
1599
|
+
accounts: {
|
|
1600
|
+
admin: this.isSubscribed
|
|
1601
|
+
? this.getStateAccount().admin
|
|
1602
|
+
: this.wallet.publicKey,
|
|
1603
|
+
state: await this.getStatePublicKey(),
|
|
1604
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
1605
|
+
},
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
async updateSpotMarketLiquidationFee(spotMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
1609
|
+
const updateSpotMarketLiquidationFeeIx = await this.getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee);
|
|
1610
|
+
const tx = await this.buildTransaction(updateSpotMarketLiquidationFeeIx);
|
|
1611
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1612
|
+
return txSig;
|
|
1613
|
+
}
|
|
1614
|
+
async getUpdateSpotMarketLiquidationFeeIx(spotMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
1615
|
+
return await this.program.instruction.updateSpotMarketLiquidationFee(liquidatorFee, ifLiquidationFee, {
|
|
1616
|
+
accounts: {
|
|
1617
|
+
admin: this.isSubscribed
|
|
1618
|
+
? this.getStateAccount().admin
|
|
1619
|
+
: this.wallet.publicKey,
|
|
1620
|
+
state: await this.getStatePublicKey(),
|
|
1621
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
1622
|
+
},
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
async initializeProtocolIfSharesTransferConfig() {
|
|
1626
|
+
const initializeProtocolIfSharesTransferConfigIx = await this.getInitializeProtocolIfSharesTransferConfigIx();
|
|
1627
|
+
const tx = await this.buildTransaction(initializeProtocolIfSharesTransferConfigIx);
|
|
1628
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1629
|
+
return txSig;
|
|
1630
|
+
}
|
|
1631
|
+
async getInitializeProtocolIfSharesTransferConfigIx() {
|
|
1632
|
+
return await this.program.instruction.initializeProtocolIfSharesTransferConfig({
|
|
1633
|
+
accounts: {
|
|
1634
|
+
admin: this.isSubscribed
|
|
1635
|
+
? this.getStateAccount().admin
|
|
1636
|
+
: this.wallet.publicKey,
|
|
1637
|
+
state: await this.getStatePublicKey(),
|
|
1638
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1639
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1640
|
+
protocolIfSharesTransferConfig: (0, pda_1.getProtocolIfSharesTransferConfigPublicKey)(this.program.programId),
|
|
1641
|
+
},
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
async updateProtocolIfSharesTransferConfig(whitelistedSigners, maxTransferPerEpoch) {
|
|
1645
|
+
const updateProtocolIfSharesTransferConfigIx = await this.getUpdateProtocolIfSharesTransferConfigIx(whitelistedSigners, maxTransferPerEpoch);
|
|
1646
|
+
const tx = await this.buildTransaction(updateProtocolIfSharesTransferConfigIx);
|
|
1647
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1648
|
+
return txSig;
|
|
1649
|
+
}
|
|
1650
|
+
async getUpdateProtocolIfSharesTransferConfigIx(whitelistedSigners, maxTransferPerEpoch) {
|
|
1651
|
+
return await this.program.instruction.updateProtocolIfSharesTransferConfig(whitelistedSigners || null, maxTransferPerEpoch, {
|
|
1652
|
+
accounts: {
|
|
1653
|
+
admin: this.isSubscribed
|
|
1654
|
+
? this.getStateAccount().admin
|
|
1655
|
+
: this.wallet.publicKey,
|
|
1656
|
+
state: await this.getStatePublicKey(),
|
|
1657
|
+
protocolIfSharesTransferConfig: (0, pda_1.getProtocolIfSharesTransferConfigPublicKey)(this.program.programId),
|
|
1658
|
+
},
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
async initializePrelaunchOracle(perpMarketIndex, price, maxPrice) {
|
|
1662
|
+
const initializePrelaunchOracleIx = await this.getInitializePrelaunchOracleIx(perpMarketIndex, price, maxPrice);
|
|
1663
|
+
const tx = await this.buildTransaction(initializePrelaunchOracleIx);
|
|
1664
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1665
|
+
return txSig;
|
|
1666
|
+
}
|
|
1667
|
+
async getInitializePrelaunchOracleIx(perpMarketIndex, price, maxPrice) {
|
|
1668
|
+
const params = {
|
|
1669
|
+
perpMarketIndex,
|
|
1670
|
+
price: price || null,
|
|
1671
|
+
maxPrice: maxPrice || null,
|
|
1672
|
+
};
|
|
1673
|
+
return await this.program.instruction.initializePrelaunchOracle(params, {
|
|
1674
|
+
accounts: {
|
|
1675
|
+
admin: this.isSubscribed
|
|
1676
|
+
? this.getStateAccount().admin
|
|
1677
|
+
: this.wallet.publicKey,
|
|
1678
|
+
state: await this.getStatePublicKey(),
|
|
1679
|
+
prelaunchOracle: await (0, pda_1.getPrelaunchOraclePublicKey)(this.program.programId, perpMarketIndex),
|
|
1680
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1681
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1682
|
+
},
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
async updatePrelaunchOracleParams(perpMarketIndex, price, maxPrice) {
|
|
1686
|
+
const updatePrelaunchOracleParamsIx = await this.getUpdatePrelaunchOracleParamsIx(perpMarketIndex, price, maxPrice);
|
|
1687
|
+
const tx = await this.buildTransaction(updatePrelaunchOracleParamsIx);
|
|
1688
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1689
|
+
return txSig;
|
|
1690
|
+
}
|
|
1691
|
+
async getUpdatePrelaunchOracleParamsIx(perpMarketIndex, price, maxPrice) {
|
|
1692
|
+
const params = {
|
|
1693
|
+
perpMarketIndex,
|
|
1694
|
+
price: price || null,
|
|
1695
|
+
maxPrice: maxPrice || null,
|
|
1696
|
+
};
|
|
1697
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1698
|
+
return await this.program.instruction.updatePrelaunchOracleParams(params, {
|
|
1699
|
+
accounts: {
|
|
1700
|
+
admin: this.isSubscribed
|
|
1701
|
+
? this.getStateAccount().admin
|
|
1702
|
+
: this.wallet.publicKey,
|
|
1703
|
+
state: await this.getStatePublicKey(),
|
|
1704
|
+
perpMarket: perpMarketPublicKey,
|
|
1705
|
+
prelaunchOracle: await (0, pda_1.getPrelaunchOraclePublicKey)(this.program.programId, perpMarketIndex),
|
|
1706
|
+
},
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
async deletePrelaunchOracle(perpMarketIndex) {
|
|
1710
|
+
const deletePrelaunchOracleIx = await this.getDeletePrelaunchOracleIx(perpMarketIndex);
|
|
1711
|
+
const tx = await this.buildTransaction(deletePrelaunchOracleIx);
|
|
1712
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1713
|
+
return txSig;
|
|
1714
|
+
}
|
|
1715
|
+
async getDeletePrelaunchOracleIx(perpMarketIndex, price, maxPrice) {
|
|
1716
|
+
const params = {
|
|
1717
|
+
perpMarketIndex,
|
|
1718
|
+
price: price || null,
|
|
1719
|
+
maxPrice: maxPrice || null,
|
|
1720
|
+
};
|
|
1721
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1722
|
+
return await this.program.instruction.deletePrelaunchOracle(params, {
|
|
1723
|
+
accounts: {
|
|
1724
|
+
admin: this.isSubscribed
|
|
1725
|
+
? this.getStateAccount().admin
|
|
1726
|
+
: this.wallet.publicKey,
|
|
1727
|
+
state: await this.getStatePublicKey(),
|
|
1728
|
+
perpMarket: perpMarketPublicKey,
|
|
1729
|
+
prelaunchOracle: await (0, pda_1.getPrelaunchOraclePublicKey)(this.program.programId, perpMarketIndex),
|
|
1730
|
+
},
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
async updateSpotMarketFuel(spotMarketIndex, fuelBoostDeposits, fuelBoostBorrows, fuelBoostTaker, fuelBoostMaker, fuelBoostInsurance) {
|
|
1734
|
+
const updateSpotMarketFuelIx = await this.getUpdateSpotMarketFuelIx(spotMarketIndex, fuelBoostDeposits || null, fuelBoostBorrows || null, fuelBoostTaker || null, fuelBoostMaker || null, fuelBoostInsurance || null);
|
|
1735
|
+
const tx = await this.buildTransaction(updateSpotMarketFuelIx);
|
|
1736
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1737
|
+
return txSig;
|
|
1738
|
+
}
|
|
1739
|
+
async getUpdateSpotMarketFuelIx(spotMarketIndex, fuelBoostDeposits, fuelBoostBorrows, fuelBoostTaker, fuelBoostMaker, fuelBoostInsurance) {
|
|
1740
|
+
const spotMarketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
|
|
1741
|
+
return await this.program.instruction.updateSpotMarketFuel(fuelBoostDeposits || null, fuelBoostBorrows || null, fuelBoostTaker || null, fuelBoostMaker || null, fuelBoostInsurance || null, {
|
|
1742
|
+
accounts: {
|
|
1743
|
+
admin: this.isSubscribed
|
|
1744
|
+
? this.getStateAccount().admin
|
|
1745
|
+
: this.wallet.publicKey,
|
|
1746
|
+
state: await this.getStatePublicKey(),
|
|
1747
|
+
spotMarket: spotMarketPublicKey,
|
|
1748
|
+
},
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
async updatePerpMarketFuel(perpMarketIndex, fuelBoostTaker, fuelBoostMaker, fuelBoostPosition) {
|
|
1752
|
+
const updatePerpMarketFuelIx = await this.getUpdatePerpMarketFuelIx(perpMarketIndex, fuelBoostTaker || null, fuelBoostMaker || null, fuelBoostPosition || null);
|
|
1753
|
+
const tx = await this.buildTransaction(updatePerpMarketFuelIx);
|
|
1754
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1755
|
+
return txSig;
|
|
1756
|
+
}
|
|
1757
|
+
async getUpdatePerpMarketFuelIx(perpMarketIndex, fuelBoostTaker, fuelBoostMaker, fuelBoostPosition) {
|
|
1758
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1759
|
+
return await this.program.instruction.updatePerpMarketFuel(fuelBoostTaker || null, fuelBoostMaker || null, fuelBoostPosition || null, {
|
|
1760
|
+
accounts: {
|
|
1761
|
+
admin: this.isSubscribed
|
|
1762
|
+
? this.getStateAccount().admin
|
|
1763
|
+
: this.wallet.publicKey,
|
|
1764
|
+
state: await this.getStatePublicKey(),
|
|
1765
|
+
perpMarket: perpMarketPublicKey,
|
|
1766
|
+
},
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
async initUserFuel(user, authority, fuelBonusDeposits, fuelBonusBorrows, fuelBonusTaker, fuelBonusMaker, fuelBonusInsurance) {
|
|
1770
|
+
const updatePerpMarketFuelIx = await this.getInitUserFuelIx(user, authority, fuelBonusDeposits, fuelBonusBorrows, fuelBonusTaker, fuelBonusMaker, fuelBonusInsurance);
|
|
1771
|
+
const tx = await this.buildTransaction(updatePerpMarketFuelIx);
|
|
1772
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1773
|
+
return txSig;
|
|
1774
|
+
}
|
|
1775
|
+
async getInitUserFuelIx(user, authority, fuelBonusDeposits, fuelBonusBorrows, fuelBonusTaker, fuelBonusMaker, fuelBonusInsurance) {
|
|
1776
|
+
const userStats = await (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority);
|
|
1777
|
+
return await this.program.instruction.initUserFuel(fuelBonusDeposits || null, fuelBonusBorrows || null, fuelBonusTaker || null, fuelBonusMaker || null, fuelBonusInsurance || null, {
|
|
1778
|
+
accounts: {
|
|
1779
|
+
admin: this.wallet.publicKey,
|
|
1780
|
+
state: await this.getStatePublicKey(),
|
|
1781
|
+
user,
|
|
1782
|
+
userStats,
|
|
1783
|
+
},
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
async initializePythPullOracle(feedId, isAdmin = false) {
|
|
1787
|
+
const initializePythPullOracleIx = await this.getInitializePythPullOracleIx(feedId, isAdmin);
|
|
1788
|
+
const tx = await this.buildTransaction(initializePythPullOracleIx);
|
|
1789
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1790
|
+
return txSig;
|
|
1791
|
+
}
|
|
1792
|
+
async getInitializePythPullOracleIx(feedId, isAdmin = false) {
|
|
1793
|
+
const feedIdBuffer = (0, pythOracleUtils_1.getFeedIdUint8Array)(feedId);
|
|
1794
|
+
return await this.program.instruction.initializePythPullOracle(feedIdBuffer, {
|
|
1795
|
+
accounts: {
|
|
1796
|
+
admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey,
|
|
1797
|
+
state: await this.getStatePublicKey(),
|
|
1798
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
1799
|
+
priceFeed: (0, pda_1.getPythPullOraclePublicKey)(this.program.programId, feedIdBuffer),
|
|
1800
|
+
pythSolanaReceiver: config_1.DRIFT_ORACLE_RECEIVER_ID,
|
|
1801
|
+
},
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
async initializePythLazerOracle(feedId, isAdmin = false) {
|
|
1805
|
+
const initializePythPullOracleIx = await this.getInitializePythLazerOracleIx(feedId, isAdmin);
|
|
1806
|
+
const tx = await this.buildTransaction(initializePythPullOracleIx);
|
|
1807
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1808
|
+
return txSig;
|
|
1809
|
+
}
|
|
1810
|
+
async getInitializePythLazerOracleIx(feedId, isAdmin = false) {
|
|
1811
|
+
return await this.program.instruction.initializePythLazerOracle(feedId, {
|
|
1812
|
+
accounts: {
|
|
1813
|
+
admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey,
|
|
1814
|
+
state: await this.getStatePublicKey(),
|
|
1815
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
1816
|
+
lazerOracle: (0, pda_1.getPythLazerOraclePublicKey)(this.program.programId, feedId),
|
|
1817
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1818
|
+
},
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
async initializeHighLeverageModeConfig(maxUsers) {
|
|
1822
|
+
const initializeHighLeverageModeConfigIx = await this.getInitializeHighLeverageModeConfigIx(maxUsers);
|
|
1823
|
+
const tx = await this.buildTransaction(initializeHighLeverageModeConfigIx);
|
|
1824
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1825
|
+
return txSig;
|
|
1826
|
+
}
|
|
1827
|
+
async getInitializeHighLeverageModeConfigIx(maxUsers) {
|
|
1828
|
+
return await this.program.instruction.initializeHighLeverageModeConfig(maxUsers, {
|
|
1829
|
+
accounts: {
|
|
1830
|
+
admin: this.isSubscribed
|
|
1831
|
+
? this.getStateAccount().admin
|
|
1832
|
+
: this.wallet.publicKey,
|
|
1833
|
+
state: await this.getStatePublicKey(),
|
|
1834
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1835
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1836
|
+
highLeverageModeConfig: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
1837
|
+
},
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
async updateUpdateHighLeverageModeConfig(maxUsers, reduceOnly) {
|
|
1841
|
+
const updateHighLeverageModeConfigIx = await this.getUpdateHighLeverageModeConfigIx(maxUsers, reduceOnly);
|
|
1842
|
+
const tx = await this.buildTransaction(updateHighLeverageModeConfigIx);
|
|
1843
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1844
|
+
return txSig;
|
|
1845
|
+
}
|
|
1846
|
+
async getUpdateHighLeverageModeConfigIx(maxUsers, reduceOnly) {
|
|
1847
|
+
return await this.program.instruction.updateHighLeverageModeConfig(maxUsers, reduceOnly, {
|
|
1848
|
+
accounts: {
|
|
1849
|
+
admin: this.isSubscribed
|
|
1850
|
+
? this.getStateAccount().admin
|
|
1851
|
+
: this.wallet.publicKey,
|
|
1852
|
+
state: await this.getStatePublicKey(),
|
|
1853
|
+
highLeverageModeConfig: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
1854
|
+
},
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
exports.AdminClient = AdminClient;
|