@drift-labs/sdk 0.2.0-master.25 → 0.2.0-master.26
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/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +13 -13
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +27 -27
- package/lib/accounts/types.d.ts +8 -9
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +14 -14
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +35 -34
- package/lib/addresses/pda.d.ts +7 -6
- package/lib/addresses/pda.js +31 -27
- package/lib/admin.d.ts +9 -6
- package/lib/admin.js +83 -42
- package/lib/clearingHouse.d.ts +69 -42
- package/lib/clearingHouse.js +753 -277
- package/lib/clearingHouseConfig.d.ts +2 -2
- package/lib/clearingHouseUser.d.ts +16 -16
- package/lib/clearingHouseUser.js +139 -119
- package/lib/config.d.ts +7 -7
- package/lib/config.js +20 -20
- package/lib/constants/numericConstants.d.ts +12 -12
- package/lib/constants/numericConstants.js +13 -13
- package/lib/constants/{markets.d.ts → perpMarkets.d.ts} +5 -5
- package/{src/constants/markets.js → lib/constants/perpMarkets.js} +4 -4
- package/lib/constants/{banks.d.ts → spotMarkets.d.ts} +6 -6
- package/lib/constants/{banks.js → spotMarkets.js} +16 -16
- package/lib/events/types.d.ts +2 -1
- package/lib/events/types.js +1 -0
- package/lib/examples/makeTradeExample.js +7 -7
- package/lib/idl/clearing_house.json +1008 -279
- package/lib/index.d.ts +5 -3
- package/lib/index.js +5 -3
- package/lib/math/amm.d.ts +2 -2
- package/lib/math/amm.js +1 -1
- package/lib/math/funding.d.ts +6 -6
- package/lib/math/funding.js +2 -1
- package/lib/math/margin.d.ts +4 -4
- package/lib/math/margin.js +18 -11
- package/lib/math/market.d.ts +10 -9
- package/lib/math/market.js +29 -6
- package/lib/math/oracles.d.ts +2 -1
- package/lib/math/oracles.js +11 -1
- package/lib/math/orders.d.ts +5 -5
- package/lib/math/position.d.ts +13 -13
- package/lib/math/position.js +19 -19
- package/lib/math/spotBalance.d.ts +19 -0
- package/lib/math/spotBalance.js +176 -0
- package/lib/math/spotMarket.d.ts +4 -0
- package/lib/math/spotMarket.js +8 -0
- package/lib/math/spotPosition.d.ts +2 -0
- package/lib/math/spotPosition.js +8 -0
- package/lib/math/state.js +2 -2
- package/lib/math/trade.d.ts +4 -4
- package/lib/orderParams.d.ts +4 -4
- package/lib/orderParams.js +12 -4
- 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/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/retryTxSender.js +4 -2
- package/lib/tx/types.d.ts +1 -1
- package/lib/types.d.ts +123 -33
- package/lib/types.js +31 -9
- package/my-script/.env +7 -0
- package/my-script/getUserStats.ts +106 -0
- package/my-script/multiConnections.ts +119 -0
- package/my-script/test-regex.ts +11 -0
- package/my-script/utils.ts +52 -0
- package/package.json +1 -1
- package/src/accounts/bulkAccountLoader.js +249 -0
- package/src/accounts/bulkUserStatsSubscription.js +75 -0
- package/src/accounts/bulkUserSubscription.js +75 -0
- package/src/accounts/fetch.js +92 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.js +465 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +38 -38
- package/src/accounts/pollingOracleSubscriber.js +156 -0
- package/src/accounts/pollingTokenAccountSubscriber.js +141 -0
- package/src/accounts/pollingUserAccountSubscriber.js +208 -0
- package/src/accounts/pollingUserStatsAccountSubscriber.js +208 -0
- package/src/accounts/types.js +28 -0
- package/src/accounts/types.ts +11 -9
- package/src/accounts/utils.js +7 -0
- package/src/accounts/webSocketAccountSubscriber.js +138 -0
- package/src/accounts/webSocketClearingHouseAccountSubscriber.js +433 -0
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +59 -52
- package/src/accounts/webSocketUserAccountSubscriber.js +113 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.js +113 -0
- package/src/addresses/pda.js +186 -0
- package/src/addresses/pda.ts +49 -44
- package/src/admin.js +1284 -0
- package/src/admin.ts +140 -47
- package/src/assert/assert.js +1 -1
- package/src/clearingHouse.js +3433 -0
- package/src/clearingHouse.ts +1083 -378
- package/src/clearingHouseConfig.js +2 -0
- package/src/clearingHouseConfig.ts +2 -2
- package/src/clearingHouseUser.js +874 -0
- package/src/clearingHouseUser.ts +232 -168
- package/src/clearingHouseUserConfig.js +2 -0
- package/src/clearingHouseUserStats.js +115 -0
- package/src/clearingHouseUserStatsConfig.js +2 -0
- package/src/config.js +80 -0
- package/src/config.ts +29 -29
- package/src/constants/numericConstants.js +18 -11
- package/src/constants/numericConstants.ts +17 -15
- package/{lib/constants/markets.js → src/constants/perpMarkets.js} +11 -11
- package/src/constants/{markets.ts → perpMarkets.ts} +5 -5
- package/src/constants/spotMarkets.js +51 -0
- package/src/constants/{banks.ts → spotMarkets.ts} +19 -19
- package/src/events/eventList.js +66 -23
- package/src/events/eventSubscriber.js +202 -0
- package/src/events/fetchLogs.js +117 -0
- package/src/events/pollingLogProvider.js +113 -0
- package/src/events/sort.js +41 -0
- package/src/events/txEventCache.js +22 -19
- package/src/events/types.js +25 -0
- package/src/events/types.ts +3 -0
- package/src/events/webSocketLogProvider.js +76 -0
- package/src/examples/makeTradeExample.ts +10 -8
- package/src/factory/bigNum.js +183 -180
- package/src/factory/oracleClient.js +9 -9
- package/src/idl/clearing_house.json +1008 -279
- package/src/index.js +75 -0
- package/src/index.ts +5 -3
- package/src/math/amm.js +422 -0
- package/src/math/amm.ts +6 -3
- package/src/math/auction.js +10 -10
- package/src/math/conversion.js +4 -3
- package/src/math/funding.js +223 -175
- package/src/math/funding.ts +7 -7
- package/src/math/insurance.js +27 -0
- package/src/math/margin.js +77 -0
- package/src/math/margin.ts +34 -23
- package/src/math/market.js +105 -0
- package/src/math/market.ts +71 -19
- package/src/math/oracles.js +40 -10
- package/src/math/oracles.ts +18 -1
- package/src/math/orders.js +153 -0
- package/src/math/orders.ts +5 -5
- package/src/math/position.js +172 -0
- package/src/math/position.ts +31 -31
- package/src/math/repeg.js +40 -40
- package/src/math/spotBalance.js +176 -0
- package/src/math/spotBalance.ts +290 -0
- package/src/math/spotMarket.js +8 -0
- package/src/math/spotMarket.ts +9 -0
- package/src/math/spotPosition.js +8 -0
- package/src/math/spotPosition.ts +6 -0
- package/src/math/state.ts +2 -2
- package/src/math/trade.js +81 -74
- package/src/math/trade.ts +4 -4
- package/src/math/utils.js +8 -7
- package/src/oracles/oracleClientCache.js +10 -9
- package/src/oracles/pythClient.js +52 -17
- package/src/oracles/quoteAssetOracleClient.js +44 -13
- package/src/oracles/switchboardClient.js +69 -37
- package/src/oracles/types.js +1 -1
- package/src/orderParams.js +14 -6
- package/src/orderParams.ts +16 -8
- package/src/serum/serumSubscriber.js +102 -0
- package/src/serum/serumSubscriber.ts +80 -0
- package/src/serum/types.js +2 -0
- package/src/serum/types.ts +13 -0
- package/src/slot/SlotSubscriber.js +67 -20
- package/src/token/index.js +4 -4
- package/src/tokenFaucet.js +288 -154
- package/src/tx/retryTxSender.js +280 -0
- package/src/tx/retryTxSender.ts +5 -2
- package/src/tx/types.js +1 -1
- package/src/tx/types.ts +2 -1
- package/src/tx/utils.js +7 -6
- package/src/types.js +216 -0
- package/src/types.ts +110 -33
- package/src/userName.js +5 -5
- package/src/util/computeUnits.js +46 -11
- package/src/util/promiseTimeout.js +5 -5
- package/src/util/tps.js +46 -12
- package/src/wallet.js +55 -18
- package/lib/math/bankBalance.d.ts +0 -15
- package/lib/math/bankBalance.js +0 -150
- package/src/addresses/marketAddresses.js +0 -26
- package/src/constants/banks.js +0 -42
- package/src/examples/makeTradeExample.js +0 -80
- package/src/math/bankBalance.ts +0 -258
- package/src/math/state.js +0 -15
- package/src/math/utils.js.map +0 -1
- package/src/util/getTokenAddress.js +0 -9
package/lib/admin.js
CHANGED
|
@@ -29,6 +29,7 @@ const types_1 = require("./types");
|
|
|
29
29
|
const anchor_1 = require("@project-serum/anchor");
|
|
30
30
|
const anchor = __importStar(require("@project-serum/anchor"));
|
|
31
31
|
const pda_1 = require("./addresses/pda");
|
|
32
|
+
const utils_1 = require("./math/utils");
|
|
32
33
|
const spl_token_1 = require("@solana/spl-token");
|
|
33
34
|
const clearingHouse_1 = require("./clearingHouse");
|
|
34
35
|
const numericConstants_1 = require("./constants/numericConstants");
|
|
@@ -57,20 +58,20 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
57
58
|
const { txSig: initializeTxSig } = await this.txSender.send(initializeTx, [], this.opts);
|
|
58
59
|
return [initializeTxSig];
|
|
59
60
|
}
|
|
60
|
-
async
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const insuranceFundVault = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId,
|
|
65
|
-
const initializeTx = await this.program.transaction.
|
|
61
|
+
async initializeSpotMarket(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = new anchor_1.BN(0), liquidationFee = numericConstants_1.ZERO) {
|
|
62
|
+
const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
|
|
63
|
+
const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
|
|
64
|
+
const spotMarketVault = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, spotMarketIndex);
|
|
65
|
+
const insuranceFundVault = await (0, pda_1.getInsuranceFundVaultPublicKey)(this.program.programId, spotMarketIndex);
|
|
66
|
+
const initializeTx = await this.program.transaction.initializeSpotMarket(optimalUtilization, optimalRate, maxRate, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidationFee, {
|
|
66
67
|
accounts: {
|
|
67
68
|
admin: this.wallet.publicKey,
|
|
68
69
|
state: await this.getStatePublicKey(),
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
spotMarket,
|
|
71
|
+
spotMarketVault,
|
|
71
72
|
insuranceFundVault,
|
|
72
73
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
73
|
-
|
|
74
|
+
spotMarketMint: mint,
|
|
74
75
|
oracle,
|
|
75
76
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
76
77
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
@@ -78,13 +79,32 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
78
79
|
},
|
|
79
80
|
});
|
|
80
81
|
const { txSig } = await this.txSender.send(initializeTx, [], this.opts);
|
|
81
|
-
await this.accountSubscriber.
|
|
82
|
+
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
82
83
|
await this.accountSubscriber.addOracle({
|
|
83
84
|
source: oracleSource,
|
|
84
85
|
publicKey: oracle,
|
|
85
86
|
});
|
|
86
87
|
return txSig;
|
|
87
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
|
+
clearingHouseSigner: 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
|
+
}
|
|
88
108
|
async initializeMarket(priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidationFee = numericConstants_1.ZERO) {
|
|
89
109
|
const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, this.getStateAccount().numberOfMarkets);
|
|
90
110
|
const initializeMarketTx = await this.program.transaction.initializeMarket(baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidationFee, {
|
|
@@ -98,20 +118,23 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
98
118
|
},
|
|
99
119
|
});
|
|
100
120
|
const { txSig } = await this.txSender.send(initializeMarketTx, [], this.opts);
|
|
101
|
-
await this.accountSubscriber.
|
|
121
|
+
await this.accountSubscriber.addPerpMarket(this.getStateAccount().numberOfMarkets);
|
|
102
122
|
await this.accountSubscriber.addOracle({
|
|
103
123
|
source: oracleSource,
|
|
104
124
|
publicKey: priceOracle,
|
|
105
125
|
});
|
|
106
126
|
return txSig;
|
|
107
127
|
}
|
|
108
|
-
async moveAmmPrice(baseAssetReserve, quoteAssetReserve,
|
|
128
|
+
async moveAmmPrice(marketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
|
|
109
129
|
const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
|
|
110
|
-
|
|
130
|
+
if (sqrtK == undefined) {
|
|
131
|
+
sqrtK = (0, utils_1.squareRootBN)(baseAssetReserve.mul(quoteAssetReserve));
|
|
132
|
+
}
|
|
133
|
+
return await this.program.rpc.moveAmmPrice(baseAssetReserve, quoteAssetReserve, sqrtK, {
|
|
111
134
|
accounts: {
|
|
112
135
|
state: await this.getStatePublicKey(),
|
|
113
136
|
admin: this.wallet.publicKey,
|
|
114
|
-
|
|
137
|
+
perpMarket: marketPublicKey,
|
|
115
138
|
},
|
|
116
139
|
});
|
|
117
140
|
}
|
|
@@ -121,27 +144,27 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
121
144
|
state: await this.getStatePublicKey(),
|
|
122
145
|
admin: this.wallet.publicKey,
|
|
123
146
|
market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
|
|
124
|
-
oracle: this.
|
|
147
|
+
oracle: this.getPerpMarketAccount(marketIndex).amm.oracle,
|
|
125
148
|
},
|
|
126
149
|
});
|
|
127
150
|
}
|
|
128
|
-
async moveAmmToPrice(
|
|
129
|
-
const market = this.
|
|
151
|
+
async moveAmmToPrice(perpMarketIndex, targetPrice) {
|
|
152
|
+
const market = this.getPerpMarketAccount(perpMarketIndex);
|
|
130
153
|
const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(market, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
|
|
131
154
|
);
|
|
132
155
|
const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(market.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
|
|
133
|
-
const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId,
|
|
134
|
-
return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, {
|
|
156
|
+
const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
157
|
+
return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, market.amm.sqrtK, {
|
|
135
158
|
accounts: {
|
|
136
159
|
state: await this.getStatePublicKey(),
|
|
137
160
|
admin: this.wallet.publicKey,
|
|
138
|
-
|
|
161
|
+
perpMarket: marketPublicKey,
|
|
139
162
|
},
|
|
140
163
|
});
|
|
141
164
|
}
|
|
142
165
|
async repegAmmCurve(newPeg, marketIndex) {
|
|
143
166
|
const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
|
|
144
|
-
const ammData = this.
|
|
167
|
+
const ammData = this.getPerpMarketAccount(marketIndex).amm;
|
|
145
168
|
return await this.program.rpc.repegAmmCurve(newPeg, {
|
|
146
169
|
accounts: {
|
|
147
170
|
state: await this.getStatePublicKey(),
|
|
@@ -152,7 +175,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
152
175
|
});
|
|
153
176
|
}
|
|
154
177
|
async updateAmmOracleTwap(marketIndex) {
|
|
155
|
-
const ammData = this.
|
|
178
|
+
const ammData = this.getPerpMarketAccount(marketIndex).amm;
|
|
156
179
|
const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
|
|
157
180
|
return await this.program.rpc.updateAmmOracleTwap({
|
|
158
181
|
accounts: {
|
|
@@ -164,7 +187,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
164
187
|
});
|
|
165
188
|
}
|
|
166
189
|
async resetAmmOracleTwap(marketIndex) {
|
|
167
|
-
const ammData = this.
|
|
190
|
+
const ammData = this.getPerpMarketAccount(marketIndex).amm;
|
|
168
191
|
const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
|
|
169
192
|
return await this.program.rpc.resetAmmOracleTwap({
|
|
170
193
|
accounts: {
|
|
@@ -177,12 +200,12 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
177
200
|
}
|
|
178
201
|
async withdrawFromInsuranceVault(amount, recipient) {
|
|
179
202
|
const state = await this.getStateAccount();
|
|
180
|
-
const
|
|
203
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
181
204
|
return await this.program.rpc.withdrawFromInsuranceVault(amount, {
|
|
182
205
|
accounts: {
|
|
183
206
|
admin: this.wallet.publicKey,
|
|
184
207
|
state: await this.getStatePublicKey(),
|
|
185
|
-
|
|
208
|
+
spotMarket: spotMarket.pubkey,
|
|
186
209
|
insuranceVault: state.insuranceVault,
|
|
187
210
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
188
211
|
recipient: recipient,
|
|
@@ -192,14 +215,14 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
192
215
|
}
|
|
193
216
|
async withdrawFromMarketToInsuranceVault(marketIndex, amount, recipient) {
|
|
194
217
|
const marketPublicKey = await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex);
|
|
195
|
-
const
|
|
218
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
196
219
|
return await this.program.rpc.withdrawFromMarketToInsuranceVault(amount, {
|
|
197
220
|
accounts: {
|
|
198
221
|
admin: this.wallet.publicKey,
|
|
199
222
|
state: await this.getStatePublicKey(),
|
|
200
223
|
market: marketPublicKey,
|
|
201
|
-
|
|
202
|
-
|
|
224
|
+
spotMarket: spotMarket.pubkey,
|
|
225
|
+
spotMarketVault: spotMarket.vault,
|
|
203
226
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
204
227
|
recipient: recipient,
|
|
205
228
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -208,7 +231,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
208
231
|
}
|
|
209
232
|
async withdrawFromInsuranceVaultToMarket(marketIndex, amount) {
|
|
210
233
|
const state = await this.getStateAccount();
|
|
211
|
-
const
|
|
234
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
212
235
|
return await this.program.rpc.withdrawFromInsuranceVaultToMarket(amount, {
|
|
213
236
|
accounts: {
|
|
214
237
|
admin: this.wallet.publicKey,
|
|
@@ -216,8 +239,8 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
216
239
|
market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
|
|
217
240
|
insuranceVault: state.insuranceVault,
|
|
218
241
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
219
|
-
|
|
220
|
-
|
|
242
|
+
quoteSpotMarket: spotMarket.pubkey,
|
|
243
|
+
spotMarketVault: spotMarket.vault,
|
|
221
244
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
222
245
|
},
|
|
223
246
|
});
|
|
@@ -341,30 +364,30 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
341
364
|
},
|
|
342
365
|
});
|
|
343
366
|
}
|
|
344
|
-
async
|
|
345
|
-
return await this.program.rpc.
|
|
367
|
+
async updateWithdrawGuardThreshold(marketIndex, withdrawGuardThreshold) {
|
|
368
|
+
return await this.program.rpc.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
|
|
346
369
|
accounts: {
|
|
347
370
|
admin: this.wallet.publicKey,
|
|
348
371
|
state: await this.getStatePublicKey(),
|
|
349
|
-
|
|
372
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
|
|
350
373
|
},
|
|
351
374
|
});
|
|
352
375
|
}
|
|
353
|
-
async
|
|
354
|
-
return await this.program.rpc.
|
|
376
|
+
async updateSpotMarketIfFactor(marketIndex, userIfFactor, totalIfFactor, liquidationIfFactor) {
|
|
377
|
+
return await this.program.rpc.updateSpotMarketIfFactor(marketIndex, userIfFactor, totalIfFactor, liquidationIfFactor, {
|
|
355
378
|
accounts: {
|
|
356
379
|
admin: this.wallet.publicKey,
|
|
357
380
|
state: await this.getStatePublicKey(),
|
|
358
|
-
|
|
381
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
|
|
359
382
|
},
|
|
360
383
|
});
|
|
361
384
|
}
|
|
362
|
-
async
|
|
363
|
-
return await this.program.rpc.
|
|
385
|
+
async updateInsuranceWithdrawEscrowPeriod(marketIndex, insuranceWithdrawEscrowPeriod) {
|
|
386
|
+
return await this.program.rpc.updateInsuranceWithdrawEscrowPeriod(insuranceWithdrawEscrowPeriod, {
|
|
364
387
|
accounts: {
|
|
365
388
|
admin: this.wallet.publicKey,
|
|
366
389
|
state: await this.getStatePublicKey(),
|
|
367
|
-
|
|
390
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
|
|
368
391
|
},
|
|
369
392
|
});
|
|
370
393
|
}
|
|
@@ -404,6 +427,15 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
404
427
|
},
|
|
405
428
|
});
|
|
406
429
|
}
|
|
430
|
+
async updateMarketExpiry(perpMarketIndex, expiryTs) {
|
|
431
|
+
return await this.program.rpc.updateMarketExpiry(expiryTs, {
|
|
432
|
+
accounts: {
|
|
433
|
+
admin: this.wallet.publicKey,
|
|
434
|
+
state: await this.getStatePublicKey(),
|
|
435
|
+
perpMarket: await (0, pda_1.getMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
}
|
|
407
439
|
async updateWhitelistMint(whitelistMint) {
|
|
408
440
|
return await this.program.rpc.updateWhitelistMint(whitelistMint, {
|
|
409
441
|
accounts: {
|
|
@@ -465,7 +497,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
465
497
|
accounts: {
|
|
466
498
|
admin: this.wallet.publicKey,
|
|
467
499
|
state: await this.getStatePublicKey(),
|
|
468
|
-
market: this.
|
|
500
|
+
market: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
469
501
|
},
|
|
470
502
|
});
|
|
471
503
|
}
|
|
@@ -474,7 +506,16 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
474
506
|
accounts: {
|
|
475
507
|
admin: this.wallet.publicKey,
|
|
476
508
|
state: await this.getStatePublicKey(),
|
|
477
|
-
market: this.
|
|
509
|
+
market: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
510
|
+
},
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
async updateMarketMaxImbalances(marketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
|
|
514
|
+
return await this.program.rpc.updateMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
|
|
515
|
+
accounts: {
|
|
516
|
+
admin: this.wallet.publicKey,
|
|
517
|
+
state: await this.getStatePublicKey(),
|
|
518
|
+
market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
|
|
478
519
|
},
|
|
479
520
|
});
|
|
480
521
|
}
|
package/lib/clearingHouse.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="bn.js" />
|
|
3
3
|
import { AnchorProvider, BN, Program } from '@project-serum/anchor';
|
|
4
|
-
import { StateAccount, IWallet, PositionDirection, UserAccount,
|
|
5
|
-
import { Connection, PublicKey, TransactionSignature, ConfirmOptions, TransactionInstruction, AccountMeta } from '@solana/web3.js';
|
|
4
|
+
import { StateAccount, IWallet, PositionDirection, UserAccount, PerpMarketAccount, OrderParams, Order, SpotMarketAccount, SpotPosition, MakerInfo, TakerInfo, OptionalOrderParams, ReferrerInfo, MarketType, SerumV3FulfillmentConfigAccount } from './types';
|
|
5
|
+
import { Connection, PublicKey, TransactionSignature, ConfirmOptions, Transaction, TransactionInstruction, AccountMeta } from '@solana/web3.js';
|
|
6
6
|
import { TokenFaucet } from './tokenFaucet';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
8
8
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
@@ -50,11 +50,12 @@ export declare class ClearingHouse {
|
|
|
50
50
|
signerPublicKey?: PublicKey;
|
|
51
51
|
getSignerPublicKey(): PublicKey;
|
|
52
52
|
getStateAccount(): StateAccount;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
getPerpMarketAccount(marketIndex: BN | number): PerpMarketAccount | undefined;
|
|
54
|
+
getPerpMarketAccounts(): PerpMarketAccount[];
|
|
55
|
+
getSpotMarketAccount(marketIndex: BN | number): SpotMarketAccount | undefined;
|
|
56
|
+
getQuoteSpotMarketAccount(): SpotMarketAccount;
|
|
57
57
|
getOraclePriceDataAndSlot(oraclePublicKey: PublicKey): DataAndSlot<OraclePriceData> | undefined;
|
|
58
|
+
getSerumV3FulfillmentConfig(serumMarket: PublicKey): Promise<SerumV3FulfillmentConfigAccount>;
|
|
58
59
|
/**
|
|
59
60
|
* Update the wallet to use for clearing house transactions and linked user account
|
|
60
61
|
* @param newWallet
|
|
@@ -67,6 +68,7 @@ export declare class ClearingHouse {
|
|
|
67
68
|
initializeUserAccount(userId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
|
|
68
69
|
getInitializeUserInstructions(userId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>;
|
|
69
70
|
getInitializeUserStatsIx(): Promise<TransactionInstruction>;
|
|
71
|
+
updateUserName(name: string, userId?: number): Promise<TransactionSignature>;
|
|
70
72
|
getUser(userId?: number): ClearingHouseUser;
|
|
71
73
|
getUsers(): ClearingHouseUser[];
|
|
72
74
|
getUserStats(): ClearingHouseUserStats;
|
|
@@ -75,17 +77,18 @@ export declare class ClearingHouse {
|
|
|
75
77
|
getUserAccountPublicKey(): Promise<PublicKey>;
|
|
76
78
|
getUserAccount(userId?: number): UserAccount | undefined;
|
|
77
79
|
getUserAccountAndSlot(userId?: number): DataAndSlot<UserAccount> | undefined;
|
|
78
|
-
|
|
80
|
+
getSpotPosition(marketIndex: number | BN): SpotPosition | undefined;
|
|
79
81
|
getQuoteAssetTokenAmount(): BN;
|
|
80
82
|
getRemainingAccounts(params: {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
writablePerpMarketIndex?: BN;
|
|
84
|
+
writableSpotMarketIndex?: BN;
|
|
85
|
+
readablePerpMarketIndex?: BN;
|
|
86
|
+
readableSpotMarketIndex?: BN;
|
|
84
87
|
}): AccountMeta[];
|
|
85
88
|
getOrder(orderId: BN | number): Order | undefined;
|
|
86
89
|
getOrderByUserId(userOrderId: number): Order | undefined;
|
|
87
|
-
deposit(amount: BN,
|
|
88
|
-
getDepositInstruction(amount: BN,
|
|
90
|
+
deposit(amount: BN, marketIndex: BN, collateralAccountPublicKey: PublicKey, userId?: number, reduceOnly?: boolean): Promise<TransactionSignature>;
|
|
91
|
+
getDepositInstruction(amount: BN, marketIndex: BN, userTokenAccount: PublicKey, userId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
|
|
89
92
|
private checkIfAccountExists;
|
|
90
93
|
private getSolWithdrawalIxs;
|
|
91
94
|
private getWrappedSolAccountCreationIxs;
|
|
@@ -93,20 +96,20 @@ export declare class ClearingHouse {
|
|
|
93
96
|
* Creates the Clearing House User account for a user, and deposits some initial collateral
|
|
94
97
|
* @param amount
|
|
95
98
|
* @param userTokenAccount
|
|
96
|
-
* @param
|
|
99
|
+
* @param marketIndex
|
|
97
100
|
* @param userId
|
|
98
101
|
* @param name
|
|
99
102
|
* @param fromUserId
|
|
100
103
|
* @returns
|
|
101
104
|
*/
|
|
102
|
-
initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey,
|
|
103
|
-
initializeUserAccountForDevnet(userId: number, name: string,
|
|
104
|
-
withdraw(amount: BN,
|
|
105
|
-
getWithdrawIx(amount: BN,
|
|
106
|
-
transferDeposit(amount: BN,
|
|
107
|
-
getTransferDepositIx(amount: BN,
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
initializeUserAccountAndDepositCollateral(amount: BN, userTokenAccount: PublicKey, marketIndex?: BN, userId?: number, name?: string, fromUserId?: number, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
|
|
106
|
+
initializeUserAccountForDevnet(userId: number, name: string, marketIndex: BN, tokenFaucet: TokenFaucet, amount: BN, referrerInfo?: ReferrerInfo): Promise<[TransactionSignature, PublicKey]>;
|
|
107
|
+
withdraw(amount: BN, marketIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionSignature>;
|
|
108
|
+
getWithdrawIx(amount: BN, marketIndex: BN, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionInstruction>;
|
|
109
|
+
transferDeposit(amount: BN, marketIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionSignature>;
|
|
110
|
+
getTransferDepositIx(amount: BN, marketIndex: BN, fromUserId: number, toUserId: number): Promise<TransactionInstruction>;
|
|
111
|
+
updateSpotMarketCumulativeInterest(marketIndex: BN): Promise<TransactionSignature>;
|
|
112
|
+
updateSpotMarketCumulativeInterestIx(marketIndex: BN): Promise<TransactionInstruction>;
|
|
110
113
|
settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: BN): Promise<TransactionSignature>;
|
|
111
114
|
settleLPIx(settleeUserAccountPublicKey: PublicKey, marketIndex: BN): Promise<TransactionInstruction>;
|
|
112
115
|
removeLiquidity(marketIndex: BN, sharesToBurn?: BN): Promise<TransactionSignature>;
|
|
@@ -114,19 +117,39 @@ export declare class ClearingHouse {
|
|
|
114
117
|
addLiquidity(amount: BN, marketIndex: BN): Promise<TransactionSignature>;
|
|
115
118
|
getAddLiquidityIx(amount: BN, marketIndex: BN): Promise<TransactionInstruction>;
|
|
116
119
|
openPosition(direction: PositionDirection, amount: BN, marketIndex: BN, limitPrice?: BN): Promise<TransactionSignature>;
|
|
120
|
+
sendSignedTx(tx: Transaction): Promise<TransactionSignature>;
|
|
121
|
+
/**
|
|
122
|
+
* Sends a market order and returns a signed tx which can fill the order against the vamm, which the caller can use to fill their own order if required.
|
|
123
|
+
* @param orderParams
|
|
124
|
+
* @param userAccountPublicKey
|
|
125
|
+
* @param userAccount
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
sendMarketOrderAndGetSignedFillTx(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<{
|
|
129
|
+
txSig: TransactionSignature;
|
|
130
|
+
signedFillTx: Transaction;
|
|
131
|
+
}>;
|
|
117
132
|
placeOrder(orderParams: OptionalOrderParams): Promise<TransactionSignature>;
|
|
118
|
-
getOrderParams(optionalOrderParams: OptionalOrderParams): OrderParams;
|
|
133
|
+
getOrderParams(optionalOrderParams: OptionalOrderParams, marketType: MarketType): OrderParams;
|
|
119
134
|
getPlaceOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
|
|
120
135
|
updateAMMs(marketIndexes: BN[]): Promise<TransactionSignature>;
|
|
121
136
|
getUpdateAMMsIx(marketIndexes: BN[]): Promise<TransactionInstruction>;
|
|
137
|
+
settleExpiredMarket(marketIndex: BN): Promise<TransactionSignature>;
|
|
138
|
+
getSettleExpiredMarketIx(marketIndex: BN): Promise<TransactionInstruction>;
|
|
122
139
|
cancelOrder(orderId?: BN): Promise<TransactionSignature>;
|
|
123
140
|
getCancelOrderIx(orderId?: BN): Promise<TransactionInstruction>;
|
|
124
141
|
cancelOrderByUserId(userOrderId: number): Promise<TransactionSignature>;
|
|
125
142
|
getCancelOrderByUserIdIx(userOrderId: number): Promise<TransactionInstruction>;
|
|
126
143
|
fillOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
|
|
127
|
-
getFillOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
144
|
+
getFillOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
145
|
+
placeSpotOrder(orderParams: OptionalOrderParams): Promise<TransactionSignature>;
|
|
146
|
+
getPlaceSpotOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
|
|
147
|
+
fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
|
|
148
|
+
getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
128
149
|
triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order): Promise<TransactionSignature>;
|
|
129
150
|
getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
|
|
151
|
+
triggerSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order): Promise<TransactionSignature>;
|
|
152
|
+
getTriggerSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
|
|
130
153
|
placeAndTake(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
|
|
131
154
|
getPlaceAndTakeIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
132
155
|
placeAndMake(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionSignature>;
|
|
@@ -143,22 +166,24 @@ export declare class ClearingHouse {
|
|
|
143
166
|
}[], marketIndex: BN): Promise<TransactionSignature>;
|
|
144
167
|
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
|
|
145
168
|
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
|
|
169
|
+
settleExpiredPosition(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
|
|
170
|
+
getSettleExpiredPositionIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
|
|
146
171
|
liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN, maxBaseAssetAmount: BN): Promise<TransactionSignature>;
|
|
147
172
|
getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN, maxBaseAssetAmount: BN): Promise<TransactionInstruction>;
|
|
148
|
-
liquidateBorrow(userAccountPublicKey: PublicKey, userAccount: UserAccount,
|
|
149
|
-
getLiquidateBorrowIx(userAccountPublicKey: PublicKey, userAccount: UserAccount,
|
|
150
|
-
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN,
|
|
151
|
-
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN,
|
|
152
|
-
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN,
|
|
153
|
-
getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN,
|
|
154
|
-
resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount,
|
|
155
|
-
getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount,
|
|
156
|
-
resolveBorrowBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount,
|
|
157
|
-
getResolveBorrowBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount,
|
|
173
|
+
liquidateBorrow(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetmarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
|
|
174
|
+
getLiquidateBorrowIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetmarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
|
|
175
|
+
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionSignature>;
|
|
176
|
+
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, liabilitymarketIndex: BN, maxLiabilityTransfer: BN): Promise<TransactionInstruction>;
|
|
177
|
+
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, assetMarketIndex: BN, maxPnlTransfer: BN): Promise<TransactionSignature>;
|
|
178
|
+
getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: BN, assetMarketIndex: BN, maxPnlTransfer: BN): Promise<TransactionInstruction>;
|
|
179
|
+
resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
|
|
180
|
+
getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
|
|
181
|
+
resolveBorrowBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionSignature>;
|
|
182
|
+
getResolveBorrowBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: BN): Promise<TransactionInstruction>;
|
|
158
183
|
getRemainingAccountsWithCounterparty(params: {
|
|
159
184
|
counterPartyUserAccount: UserAccount;
|
|
160
|
-
|
|
161
|
-
|
|
185
|
+
writablePerpMarketIndex?: BN;
|
|
186
|
+
writableSpotMarketIndexes?: BN[];
|
|
162
187
|
}): AccountMeta[];
|
|
163
188
|
updateFundingRate(oracle: PublicKey, marketIndex: BN): Promise<TransactionSignature>;
|
|
164
189
|
getUpdateFundingRateIx(oracle: PublicKey, marketIndex: BN): Promise<TransactionInstruction>;
|
|
@@ -166,11 +191,13 @@ export declare class ClearingHouse {
|
|
|
166
191
|
getSettleFundingPaymentIx(userAccount: PublicKey): Promise<TransactionInstruction>;
|
|
167
192
|
triggerEvent(eventName: keyof ClearingHouseAccountEvents, data?: any): void;
|
|
168
193
|
getOracleDataForMarket(marketIndex: BN): OraclePriceData;
|
|
169
|
-
initializeInsuranceFundStake(
|
|
170
|
-
getInitializeInsuranceFundStakeIx(
|
|
171
|
-
addInsuranceFundStake(
|
|
172
|
-
requestRemoveInsuranceFundStake(
|
|
173
|
-
cancelRequestRemoveInsuranceFundStake(
|
|
174
|
-
removeInsuranceFundStake(
|
|
175
|
-
settleRevenueToInsuranceFund(
|
|
194
|
+
initializeInsuranceFundStake(marketIndex: BN): Promise<TransactionSignature>;
|
|
195
|
+
getInitializeInsuranceFundStakeIx(marketIndex: BN): Promise<TransactionInstruction>;
|
|
196
|
+
addInsuranceFundStake(marketIndex: BN, amount: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
197
|
+
requestRemoveInsuranceFundStake(marketIndex: BN, amount: BN): Promise<TransactionSignature>;
|
|
198
|
+
cancelRequestRemoveInsuranceFundStake(marketIndex: BN): Promise<TransactionSignature>;
|
|
199
|
+
removeInsuranceFundStake(marketIndex: BN, collateralAccountPublicKey: PublicKey): Promise<TransactionSignature>;
|
|
200
|
+
settleRevenueToInsuranceFund(marketIndex: BN): Promise<TransactionSignature>;
|
|
201
|
+
resolvePerpPnlDeficit(spotMarketIndex: BN, perpMarketIndex: BN): Promise<TransactionSignature>;
|
|
202
|
+
getResolvePerpPnlDeficitIx(spotMarketIndex: BN, perpMarketIndex: BN): Promise<TransactionInstruction>;
|
|
176
203
|
}
|