@drift-labs/sdk 0.2.0-master.3 → 0.2.0-master.30
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 +13 -13
- package/lib/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/accounts/bulkUserStatsSubscription.js +21 -0
- 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 +16 -16
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +31 -28
- package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +113 -0
- package/lib/accounts/types.d.ts +22 -11
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +17 -17
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +37 -35
- 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/pda.d.ts +10 -4
- package/lib/addresses/pda.js +51 -14
- package/lib/admin.d.ts +34 -22
- package/lib/admin.js +182 -73
- package/lib/clearingHouse.d.ts +120 -42
- package/lib/clearingHouse.js +1505 -254
- package/lib/clearingHouseConfig.d.ts +4 -4
- package/lib/clearingHouseUser.d.ts +50 -38
- package/lib/clearingHouseUser.js +410 -190
- package/lib/clearingHouseUserStats.d.ts +18 -0
- package/lib/clearingHouseUserStats.js +49 -0
- package/lib/clearingHouseUserStatsConfig.d.ts +14 -0
- package/lib/clearingHouseUserStatsConfig.js +2 -0
- package/lib/config.d.ts +7 -9
- package/lib/config.js +21 -21
- package/lib/constants/numericConstants.d.ts +18 -12
- package/lib/constants/numericConstants.js +28 -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 +73 -0
- package/lib/dlob/DLOB.js +553 -0
- package/lib/dlob/DLOBNode.d.ts +52 -0
- package/lib/dlob/DLOBNode.js +82 -0
- package/lib/dlob/NodeList.d.ts +26 -0
- package/lib/dlob/NodeList.js +138 -0
- package/lib/events/eventList.js +3 -0
- package/lib/events/eventSubscriber.d.ts +4 -2
- package/lib/events/eventSubscriber.js +16 -9
- package/lib/events/fetchLogs.d.ts +10 -1
- package/lib/events/fetchLogs.js +27 -7
- package/lib/events/pollingLogProvider.d.ts +2 -1
- package/lib/events/pollingLogProvider.js +6 -2
- package/lib/events/sort.js +8 -11
- package/lib/events/types.d.ts +7 -2
- package/lib/events/types.js +5 -0
- package/lib/examples/makeTradeExample.js +20 -8
- package/lib/factory/bigNum.d.ts +1 -0
- package/lib/factory/bigNum.js +34 -10
- package/lib/idl/clearing_house.json +4313 -1433
- package/lib/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/lib/index.d.ts +21 -6
- package/lib/index.js +25 -6
- package/lib/math/amm.d.ts +8 -5
- package/lib/math/amm.js +68 -46
- package/lib/math/auction.js +4 -1
- package/lib/math/conversion.js +1 -1
- package/lib/math/funding.d.ts +6 -6
- package/lib/math/funding.js +11 -10
- 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 +77 -0
- package/lib/math/market.d.ts +14 -9
- package/lib/math/market.js +69 -7
- package/lib/math/oracles.d.ts +4 -0
- package/lib/math/oracles.js +36 -8
- package/lib/math/orders.d.ts +6 -2
- package/lib/math/orders.js +78 -3
- package/lib/math/position.d.ts +21 -13
- package/lib/math/position.js +76 -36
- package/lib/math/repeg.js +14 -5
- package/lib/math/spotBalance.d.ts +22 -0
- package/lib/math/spotBalance.js +193 -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 +22 -29
- 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 +14 -5
- package/lib/orderParams.js +12 -92
- package/lib/serum/serumSubscriber.d.ts +23 -0
- package/lib/serum/serumSubscriber.js +41 -0
- package/lib/serum/types.d.ts +11 -0
- package/lib/serum/types.js +2 -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 +474 -123
- package/lib/types.js +99 -5
- package/lib/userMap/userMap.d.ts +25 -0
- package/lib/userMap/userMap.js +73 -0
- package/lib/userMap/userStatsMap.d.ts +19 -0
- package/lib/userMap/userStatsMap.js +68 -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 +9 -5
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +0 -1
- package/src/accounts/fetch.ts +27 -2
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +46 -42
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +172 -0
- package/src/accounts/types.ts +31 -11
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +64 -59
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +80 -0
- package/src/addresses/marketAddresses.ts +1 -2
- package/src/addresses/pda.ts +88 -14
- package/src/admin.ts +333 -128
- package/src/assert/assert.js +9 -0
- package/src/clearingHouse.ts +2464 -458
- package/src/clearingHouseConfig.ts +4 -3
- package/src/clearingHouseUser.ts +747 -291
- package/src/clearingHouseUserStats.ts +75 -0
- package/src/clearingHouseUserStatsConfig.ts +18 -0
- package/src/config.ts +30 -31
- package/src/constants/numericConstants.ts +41 -25
- package/src/constants/{markets.ts → perpMarkets.ts} +10 -10
- package/src/constants/spotMarkets.ts +72 -0
- package/src/dlob/DLOB.ts +868 -0
- package/src/dlob/DLOBNode.ts +162 -0
- package/src/dlob/NodeList.ts +185 -0
- package/src/events/eventList.js +77 -0
- package/src/events/eventList.ts +3 -0
- package/src/events/eventSubscriber.ts +20 -12
- package/src/events/fetchLogs.ts +35 -8
- package/src/events/pollingLogProvider.ts +10 -2
- package/src/events/sort.ts +11 -15
- package/src/events/types.ts +16 -1
- package/src/examples/makeTradeExample.js +157 -0
- package/src/examples/makeTradeExample.ts +32 -14
- package/src/factory/bigNum.ts +42 -13
- package/src/idl/clearing_house.json +4313 -1433
- package/src/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/src/index.ts +21 -6
- package/src/math/amm.ts +136 -66
- package/src/math/auction.ts +5 -1
- package/src/math/conversion.ts +2 -2
- package/src/math/funding.ts +20 -18
- package/src/math/insurance.ts +35 -0
- package/src/math/margin.ts +127 -0
- package/src/math/market.ts +138 -12
- package/src/math/oracles.ts +63 -9
- package/src/math/orders.ts +138 -4
- package/src/math/position.ts +119 -58
- package/src/math/repeg.ts +16 -6
- package/src/math/spotBalance.ts +316 -0
- package/src/math/spotMarket.ts +9 -0
- package/src/math/spotPosition.ts +47 -0
- package/src/math/trade.ts +43 -49
- 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 +24 -137
- package/src/serum/serumSubscriber.ts +80 -0
- package/src/serum/types.ts +13 -0
- package/src/slot/SlotSubscriber.ts +11 -1
- package/src/token/index.js +38 -0
- package/src/{mockUSDCFaucet.ts → tokenFaucet.ts} +82 -70
- package/src/tx/retryTxSender.ts +16 -5
- package/src/tx/types.js +2 -0
- package/src/tx/types.ts +2 -1
- package/src/tx/utils.js +17 -0
- package/src/tx/utils.ts +1 -1
- package/src/types.ts +477 -125
- package/src/userMap/userMap.ts +100 -0
- package/src/userMap/userStatsMap.ts +110 -0
- package/src/util/computeUnits.js +21 -11
- package/src/util/computeUnits.ts +1 -1
- package/src/util/getTokenAddress.js +9 -0
- package/src/util/getTokenAddress.ts +18 -0
- package/src/util/promiseTimeout.js +14 -0
- package/src/util/tps.js +27 -0
- package/tests/bn/test.ts +12 -3
- package/tests/dlob/helpers.ts +374 -0
- package/tests/dlob/test.ts +2865 -0
- 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/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/constants/banks.ts +0 -43
- 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.map +0 -1
package/src/admin.ts
CHANGED
|
@@ -3,24 +3,22 @@ import {
|
|
|
3
3
|
SYSVAR_RENT_PUBKEY,
|
|
4
4
|
TransactionSignature,
|
|
5
5
|
} from '@solana/web3.js';
|
|
6
|
-
import {
|
|
7
|
-
FeeStructure,
|
|
8
|
-
OracleGuardRails,
|
|
9
|
-
OracleSource,
|
|
10
|
-
OrderFillerRewardStructure,
|
|
11
|
-
} from './types';
|
|
6
|
+
import { FeeStructure, OracleGuardRails, OracleSource } from './types';
|
|
12
7
|
import { BN } from '@project-serum/anchor';
|
|
13
8
|
import * as anchor from '@project-serum/anchor';
|
|
14
9
|
import {
|
|
15
10
|
getClearingHouseStateAccountPublicKeyAndNonce,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
getBankVaultPublicKey,
|
|
11
|
+
getSpotMarketPublicKey,
|
|
12
|
+
getSpotMarketVaultPublicKey,
|
|
19
13
|
getMarketPublicKey,
|
|
14
|
+
getInsuranceFundVaultPublicKey,
|
|
15
|
+
getSerumOpenOrdersPublicKey,
|
|
16
|
+
getSerumFulfillmentConfigPublicKey,
|
|
20
17
|
} from './addresses/pda';
|
|
18
|
+
import { squareRootBN } from './math/utils';
|
|
21
19
|
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
22
20
|
import { ClearingHouse } from './clearingHouse';
|
|
23
|
-
import { PEG_PRECISION } from './constants/numericConstants';
|
|
21
|
+
import { PEG_PRECISION, ZERO } from './constants/numericConstants';
|
|
24
22
|
import { calculateTargetPriceTrade } from './math/trade';
|
|
25
23
|
import { calculateAmmReservesAfterSwap, getSwapDirection } from './math/amm';
|
|
26
24
|
|
|
@@ -36,20 +34,11 @@ export class Admin extends ClearingHouse {
|
|
|
36
34
|
throw new Error('Clearing house already initialized');
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
const [insuranceVaultPublicKey] = await PublicKey.findProgramAddress(
|
|
40
|
-
[Buffer.from(anchor.utils.bytes.utf8.encode('insurance_vault'))],
|
|
41
|
-
this.program.programId
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const [insuranceVaultAuthority] = await PublicKey.findProgramAddress(
|
|
45
|
-
[insuranceVaultPublicKey.toBuffer()],
|
|
46
|
-
this.program.programId
|
|
47
|
-
);
|
|
48
|
-
|
|
49
37
|
const [clearingHouseStatePublicKey] =
|
|
50
38
|
await getClearingHouseStateAccountPublicKeyAndNonce(
|
|
51
39
|
this.program.programId
|
|
52
40
|
);
|
|
41
|
+
|
|
53
42
|
const initializeTx = await this.program.transaction.initialize(
|
|
54
43
|
adminControlsPrices,
|
|
55
44
|
{
|
|
@@ -57,9 +46,8 @@ export class Admin extends ClearingHouse {
|
|
|
57
46
|
admin: this.wallet.publicKey,
|
|
58
47
|
state: clearingHouseStatePublicKey,
|
|
59
48
|
quoteAssetMint: usdcMint,
|
|
60
|
-
insuranceVault: insuranceVaultPublicKey,
|
|
61
|
-
insuranceVaultAuthority: insuranceVaultAuthority,
|
|
62
49
|
rent: SYSVAR_RENT_PUBKEY,
|
|
50
|
+
clearingHouseSigner: this.getSignerPublicKey(),
|
|
63
51
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
64
52
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
65
53
|
},
|
|
@@ -75,7 +63,7 @@ export class Admin extends ClearingHouse {
|
|
|
75
63
|
return [initializeTxSig];
|
|
76
64
|
}
|
|
77
65
|
|
|
78
|
-
public async
|
|
66
|
+
public async initializeSpotMarket(
|
|
79
67
|
mint: PublicKey,
|
|
80
68
|
optimalUtilization: BN,
|
|
81
69
|
optimalRate: BN,
|
|
@@ -85,22 +73,27 @@ export class Admin extends ClearingHouse {
|
|
|
85
73
|
initialAssetWeight: BN,
|
|
86
74
|
maintenanceAssetWeight: BN,
|
|
87
75
|
initialLiabilityWeight: BN,
|
|
88
|
-
maintenanceLiabilityWeight: BN
|
|
76
|
+
maintenanceLiabilityWeight: BN,
|
|
77
|
+
imfFactor = new BN(0),
|
|
78
|
+
liquidationFee = ZERO
|
|
89
79
|
): Promise<TransactionSignature> {
|
|
90
|
-
const
|
|
91
|
-
const
|
|
80
|
+
const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
|
|
81
|
+
const spotMarket = await getSpotMarketPublicKey(
|
|
82
|
+
this.program.programId,
|
|
83
|
+
spotMarketIndex
|
|
84
|
+
);
|
|
92
85
|
|
|
93
|
-
const
|
|
86
|
+
const spotMarketVault = await getSpotMarketVaultPublicKey(
|
|
94
87
|
this.program.programId,
|
|
95
|
-
|
|
88
|
+
spotMarketIndex
|
|
96
89
|
);
|
|
97
90
|
|
|
98
|
-
const
|
|
91
|
+
const insuranceFundVault = await getInsuranceFundVaultPublicKey(
|
|
99
92
|
this.program.programId,
|
|
100
|
-
|
|
93
|
+
spotMarketIndex
|
|
101
94
|
);
|
|
102
95
|
|
|
103
|
-
const initializeTx = await this.program.transaction.
|
|
96
|
+
const initializeTx = await this.program.transaction.initializeSpotMarket(
|
|
104
97
|
optimalUtilization,
|
|
105
98
|
optimalRate,
|
|
106
99
|
maxRate,
|
|
@@ -109,14 +102,17 @@ export class Admin extends ClearingHouse {
|
|
|
109
102
|
maintenanceAssetWeight,
|
|
110
103
|
initialLiabilityWeight,
|
|
111
104
|
maintenanceLiabilityWeight,
|
|
105
|
+
imfFactor,
|
|
106
|
+
liquidationFee,
|
|
112
107
|
{
|
|
113
108
|
accounts: {
|
|
114
109
|
admin: this.wallet.publicKey,
|
|
115
110
|
state: await this.getStatePublicKey(),
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
spotMarket,
|
|
112
|
+
spotMarketVault,
|
|
113
|
+
insuranceFundVault,
|
|
114
|
+
clearingHouseSigner: this.getSignerPublicKey(),
|
|
115
|
+
spotMarketMint: mint,
|
|
120
116
|
oracle,
|
|
121
117
|
rent: SYSVAR_RENT_PUBKEY,
|
|
122
118
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
@@ -127,7 +123,7 @@ export class Admin extends ClearingHouse {
|
|
|
127
123
|
|
|
128
124
|
const { txSig } = await this.txSender.send(initializeTx, [], this.opts);
|
|
129
125
|
|
|
130
|
-
await this.accountSubscriber.
|
|
126
|
+
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
131
127
|
await this.accountSubscriber.addOracle({
|
|
132
128
|
source: oracleSource,
|
|
133
129
|
publicKey: oracle,
|
|
@@ -136,6 +132,41 @@ export class Admin extends ClearingHouse {
|
|
|
136
132
|
return txSig;
|
|
137
133
|
}
|
|
138
134
|
|
|
135
|
+
public async initializeSerumFulfillmentConfig(
|
|
136
|
+
marketIndex: number,
|
|
137
|
+
serumMarket: PublicKey,
|
|
138
|
+
serumProgram: PublicKey
|
|
139
|
+
): Promise<TransactionSignature> {
|
|
140
|
+
const serumOpenOrders = getSerumOpenOrdersPublicKey(
|
|
141
|
+
this.program.programId,
|
|
142
|
+
serumMarket
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const serumFulfillmentConfig = getSerumFulfillmentConfigPublicKey(
|
|
146
|
+
this.program.programId,
|
|
147
|
+
serumMarket
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
return await this.program.rpc.initializeSerumFulfillmentConfig(
|
|
151
|
+
marketIndex,
|
|
152
|
+
{
|
|
153
|
+
accounts: {
|
|
154
|
+
admin: this.wallet.publicKey,
|
|
155
|
+
state: await this.getStatePublicKey(),
|
|
156
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
157
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
158
|
+
clearingHouseSigner: this.getSignerPublicKey(),
|
|
159
|
+
serumProgram,
|
|
160
|
+
serumMarket,
|
|
161
|
+
serumOpenOrders,
|
|
162
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
163
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
164
|
+
serumFulfillmentConfig,
|
|
165
|
+
},
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
139
170
|
public async initializeMarket(
|
|
140
171
|
priceOracle: PublicKey,
|
|
141
172
|
baseAssetReserve: BN,
|
|
@@ -144,8 +175,8 @@ export class Admin extends ClearingHouse {
|
|
|
144
175
|
pegMultiplier: BN = PEG_PRECISION,
|
|
145
176
|
oracleSource: OracleSource = OracleSource.PYTH,
|
|
146
177
|
marginRatioInitial = 2000,
|
|
147
|
-
|
|
148
|
-
|
|
178
|
+
marginRatioMaintenance = 500,
|
|
179
|
+
liquidationFee = ZERO
|
|
149
180
|
): Promise<TransactionSignature> {
|
|
150
181
|
const marketPublicKey = await getMarketPublicKey(
|
|
151
182
|
this.program.programId,
|
|
@@ -159,8 +190,8 @@ export class Admin extends ClearingHouse {
|
|
|
159
190
|
pegMultiplier,
|
|
160
191
|
oracleSource,
|
|
161
192
|
marginRatioInitial,
|
|
162
|
-
marginRatioPartial,
|
|
163
193
|
marginRatioMaintenance,
|
|
194
|
+
liquidationFee,
|
|
164
195
|
{
|
|
165
196
|
accounts: {
|
|
166
197
|
state: await this.getStatePublicKey(),
|
|
@@ -178,7 +209,7 @@ export class Admin extends ClearingHouse {
|
|
|
178
209
|
this.opts
|
|
179
210
|
);
|
|
180
211
|
|
|
181
|
-
await this.accountSubscriber.
|
|
212
|
+
await this.accountSubscriber.addPerpMarket(
|
|
182
213
|
this.getStateAccount().numberOfMarkets
|
|
183
214
|
);
|
|
184
215
|
await this.accountSubscriber.addOracle({
|
|
@@ -190,23 +221,29 @@ export class Admin extends ClearingHouse {
|
|
|
190
221
|
}
|
|
191
222
|
|
|
192
223
|
public async moveAmmPrice(
|
|
224
|
+
marketIndex: number,
|
|
193
225
|
baseAssetReserve: BN,
|
|
194
226
|
quoteAssetReserve: BN,
|
|
195
|
-
|
|
227
|
+
sqrtK?: BN
|
|
196
228
|
): Promise<TransactionSignature> {
|
|
197
229
|
const marketPublicKey = await getMarketPublicKey(
|
|
198
230
|
this.program.programId,
|
|
199
231
|
marketIndex
|
|
200
232
|
);
|
|
201
233
|
|
|
234
|
+
if (sqrtK == undefined) {
|
|
235
|
+
sqrtK = squareRootBN(baseAssetReserve.mul(quoteAssetReserve));
|
|
236
|
+
}
|
|
237
|
+
|
|
202
238
|
return await this.program.rpc.moveAmmPrice(
|
|
203
239
|
baseAssetReserve,
|
|
204
240
|
quoteAssetReserve,
|
|
241
|
+
sqrtK,
|
|
205
242
|
{
|
|
206
243
|
accounts: {
|
|
207
244
|
state: await this.getStatePublicKey(),
|
|
208
245
|
admin: this.wallet.publicKey,
|
|
209
|
-
|
|
246
|
+
perpMarket: marketPublicKey,
|
|
210
247
|
},
|
|
211
248
|
}
|
|
212
249
|
);
|
|
@@ -214,23 +251,36 @@ export class Admin extends ClearingHouse {
|
|
|
214
251
|
|
|
215
252
|
public async updateK(
|
|
216
253
|
sqrtK: BN,
|
|
217
|
-
marketIndex:
|
|
254
|
+
marketIndex: number
|
|
218
255
|
): Promise<TransactionSignature> {
|
|
219
256
|
return await this.program.rpc.updateK(sqrtK, {
|
|
220
257
|
accounts: {
|
|
221
258
|
state: await this.getStatePublicKey(),
|
|
222
259
|
admin: this.wallet.publicKey,
|
|
223
260
|
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
224
|
-
oracle: this.
|
|
261
|
+
oracle: this.getPerpMarketAccount(marketIndex).amm.oracle,
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
public async updateConcentrationScale(
|
|
267
|
+
marketIndex: number,
|
|
268
|
+
concentrationScale: BN
|
|
269
|
+
): Promise<TransactionSignature> {
|
|
270
|
+
return await this.program.rpc.updateConcentrationCoef(concentrationScale, {
|
|
271
|
+
accounts: {
|
|
272
|
+
state: await this.getStatePublicKey(),
|
|
273
|
+
admin: this.wallet.publicKey,
|
|
274
|
+
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
225
275
|
},
|
|
226
276
|
});
|
|
227
277
|
}
|
|
228
278
|
|
|
229
279
|
public async moveAmmToPrice(
|
|
230
|
-
|
|
280
|
+
perpMarketIndex: number,
|
|
231
281
|
targetPrice: BN
|
|
232
282
|
): Promise<TransactionSignature> {
|
|
233
|
-
const market = this.
|
|
283
|
+
const market = this.getPerpMarketAccount(perpMarketIndex);
|
|
234
284
|
|
|
235
285
|
const [direction, tradeSize, _] = calculateTargetPriceTrade(
|
|
236
286
|
market,
|
|
@@ -250,17 +300,18 @@ export class Admin extends ClearingHouse {
|
|
|
250
300
|
|
|
251
301
|
const marketPublicKey = await getMarketPublicKey(
|
|
252
302
|
this.program.programId,
|
|
253
|
-
|
|
303
|
+
perpMarketIndex
|
|
254
304
|
);
|
|
255
305
|
|
|
256
306
|
return await this.program.rpc.moveAmmPrice(
|
|
257
307
|
newBaseAssetAmount,
|
|
258
308
|
newQuoteAssetAmount,
|
|
309
|
+
market.amm.sqrtK,
|
|
259
310
|
{
|
|
260
311
|
accounts: {
|
|
261
312
|
state: await this.getStatePublicKey(),
|
|
262
313
|
admin: this.wallet.publicKey,
|
|
263
|
-
|
|
314
|
+
perpMarket: marketPublicKey,
|
|
264
315
|
},
|
|
265
316
|
}
|
|
266
317
|
);
|
|
@@ -268,13 +319,13 @@ export class Admin extends ClearingHouse {
|
|
|
268
319
|
|
|
269
320
|
public async repegAmmCurve(
|
|
270
321
|
newPeg: BN,
|
|
271
|
-
marketIndex:
|
|
322
|
+
marketIndex: number
|
|
272
323
|
): Promise<TransactionSignature> {
|
|
273
324
|
const marketPublicKey = await getMarketPublicKey(
|
|
274
325
|
this.program.programId,
|
|
275
326
|
marketIndex
|
|
276
327
|
);
|
|
277
|
-
const ammData = this.
|
|
328
|
+
const ammData = this.getPerpMarketAccount(marketIndex).amm;
|
|
278
329
|
|
|
279
330
|
return await this.program.rpc.repegAmmCurve(newPeg, {
|
|
280
331
|
accounts: {
|
|
@@ -287,9 +338,9 @@ export class Admin extends ClearingHouse {
|
|
|
287
338
|
}
|
|
288
339
|
|
|
289
340
|
public async updateAmmOracleTwap(
|
|
290
|
-
marketIndex:
|
|
341
|
+
marketIndex: number
|
|
291
342
|
): Promise<TransactionSignature> {
|
|
292
|
-
const ammData = this.
|
|
343
|
+
const ammData = this.getPerpMarketAccount(marketIndex).amm;
|
|
293
344
|
const marketPublicKey = await getMarketPublicKey(
|
|
294
345
|
this.program.programId,
|
|
295
346
|
marketIndex
|
|
@@ -306,9 +357,9 @@ export class Admin extends ClearingHouse {
|
|
|
306
357
|
}
|
|
307
358
|
|
|
308
359
|
public async resetAmmOracleTwap(
|
|
309
|
-
marketIndex:
|
|
360
|
+
marketIndex: number
|
|
310
361
|
): Promise<TransactionSignature> {
|
|
311
|
-
const ammData = this.
|
|
362
|
+
const ammData = this.getPerpMarketAccount(marketIndex).amm;
|
|
312
363
|
const marketPublicKey = await getMarketPublicKey(
|
|
313
364
|
this.program.programId,
|
|
314
365
|
marketIndex
|
|
@@ -324,60 +375,22 @@ export class Admin extends ClearingHouse {
|
|
|
324
375
|
});
|
|
325
376
|
}
|
|
326
377
|
|
|
327
|
-
public async
|
|
378
|
+
public async depositIntoMarketFeePool(
|
|
379
|
+
marketIndex: number,
|
|
328
380
|
amount: BN,
|
|
329
|
-
|
|
381
|
+
sourceVault: PublicKey
|
|
330
382
|
): Promise<TransactionSignature> {
|
|
331
|
-
const
|
|
332
|
-
return await this.program.rpc.withdrawFromInsuranceVault(amount, {
|
|
333
|
-
accounts: {
|
|
334
|
-
admin: this.wallet.publicKey,
|
|
335
|
-
state: await this.getStatePublicKey(),
|
|
336
|
-
insuranceVault: state.insuranceVault,
|
|
337
|
-
insuranceVaultAuthority: state.insuranceVaultAuthority,
|
|
338
|
-
recipient: recipient,
|
|
339
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
340
|
-
},
|
|
341
|
-
});
|
|
342
|
-
}
|
|
383
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
343
384
|
|
|
344
|
-
|
|
345
|
-
marketIndex: BN,
|
|
346
|
-
amount: BN,
|
|
347
|
-
recipient: PublicKey
|
|
348
|
-
): Promise<TransactionSignature> {
|
|
349
|
-
const marketPublicKey = await getMarketPublicKey(
|
|
350
|
-
this.program.programId,
|
|
351
|
-
marketIndex
|
|
352
|
-
);
|
|
353
|
-
const bank = this.getQuoteAssetBankAccount();
|
|
354
|
-
return await this.program.rpc.withdrawFees(amount, {
|
|
355
|
-
accounts: {
|
|
356
|
-
admin: this.wallet.publicKey,
|
|
357
|
-
state: await this.getStatePublicKey(),
|
|
358
|
-
market: marketPublicKey,
|
|
359
|
-
bank: bank.pubkey,
|
|
360
|
-
bankVault: bank.vault,
|
|
361
|
-
bankVaultAuthority: bank.vaultAuthority,
|
|
362
|
-
recipient: recipient,
|
|
363
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
|
364
|
-
},
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
public async withdrawFromInsuranceVaultToMarket(
|
|
369
|
-
marketIndex: BN,
|
|
370
|
-
amount: BN
|
|
371
|
-
): Promise<TransactionSignature> {
|
|
372
|
-
const state = await this.getStateAccount();
|
|
373
|
-
return await this.program.rpc.withdrawFromInsuranceVaultToMarket(amount, {
|
|
385
|
+
return await this.program.rpc.depositIntoMarketFeePool(amount, {
|
|
374
386
|
accounts: {
|
|
375
387
|
admin: this.wallet.publicKey,
|
|
376
388
|
state: await this.getStatePublicKey(),
|
|
377
389
|
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
390
|
+
sourceVault,
|
|
391
|
+
clearingHouseSigner: this.getSignerPublicKey(),
|
|
392
|
+
quoteSpotMarket: spotMarket.pubkey,
|
|
393
|
+
spotMarketVault: spotMarket.vault,
|
|
381
394
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
382
395
|
},
|
|
383
396
|
});
|
|
@@ -393,7 +406,7 @@ export class Admin extends ClearingHouse {
|
|
|
393
406
|
}
|
|
394
407
|
|
|
395
408
|
public async updateCurveUpdateIntensity(
|
|
396
|
-
marketIndex:
|
|
409
|
+
marketIndex: number,
|
|
397
410
|
curveUpdateIntensity: number
|
|
398
411
|
): Promise<TransactionSignature> {
|
|
399
412
|
// assert(curveUpdateIntensity >= 0 && curveUpdateIntensity <= 100);
|
|
@@ -412,14 +425,12 @@ export class Admin extends ClearingHouse {
|
|
|
412
425
|
}
|
|
413
426
|
|
|
414
427
|
public async updateMarginRatio(
|
|
415
|
-
marketIndex:
|
|
428
|
+
marketIndex: number,
|
|
416
429
|
marginRatioInitial: number,
|
|
417
|
-
marginRatioPartial: number,
|
|
418
430
|
marginRatioMaintenance: number
|
|
419
431
|
): Promise<TransactionSignature> {
|
|
420
432
|
return await this.program.rpc.updateMarginRatio(
|
|
421
433
|
marginRatioInitial,
|
|
422
|
-
marginRatioPartial,
|
|
423
434
|
marginRatioMaintenance,
|
|
424
435
|
{
|
|
425
436
|
accounts: {
|
|
@@ -432,7 +443,7 @@ export class Admin extends ClearingHouse {
|
|
|
432
443
|
}
|
|
433
444
|
|
|
434
445
|
public async updateMarketBaseSpread(
|
|
435
|
-
marketIndex:
|
|
446
|
+
marketIndex: number,
|
|
436
447
|
baseSpread: number
|
|
437
448
|
): Promise<TransactionSignature> {
|
|
438
449
|
return await this.program.rpc.updateMarketBaseSpread(baseSpread, {
|
|
@@ -444,8 +455,21 @@ export class Admin extends ClearingHouse {
|
|
|
444
455
|
});
|
|
445
456
|
}
|
|
446
457
|
|
|
458
|
+
public async updateAmmJitIntensity(
|
|
459
|
+
marketIndex: number,
|
|
460
|
+
ammJitIntensity: number
|
|
461
|
+
): Promise<TransactionSignature> {
|
|
462
|
+
return await this.program.rpc.updateAmmJitIntensity(ammJitIntensity, {
|
|
463
|
+
accounts: {
|
|
464
|
+
admin: this.wallet.publicKey,
|
|
465
|
+
state: await this.getStatePublicKey(),
|
|
466
|
+
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
|
|
447
471
|
public async updateMarketMaxSpread(
|
|
448
|
-
marketIndex:
|
|
472
|
+
marketIndex: number,
|
|
449
473
|
maxSpread: number
|
|
450
474
|
): Promise<TransactionSignature> {
|
|
451
475
|
return await this.program.rpc.updateMarketMaxSpread(maxSpread, {
|
|
@@ -533,22 +557,21 @@ export class Admin extends ClearingHouse {
|
|
|
533
557
|
);
|
|
534
558
|
}
|
|
535
559
|
|
|
536
|
-
public async
|
|
537
|
-
|
|
560
|
+
public async updatePerpFeeStructure(
|
|
561
|
+
feeStructure: FeeStructure
|
|
538
562
|
): Promise<TransactionSignature> {
|
|
539
|
-
return await this.program.rpc.
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
},
|
|
546
|
-
}
|
|
547
|
-
);
|
|
563
|
+
return await this.program.rpc.updatePerpFeeStructure(feeStructure, {
|
|
564
|
+
accounts: {
|
|
565
|
+
admin: this.wallet.publicKey,
|
|
566
|
+
state: await this.getStatePublicKey(),
|
|
567
|
+
},
|
|
568
|
+
});
|
|
548
569
|
}
|
|
549
570
|
|
|
550
|
-
public async
|
|
551
|
-
|
|
571
|
+
public async updateSpotFeeStructure(
|
|
572
|
+
feeStructure: FeeStructure
|
|
573
|
+
): Promise<TransactionSignature> {
|
|
574
|
+
return await this.program.rpc.updateSpotFeeStructure(feeStructure, {
|
|
552
575
|
accounts: {
|
|
553
576
|
admin: this.wallet.publicKey,
|
|
554
577
|
state: await this.getStatePublicKey(),
|
|
@@ -567,8 +590,100 @@ export class Admin extends ClearingHouse {
|
|
|
567
590
|
});
|
|
568
591
|
}
|
|
569
592
|
|
|
593
|
+
public async updateWithdrawGuardThreshold(
|
|
594
|
+
marketIndex: number,
|
|
595
|
+
withdrawGuardThreshold: BN
|
|
596
|
+
): Promise<TransactionSignature> {
|
|
597
|
+
return await this.program.rpc.updateWithdrawGuardThreshold(
|
|
598
|
+
withdrawGuardThreshold,
|
|
599
|
+
{
|
|
600
|
+
accounts: {
|
|
601
|
+
admin: this.wallet.publicKey,
|
|
602
|
+
state: await this.getStatePublicKey(),
|
|
603
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
604
|
+
this.program.programId,
|
|
605
|
+
marketIndex
|
|
606
|
+
),
|
|
607
|
+
},
|
|
608
|
+
}
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
public async updateSpotMarketIfFactor(
|
|
613
|
+
marketIndex: number,
|
|
614
|
+
userIfFactor: BN,
|
|
615
|
+
totalIfFactor: BN
|
|
616
|
+
): Promise<TransactionSignature> {
|
|
617
|
+
return await this.program.rpc.updateSpotMarketIfFactor(
|
|
618
|
+
marketIndex,
|
|
619
|
+
userIfFactor,
|
|
620
|
+
totalIfFactor,
|
|
621
|
+
{
|
|
622
|
+
accounts: {
|
|
623
|
+
admin: this.wallet.publicKey,
|
|
624
|
+
state: await this.getStatePublicKey(),
|
|
625
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
626
|
+
this.program.programId,
|
|
627
|
+
marketIndex
|
|
628
|
+
),
|
|
629
|
+
},
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
public async updateSpotMarketRevenueSettlePeriod(
|
|
635
|
+
marketIndex: number,
|
|
636
|
+
revenueSettlePeriod: BN
|
|
637
|
+
): Promise<TransactionSignature> {
|
|
638
|
+
return await this.program.rpc.updateSpotMarketRevenueSettlePeriod(
|
|
639
|
+
revenueSettlePeriod,
|
|
640
|
+
{
|
|
641
|
+
accounts: {
|
|
642
|
+
admin: this.wallet.publicKey,
|
|
643
|
+
state: await this.getStatePublicKey(),
|
|
644
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
645
|
+
this.program.programId,
|
|
646
|
+
marketIndex
|
|
647
|
+
),
|
|
648
|
+
},
|
|
649
|
+
}
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
public async updateInsuranceWithdrawEscrowPeriod(
|
|
654
|
+
marketIndex: number,
|
|
655
|
+
insuranceWithdrawEscrowPeriod: BN
|
|
656
|
+
): Promise<TransactionSignature> {
|
|
657
|
+
return await this.program.rpc.updateInsuranceWithdrawEscrowPeriod(
|
|
658
|
+
insuranceWithdrawEscrowPeriod,
|
|
659
|
+
{
|
|
660
|
+
accounts: {
|
|
661
|
+
admin: this.wallet.publicKey,
|
|
662
|
+
state: await this.getStatePublicKey(),
|
|
663
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
664
|
+
this.program.programId,
|
|
665
|
+
marketIndex
|
|
666
|
+
),
|
|
667
|
+
},
|
|
668
|
+
}
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
public async updateLpCooldownTime(
|
|
673
|
+
marketIndex: number,
|
|
674
|
+
cooldownTime: BN
|
|
675
|
+
): Promise<TransactionSignature> {
|
|
676
|
+
return await this.program.rpc.updateLpCooldownTime(cooldownTime, {
|
|
677
|
+
accounts: {
|
|
678
|
+
admin: this.wallet.publicKey,
|
|
679
|
+
state: await this.getStatePublicKey(),
|
|
680
|
+
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
681
|
+
},
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
|
|
570
685
|
public async updateMarketOracle(
|
|
571
|
-
marketIndex:
|
|
686
|
+
marketIndex: number,
|
|
572
687
|
oracle: PublicKey,
|
|
573
688
|
oracleSource: OracleSource
|
|
574
689
|
): Promise<TransactionSignature> {
|
|
@@ -582,7 +697,7 @@ export class Admin extends ClearingHouse {
|
|
|
582
697
|
}
|
|
583
698
|
|
|
584
699
|
public async updateMarketMinimumQuoteAssetTradeSize(
|
|
585
|
-
marketIndex:
|
|
700
|
+
marketIndex: number,
|
|
586
701
|
minimumTradeSize: BN
|
|
587
702
|
): Promise<TransactionSignature> {
|
|
588
703
|
return await this.program.rpc.updateMarketMinimumQuoteAssetTradeSize(
|
|
@@ -598,7 +713,7 @@ export class Admin extends ClearingHouse {
|
|
|
598
713
|
}
|
|
599
714
|
|
|
600
715
|
public async updateMarketBaseAssetAmountStepSize(
|
|
601
|
-
marketIndex:
|
|
716
|
+
marketIndex: number,
|
|
602
717
|
stepSize: BN
|
|
603
718
|
): Promise<TransactionSignature> {
|
|
604
719
|
return await this.program.rpc.updateMarketBaseAssetAmountStepSize(
|
|
@@ -613,6 +728,22 @@ export class Admin extends ClearingHouse {
|
|
|
613
728
|
);
|
|
614
729
|
}
|
|
615
730
|
|
|
731
|
+
public async updateMarketExpiry(
|
|
732
|
+
perpMarketIndex: number,
|
|
733
|
+
expiryTs: BN
|
|
734
|
+
): Promise<TransactionSignature> {
|
|
735
|
+
return await this.program.rpc.updateMarketExpiry(expiryTs, {
|
|
736
|
+
accounts: {
|
|
737
|
+
admin: this.wallet.publicKey,
|
|
738
|
+
state: await this.getStatePublicKey(),
|
|
739
|
+
perpMarket: await getMarketPublicKey(
|
|
740
|
+
this.program.programId,
|
|
741
|
+
perpMarketIndex
|
|
742
|
+
),
|
|
743
|
+
},
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
|
|
616
747
|
public async updateWhitelistMint(
|
|
617
748
|
whitelistMint?: PublicKey
|
|
618
749
|
): Promise<TransactionSignature> {
|
|
@@ -654,7 +785,6 @@ export class Admin extends ClearingHouse {
|
|
|
654
785
|
},
|
|
655
786
|
});
|
|
656
787
|
}
|
|
657
|
-
|
|
658
788
|
public async updateExchangePaused(
|
|
659
789
|
exchangePaused: boolean
|
|
660
790
|
): Promise<TransactionSignature> {
|
|
@@ -675,11 +805,11 @@ export class Admin extends ClearingHouse {
|
|
|
675
805
|
});
|
|
676
806
|
}
|
|
677
807
|
|
|
678
|
-
public async
|
|
679
|
-
|
|
808
|
+
public async updatePerpAuctionDuration(
|
|
809
|
+
minDuration: BN | number
|
|
680
810
|
): Promise<TransactionSignature> {
|
|
681
|
-
return await this.program.rpc.
|
|
682
|
-
typeof
|
|
811
|
+
return await this.program.rpc.updatePerpAuctionDuration(
|
|
812
|
+
typeof minDuration === 'number' ? minDuration : minDuration.toNumber(),
|
|
683
813
|
{
|
|
684
814
|
accounts: {
|
|
685
815
|
admin: this.wallet.publicKey,
|
|
@@ -688,4 +818,79 @@ export class Admin extends ClearingHouse {
|
|
|
688
818
|
}
|
|
689
819
|
);
|
|
690
820
|
}
|
|
821
|
+
|
|
822
|
+
public async updateSpotAuctionDuration(
|
|
823
|
+
defaultAuctionDuration: number
|
|
824
|
+
): Promise<TransactionSignature> {
|
|
825
|
+
return await this.program.rpc.updateSpotAuctionDuration(
|
|
826
|
+
defaultAuctionDuration,
|
|
827
|
+
{
|
|
828
|
+
accounts: {
|
|
829
|
+
admin: this.wallet.publicKey,
|
|
830
|
+
state: await this.getStatePublicKey(),
|
|
831
|
+
},
|
|
832
|
+
}
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
public async updateMaxBaseAssetAmountRatio(
|
|
837
|
+
marketIndex: number,
|
|
838
|
+
maxBaseAssetAmountRatio: number
|
|
839
|
+
): Promise<TransactionSignature> {
|
|
840
|
+
return await this.program.rpc.updateMaxBaseAssetAmountRatio(
|
|
841
|
+
maxBaseAssetAmountRatio,
|
|
842
|
+
{
|
|
843
|
+
accounts: {
|
|
844
|
+
admin: this.wallet.publicKey,
|
|
845
|
+
state: await this.getStatePublicKey(),
|
|
846
|
+
market: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
847
|
+
},
|
|
848
|
+
}
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
public async updateMaxSlippageRatio(
|
|
853
|
+
marketIndex: number,
|
|
854
|
+
maxSlippageRatio: number
|
|
855
|
+
): Promise<TransactionSignature> {
|
|
856
|
+
return await this.program.rpc.updateMaxSlippageRatio(maxSlippageRatio, {
|
|
857
|
+
accounts: {
|
|
858
|
+
admin: this.wallet.publicKey,
|
|
859
|
+
state: await this.getStatePublicKey(),
|
|
860
|
+
market: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
861
|
+
},
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
public async updateMarketMaxImbalances(
|
|
866
|
+
marketIndex: number,
|
|
867
|
+
unrealizedMaxImbalance: BN,
|
|
868
|
+
maxRevenueWithdrawPerPeriod: BN,
|
|
869
|
+
quoteMaxInsurance: BN
|
|
870
|
+
): Promise<TransactionSignature> {
|
|
871
|
+
return await this.program.rpc.updateMarketMaxImbalances(
|
|
872
|
+
unrealizedMaxImbalance,
|
|
873
|
+
maxRevenueWithdrawPerPeriod,
|
|
874
|
+
quoteMaxInsurance,
|
|
875
|
+
{
|
|
876
|
+
accounts: {
|
|
877
|
+
admin: this.wallet.publicKey,
|
|
878
|
+
state: await this.getStatePublicKey(),
|
|
879
|
+
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
880
|
+
},
|
|
881
|
+
}
|
|
882
|
+
);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
public async updateSerumVault(
|
|
886
|
+
srmVault: PublicKey
|
|
887
|
+
): Promise<TransactionSignature> {
|
|
888
|
+
return await this.program.rpc.updateSerumVault({
|
|
889
|
+
accounts: {
|
|
890
|
+
admin: this.wallet.publicKey,
|
|
891
|
+
state: await this.getStatePublicKey(),
|
|
892
|
+
srmVault: srmVault,
|
|
893
|
+
},
|
|
894
|
+
});
|
|
895
|
+
}
|
|
691
896
|
}
|