@drift-labs/sdk 0.2.0-master.4 → 0.2.0-master.40
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 +27 -27
- package/lib/accounts/bulkAccountLoader.d.ts +2 -0
- package/lib/accounts/bulkAccountLoader.js +36 -29
- package/lib/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/accounts/bulkUserSubscription.d.ts +2 -2
- package/lib/accounts/bulkUserSubscription.js +0 -1
- package/lib/accounts/fetch.d.ts +2 -1
- package/lib/accounts/fetch.js +9 -1
- package/lib/accounts/{pollingClearingHouseAccountSubscriber.d.ts → pollingDriftClientAccountSubscriber.d.ts} +20 -25
- package/lib/accounts/{pollingClearingHouseAccountSubscriber.js → pollingDriftClientAccountSubscriber.js} +45 -49
- package/lib/accounts/{pollingOracleSubscriber.d.ts → pollingOracleAccountSubscriber.d.ts} +2 -2
- package/lib/accounts/{pollingOracleSubscriber.js → pollingOracleAccountSubscriber.js} +3 -3
- package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +113 -0
- package/lib/accounts/types.d.ts +26 -15
- package/lib/accounts/webSocketDriftClientAccountSubscriber.d.ts +49 -0
- package/lib/accounts/{webSocketClearingHouseAccountSubscriber.js → webSocketDriftClientAccountSubscriber.js} +47 -45
- package/lib/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/accounts/webSocketUserStatsAccountSubsriber.js +47 -0
- package/lib/addresses/marketAddresses.d.ts +1 -3
- package/lib/addresses/marketAddresses.js +1 -1
- package/lib/addresses/pda.d.ts +15 -9
- package/lib/addresses/pda.js +73 -35
- package/lib/adminClient.d.ts +65 -0
- package/lib/adminClient.js +637 -0
- package/lib/config.d.ts +9 -9
- package/lib/config.js +25 -21
- package/lib/constants/numericConstants.d.ts +30 -12
- package/lib/constants/numericConstants.js +41 -21
- package/lib/constants/perpMarkets.d.ts +18 -0
- package/lib/constants/{markets.js → perpMarkets.js} +7 -7
- package/lib/constants/spotMarkets.d.ts +19 -0
- package/lib/constants/spotMarkets.js +53 -0
- package/lib/dlob/DLOB.d.ts +82 -0
- package/lib/dlob/DLOB.js +696 -0
- package/lib/dlob/DLOBNode.d.ts +54 -0
- package/lib/dlob/DLOBNode.js +77 -0
- package/lib/dlob/NodeList.d.ts +27 -0
- package/lib/dlob/NodeList.js +144 -0
- package/lib/driftClient.d.ts +233 -0
- package/lib/driftClient.js +2096 -0
- package/lib/{clearingHouseConfig.d.ts → driftClientConfig.d.ts} +9 -9
- package/lib/{clearingHouseConfig.js → driftClientConfig.js} +0 -0
- package/lib/events/eventList.js +3 -0
- package/lib/events/eventSubscriber.d.ts +5 -2
- package/lib/events/eventSubscriber.js +25 -11
- package/lib/events/fetchLogs.d.ts +13 -2
- package/lib/events/fetchLogs.js +40 -12
- package/lib/events/pollingLogProvider.d.ts +2 -1
- package/lib/events/pollingLogProvider.js +7 -3
- package/lib/events/sort.js +8 -11
- package/lib/events/types.d.ts +9 -3
- package/lib/events/types.js +6 -0
- package/lib/events/webSocketLogProvider.js +1 -1
- package/lib/examples/makeTradeExample.js +30 -18
- package/lib/factory/bigNum.d.ts +8 -4
- package/lib/factory/bigNum.js +109 -19
- package/lib/idl/drift.json +8250 -0
- package/lib/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/lib/index.d.ts +30 -13
- package/lib/index.js +30 -13
- package/lib/math/amm.d.ts +9 -6
- package/lib/math/amm.js +91 -38
- package/lib/math/conversion.js +1 -1
- package/lib/math/exchangeStatus.d.ts +4 -0
- package/lib/math/exchangeStatus.js +18 -0
- package/lib/math/funding.d.ts +6 -6
- package/lib/math/funding.js +23 -21
- package/lib/math/insurance.d.ts +4 -0
- package/lib/math/insurance.js +27 -0
- package/lib/math/margin.d.ts +11 -0
- package/lib/math/margin.js +82 -0
- package/lib/math/market.d.ts +14 -9
- package/lib/math/market.js +70 -10
- package/lib/math/oracles.d.ts +4 -0
- package/lib/math/oracles.js +36 -8
- package/lib/math/orders.d.ts +14 -6
- package/lib/math/orders.js +90 -17
- package/lib/math/position.d.ts +27 -13
- package/lib/math/position.js +92 -36
- package/lib/math/repeg.js +17 -8
- package/lib/math/spotBalance.d.ts +22 -0
- package/lib/math/spotBalance.js +192 -0
- package/lib/math/spotMarket.d.ts +4 -0
- package/lib/math/spotMarket.js +8 -0
- package/lib/math/spotPosition.d.ts +6 -0
- package/lib/math/spotPosition.js +23 -0
- package/lib/math/trade.d.ts +10 -10
- package/lib/math/trade.js +27 -31
- package/lib/oracles/pythClient.js +1 -1
- package/lib/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/oracles/switchboardClient.js +1 -1
- package/lib/orderParams.d.ts +4 -4
- package/lib/orderParams.js +12 -4
- package/lib/serum/serumFulfillmentConfigMap.d.ts +10 -0
- package/lib/serum/serumFulfillmentConfigMap.js +17 -0
- package/lib/serum/serumSubscriber.d.ts +27 -0
- package/lib/serum/serumSubscriber.js +56 -0
- package/lib/serum/types.d.ts +11 -0
- package/lib/{clearingHouseUserConfig.js → serum/types.js} +0 -0
- package/lib/slot/SlotSubscriber.d.ts +7 -0
- package/lib/slot/SlotSubscriber.js +3 -0
- package/lib/{mockUSDCFaucet.d.ts → tokenFaucet.d.ts} +8 -5
- package/lib/{mockUSDCFaucet.js → tokenFaucet.js} +63 -51
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/retryTxSender.js +13 -4
- package/lib/tx/types.d.ts +1 -1
- package/lib/tx/utils.js +1 -1
- package/lib/types.d.ts +589 -196
- package/lib/types.js +108 -17
- package/lib/user.d.ts +226 -0
- package/lib/user.js +949 -0
- package/lib/userConfig.d.ts +14 -0
- package/lib/userConfig.js +2 -0
- package/lib/userMap/userMap.d.ts +41 -0
- package/lib/userMap/userMap.js +85 -0
- package/lib/userMap/userStatsMap.d.ts +19 -0
- package/lib/userMap/userStatsMap.js +68 -0
- package/lib/userName.d.ts +1 -0
- package/lib/userName.js +3 -2
- package/lib/userStats.d.ts +18 -0
- package/lib/userStats.js +49 -0
- package/lib/userStatsConfig.d.ts +14 -0
- package/lib/userStatsConfig.js +2 -0
- package/lib/util/computeUnits.js +1 -1
- package/lib/util/getTokenAddress.d.ts +2 -0
- package/lib/util/getTokenAddress.js +9 -0
- package/package.json +10 -3
- package/src/accounts/bulkAccountLoader.ts +44 -34
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +2 -3
- package/src/accounts/fetch.ts +27 -2
- package/src/accounts/{pollingClearingHouseAccountSubscriber.ts → pollingDriftClientAccountSubscriber.ts} +65 -75
- package/src/accounts/{pollingOracleSubscriber.ts → pollingOracleAccountSubscriber.ts} +2 -2
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +172 -0
- package/src/accounts/types.ts +35 -15
- package/src/accounts/{webSocketClearingHouseAccountSubscriber.ts → webSocketDriftClientAccountSubscriber.ts} +78 -73
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +80 -0
- package/src/addresses/marketAddresses.ts +3 -4
- package/src/addresses/pda.ts +105 -33
- package/src/adminClient.ts +1207 -0
- package/src/config.ts +37 -31
- package/src/constants/numericConstants.ts +58 -24
- package/src/constants/{markets.ts → perpMarkets.ts} +10 -10
- package/src/constants/spotMarkets.ts +73 -0
- package/src/dlob/DLOB.ts +1123 -0
- package/src/dlob/DLOBNode.ts +155 -0
- package/src/dlob/NodeList.ts +195 -0
- package/src/driftClient.ts +3564 -0
- package/src/{clearingHouseConfig.ts → driftClientConfig.ts} +9 -8
- package/src/events/eventList.ts +3 -0
- package/src/events/eventSubscriber.ts +36 -14
- package/src/events/fetchLogs.ts +55 -13
- package/src/events/pollingLogProvider.ts +11 -3
- package/src/events/sort.ts +11 -15
- package/src/events/types.ts +21 -2
- package/src/events/webSocketLogProvider.ts +1 -1
- package/src/examples/makeTradeExample.ts +44 -28
- package/src/factory/bigNum.ts +150 -22
- package/src/idl/drift.json +8250 -0
- package/src/idl/pyth.json +98 -2
- package/src/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/src/index.ts +30 -13
- package/src/math/amm.ts +161 -48
- package/src/math/conversion.ts +2 -2
- package/src/math/exchangeStatus.ts +31 -0
- package/src/math/funding.ts +41 -31
- package/src/math/insurance.ts +35 -0
- package/src/math/margin.ts +133 -0
- package/src/math/market.ts +143 -14
- package/src/math/oracles.ts +63 -9
- package/src/math/orders.ts +163 -26
- package/src/math/position.ts +136 -58
- package/src/math/repeg.ts +19 -9
- package/src/math/spotBalance.ts +319 -0
- package/src/math/spotMarket.ts +9 -0
- package/src/math/spotPosition.ts +47 -0
- package/src/math/trade.ts +33 -37
- package/src/oracles/pythClient.ts +2 -2
- package/src/oracles/quoteAssetOracleClient.ts +2 -2
- package/src/oracles/switchboardClient.ts +2 -2
- package/src/orderParams.ts +16 -8
- package/src/serum/serumFulfillmentConfigMap.ts +26 -0
- package/src/serum/serumSubscriber.ts +99 -0
- package/src/serum/types.ts +13 -0
- package/src/slot/SlotSubscriber.ts +11 -1
- package/src/{mockUSDCFaucet.ts → tokenFaucet.ts} +82 -70
- package/src/tx/retryTxSender.ts +16 -5
- package/src/tx/types.ts +2 -1
- package/src/tx/utils.ts +1 -1
- package/src/types.ts +572 -178
- package/src/user.ts +1582 -0
- package/src/{clearingHouseUserConfig.ts → userConfig.ts} +5 -5
- package/src/userMap/userMap.ts +124 -0
- package/src/userMap/userStatsMap.ts +108 -0
- package/src/userName.ts +2 -1
- package/src/userStats.ts +75 -0
- package/src/userStatsConfig.ts +18 -0
- package/src/util/computeUnits.ts +1 -1
- package/src/util/getTokenAddress.ts +18 -0
- package/tests/bn/test.ts +46 -11
- package/tests/dlob/helpers.ts +611 -0
- package/tests/dlob/test.ts +4588 -0
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +0 -49
- package/lib/admin.d.ts +0 -44
- package/lib/admin.js +0 -433
- package/lib/clearingHouse.d.ts +0 -133
- package/lib/clearingHouse.js +0 -931
- package/lib/clearingHouseUser.d.ts +0 -187
- package/lib/clearingHouseUser.js +0 -643
- package/lib/clearingHouseUserConfig.d.ts +0 -14
- package/lib/constants/banks.d.ts +0 -16
- package/lib/constants/banks.js +0 -34
- package/lib/constants/markets.d.ts +0 -19
- package/lib/idl/clearing_house.json +0 -3998
- package/lib/math/bankBalance.d.ts +0 -9
- package/lib/math/bankBalance.js +0 -75
- package/lib/math/state.d.ts +0 -8
- package/lib/math/state.js +0 -15
- package/lib/orders.d.ts +0 -8
- package/lib/orders.js +0 -134
- package/src/admin.ts +0 -722
- package/src/clearingHouse.ts +0 -1451
- package/src/clearingHouseUser.ts +0 -989
- package/src/constants/banks.ts +0 -43
- package/src/idl/clearing_house.json +0 -3998
- package/src/math/bankBalance.ts +0 -112
- package/src/math/state.ts +0 -14
- package/src/math/utils.js +0 -27
- package/src/math/utils.js.map +0 -1
- package/src/orders.ts +0 -244
- package/src/util/computeUnits.js +0 -17
- package/src/util/computeUnits.js.map +0 -1
|
@@ -0,0 +1,637 @@
|
|
|
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("@project-serum/anchor");
|
|
31
|
+
const anchor = __importStar(require("@project-serum/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
|
+
class AdminClient extends driftClient_1.DriftClient {
|
|
40
|
+
async initialize(usdcMint, _adminControlsPrices) {
|
|
41
|
+
const stateAccountRPCResponse = await this.connection.getParsedAccountInfo(await this.getStatePublicKey());
|
|
42
|
+
if (stateAccountRPCResponse.value !== null) {
|
|
43
|
+
throw new Error('Clearing house already initialized');
|
|
44
|
+
}
|
|
45
|
+
const [driftStatePublicKey] = await (0, pda_1.getDriftStateAccountPublicKeyAndNonce)(this.program.programId);
|
|
46
|
+
const initializeTx = await this.program.transaction.initialize({
|
|
47
|
+
accounts: {
|
|
48
|
+
admin: this.wallet.publicKey,
|
|
49
|
+
state: driftStatePublicKey,
|
|
50
|
+
quoteAssetMint: usdcMint,
|
|
51
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
52
|
+
driftSigner: this.getSignerPublicKey(),
|
|
53
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
54
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const { txSig: initializeTxSig } = await this.txSender.send(initializeTx, [], this.opts);
|
|
58
|
+
return [initializeTxSig];
|
|
59
|
+
}
|
|
60
|
+
async initializeSpotMarket(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0, liquidatorFee = 0, activeStatus = true, name = userName_1.DEFAULT_MARKET_NAME) {
|
|
61
|
+
const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
|
|
62
|
+
const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
|
|
63
|
+
const spotMarketVault = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, spotMarketIndex);
|
|
64
|
+
const insuranceFundVault = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, spotMarketIndex);
|
|
65
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
66
|
+
const initializeTx = await this.program.transaction.initializeSpotMarket(optimalUtilization, optimalRate, maxRate, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, activeStatus, nameBuffer, {
|
|
67
|
+
accounts: {
|
|
68
|
+
admin: this.wallet.publicKey,
|
|
69
|
+
state: await this.getStatePublicKey(),
|
|
70
|
+
spotMarket,
|
|
71
|
+
spotMarketVault,
|
|
72
|
+
insuranceFundVault,
|
|
73
|
+
driftSigner: this.getSignerPublicKey(),
|
|
74
|
+
spotMarketMint: mint,
|
|
75
|
+
oracle,
|
|
76
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
77
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
78
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const { txSig } = await this.txSender.send(initializeTx, [], this.opts);
|
|
82
|
+
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
83
|
+
await this.accountSubscriber.addOracle({
|
|
84
|
+
source: oracleSource,
|
|
85
|
+
publicKey: oracle,
|
|
86
|
+
});
|
|
87
|
+
return txSig;
|
|
88
|
+
}
|
|
89
|
+
async initializeSerumFulfillmentConfig(marketIndex, serumMarket, serumProgram) {
|
|
90
|
+
const serumOpenOrders = (0, pda_1.getSerumOpenOrdersPublicKey)(this.program.programId, serumMarket);
|
|
91
|
+
const serumFulfillmentConfig = (0, pda_1.getSerumFulfillmentConfigPublicKey)(this.program.programId, serumMarket);
|
|
92
|
+
return await this.program.rpc.initializeSerumFulfillmentConfig(marketIndex, {
|
|
93
|
+
accounts: {
|
|
94
|
+
admin: this.wallet.publicKey,
|
|
95
|
+
state: await this.getStatePublicKey(),
|
|
96
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
97
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
98
|
+
driftSigner: this.getSignerPublicKey(),
|
|
99
|
+
serumProgram,
|
|
100
|
+
serumMarket,
|
|
101
|
+
serumOpenOrders,
|
|
102
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
103
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
104
|
+
serumFulfillmentConfig,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async initializePerpMarket(priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, activeStatus = true, name = userName_1.DEFAULT_MARKET_NAME) {
|
|
109
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, this.getStateAccount().numberOfMarkets);
|
|
110
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
111
|
+
const initializeMarketTx = await this.program.transaction.initializePerpMarket(baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidatorFee, activeStatus, nameBuffer, {
|
|
112
|
+
accounts: {
|
|
113
|
+
state: await this.getStatePublicKey(),
|
|
114
|
+
admin: this.wallet.publicKey,
|
|
115
|
+
oracle: priceOracle,
|
|
116
|
+
perpMarket: perpMarketPublicKey,
|
|
117
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
118
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
const { txSig } = await this.txSender.send(initializeMarketTx, [], this.opts);
|
|
122
|
+
await this.accountSubscriber.addPerpMarket(this.getStateAccount().numberOfMarkets);
|
|
123
|
+
await this.accountSubscriber.addOracle({
|
|
124
|
+
source: oracleSource,
|
|
125
|
+
publicKey: priceOracle,
|
|
126
|
+
});
|
|
127
|
+
return txSig;
|
|
128
|
+
}
|
|
129
|
+
async moveAmmPrice(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
|
|
130
|
+
const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
131
|
+
if (sqrtK == undefined) {
|
|
132
|
+
sqrtK = (0, utils_1.squareRootBN)(baseAssetReserve.mul(quoteAssetReserve));
|
|
133
|
+
}
|
|
134
|
+
return await this.program.rpc.moveAmmPrice(baseAssetReserve, quoteAssetReserve, sqrtK, {
|
|
135
|
+
accounts: {
|
|
136
|
+
state: await this.getStatePublicKey(),
|
|
137
|
+
admin: this.wallet.publicKey,
|
|
138
|
+
perpMarket: marketPublicKey,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async updateK(perpMarketIndex, sqrtK) {
|
|
143
|
+
return await this.program.rpc.updateK(sqrtK, {
|
|
144
|
+
accounts: {
|
|
145
|
+
state: await this.getStatePublicKey(),
|
|
146
|
+
admin: this.wallet.publicKey,
|
|
147
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
148
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async updatePerpMarketConcentrationScale(perpMarketIndex, concentrationScale) {
|
|
153
|
+
return await this.program.rpc.updatePerpMarketConcentrationCoef(concentrationScale, {
|
|
154
|
+
accounts: {
|
|
155
|
+
state: await this.getStatePublicKey(),
|
|
156
|
+
admin: this.wallet.publicKey,
|
|
157
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
async moveAmmToPrice(perpMarketIndex, targetPrice) {
|
|
162
|
+
const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
|
|
163
|
+
const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(perpMarket, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
|
|
164
|
+
);
|
|
165
|
+
const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(perpMarket.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
|
|
166
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
167
|
+
return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, perpMarket.amm.sqrtK, {
|
|
168
|
+
accounts: {
|
|
169
|
+
state: await this.getStatePublicKey(),
|
|
170
|
+
admin: this.wallet.publicKey,
|
|
171
|
+
perpMarket: perpMarketPublicKey,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async repegAmmCurve(newPeg, perpMarketIndex) {
|
|
176
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
177
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
178
|
+
return await this.program.rpc.repegAmmCurve(newPeg, {
|
|
179
|
+
accounts: {
|
|
180
|
+
state: await this.getStatePublicKey(),
|
|
181
|
+
admin: this.wallet.publicKey,
|
|
182
|
+
oracle: ammData.oracle,
|
|
183
|
+
perpMarket: perpMarketPublicKey,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
async updatePerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
188
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
189
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
190
|
+
return await this.program.rpc.updatePerpMarketAmmOracleTwap({
|
|
191
|
+
accounts: {
|
|
192
|
+
state: await this.getStatePublicKey(),
|
|
193
|
+
admin: this.wallet.publicKey,
|
|
194
|
+
oracle: ammData.oracle,
|
|
195
|
+
perpMarket: perpMarketPublicKey,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
async resetPerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
200
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
201
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
202
|
+
return await this.program.rpc.resetPerpMarketAmmOracleTwap({
|
|
203
|
+
accounts: {
|
|
204
|
+
state: await this.getStatePublicKey(),
|
|
205
|
+
admin: this.wallet.publicKey,
|
|
206
|
+
oracle: ammData.oracle,
|
|
207
|
+
perpMarket: perpMarketPublicKey,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
async depositIntoPerpMarketFeePool(perpMarketIndex, amount, sourceVault) {
|
|
212
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
213
|
+
return await this.program.rpc.depositIntoPerpMarketFeePool(amount, {
|
|
214
|
+
accounts: {
|
|
215
|
+
admin: this.wallet.publicKey,
|
|
216
|
+
state: await this.getStatePublicKey(),
|
|
217
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
218
|
+
sourceVault,
|
|
219
|
+
driftSigner: this.getSignerPublicKey(),
|
|
220
|
+
quoteSpotMarket: spotMarket.pubkey,
|
|
221
|
+
spotMarketVault: spotMarket.vault,
|
|
222
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
async updateAdmin(admin) {
|
|
227
|
+
return await this.program.rpc.updateAdmin(admin, {
|
|
228
|
+
accounts: {
|
|
229
|
+
admin: this.wallet.publicKey,
|
|
230
|
+
state: await this.getStatePublicKey(),
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
async updatePerpMarketCurveUpdateIntensity(perpMarketIndex, curveUpdateIntensity) {
|
|
235
|
+
// assert(curveUpdateIntensity >= 0 && curveUpdateIntensity <= 100);
|
|
236
|
+
// assert(Number.isInteger(curveUpdateIntensity));
|
|
237
|
+
return await this.program.rpc.updatePerpMarketCurveUpdateIntensity(curveUpdateIntensity, {
|
|
238
|
+
accounts: {
|
|
239
|
+
admin: this.wallet.publicKey,
|
|
240
|
+
state: await this.getStatePublicKey(),
|
|
241
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
async updatePerpMarketMarginRatio(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
246
|
+
return await this.program.rpc.updatePerpMarketMarginRatio(marginRatioInitial, marginRatioMaintenance, {
|
|
247
|
+
accounts: {
|
|
248
|
+
admin: this.wallet.publicKey,
|
|
249
|
+
state: await this.getStatePublicKey(),
|
|
250
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
async updatePerpMarketImfFactor(perpMarketIndex, imfFactor, unrealizedPnlImfFactor) {
|
|
255
|
+
return await this.program.rpc.updatePerpMarketImfFactor(imfFactor, unrealizedPnlImfFactor, {
|
|
256
|
+
accounts: {
|
|
257
|
+
admin: this.wallet.publicKey,
|
|
258
|
+
state: await this.getStatePublicKey(),
|
|
259
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
async updatePerpMarketBaseSpread(perpMarketIndex, baseSpread) {
|
|
264
|
+
return await this.program.rpc.updatePerpMarketBaseSpread(baseSpread, {
|
|
265
|
+
accounts: {
|
|
266
|
+
admin: this.wallet.publicKey,
|
|
267
|
+
state: await this.getStatePublicKey(),
|
|
268
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
async updateAmmJitIntensity(perpMarketIndex, ammJitIntensity) {
|
|
273
|
+
return await this.program.rpc.updateAmmJitIntensity(ammJitIntensity, {
|
|
274
|
+
accounts: {
|
|
275
|
+
admin: this.wallet.publicKey,
|
|
276
|
+
state: await this.getStatePublicKey(),
|
|
277
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
async updatePerpMarketName(perpMarketIndex, name) {
|
|
282
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
283
|
+
return await this.program.rpc.updatePerpMarketName(nameBuffer, {
|
|
284
|
+
accounts: {
|
|
285
|
+
admin: this.wallet.publicKey,
|
|
286
|
+
state: await this.getStatePublicKey(),
|
|
287
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
288
|
+
},
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
async updateSpotMarketName(spotMarketIndex, name) {
|
|
292
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
293
|
+
return await this.program.rpc.updateSpotMarketName(nameBuffer, {
|
|
294
|
+
accounts: {
|
|
295
|
+
admin: this.wallet.publicKey,
|
|
296
|
+
state: await this.getStatePublicKey(),
|
|
297
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
async updatePerpMarketMaxSpread(perpMarketIndex, maxSpread) {
|
|
302
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
303
|
+
return await this.program.rpc.updatePerpMarketMaxSpread(maxSpread, {
|
|
304
|
+
accounts: {
|
|
305
|
+
admin: this.wallet.publicKey,
|
|
306
|
+
state: await this.getStatePublicKey(),
|
|
307
|
+
perpMarket: perpMarketPublicKey,
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
async updatePerpFeeStructure(feeStructure) {
|
|
312
|
+
return await this.program.rpc.updatePerpFeeStructure(feeStructure, {
|
|
313
|
+
accounts: {
|
|
314
|
+
admin: this.wallet.publicKey,
|
|
315
|
+
state: await this.getStatePublicKey(),
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
async updateSpotFeeStructure(feeStructure) {
|
|
320
|
+
return await this.program.rpc.updateSpotFeeStructure(feeStructure, {
|
|
321
|
+
accounts: {
|
|
322
|
+
admin: this.wallet.publicKey,
|
|
323
|
+
state: await this.getStatePublicKey(),
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
async updateOracleGuardRails(oracleGuardRails) {
|
|
328
|
+
return await this.program.rpc.updateOracleGuardRails(oracleGuardRails, {
|
|
329
|
+
accounts: {
|
|
330
|
+
admin: this.wallet.publicKey,
|
|
331
|
+
state: await this.getStatePublicKey(),
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
async updateStateSettlementDuration(settlementDuration) {
|
|
336
|
+
return await this.program.rpc.updateStateSettlementDuration(settlementDuration, {
|
|
337
|
+
accounts: {
|
|
338
|
+
admin: this.wallet.publicKey,
|
|
339
|
+
state: await this.getStatePublicKey(),
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
async updateWithdrawGuardThreshold(spotMarketIndex, withdrawGuardThreshold) {
|
|
344
|
+
return await this.program.rpc.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
|
|
345
|
+
accounts: {
|
|
346
|
+
admin: this.wallet.publicKey,
|
|
347
|
+
state: await this.getStatePublicKey(),
|
|
348
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
async updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor) {
|
|
353
|
+
return await this.program.rpc.updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor, {
|
|
354
|
+
accounts: {
|
|
355
|
+
admin: this.wallet.publicKey,
|
|
356
|
+
state: await this.getStatePublicKey(),
|
|
357
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
async updateSpotMarketRevenueSettlePeriod(spotMarketIndex, revenueSettlePeriod) {
|
|
362
|
+
return await this.program.rpc.updateSpotMarketRevenueSettlePeriod(revenueSettlePeriod, {
|
|
363
|
+
accounts: {
|
|
364
|
+
admin: this.wallet.publicKey,
|
|
365
|
+
state: await this.getStatePublicKey(),
|
|
366
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
async updateSpotMarketMaxTokenDeposits(spotMarketIndex, maxTokenDeposits) {
|
|
371
|
+
return await this.program.rpc.updateSpotMarketMaxTokenDeposits(maxTokenDeposits, {
|
|
372
|
+
accounts: {
|
|
373
|
+
admin: this.wallet.publicKey,
|
|
374
|
+
state: await this.getStatePublicKey(),
|
|
375
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
376
|
+
},
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
async updateInsuranceFundUnstakingPeriod(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
|
|
380
|
+
return await this.program.rpc.updateInsuranceFundUnstakingPeriod(insuranceWithdrawEscrowPeriod, {
|
|
381
|
+
accounts: {
|
|
382
|
+
admin: this.wallet.publicKey,
|
|
383
|
+
state: await this.getStatePublicKey(),
|
|
384
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
async updateLpCooldownTime(cooldownTime) {
|
|
389
|
+
return await this.program.rpc.updateLpCooldownTime(cooldownTime, {
|
|
390
|
+
accounts: {
|
|
391
|
+
admin: this.wallet.publicKey,
|
|
392
|
+
state: await this.getStatePublicKey(),
|
|
393
|
+
},
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
async updatePerpMarketOracle(perpMarketIndex, oracle, oracleSource) {
|
|
397
|
+
return await this.program.rpc.updatePerpMarketOracle(oracle, oracleSource, {
|
|
398
|
+
accounts: {
|
|
399
|
+
admin: this.wallet.publicKey,
|
|
400
|
+
state: await this.getStatePublicKey(),
|
|
401
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
402
|
+
oracle: oracle,
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
async updatePerpMarketStepSizeAndTickSize(perpMarketIndex, stepSize, tickSize) {
|
|
407
|
+
return await this.program.rpc.updatePerpMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
408
|
+
accounts: {
|
|
409
|
+
admin: this.wallet.publicKey,
|
|
410
|
+
state: await this.getStatePublicKey(),
|
|
411
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
412
|
+
},
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
async updatePerpMarketMinOrderSize(perpMarketIndex, orderSize) {
|
|
416
|
+
return await this.program.rpc.updatePerpMarketMinOrderSize(orderSize, {
|
|
417
|
+
accounts: {
|
|
418
|
+
admin: this.wallet.publicKey,
|
|
419
|
+
state: await this.getStatePublicKey(),
|
|
420
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
async updateSpotMarketStepSizeAndTickSize(spotMarketIndex, stepSize, tickSize) {
|
|
425
|
+
return await this.program.rpc.updateSpotMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
426
|
+
accounts: {
|
|
427
|
+
admin: this.wallet.publicKey,
|
|
428
|
+
state: await this.getStatePublicKey(),
|
|
429
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
async updateSpotMarketMinOrderSize(spotMarketIndex, orderSize) {
|
|
434
|
+
return await this.program.rpc.updateSpotMarketMinOrderSize(orderSize, {
|
|
435
|
+
accounts: {
|
|
436
|
+
admin: this.wallet.publicKey,
|
|
437
|
+
state: await this.getStatePublicKey(),
|
|
438
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
439
|
+
},
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
async updatePerpMarketExpiry(perpMarketIndex, expiryTs) {
|
|
443
|
+
return await this.program.rpc.updatePerpMarketExpiry(expiryTs, {
|
|
444
|
+
accounts: {
|
|
445
|
+
admin: this.wallet.publicKey,
|
|
446
|
+
state: await this.getStatePublicKey(),
|
|
447
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
448
|
+
},
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
async updateSpotMarketOracle(spotMarketIndex, oracle, oracleSource) {
|
|
452
|
+
return await this.program.rpc.updatePerpMarketOracle(oracle, oracleSource, {
|
|
453
|
+
accounts: {
|
|
454
|
+
admin: this.wallet.publicKey,
|
|
455
|
+
state: await this.getStatePublicKey(),
|
|
456
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
457
|
+
oracle: oracle,
|
|
458
|
+
},
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
async updateSpotMarketExpiry(spotMarketIndex, expiryTs) {
|
|
462
|
+
return await this.program.rpc.updateSpotMarketExpiry(expiryTs, {
|
|
463
|
+
accounts: {
|
|
464
|
+
admin: this.wallet.publicKey,
|
|
465
|
+
state: await this.getStatePublicKey(),
|
|
466
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
async updateWhitelistMint(whitelistMint) {
|
|
471
|
+
return await this.program.rpc.updateWhitelistMint(whitelistMint, {
|
|
472
|
+
accounts: {
|
|
473
|
+
admin: this.wallet.publicKey,
|
|
474
|
+
state: await this.getStatePublicKey(),
|
|
475
|
+
},
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
async updateDiscountMint(discountMint) {
|
|
479
|
+
return await this.program.rpc.updateDiscountMint(discountMint, {
|
|
480
|
+
accounts: {
|
|
481
|
+
admin: this.wallet.publicKey,
|
|
482
|
+
state: await this.getStatePublicKey(),
|
|
483
|
+
},
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
async updateSpotMarketMarginWeights(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0) {
|
|
487
|
+
return await this.program.rpc.updateSpotMarketMarginWeights(initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, {
|
|
488
|
+
accounts: {
|
|
489
|
+
admin: this.wallet.publicKey,
|
|
490
|
+
state: await this.getStatePublicKey(),
|
|
491
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
492
|
+
},
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
async updateSpotMarketBorrowRate(spotMarketIndex, optimalUtilization, optimalBorrowRate, optimalMaxRate) {
|
|
496
|
+
return await this.program.rpc.updateSpotMarketBorrowRate(optimalUtilization, optimalBorrowRate, optimalMaxRate, {
|
|
497
|
+
accounts: {
|
|
498
|
+
admin: this.wallet.publicKey,
|
|
499
|
+
state: await this.getStatePublicKey(),
|
|
500
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
501
|
+
},
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
async updateSpotMarketAssetTier(spotMarketIndex, assetTier) {
|
|
505
|
+
return await this.program.rpc.updateSpotMarketAssetTier(assetTier, {
|
|
506
|
+
accounts: {
|
|
507
|
+
admin: this.wallet.publicKey,
|
|
508
|
+
state: await this.getStatePublicKey(),
|
|
509
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
510
|
+
},
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
async updateSpotMarketStatus(spotMarketIndex, marketStatus) {
|
|
514
|
+
return await this.program.rpc.updateSpotMarketStatus(marketStatus, {
|
|
515
|
+
accounts: {
|
|
516
|
+
admin: this.wallet.publicKey,
|
|
517
|
+
state: await this.getStatePublicKey(),
|
|
518
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
async updatePerpMarketStatus(perpMarketIndex, marketStatus) {
|
|
523
|
+
return await this.program.rpc.updatePerpMarketStatus(marketStatus, {
|
|
524
|
+
accounts: {
|
|
525
|
+
admin: this.wallet.publicKey,
|
|
526
|
+
state: await this.getStatePublicKey(),
|
|
527
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
528
|
+
},
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
async updatePerpMarketContractTier(perpMarketIndex, contractTier) {
|
|
532
|
+
return await this.program.rpc.updatePerpMarketContractTier(contractTier, {
|
|
533
|
+
accounts: {
|
|
534
|
+
admin: this.wallet.publicKey,
|
|
535
|
+
state: await this.getStatePublicKey(),
|
|
536
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
async updateExchangeStatus(exchangeStatus) {
|
|
541
|
+
return await this.program.rpc.updateExchangeStatus(exchangeStatus, {
|
|
542
|
+
accounts: {
|
|
543
|
+
admin: this.wallet.publicKey,
|
|
544
|
+
state: await this.getStatePublicKey(),
|
|
545
|
+
},
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
async updatePerpAuctionDuration(minDuration) {
|
|
549
|
+
return await this.program.rpc.updatePerpAuctionDuration(typeof minDuration === 'number' ? minDuration : minDuration.toNumber(), {
|
|
550
|
+
accounts: {
|
|
551
|
+
admin: this.wallet.publicKey,
|
|
552
|
+
state: await this.getStatePublicKey(),
|
|
553
|
+
},
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
async updateSpotAuctionDuration(defaultAuctionDuration) {
|
|
557
|
+
return await this.program.rpc.updateSpotAuctionDuration(defaultAuctionDuration, {
|
|
558
|
+
accounts: {
|
|
559
|
+
admin: this.wallet.publicKey,
|
|
560
|
+
state: await this.getStatePublicKey(),
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
async updatePerpMarketMaxFillReserveFraction(perpMarketIndex, maxBaseAssetAmountRatio) {
|
|
565
|
+
return await this.program.rpc.updatePerpMarketMaxFillReserveFraction(maxBaseAssetAmountRatio, {
|
|
566
|
+
accounts: {
|
|
567
|
+
admin: this.wallet.publicKey,
|
|
568
|
+
state: await this.getStatePublicKey(),
|
|
569
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
570
|
+
},
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
async updateMaxSlippageRatio(perpMarketIndex, maxSlippageRatio) {
|
|
574
|
+
return await this.program.rpc.updateMaxSlippageRatio(maxSlippageRatio, {
|
|
575
|
+
accounts: {
|
|
576
|
+
admin: this.wallet.publicKey,
|
|
577
|
+
state: await this.getStatePublicKey(),
|
|
578
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
579
|
+
},
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
async updatePerpMarketUnrealizedAssetWeight(perpMarketIndex, unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight) {
|
|
583
|
+
return await this.program.rpc.updatePerpMarketUnrealizedAssetWeight(unrealizedInitialAssetWeight, unrealizedMaintenanceAssetWeight, {
|
|
584
|
+
accounts: {
|
|
585
|
+
admin: this.wallet.publicKey,
|
|
586
|
+
state: await this.getStatePublicKey(),
|
|
587
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
588
|
+
},
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
async updatePerpMarketMaxImbalances(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
|
|
592
|
+
return await this.program.rpc.updatePerpMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
|
|
593
|
+
accounts: {
|
|
594
|
+
admin: this.wallet.publicKey,
|
|
595
|
+
state: await this.getStatePublicKey(),
|
|
596
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
597
|
+
},
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
async updatePerpMarketMaxOpenInterest(perpMarketIndex, maxOpenInterest) {
|
|
601
|
+
return await this.program.rpc.updatePerpMarketMaxOpenInterest(maxOpenInterest, {
|
|
602
|
+
accounts: {
|
|
603
|
+
admin: this.wallet.publicKey,
|
|
604
|
+
state: await this.getStatePublicKey(),
|
|
605
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
606
|
+
},
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
async updateSerumVault(srmVault) {
|
|
610
|
+
return await this.program.rpc.updateSerumVault({
|
|
611
|
+
accounts: {
|
|
612
|
+
admin: this.wallet.publicKey,
|
|
613
|
+
state: await this.getStatePublicKey(),
|
|
614
|
+
srmVault: srmVault,
|
|
615
|
+
},
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
async updatePerpMarketLiquidationFee(perpMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
619
|
+
return await this.program.rpc.updatePerpMarketLiquidationFee(liquidatorFee, ifLiquidationFee, {
|
|
620
|
+
accounts: {
|
|
621
|
+
admin: this.wallet.publicKey,
|
|
622
|
+
state: await this.getStatePublicKey(),
|
|
623
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
624
|
+
},
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
async updateSpotMarketLiquidationFee(spotMarketIndex, liquidatorFee, ifLiquidationFee) {
|
|
628
|
+
return await this.program.rpc.updateSpotMarketLiquidationFee(liquidatorFee, ifLiquidationFee, {
|
|
629
|
+
accounts: {
|
|
630
|
+
admin: this.wallet.publicKey,
|
|
631
|
+
state: await this.getStatePublicKey(),
|
|
632
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
exports.AdminClient = AdminClient;
|
package/lib/config.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { BankConfig } from './constants/banks';
|
|
4
|
-
import { BN } from '@project-serum/anchor';
|
|
1
|
+
import { PerpMarketConfig } from './constants/perpMarkets';
|
|
2
|
+
import { SpotMarketConfig } from './constants/spotMarkets';
|
|
5
3
|
import { OracleInfo } from './oracles/types';
|
|
6
4
|
declare type DriftConfig = {
|
|
7
5
|
ENV: DriftEnv;
|
|
8
6
|
PYTH_ORACLE_MAPPING_ADDRESS: string;
|
|
9
7
|
CLEARING_HOUSE_PROGRAM_ID: string;
|
|
10
8
|
USDC_MINT_ADDRESS: string;
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
SERUM_V3: string;
|
|
10
|
+
V2_ALPHA_TICKET_MINT_ADDRESS: string;
|
|
11
|
+
PERP_MARKETS: PerpMarketConfig[];
|
|
12
|
+
SPOT_MARKETS: SpotMarketConfig[];
|
|
13
13
|
};
|
|
14
14
|
export declare type DriftEnv = 'devnet' | 'mainnet-beta';
|
|
15
15
|
export declare const configs: {
|
|
@@ -27,9 +27,9 @@ export declare const initialize: (props: {
|
|
|
27
27
|
env: DriftEnv;
|
|
28
28
|
overrideEnv?: Partial<DriftConfig>;
|
|
29
29
|
}) => DriftConfig;
|
|
30
|
-
export declare function
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
export declare function getMarketsAndOraclesForSubscription(env: DriftEnv): {
|
|
31
|
+
perpMarketIndexes: number[];
|
|
32
|
+
spotMarketIndexes: number[];
|
|
33
33
|
oracleInfos: OracleInfo[];
|
|
34
34
|
};
|
|
35
35
|
export {};
|