@drift-labs/sdk 2.74.0-beta.10 → 2.74.0-beta.12
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/VERSION +1 -1
- package/lib/adminClient.d.ts +10 -2
- package/lib/adminClient.js +59 -38
- package/lib/idl/drift.json +4 -7
- package/package.json +1 -1
- package/src/adminClient.ts +300 -133
- package/src/idl/drift.json +4 -7
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.74.0-beta.
|
|
1
|
+
2.74.0-beta.12
|
package/lib/adminClient.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
|
-
import { PublicKey, TransactionSignature } from '@solana/web3.js';
|
|
2
|
+
import { PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
|
|
3
3
|
import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus } from './types';
|
|
4
4
|
import { BN } from '@coral-xyz/anchor';
|
|
5
5
|
import { DriftClient } from './driftClient';
|
|
@@ -8,9 +8,15 @@ export declare class AdminClient extends DriftClient {
|
|
|
8
8
|
initializeSpotMarket(mint: PublicKey, optimalUtilization: number, optimalRate: number, maxRate: number, oracle: PublicKey, oracleSource: OracleSource, initialAssetWeight: number, maintenanceAssetWeight: number, initialLiabilityWeight: number, maintenanceLiabilityWeight: number, imfFactor?: number, liquidatorFee?: number, ifLiquidationFee?: number, activeStatus?: boolean, assetTier?: {
|
|
9
9
|
collateral: {};
|
|
10
10
|
}, scaleInitialAssetWeightStart?: BN, withdrawGuardThreshold?: BN, orderTickSize?: BN, orderStepSize?: BN, ifTotalFactor?: number, name?: string): Promise<TransactionSignature>;
|
|
11
|
+
getInitializeSpotMarketIx(admin: PublicKey, mint: PublicKey, optimalUtilization: number, optimalRate: number, maxRate: number, oracle: PublicKey, oracleSource: OracleSource, initialAssetWeight: number, maintenanceAssetWeight: number, initialLiabilityWeight: number, maintenanceLiabilityWeight: number, imfFactor?: number, liquidatorFee?: number, ifLiquidationFee?: number, activeStatus?: boolean, assetTier?: {
|
|
12
|
+
collateral: {};
|
|
13
|
+
}, scaleInitialAssetWeightStart?: BN, withdrawGuardThreshold?: BN, orderTickSize?: BN, orderStepSize?: BN, ifTotalFactor?: number, name?: string): Promise<TransactionInstruction>;
|
|
11
14
|
initializeSerumFulfillmentConfig(marketIndex: number, serumMarket: PublicKey, serumProgram: PublicKey): Promise<TransactionSignature>;
|
|
15
|
+
getInitializeSerumFulfillmentConfigIx(admin: PublicKey, marketIndex: number, serumMarket: PublicKey, serumProgram: PublicKey): Promise<TransactionInstruction>;
|
|
12
16
|
initializePhoenixFulfillmentConfig(marketIndex: number, phoenixMarket: PublicKey): Promise<TransactionSignature>;
|
|
17
|
+
getInitializePhoenixFulfillmentConfigIx(admin: PublicKey, marketIndex: number, phoenixMarket: PublicKey): Promise<TransactionInstruction>;
|
|
13
18
|
initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string): Promise<TransactionSignature>;
|
|
19
|
+
getInitializePerpMarketIx(admin: PublicKey, marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string): Promise<TransactionInstruction>;
|
|
14
20
|
deleteInitializedPerpMarket(marketIndex: number): Promise<TransactionSignature>;
|
|
15
21
|
moveAmmPrice(perpMarketIndex: number, baseAssetReserve: BN, quoteAssetReserve: BN, sqrtK?: BN): Promise<TransactionSignature>;
|
|
16
22
|
updateK(perpMarketIndex: number, sqrtK: BN): Promise<TransactionSignature>;
|
|
@@ -84,6 +90,8 @@ export declare class AdminClient extends DriftClient {
|
|
|
84
90
|
initializeProtocolIfSharesTransferConfig(): Promise<TransactionSignature>;
|
|
85
91
|
updateProtocolIfSharesTransferConfig(whitelistedSigners?: PublicKey[], maxTransferPerEpoch?: BN): Promise<TransactionSignature>;
|
|
86
92
|
initializePrelaunchOracle(perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionSignature>;
|
|
87
|
-
|
|
93
|
+
getInitializePrelaunchOracleIx(admin: PublicKey, perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionInstruction>;
|
|
94
|
+
updatePrelaunchOracleParams(admin: PublicKey, perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionSignature>;
|
|
95
|
+
getUpdatePrelaunchOracleParamsIx(admin: PublicKey, perpMarketIndex: number, price?: BN, maxPrice?: BN): Promise<TransactionInstruction>;
|
|
88
96
|
deletePrelaunchOracle(perpMarketIndex: number): Promise<TransactionSignature>;
|
|
89
97
|
}
|
package/lib/adminClient.js
CHANGED
|
@@ -60,6 +60,20 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
60
60
|
return [txSig];
|
|
61
61
|
}
|
|
62
62
|
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) {
|
|
63
|
+
const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
|
|
64
|
+
const initializeIx = await this.getInitializeSpotMarketIx(this.wallet.publicKey, mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, ifLiquidationFee, activeStatus, assetTier, scaleInitialAssetWeightStart, withdrawGuardThreshold, orderTickSize, orderStepSize, ifTotalFactor, name);
|
|
65
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
66
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
67
|
+
// const { txSig } = await this.sendTransaction(initializeTx, [], this.opts);
|
|
68
|
+
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
69
|
+
await this.accountSubscriber.addOracle({
|
|
70
|
+
source: oracleSource,
|
|
71
|
+
publicKey: oracle,
|
|
72
|
+
});
|
|
73
|
+
await this.accountSubscriber.setSpotOracleMap();
|
|
74
|
+
return txSig;
|
|
75
|
+
}
|
|
76
|
+
async getInitializeSpotMarketIx(admin, 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) {
|
|
63
77
|
const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
|
|
64
78
|
const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
|
|
65
79
|
const spotMarketVault = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, spotMarketIndex);
|
|
@@ -67,7 +81,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
67
81
|
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
68
82
|
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, {
|
|
69
83
|
accounts: {
|
|
70
|
-
admin
|
|
84
|
+
admin,
|
|
71
85
|
state: await this.getStatePublicKey(),
|
|
72
86
|
spotMarket,
|
|
73
87
|
spotMarketVault,
|
|
@@ -80,23 +94,20 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
80
94
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
81
95
|
},
|
|
82
96
|
});
|
|
97
|
+
return initializeIx;
|
|
98
|
+
}
|
|
99
|
+
async initializeSerumFulfillmentConfig(marketIndex, serumMarket, serumProgram) {
|
|
100
|
+
const initializeIx = await this.getInitializeSerumFulfillmentConfigIx(this.wallet.publicKey, marketIndex, serumMarket, serumProgram);
|
|
83
101
|
const tx = await this.buildTransaction(initializeIx);
|
|
84
102
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
85
|
-
// const { txSig } = await this.sendTransaction(initializeTx, [], this.opts);
|
|
86
|
-
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
87
|
-
await this.accountSubscriber.addOracle({
|
|
88
|
-
source: oracleSource,
|
|
89
|
-
publicKey: oracle,
|
|
90
|
-
});
|
|
91
|
-
await this.accountSubscriber.setSpotOracleMap();
|
|
92
103
|
return txSig;
|
|
93
104
|
}
|
|
94
|
-
async
|
|
105
|
+
async getInitializeSerumFulfillmentConfigIx(admin, marketIndex, serumMarket, serumProgram) {
|
|
95
106
|
const serumOpenOrders = (0, pda_1.getSerumOpenOrdersPublicKey)(this.program.programId, serumMarket);
|
|
96
107
|
const serumFulfillmentConfig = (0, pda_1.getSerumFulfillmentConfigPublicKey)(this.program.programId, serumMarket);
|
|
97
|
-
|
|
108
|
+
return await this.program.instruction.initializeSerumFulfillmentConfig(marketIndex, {
|
|
98
109
|
accounts: {
|
|
99
|
-
admin
|
|
110
|
+
admin,
|
|
100
111
|
state: await this.getStatePublicKey(),
|
|
101
112
|
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
102
113
|
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
@@ -109,15 +120,18 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
109
120
|
serumFulfillmentConfig,
|
|
110
121
|
},
|
|
111
122
|
});
|
|
123
|
+
}
|
|
124
|
+
async initializePhoenixFulfillmentConfig(marketIndex, phoenixMarket) {
|
|
125
|
+
const initializeIx = await this.getInitializePhoenixFulfillmentConfigIx(this.wallet.publicKey, marketIndex, phoenixMarket);
|
|
112
126
|
const tx = await this.buildTransaction(initializeIx);
|
|
113
127
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
114
128
|
return txSig;
|
|
115
129
|
}
|
|
116
|
-
async
|
|
130
|
+
async getInitializePhoenixFulfillmentConfigIx(admin, marketIndex, phoenixMarket) {
|
|
117
131
|
const phoenixFulfillmentConfig = (0, pda_1.getPhoenixFulfillmentConfigPublicKey)(this.program.programId, phoenixMarket);
|
|
118
|
-
|
|
132
|
+
return await this.program.instruction.initializePhoenixFulfillmentConfig(marketIndex, {
|
|
119
133
|
accounts: {
|
|
120
|
-
admin
|
|
134
|
+
admin,
|
|
121
135
|
state: await this.getStatePublicKey(),
|
|
122
136
|
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
123
137
|
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
@@ -129,24 +143,10 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
129
143
|
phoenixFulfillmentConfig,
|
|
130
144
|
},
|
|
131
145
|
});
|
|
132
|
-
const tx = await this.buildTransaction(initializeIx);
|
|
133
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
134
|
-
return txSig;
|
|
135
146
|
}
|
|
136
147
|
async initializePerpMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, 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) {
|
|
137
148
|
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
138
|
-
const
|
|
139
|
-
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
140
|
-
const initializeMarketIx = await this.program.instruction.initializePerpMarket(marketIndex, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, nameBuffer, {
|
|
141
|
-
accounts: {
|
|
142
|
-
state: await this.getStatePublicKey(),
|
|
143
|
-
admin: this.wallet.publicKey,
|
|
144
|
-
oracle: priceOracle,
|
|
145
|
-
perpMarket: perpMarketPublicKey,
|
|
146
|
-
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
147
|
-
systemProgram: anchor.web3.SystemProgram.programId,
|
|
148
|
-
},
|
|
149
|
-
});
|
|
149
|
+
const initializeMarketIx = await this.getInitializePerpMarketIx(this.wallet.publicKey, marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name);
|
|
150
150
|
const tx = await this.buildTransaction(initializeMarketIx);
|
|
151
151
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
152
152
|
while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
|
|
@@ -160,6 +160,21 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
160
160
|
await this.accountSubscriber.setPerpOracleMap();
|
|
161
161
|
return txSig;
|
|
162
162
|
}
|
|
163
|
+
async getInitializePerpMarketIx(admin, marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, 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) {
|
|
164
|
+
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
165
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, currentPerpMarketIndex);
|
|
166
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
167
|
+
return await this.program.instruction.initializePerpMarket(marketIndex, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, nameBuffer, {
|
|
168
|
+
accounts: {
|
|
169
|
+
state: await this.getStatePublicKey(),
|
|
170
|
+
admin,
|
|
171
|
+
oracle: priceOracle,
|
|
172
|
+
perpMarket: perpMarketPublicKey,
|
|
173
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
174
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
163
178
|
async deleteInitializedPerpMarket(marketIndex) {
|
|
164
179
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
165
180
|
const deleteInitializeMarketIx = await this.program.instruction.deleteInitializedPerpMarket(marketIndex, {
|
|
@@ -1046,42 +1061,48 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
1046
1061
|
return txSig;
|
|
1047
1062
|
}
|
|
1048
1063
|
async initializePrelaunchOracle(perpMarketIndex, price, maxPrice) {
|
|
1064
|
+
const initializePrelaunchOracleIx = await this.getInitializePrelaunchOracleIx(this.wallet.publicKey, perpMarketIndex, price, maxPrice);
|
|
1065
|
+
const tx = await this.buildTransaction(initializePrelaunchOracleIx);
|
|
1066
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1067
|
+
return txSig;
|
|
1068
|
+
}
|
|
1069
|
+
async getInitializePrelaunchOracleIx(admin, perpMarketIndex, price, maxPrice) {
|
|
1049
1070
|
const params = {
|
|
1050
1071
|
perpMarketIndex,
|
|
1051
1072
|
price: price || null,
|
|
1052
1073
|
maxPrice: maxPrice || null,
|
|
1053
1074
|
};
|
|
1054
|
-
|
|
1075
|
+
return await this.program.instruction.initializePrelaunchOracle(params, {
|
|
1055
1076
|
accounts: {
|
|
1056
|
-
admin
|
|
1077
|
+
admin,
|
|
1057
1078
|
state: await this.getStatePublicKey(),
|
|
1058
1079
|
prelaunchOracle: await (0, pda_1.getPrelaunchOraclePublicKey)(this.program.programId, perpMarketIndex),
|
|
1059
1080
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1060
1081
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
1061
1082
|
},
|
|
1062
1083
|
});
|
|
1063
|
-
|
|
1084
|
+
}
|
|
1085
|
+
async updatePrelaunchOracleParams(admin, perpMarketIndex, price, maxPrice) {
|
|
1086
|
+
const updatePrelaunchOracleParamsIx = await this.getUpdatePrelaunchOracleParamsIx(this.wallet.publicKey, perpMarketIndex, price, maxPrice);
|
|
1087
|
+
const tx = await this.buildTransaction(updatePrelaunchOracleParamsIx);
|
|
1064
1088
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1065
1089
|
return txSig;
|
|
1066
1090
|
}
|
|
1067
|
-
async
|
|
1091
|
+
async getUpdatePrelaunchOracleParamsIx(admin, perpMarketIndex, price, maxPrice) {
|
|
1068
1092
|
const params = {
|
|
1069
1093
|
perpMarketIndex,
|
|
1070
1094
|
price: price || null,
|
|
1071
1095
|
maxPrice: maxPrice || null,
|
|
1072
1096
|
};
|
|
1073
1097
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
1074
|
-
|
|
1098
|
+
return await this.program.instruction.updatePrelaunchOracleParams(params, {
|
|
1075
1099
|
accounts: {
|
|
1076
|
-
admin
|
|
1100
|
+
admin,
|
|
1077
1101
|
state: await this.getStatePublicKey(),
|
|
1078
1102
|
perpMarket: perpMarketPublicKey,
|
|
1079
1103
|
prelaunchOracle: await (0, pda_1.getPrelaunchOraclePublicKey)(this.program.programId, perpMarketIndex),
|
|
1080
1104
|
},
|
|
1081
1105
|
});
|
|
1082
|
-
const tx = await this.buildTransaction(updatePrelaunchOracleParamsIx);
|
|
1083
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1084
|
-
return txSig;
|
|
1085
1106
|
}
|
|
1086
1107
|
async deletePrelaunchOracle(perpMarketIndex) {
|
|
1087
1108
|
const deletePrelaunchOracleIx = await this.program.instruction.deletePrelaunchOracle(perpMarketIndex, {
|
package/lib/idl/drift.json
CHANGED
|
@@ -3023,11 +3023,11 @@
|
|
|
3023
3023
|
},
|
|
3024
3024
|
{
|
|
3025
3025
|
"name": "curveUpdateIntensity",
|
|
3026
|
-
"type": "
|
|
3026
|
+
"type": "u8"
|
|
3027
3027
|
},
|
|
3028
3028
|
{
|
|
3029
|
-
"name": "
|
|
3030
|
-
"type": "
|
|
3029
|
+
"name": "ammJitIntensity",
|
|
3030
|
+
"type": "u8"
|
|
3031
3031
|
},
|
|
3032
3032
|
{
|
|
3033
3033
|
"name": "name",
|
|
@@ -11711,8 +11711,5 @@
|
|
|
11711
11711
|
"name": "CantReclaimRent",
|
|
11712
11712
|
"msg": "CantReclaimRent"
|
|
11713
11713
|
}
|
|
11714
|
-
]
|
|
11715
|
-
"metadata": {
|
|
11716
|
-
"address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
11717
|
-
}
|
|
11714
|
+
]
|
|
11718
11715
|
}
|
package/package.json
CHANGED
package/src/adminClient.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PublicKey,
|
|
3
3
|
SYSVAR_RENT_PUBKEY,
|
|
4
|
+
TransactionInstruction,
|
|
4
5
|
TransactionSignature,
|
|
5
6
|
} from '@solana/web3.js';
|
|
6
7
|
import {
|
|
@@ -101,6 +102,73 @@ export class AdminClient extends DriftClient {
|
|
|
101
102
|
name = DEFAULT_MARKET_NAME
|
|
102
103
|
): Promise<TransactionSignature> {
|
|
103
104
|
const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
|
|
105
|
+
|
|
106
|
+
const initializeIx = await this.getInitializeSpotMarketIx(
|
|
107
|
+
this.wallet.publicKey,
|
|
108
|
+
mint,
|
|
109
|
+
optimalUtilization,
|
|
110
|
+
optimalRate,
|
|
111
|
+
maxRate,
|
|
112
|
+
oracle,
|
|
113
|
+
oracleSource,
|
|
114
|
+
initialAssetWeight,
|
|
115
|
+
maintenanceAssetWeight,
|
|
116
|
+
initialLiabilityWeight,
|
|
117
|
+
maintenanceLiabilityWeight,
|
|
118
|
+
imfFactor,
|
|
119
|
+
liquidatorFee,
|
|
120
|
+
ifLiquidationFee,
|
|
121
|
+
activeStatus,
|
|
122
|
+
assetTier,
|
|
123
|
+
scaleInitialAssetWeightStart,
|
|
124
|
+
withdrawGuardThreshold,
|
|
125
|
+
orderTickSize,
|
|
126
|
+
orderStepSize,
|
|
127
|
+
ifTotalFactor,
|
|
128
|
+
name
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
132
|
+
|
|
133
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
134
|
+
|
|
135
|
+
// const { txSig } = await this.sendTransaction(initializeTx, [], this.opts);
|
|
136
|
+
|
|
137
|
+
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
138
|
+
await this.accountSubscriber.addOracle({
|
|
139
|
+
source: oracleSource,
|
|
140
|
+
publicKey: oracle,
|
|
141
|
+
});
|
|
142
|
+
await this.accountSubscriber.setSpotOracleMap();
|
|
143
|
+
|
|
144
|
+
return txSig;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public async getInitializeSpotMarketIx(
|
|
148
|
+
admin: PublicKey,
|
|
149
|
+
mint: PublicKey,
|
|
150
|
+
optimalUtilization: number,
|
|
151
|
+
optimalRate: number,
|
|
152
|
+
maxRate: number,
|
|
153
|
+
oracle: PublicKey,
|
|
154
|
+
oracleSource: OracleSource,
|
|
155
|
+
initialAssetWeight: number,
|
|
156
|
+
maintenanceAssetWeight: number,
|
|
157
|
+
initialLiabilityWeight: number,
|
|
158
|
+
maintenanceLiabilityWeight: number,
|
|
159
|
+
imfFactor = 0,
|
|
160
|
+
liquidatorFee = 0,
|
|
161
|
+
ifLiquidationFee = 0,
|
|
162
|
+
activeStatus = true,
|
|
163
|
+
assetTier = AssetTier.COLLATERAL,
|
|
164
|
+
scaleInitialAssetWeightStart = ZERO,
|
|
165
|
+
withdrawGuardThreshold = ZERO,
|
|
166
|
+
orderTickSize = ONE,
|
|
167
|
+
orderStepSize = ONE,
|
|
168
|
+
ifTotalFactor = 0,
|
|
169
|
+
name = DEFAULT_MARKET_NAME
|
|
170
|
+
): Promise<TransactionInstruction> {
|
|
171
|
+
const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
|
|
104
172
|
const spotMarket = await getSpotMarketPublicKey(
|
|
105
173
|
this.program.programId,
|
|
106
174
|
spotMarketIndex
|
|
@@ -139,7 +207,7 @@ export class AdminClient extends DriftClient {
|
|
|
139
207
|
nameBuffer,
|
|
140
208
|
{
|
|
141
209
|
accounts: {
|
|
142
|
-
admin
|
|
210
|
+
admin,
|
|
143
211
|
state: await this.getStatePublicKey(),
|
|
144
212
|
spotMarket,
|
|
145
213
|
spotMarketVault,
|
|
@@ -154,27 +222,34 @@ export class AdminClient extends DriftClient {
|
|
|
154
222
|
}
|
|
155
223
|
);
|
|
156
224
|
|
|
157
|
-
|
|
225
|
+
return initializeIx;
|
|
226
|
+
}
|
|
158
227
|
|
|
159
|
-
|
|
228
|
+
public async initializeSerumFulfillmentConfig(
|
|
229
|
+
marketIndex: number,
|
|
230
|
+
serumMarket: PublicKey,
|
|
231
|
+
serumProgram: PublicKey
|
|
232
|
+
): Promise<TransactionSignature> {
|
|
233
|
+
const initializeIx = await this.getInitializeSerumFulfillmentConfigIx(
|
|
234
|
+
this.wallet.publicKey,
|
|
235
|
+
marketIndex,
|
|
236
|
+
serumMarket,
|
|
237
|
+
serumProgram
|
|
238
|
+
);
|
|
160
239
|
|
|
161
|
-
|
|
240
|
+
const tx = await this.buildTransaction(initializeIx);
|
|
162
241
|
|
|
163
|
-
await this.
|
|
164
|
-
await this.accountSubscriber.addOracle({
|
|
165
|
-
source: oracleSource,
|
|
166
|
-
publicKey: oracle,
|
|
167
|
-
});
|
|
168
|
-
await this.accountSubscriber.setSpotOracleMap();
|
|
242
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
169
243
|
|
|
170
244
|
return txSig;
|
|
171
245
|
}
|
|
172
246
|
|
|
173
|
-
public async
|
|
247
|
+
public async getInitializeSerumFulfillmentConfigIx(
|
|
248
|
+
admin: PublicKey,
|
|
174
249
|
marketIndex: number,
|
|
175
250
|
serumMarket: PublicKey,
|
|
176
251
|
serumProgram: PublicKey
|
|
177
|
-
): Promise<
|
|
252
|
+
): Promise<TransactionInstruction> {
|
|
178
253
|
const serumOpenOrders = getSerumOpenOrdersPublicKey(
|
|
179
254
|
this.program.programId,
|
|
180
255
|
serumMarket
|
|
@@ -185,25 +260,35 @@ export class AdminClient extends DriftClient {
|
|
|
185
260
|
serumMarket
|
|
186
261
|
);
|
|
187
262
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
263
|
+
return await this.program.instruction.initializeSerumFulfillmentConfig(
|
|
264
|
+
marketIndex,
|
|
265
|
+
{
|
|
266
|
+
accounts: {
|
|
267
|
+
admin,
|
|
268
|
+
state: await this.getStatePublicKey(),
|
|
269
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
270
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
271
|
+
driftSigner: this.getSignerPublicKey(),
|
|
272
|
+
serumProgram,
|
|
273
|
+
serumMarket,
|
|
274
|
+
serumOpenOrders,
|
|
275
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
276
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
277
|
+
serumFulfillmentConfig,
|
|
278
|
+
},
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
public async initializePhoenixFulfillmentConfig(
|
|
284
|
+
marketIndex: number,
|
|
285
|
+
phoenixMarket: PublicKey
|
|
286
|
+
): Promise<TransactionSignature> {
|
|
287
|
+
const initializeIx = await this.getInitializePhoenixFulfillmentConfigIx(
|
|
288
|
+
this.wallet.publicKey,
|
|
289
|
+
marketIndex,
|
|
290
|
+
phoenixMarket
|
|
291
|
+
);
|
|
207
292
|
|
|
208
293
|
const tx = await this.buildTransaction(initializeIx);
|
|
209
294
|
|
|
@@ -212,39 +297,33 @@ export class AdminClient extends DriftClient {
|
|
|
212
297
|
return txSig;
|
|
213
298
|
}
|
|
214
299
|
|
|
215
|
-
public async
|
|
300
|
+
public async getInitializePhoenixFulfillmentConfigIx(
|
|
301
|
+
admin: PublicKey,
|
|
216
302
|
marketIndex: number,
|
|
217
303
|
phoenixMarket: PublicKey
|
|
218
|
-
): Promise<
|
|
304
|
+
): Promise<TransactionInstruction> {
|
|
219
305
|
const phoenixFulfillmentConfig = getPhoenixFulfillmentConfigPublicKey(
|
|
220
306
|
this.program.programId,
|
|
221
307
|
phoenixMarket
|
|
222
308
|
);
|
|
223
309
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
{
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
const tx = await this.buildTransaction(initializeIx);
|
|
244
|
-
|
|
245
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
246
|
-
|
|
247
|
-
return txSig;
|
|
310
|
+
return await this.program.instruction.initializePhoenixFulfillmentConfig(
|
|
311
|
+
marketIndex,
|
|
312
|
+
{
|
|
313
|
+
accounts: {
|
|
314
|
+
admin,
|
|
315
|
+
state: await this.getStatePublicKey(),
|
|
316
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
317
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
318
|
+
driftSigner: this.getSignerPublicKey(),
|
|
319
|
+
phoenixMarket: phoenixMarket,
|
|
320
|
+
phoenixProgram: PHOENIX_PROGRAM_ID,
|
|
321
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
322
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
323
|
+
phoenixFulfillmentConfig,
|
|
324
|
+
},
|
|
325
|
+
}
|
|
326
|
+
);
|
|
248
327
|
}
|
|
249
328
|
|
|
250
329
|
public async initializePerpMarket(
|
|
@@ -275,49 +354,35 @@ export class AdminClient extends DriftClient {
|
|
|
275
354
|
name = DEFAULT_MARKET_NAME
|
|
276
355
|
): Promise<TransactionSignature> {
|
|
277
356
|
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
278
|
-
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
279
|
-
this.program.programId,
|
|
280
|
-
currentPerpMarketIndex
|
|
281
|
-
);
|
|
282
357
|
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
accounts: {
|
|
312
|
-
state: await this.getStatePublicKey(),
|
|
313
|
-
admin: this.wallet.publicKey,
|
|
314
|
-
oracle: priceOracle,
|
|
315
|
-
perpMarket: perpMarketPublicKey,
|
|
316
|
-
rent: SYSVAR_RENT_PUBKEY,
|
|
317
|
-
systemProgram: anchor.web3.SystemProgram.programId,
|
|
318
|
-
},
|
|
319
|
-
}
|
|
320
|
-
);
|
|
358
|
+
const initializeMarketIx = await this.getInitializePerpMarketIx(
|
|
359
|
+
this.wallet.publicKey,
|
|
360
|
+
marketIndex,
|
|
361
|
+
priceOracle,
|
|
362
|
+
baseAssetReserve,
|
|
363
|
+
quoteAssetReserve,
|
|
364
|
+
periodicity,
|
|
365
|
+
pegMultiplier,
|
|
366
|
+
oracleSource,
|
|
367
|
+
marginRatioInitial,
|
|
368
|
+
marginRatioMaintenance,
|
|
369
|
+
liquidatorFee,
|
|
370
|
+
ifLiquidatorFee,
|
|
371
|
+
imfFactor,
|
|
372
|
+
activeStatus,
|
|
373
|
+
baseSpread,
|
|
374
|
+
maxSpread,
|
|
375
|
+
maxOpenInterest,
|
|
376
|
+
maxRevenueWithdrawPerPeriod,
|
|
377
|
+
quoteMaxInsurance,
|
|
378
|
+
orderStepSize,
|
|
379
|
+
orderTickSize,
|
|
380
|
+
minOrderSize,
|
|
381
|
+
concentrationCoefScale,
|
|
382
|
+
curveUpdateIntensity,
|
|
383
|
+
ammJitIntensity,
|
|
384
|
+
name
|
|
385
|
+
);
|
|
321
386
|
const tx = await this.buildTransaction(initializeMarketIx);
|
|
322
387
|
|
|
323
388
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
@@ -336,6 +401,79 @@ export class AdminClient extends DriftClient {
|
|
|
336
401
|
return txSig;
|
|
337
402
|
}
|
|
338
403
|
|
|
404
|
+
public async getInitializePerpMarketIx(
|
|
405
|
+
admin: PublicKey,
|
|
406
|
+
marketIndex: number,
|
|
407
|
+
priceOracle: PublicKey,
|
|
408
|
+
baseAssetReserve: BN,
|
|
409
|
+
quoteAssetReserve: BN,
|
|
410
|
+
periodicity: BN,
|
|
411
|
+
pegMultiplier: BN = PEG_PRECISION,
|
|
412
|
+
oracleSource: OracleSource = OracleSource.PYTH,
|
|
413
|
+
marginRatioInitial = 2000,
|
|
414
|
+
marginRatioMaintenance = 500,
|
|
415
|
+
liquidatorFee = 0,
|
|
416
|
+
ifLiquidatorFee = 10000,
|
|
417
|
+
imfFactor = 0,
|
|
418
|
+
activeStatus = true,
|
|
419
|
+
baseSpread = 0,
|
|
420
|
+
maxSpread = 142500,
|
|
421
|
+
maxOpenInterest = ZERO,
|
|
422
|
+
maxRevenueWithdrawPerPeriod = ZERO,
|
|
423
|
+
quoteMaxInsurance = ZERO,
|
|
424
|
+
orderStepSize = BASE_PRECISION.divn(10000),
|
|
425
|
+
orderTickSize = PRICE_PRECISION.divn(100000),
|
|
426
|
+
minOrderSize = BASE_PRECISION.divn(10000),
|
|
427
|
+
concentrationCoefScale = ONE,
|
|
428
|
+
curveUpdateIntensity = 0,
|
|
429
|
+
ammJitIntensity = 0,
|
|
430
|
+
name = DEFAULT_MARKET_NAME
|
|
431
|
+
): Promise<TransactionInstruction> {
|
|
432
|
+
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
433
|
+
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
434
|
+
this.program.programId,
|
|
435
|
+
currentPerpMarketIndex
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
const nameBuffer = encodeName(name);
|
|
439
|
+
return await this.program.instruction.initializePerpMarket(
|
|
440
|
+
marketIndex,
|
|
441
|
+
baseAssetReserve,
|
|
442
|
+
quoteAssetReserve,
|
|
443
|
+
periodicity,
|
|
444
|
+
pegMultiplier,
|
|
445
|
+
oracleSource,
|
|
446
|
+
marginRatioInitial,
|
|
447
|
+
marginRatioMaintenance,
|
|
448
|
+
liquidatorFee,
|
|
449
|
+
ifLiquidatorFee,
|
|
450
|
+
imfFactor,
|
|
451
|
+
activeStatus,
|
|
452
|
+
baseSpread,
|
|
453
|
+
maxSpread,
|
|
454
|
+
maxOpenInterest,
|
|
455
|
+
maxRevenueWithdrawPerPeriod,
|
|
456
|
+
quoteMaxInsurance,
|
|
457
|
+
orderStepSize,
|
|
458
|
+
orderTickSize,
|
|
459
|
+
minOrderSize,
|
|
460
|
+
concentrationCoefScale,
|
|
461
|
+
curveUpdateIntensity,
|
|
462
|
+
ammJitIntensity,
|
|
463
|
+
nameBuffer,
|
|
464
|
+
{
|
|
465
|
+
accounts: {
|
|
466
|
+
state: await this.getStatePublicKey(),
|
|
467
|
+
admin,
|
|
468
|
+
oracle: priceOracle,
|
|
469
|
+
perpMarket: perpMarketPublicKey,
|
|
470
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
471
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
472
|
+
},
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
|
|
339
477
|
public async deleteInitializedPerpMarket(
|
|
340
478
|
marketIndex: number
|
|
341
479
|
): Promise<TransactionSignature> {
|
|
@@ -2156,38 +2294,74 @@ export class AdminClient extends DriftClient {
|
|
|
2156
2294
|
price?: BN,
|
|
2157
2295
|
maxPrice?: BN
|
|
2158
2296
|
): Promise<TransactionSignature> {
|
|
2297
|
+
const initializePrelaunchOracleIx =
|
|
2298
|
+
await this.getInitializePrelaunchOracleIx(
|
|
2299
|
+
this.wallet.publicKey,
|
|
2300
|
+
perpMarketIndex,
|
|
2301
|
+
price,
|
|
2302
|
+
maxPrice
|
|
2303
|
+
);
|
|
2304
|
+
|
|
2305
|
+
const tx = await this.buildTransaction(initializePrelaunchOracleIx);
|
|
2306
|
+
|
|
2307
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2308
|
+
|
|
2309
|
+
return txSig;
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
public async getInitializePrelaunchOracleIx(
|
|
2313
|
+
admin: PublicKey,
|
|
2314
|
+
perpMarketIndex: number,
|
|
2315
|
+
price?: BN,
|
|
2316
|
+
maxPrice?: BN
|
|
2317
|
+
): Promise<TransactionInstruction> {
|
|
2159
2318
|
const params = {
|
|
2160
2319
|
perpMarketIndex,
|
|
2161
2320
|
price: price || null,
|
|
2162
2321
|
maxPrice: maxPrice || null,
|
|
2163
2322
|
};
|
|
2164
2323
|
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2324
|
+
return await this.program.instruction.initializePrelaunchOracle(params, {
|
|
2325
|
+
accounts: {
|
|
2326
|
+
admin,
|
|
2327
|
+
state: await this.getStatePublicKey(),
|
|
2328
|
+
prelaunchOracle: await getPrelaunchOraclePublicKey(
|
|
2329
|
+
this.program.programId,
|
|
2330
|
+
perpMarketIndex
|
|
2331
|
+
),
|
|
2332
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
2333
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
2334
|
+
},
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2178
2337
|
|
|
2179
|
-
|
|
2338
|
+
public async updatePrelaunchOracleParams(
|
|
2339
|
+
admin: PublicKey,
|
|
2340
|
+
perpMarketIndex: number,
|
|
2341
|
+
price?: BN,
|
|
2342
|
+
maxPrice?: BN
|
|
2343
|
+
): Promise<TransactionSignature> {
|
|
2344
|
+
const updatePrelaunchOracleParamsIx =
|
|
2345
|
+
await this.getUpdatePrelaunchOracleParamsIx(
|
|
2346
|
+
this.wallet.publicKey,
|
|
2347
|
+
perpMarketIndex,
|
|
2348
|
+
price,
|
|
2349
|
+
maxPrice
|
|
2350
|
+
);
|
|
2351
|
+
|
|
2352
|
+
const tx = await this.buildTransaction(updatePrelaunchOracleParamsIx);
|
|
2180
2353
|
|
|
2181
2354
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2182
2355
|
|
|
2183
2356
|
return txSig;
|
|
2184
2357
|
}
|
|
2185
2358
|
|
|
2186
|
-
public async
|
|
2359
|
+
public async getUpdatePrelaunchOracleParamsIx(
|
|
2360
|
+
admin: PublicKey,
|
|
2187
2361
|
perpMarketIndex: number,
|
|
2188
2362
|
price?: BN,
|
|
2189
2363
|
maxPrice?: BN
|
|
2190
|
-
): Promise<
|
|
2364
|
+
): Promise<TransactionInstruction> {
|
|
2191
2365
|
const params = {
|
|
2192
2366
|
perpMarketIndex,
|
|
2193
2367
|
price: price || null,
|
|
@@ -2199,24 +2373,17 @@ export class AdminClient extends DriftClient {
|
|
|
2199
2373
|
perpMarketIndex
|
|
2200
2374
|
);
|
|
2201
2375
|
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
});
|
|
2214
|
-
|
|
2215
|
-
const tx = await this.buildTransaction(updatePrelaunchOracleParamsIx);
|
|
2216
|
-
|
|
2217
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
2218
|
-
|
|
2219
|
-
return txSig;
|
|
2376
|
+
return await this.program.instruction.updatePrelaunchOracleParams(params, {
|
|
2377
|
+
accounts: {
|
|
2378
|
+
admin,
|
|
2379
|
+
state: await this.getStatePublicKey(),
|
|
2380
|
+
perpMarket: perpMarketPublicKey,
|
|
2381
|
+
prelaunchOracle: await getPrelaunchOraclePublicKey(
|
|
2382
|
+
this.program.programId,
|
|
2383
|
+
perpMarketIndex
|
|
2384
|
+
),
|
|
2385
|
+
},
|
|
2386
|
+
});
|
|
2220
2387
|
}
|
|
2221
2388
|
|
|
2222
2389
|
public async deletePrelaunchOracle(
|
package/src/idl/drift.json
CHANGED
|
@@ -3023,11 +3023,11 @@
|
|
|
3023
3023
|
},
|
|
3024
3024
|
{
|
|
3025
3025
|
"name": "curveUpdateIntensity",
|
|
3026
|
-
"type": "
|
|
3026
|
+
"type": "u8"
|
|
3027
3027
|
},
|
|
3028
3028
|
{
|
|
3029
|
-
"name": "
|
|
3030
|
-
"type": "
|
|
3029
|
+
"name": "ammJitIntensity",
|
|
3030
|
+
"type": "u8"
|
|
3031
3031
|
},
|
|
3032
3032
|
{
|
|
3033
3033
|
"name": "name",
|
|
@@ -11711,8 +11711,5 @@
|
|
|
11711
11711
|
"name": "CantReclaimRent",
|
|
11712
11712
|
"msg": "CantReclaimRent"
|
|
11713
11713
|
}
|
|
11714
|
-
]
|
|
11715
|
-
"metadata": {
|
|
11716
|
-
"address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
|
|
11717
|
-
}
|
|
11714
|
+
]
|
|
11718
11715
|
}
|