@drift-labs/sdk 0.2.0-master.10 → 0.2.0-master.11

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/src/types.ts CHANGED
@@ -161,20 +161,67 @@ export type FundingPaymentRecord = {
161
161
 
162
162
  export type LiquidationRecord = {
163
163
  ts: BN;
164
- recordId: BN;
165
- userAuthority: PublicKey;
166
164
  user: PublicKey;
167
- partial: boolean;
168
- baseAssetValue: BN;
169
- baseAssetValueClosed: BN;
170
- liquidationFee: BN;
171
- feeToLiquidator: BN;
172
- feeToInsuranceFund: BN;
173
165
  liquidator: PublicKey;
166
+ liquidationType: LiquidationType;
167
+ marginRequirement: BN;
174
168
  totalCollateral: BN;
175
- collateral: BN;
176
- unrealizedPnl: BN;
177
- marginRatio: BN;
169
+ liquidatePerp: LiquidatePerpRecord;
170
+ liquidateBorrow: LiquidateBorrowRecord;
171
+ liquidateBorrowForPerpPnl: LiquidateBorrowForPerpPnlRecord;
172
+ liquidatePerpPnlForDeposit: LiquidatePerpPnlForDepositRecord;
173
+ };
174
+
175
+ export class LiquidationType {
176
+ static readonly LIQUIDATE_PERP = { liquidatePerp: {} };
177
+ static readonly LIQUIDATE_BORROW = { liquidateBorrow: {} };
178
+ static readonly LIQUIDATE_BORROW_FOR_PERP_PNL = {
179
+ liquidateBorrowForPerpPnl: {},
180
+ };
181
+ static readonly LIQUIDATE_PERP_PNL_FOR_DEPOSIT = {
182
+ liquidatePerpPnlForDeposit: {},
183
+ };
184
+ }
185
+
186
+ export type LiquidatePerpRecord = {
187
+ marketIndex: BN;
188
+ orderIds: BN[];
189
+ oraclePrice: BN;
190
+ baseAssetAmount: BN;
191
+ quoteAssetAmount: BN;
192
+ userPnl: BN;
193
+ liquidatorPnl: BN;
194
+ canceledOrdersFee: BN;
195
+ userOrderId: BN;
196
+ liquidatorOrderId: BN;
197
+ fillRecordId: BN;
198
+ };
199
+
200
+ export type LiquidateBorrowRecord = {
201
+ assetBankIndex: BN;
202
+ assetPrice: BN;
203
+ assetTransfer: BN;
204
+ liabilityBankIndex: BN;
205
+ liabilityPrice: BN;
206
+ liabilityTransfer: BN;
207
+ };
208
+
209
+ export type LiquidateBorrowForPerpPnlRecord = {
210
+ marketIndex: BN;
211
+ marketOraclePrice: BN;
212
+ pnlTransfer: BN;
213
+ liabilityBankIndex: BN;
214
+ liabilityPrice: BN;
215
+ liabilityTransfer: BN;
216
+ };
217
+
218
+ export type LiquidatePerpPnlForDepositRecord = {
219
+ marketIndex: BN;
220
+ marketOraclePrice: BN;
221
+ pnlTransfer: BN;
222
+ assetBankIndex: BN;
223
+ assetPrice: BN;
224
+ assetTransfer: BN;
178
225
  };
179
226
 
180
227
  export type OrderRecord = {
@@ -241,9 +288,9 @@ export type MarketAccount = {
241
288
  openInterest: BN;
242
289
  marginRatioInitial: number;
243
290
  marginRatioMaintenance: number;
244
- marginRatioPartial: number;
245
291
  nextFillRecordId: BN;
246
292
  pnlPool: PoolBalance;
293
+ liquidationFee: BN;
247
294
  };
248
295
 
249
296
  export type BankAccount = {
@@ -267,6 +314,7 @@ export type BankAccount = {
267
314
  maintenanceAssetWeight: BN;
268
315
  initialLiabilityWeight: BN;
269
316
  maintenanceLiabilityWeight: BN;
317
+ liquidationFee: BN;
270
318
  };
271
319
 
272
320
  export type PoolBalance = {
@@ -349,6 +397,7 @@ export type UserAccount = {
349
397
  };
350
398
  positions: UserPosition[];
351
399
  orders: Order[];
400
+ beingLiquidated: boolean;
352
401
  };
353
402
 
354
403
  export type UserBankBalance = {
@@ -493,6 +542,7 @@ export type FeeStructure = {
493
542
  makerRebateNumerator: BN;
494
543
  makerRebateDenominator: BN;
495
544
  fillerRewardStructure: OrderFillerRewardStructure;
545
+ cancelOrderFee: BN;
496
546
  };
497
547
 
498
548
  export type OracleGuardRails = {
@@ -514,4 +564,4 @@ export type OrderFillerRewardStructure = {
514
564
  timeBasedRewardLowerBound: BN;
515
565
  };
516
566
 
517
- export type MarginCategory = 'Initial' | 'Partial' | 'Maintenance';
567
+ export type MarginCategory = 'Initial' | 'Maintenance';
@@ -9,7 +9,7 @@ export async function findComputeUnitConsumption(
9
9
  const tx = await connection.getTransaction(txSignature, { commitment });
10
10
  const computeUnits = [];
11
11
  const regex = new RegExp(
12
- `Program ${programId.toString()} consumed ([0-9]{0,6}) of 200000 compute units`
12
+ `Program ${programId.toString()} consumed ([0-9]{0,6}) of ([0-9]{0,7}) compute units`
13
13
  );
14
14
  tx.meta.logMessages.forEach((logMessage) => {
15
15
  const match = logMessage.match(regex);