@drift-labs/sdk 0.2.0-master.8 → 0.2.0-temp.1

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.
Files changed (55) hide show
  1. package/lib/admin.d.ts +3 -3
  2. package/lib/admin.js +6 -6
  3. package/lib/clearingHouse.d.ts +15 -4
  4. package/lib/clearingHouse.js +200 -37
  5. package/lib/clearingHouseUser.d.ts +2 -2
  6. package/lib/clearingHouseUser.js +8 -17
  7. package/lib/config.js +1 -1
  8. package/lib/constants/banks.js +2 -3
  9. package/lib/constants/numericConstants.d.ts +1 -0
  10. package/lib/constants/numericConstants.js +2 -1
  11. package/lib/idl/clearing_house.json +484 -103
  12. package/lib/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
  13. package/lib/index.d.ts +1 -1
  14. package/lib/index.js +1 -1
  15. package/lib/orders.js +1 -1
  16. package/lib/{mockUSDCFaucet.d.ts → tokenFaucet.d.ts} +7 -5
  17. package/lib/{mockUSDCFaucet.js → tokenFaucet.js} +41 -40
  18. package/lib/types.d.ts +62 -13
  19. package/lib/types.js +12 -1
  20. package/lib/util/computeUnits.js +1 -1
  21. package/package.json +1 -1
  22. package/src/admin.js +517 -0
  23. package/src/admin.ts +7 -7
  24. package/src/clearingHouse.ts +335 -47
  25. package/src/clearingHouseConfig.js +2 -0
  26. package/src/clearingHouseUser.ts +12 -23
  27. package/src/clearingHouseUserConfig.js +2 -0
  28. package/src/config.js +67 -0
  29. package/src/config.ts +1 -1
  30. package/src/constants/banks.js +42 -0
  31. package/src/constants/banks.ts +2 -3
  32. package/src/constants/markets.js +42 -0
  33. package/src/constants/numericConstants.js +41 -0
  34. package/src/constants/numericConstants.ts +1 -0
  35. package/src/factory/bigNum.js +37 -11
  36. package/src/idl/clearing_house.json +484 -103
  37. package/src/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
  38. package/src/index.js +1 -1
  39. package/src/index.ts +1 -1
  40. package/src/mockUSDCFaucet.js +276 -167
  41. package/src/orders.ts +2 -1
  42. package/src/tokenFaucet.js +189 -0
  43. package/src/{mockUSDCFaucet.ts → tokenFaucet.ts} +48 -59
  44. package/src/types.js +12 -1
  45. package/src/types.ts +63 -13
  46. package/src/{accounts/fetch.js → util/computeUnits.js} +11 -13
  47. package/src/util/computeUnits.ts +1 -1
  48. package/src/util/getTokenAddress.js +9 -0
  49. package/src/addresses/pda.js +0 -104
  50. package/src/math/bankBalance.js +0 -75
  51. package/src/math/market.js +0 -57
  52. package/src/math/orders.js +0 -110
  53. package/src/math/position.js +0 -140
  54. package/src/orders.js +0 -134
  55. package/src/tx/retryTxSender.js +0 -188
@@ -1,23 +1,23 @@
1
1
  {
2
- "version": "0.0.0",
3
- "name": "mock_usdc_faucet",
2
+ "version": "0.1.0",
3
+ "name": "token_faucet",
4
4
  "instructions": [
5
5
  {
6
6
  "name": "initialize",
7
7
  "accounts": [
8
8
  {
9
- "name": "mockUsdcFaucetState",
9
+ "name": "faucetConfig",
10
10
  "isMut": true,
11
11
  "isSigner": false
12
12
  },
13
13
  {
14
14
  "name": "admin",
15
- "isMut": false,
15
+ "isMut": true,
16
16
  "isSigner": true
17
17
  },
18
18
  {
19
19
  "name": "mintAccount",
20
- "isMut": false,
20
+ "isMut": true,
21
21
  "isSigner": false
22
22
  },
23
23
  {
@@ -29,20 +29,20 @@
29
29
  "name": "systemProgram",
30
30
  "isMut": false,
31
31
  "isSigner": false
32
- }
33
- ],
34
- "args": [
32
+ },
35
33
  {
36
- "name": "mockUsdcFaucetNonce",
37
- "type": "u8"
34
+ "name": "tokenProgram",
35
+ "isMut": false,
36
+ "isSigner": false
38
37
  }
39
- ]
38
+ ],
39
+ "args": []
40
40
  },
41
41
  {
42
42
  "name": "mintToUser",
43
43
  "accounts": [
44
44
  {
45
- "name": "mockUsdcFaucetState",
45
+ "name": "faucetConfig",
46
46
  "isMut": false,
47
47
  "isSigner": false
48
48
  },
@@ -73,11 +73,42 @@
73
73
  "type": "u64"
74
74
  }
75
75
  ]
76
+ },
77
+ {
78
+ "name": "transferMintAuthority",
79
+ "accounts": [
80
+ {
81
+ "name": "faucetConfig",
82
+ "isMut": false,
83
+ "isSigner": false
84
+ },
85
+ {
86
+ "name": "admin",
87
+ "isMut": true,
88
+ "isSigner": true
89
+ },
90
+ {
91
+ "name": "mintAccount",
92
+ "isMut": true,
93
+ "isSigner": false
94
+ },
95
+ {
96
+ "name": "mintAuthority",
97
+ "isMut": false,
98
+ "isSigner": false
99
+ },
100
+ {
101
+ "name": "tokenProgram",
102
+ "isMut": false,
103
+ "isSigner": false
104
+ }
105
+ ],
106
+ "args": []
76
107
  }
77
108
  ],
78
109
  "accounts": [
79
110
  {
80
- "name": "MockUSDCFaucetState",
111
+ "name": "FaucetConfig",
81
112
  "type": {
82
113
  "kind": "struct",
83
114
  "fields": [
@@ -103,17 +134,9 @@
103
134
  ],
104
135
  "errors": [
105
136
  {
106
- "code": 300,
137
+ "code": 6000,
107
138
  "name": "InvalidMintAccountAuthority",
108
139
  "msg": "Program not mint authority"
109
- },
110
- {
111
- "code": 301,
112
- "name": "Unauthorized",
113
- "msg": "Signer must be MockUSDCFaucet admin"
114
140
  }
115
- ],
116
- "metadata": {
117
- "address": "2z2DLVD3tBWc86pbvvy5qN31v1NXprM6zA5MDr2FMx64"
118
- }
141
+ ]
119
142
  }
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BN } from '@project-serum/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import pyth from '@pythnetwork/client';
4
- export * from './mockUSDCFaucet';
4
+ export * from './tokenFaucet';
5
5
  export * from './oracles/types';
6
6
  export * from './oracles/pythClient';
7
7
  export * from './oracles/switchboardClient';
package/lib/index.js CHANGED
@@ -24,7 +24,7 @@ const web3_js_1 = require("@solana/web3.js");
24
24
  Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return web3_js_1.PublicKey; } });
25
25
  const client_1 = __importDefault(require("@pythnetwork/client"));
26
26
  exports.pyth = client_1.default;
27
- __exportStar(require("./mockUSDCFaucet"), exports);
27
+ __exportStar(require("./tokenFaucet"), exports);
28
28
  __exportStar(require("./oracles/types"), exports);
29
29
  __exportStar(require("./oracles/pythClient"), exports);
30
30
  __exportStar(require("./oracles/switchboardClient"), exports);
package/lib/orders.js CHANGED
@@ -103,7 +103,7 @@ function calculateAmountToTradeForLimit(market, order, oraclePriceData) {
103
103
  }
104
104
  limitPrice = oraclePriceData.price.add(order.oraclePriceOffset);
105
105
  }
106
- const [maxAmountToTrade, direction] = (0, amm_1.calculateMaxBaseAssetAmountToTrade)(market.amm, limitPrice, order.direction);
106
+ const [maxAmountToTrade, direction] = (0, amm_1.calculateMaxBaseAssetAmountToTrade)(market.amm, limitPrice, order.direction, oraclePriceData);
107
107
  const baseAssetAmount = (0, _1.standardizeBaseAssetAmount)(maxAmountToTrade, market.amm.baseAssetAmountStepSize);
108
108
  // Check that directions are the same
109
109
  const sameDirection = isSameDirection(direction, order.direction);
@@ -5,22 +5,24 @@ import { AccountInfo } from '@solana/spl-token';
5
5
  import { ConfirmOptions, Connection, PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
6
6
  import { BN } from '.';
7
7
  import { IWallet } from './types';
8
- export declare class MockUSDCFaucet {
8
+ export declare class TokenFaucet {
9
9
  connection: Connection;
10
10
  wallet: IWallet;
11
11
  program: Program;
12
12
  provider: AnchorProvider;
13
+ mint: PublicKey;
13
14
  opts?: ConfirmOptions;
14
- constructor(connection: Connection, wallet: IWallet, programId: PublicKey, opts?: ConfirmOptions);
15
- getMockUSDCFaucetStatePublicKeyAndNonce(): Promise<[
15
+ constructor(connection: Connection, wallet: IWallet, programId: PublicKey, mint: PublicKey, opts?: ConfirmOptions);
16
+ getFaucetConfigPublicKeyAndNonce(): Promise<[
16
17
  PublicKey,
17
18
  number
18
19
  ]>;
19
- mockUSDCFaucetStatePublicKey?: PublicKey;
20
- getMockUSDCFaucetStatePublicKey(): Promise<PublicKey>;
20
+ getMintAuthority(): Promise<PublicKey>;
21
+ getFaucetConfigPublicKey(): Promise<PublicKey>;
21
22
  initialize(): Promise<TransactionSignature>;
22
23
  fetchState(): Promise<any>;
23
24
  mintToUser(userTokenAccount: PublicKey, amount: BN): Promise<TransactionSignature>;
25
+ transferMintAuthority(): Promise<TransactionSignature>;
24
26
  createAssociatedTokenAccountAndMintTo(userPublicKey: PublicKey, amount: BN): Promise<[PublicKey, TransactionSignature]>;
25
27
  createAssociatedTokenAccountAndMintToInstructions(userPublicKey: PublicKey, amount: BN): Promise<[PublicKey, TransactionInstruction, TransactionInstruction]>;
26
28
  getAssosciatedMockUSDMintAddress(props: {
@@ -26,74 +26,75 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.MockUSDCFaucet = void 0;
29
+ exports.TokenFaucet = void 0;
30
30
  const anchor = __importStar(require("@project-serum/anchor"));
31
31
  const anchor_1 = require("@project-serum/anchor");
32
32
  const spl_token_1 = require("@solana/spl-token");
33
33
  const web3_js_1 = require("@solana/web3.js");
34
- const mock_usdc_faucet_json_1 = __importDefault(require("./idl/mock_usdc_faucet.json"));
35
- class MockUSDCFaucet {
36
- constructor(connection, wallet, programId, opts) {
34
+ const token_faucet_json_1 = __importDefault(require("./idl/token_faucet.json"));
35
+ class TokenFaucet {
36
+ constructor(connection, wallet, programId, mint, opts) {
37
37
  this.connection = connection;
38
38
  this.wallet = wallet;
39
39
  this.opts = opts || anchor_1.AnchorProvider.defaultOptions();
40
40
  const provider = new anchor_1.AnchorProvider(connection, wallet, this.opts);
41
41
  this.provider = provider;
42
- this.program = new anchor_1.Program(mock_usdc_faucet_json_1.default, programId, provider);
42
+ this.program = new anchor_1.Program(token_faucet_json_1.default, programId, provider);
43
+ this.mint = mint;
43
44
  }
44
- async getMockUSDCFaucetStatePublicKeyAndNonce() {
45
- return anchor.web3.PublicKey.findProgramAddress([Buffer.from(anchor.utils.bytes.utf8.encode('mock_usdc_faucet'))], this.program.programId);
45
+ async getFaucetConfigPublicKeyAndNonce() {
46
+ return anchor.web3.PublicKey.findProgramAddress([
47
+ Buffer.from(anchor.utils.bytes.utf8.encode('faucet_config')),
48
+ this.mint.toBuffer(),
49
+ ], this.program.programId);
46
50
  }
47
- async getMockUSDCFaucetStatePublicKey() {
48
- if (this.mockUSDCFaucetStatePublicKey) {
49
- return this.mockUSDCFaucetStatePublicKey;
50
- }
51
- this.mockUSDCFaucetStatePublicKey = (await this.getMockUSDCFaucetStatePublicKeyAndNonce())[0];
52
- return this.mockUSDCFaucetStatePublicKey;
51
+ async getMintAuthority() {
52
+ return (await anchor.web3.PublicKey.findProgramAddress([
53
+ Buffer.from(anchor.utils.bytes.utf8.encode('mint_authority')),
54
+ this.mint.toBuffer(),
55
+ ], this.program.programId))[0];
56
+ }
57
+ async getFaucetConfigPublicKey() {
58
+ return (await this.getFaucetConfigPublicKeyAndNonce())[0];
53
59
  }
54
60
  async initialize() {
55
- const stateAccountRPCResponse = await this.connection.getParsedAccountInfo(await this.getMockUSDCFaucetStatePublicKey());
56
- if (stateAccountRPCResponse.value !== null) {
57
- throw new Error('Faucet already initialized');
58
- }
59
- const fakeUSDCMint = anchor.web3.Keypair.generate();
60
- const createUSDCMintAccountIx = web3_js_1.SystemProgram.createAccount({
61
- fromPubkey: this.wallet.publicKey,
62
- newAccountPubkey: fakeUSDCMint.publicKey,
63
- lamports: await spl_token_1.Token.getMinBalanceRentForExemptMint(this.connection),
64
- space: spl_token_1.MintLayout.span,
65
- programId: spl_token_1.TOKEN_PROGRAM_ID,
66
- });
67
- const [mintAuthority, _mintAuthorityNonce] = await web3_js_1.PublicKey.findProgramAddress([fakeUSDCMint.publicKey.toBuffer()], this.program.programId);
68
- const initUSDCMintIx = spl_token_1.Token.createInitMintInstruction(spl_token_1.TOKEN_PROGRAM_ID, fakeUSDCMint.publicKey, 6, mintAuthority, null);
69
- const [mockUSDCFaucetStatePublicKey, mockUSDCFaucetStateNonce] = await this.getMockUSDCFaucetStatePublicKeyAndNonce();
70
- return await this.program.rpc.initialize(mockUSDCFaucetStateNonce, {
61
+ const [faucetConfigPublicKey] = await this.getFaucetConfigPublicKeyAndNonce();
62
+ return await this.program.rpc.initialize({
71
63
  accounts: {
72
- mockUsdcFaucetState: mockUSDCFaucetStatePublicKey,
64
+ faucetConfig: faucetConfigPublicKey,
73
65
  admin: this.wallet.publicKey,
74
- mintAccount: fakeUSDCMint.publicKey,
66
+ mintAccount: this.mint,
75
67
  rent: web3_js_1.SYSVAR_RENT_PUBKEY,
76
68
  systemProgram: anchor.web3.SystemProgram.programId,
69
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
77
70
  },
78
- instructions: [createUSDCMintAccountIx, initUSDCMintIx],
79
- signers: [fakeUSDCMint],
80
71
  });
81
72
  }
82
73
  async fetchState() {
83
- return await this.program.account.mockUsdcFaucetState.fetch(await this.getMockUSDCFaucetStatePublicKey());
74
+ return await this.program.account.faucetConfig.fetch(await this.getFaucetConfigPublicKey());
84
75
  }
85
76
  async mintToUser(userTokenAccount, amount) {
86
- const state = await this.fetchState();
87
77
  return await this.program.rpc.mintToUser(amount, {
88
78
  accounts: {
89
- mockUsdcFaucetState: await this.getMockUSDCFaucetStatePublicKey(),
90
- mintAccount: state.mint,
79
+ faucetConfig: await this.getFaucetConfigPublicKey(),
80
+ mintAccount: this.mint,
91
81
  userTokenAccount,
92
- mintAuthority: state.mintAuthority,
82
+ mintAuthority: await this.getMintAuthority(),
93
83
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
94
84
  },
95
85
  });
96
86
  }
87
+ async transferMintAuthority() {
88
+ return await this.program.rpc.transferMintAuthority({
89
+ accounts: {
90
+ faucetConfig: await this.getFaucetConfigPublicKey(),
91
+ mintAccount: this.mint,
92
+ mintAuthority: await this.getMintAuthority(),
93
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
94
+ admin: this.wallet.publicKey,
95
+ },
96
+ });
97
+ }
97
98
  async createAssociatedTokenAccountAndMintTo(userPublicKey, amount) {
98
99
  const [associatedTokenPublicKey, createAssociatedAccountIx, mintToTx] = await this.createAssociatedTokenAccountAndMintToInstructions(userPublicKey, amount);
99
100
  const tx = new web3_js_1.Transaction().add(createAssociatedAccountIx).add(mintToTx);
@@ -106,7 +107,7 @@ class MockUSDCFaucet {
106
107
  const createAssociatedAccountIx = spl_token_1.Token.createAssociatedTokenAccountInstruction(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, state.mint, associateTokenPublicKey, userPublicKey, this.wallet.publicKey);
107
108
  const mintToIx = await this.program.instruction.mintToUser(amount, {
108
109
  accounts: {
109
- mockUsdcFaucetState: await this.getMockUSDCFaucetStatePublicKey(),
110
+ faucetConfig: await this.getFaucetConfigPublicKey(),
110
111
  mintAccount: state.mint,
111
112
  userTokenAccount: associateTokenPublicKey,
112
113
  mintAuthority: state.mintAuthority,
@@ -143,4 +144,4 @@ class MockUSDCFaucet {
143
144
  }
144
145
  }
145
146
  }
146
- exports.MockUSDCFaucet = MockUSDCFaucet;
147
+ exports.TokenFaucet = TokenFaucet;
package/lib/types.d.ts CHANGED
@@ -187,20 +187,66 @@ export declare type FundingPaymentRecord = {
187
187
  };
188
188
  export declare type LiquidationRecord = {
189
189
  ts: BN;
190
- recordId: BN;
191
- userAuthority: PublicKey;
192
190
  user: PublicKey;
193
- partial: boolean;
194
- baseAssetValue: BN;
195
- baseAssetValueClosed: BN;
196
- liquidationFee: BN;
197
- feeToLiquidator: BN;
198
- feeToInsuranceFund: BN;
199
191
  liquidator: PublicKey;
192
+ liquidationType: LiquidationType;
193
+ marginRequirement: BN;
200
194
  totalCollateral: BN;
201
- collateral: BN;
202
- unrealizedPnl: BN;
203
- marginRatio: BN;
195
+ liquidatePerp: LiquidatePerpRecord;
196
+ liquidateBorrow: LiquidateBorrowRecord;
197
+ liquidateBorrowForPerpPnl: LiquidateBorrowForPerpPnlRecord;
198
+ liquidatePerpPnlForDeposit: LiquidatePerpPnlForDepositRecord;
199
+ };
200
+ export declare class LiquidationType {
201
+ static readonly LIQUIDATE_PERP: {
202
+ liquidatePerp: {};
203
+ };
204
+ static readonly LIQUIDATE_BORROW: {
205
+ liquidateBorrow: {};
206
+ };
207
+ static readonly LIQUIDATE_BORROW_FOR_PERP_PNL: {
208
+ liquidateBorrowForPerpPnl: {};
209
+ };
210
+ static readonly LIQUIDATE_PERP_PNL_FOR_DEPOSIT: {
211
+ liquidatePerpPnlForDeposit: {};
212
+ };
213
+ }
214
+ export declare type LiquidatePerpRecord = {
215
+ marketIndex: BN;
216
+ orderIds: BN[];
217
+ oraclePrice: BN;
218
+ baseAssetAmount: BN;
219
+ quoteAssetAmount: BN;
220
+ userPnl: BN;
221
+ liquidatorPnl: BN;
222
+ canceledOrdersFee: BN;
223
+ userOrderId: BN;
224
+ liquidatorOrderId: BN;
225
+ fillRecordId: BN;
226
+ };
227
+ export declare type LiquidateBorrowRecord = {
228
+ assetBankIndex: BN;
229
+ assetPrice: BN;
230
+ assetTransfer: BN;
231
+ liabilityBankIndex: BN;
232
+ liabilityPrice: BN;
233
+ liabilityTransfer: BN;
234
+ };
235
+ export declare type LiquidateBorrowForPerpPnlRecord = {
236
+ marketIndex: BN;
237
+ marketOraclePrice: BN;
238
+ pnlTransfer: BN;
239
+ liabilityBankIndex: BN;
240
+ liabilityPrice: BN;
241
+ liabilityTransfer: BN;
242
+ };
243
+ export declare type LiquidatePerpPnlForDepositRecord = {
244
+ marketIndex: BN;
245
+ marketOraclePrice: BN;
246
+ pnlTransfer: BN;
247
+ assetBankIndex: BN;
248
+ assetPrice: BN;
249
+ assetTransfer: BN;
204
250
  };
205
251
  export declare type OrderRecord = {
206
252
  ts: BN;
@@ -264,9 +310,9 @@ export declare type MarketAccount = {
264
310
  openInterest: BN;
265
311
  marginRatioInitial: number;
266
312
  marginRatioMaintenance: number;
267
- marginRatioPartial: number;
268
313
  nextFillRecordId: BN;
269
314
  pnlPool: PoolBalance;
315
+ liquidationFee: BN;
270
316
  };
271
317
  export declare type BankAccount = {
272
318
  bankIndex: BN;
@@ -289,6 +335,7 @@ export declare type BankAccount = {
289
335
  maintenanceAssetWeight: BN;
290
336
  initialLiabilityWeight: BN;
291
337
  maintenanceLiabilityWeight: BN;
338
+ liquidationFee: BN;
292
339
  };
293
340
  export declare type PoolBalance = {
294
341
  balance: BN;
@@ -366,6 +413,7 @@ export declare type UserAccount = {
366
413
  };
367
414
  positions: UserPosition[];
368
415
  orders: Order[];
416
+ beingLiquidated: boolean;
369
417
  };
370
418
  export declare type UserBankBalance = {
371
419
  bankIndex: BN;
@@ -505,6 +553,7 @@ export declare type FeeStructure = {
505
553
  makerRebateNumerator: BN;
506
554
  makerRebateDenominator: BN;
507
555
  fillerRewardStructure: OrderFillerRewardStructure;
556
+ cancelOrderFee: BN;
508
557
  };
509
558
  export declare type OracleGuardRails = {
510
559
  priceDivergence: {
@@ -523,4 +572,4 @@ export declare type OrderFillerRewardStructure = {
523
572
  rewardDenominator: BN;
524
573
  timeBasedRewardLowerBound: BN;
525
574
  };
526
- export declare type MarginCategory = 'Initial' | 'Partial' | 'Maintenance';
575
+ export declare type MarginCategory = 'Initial' | 'Maintenance';
package/lib/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultOrderParams = exports.TradeSide = exports.isOneOfVariant = exports.isVariant = exports.OrderTriggerCondition = exports.OrderActionExplanation = exports.OrderAction = exports.OrderDiscountTier = exports.OrderStatus = exports.OrderType = exports.OracleSource = exports.DepositDirection = exports.PositionDirection = exports.BankBalanceType = exports.SwapDirection = void 0;
3
+ exports.DefaultOrderParams = exports.LiquidationType = exports.TradeSide = exports.isOneOfVariant = exports.isVariant = exports.OrderTriggerCondition = exports.OrderActionExplanation = exports.OrderAction = exports.OrderDiscountTier = exports.OrderStatus = exports.OrderType = exports.OracleSource = exports.DepositDirection = exports.PositionDirection = exports.BankBalanceType = exports.SwapDirection = void 0;
4
4
  const _1 = require(".");
5
5
  // # Utility Types / Enums / Constants
6
6
  class SwapDirection {
@@ -91,6 +91,17 @@ var TradeSide;
91
91
  TradeSide[TradeSide["Buy"] = 1] = "Buy";
92
92
  TradeSide[TradeSide["Sell"] = 2] = "Sell";
93
93
  })(TradeSide = exports.TradeSide || (exports.TradeSide = {}));
94
+ class LiquidationType {
95
+ }
96
+ exports.LiquidationType = LiquidationType;
97
+ LiquidationType.LIQUIDATE_PERP = { liquidatePerp: {} };
98
+ LiquidationType.LIQUIDATE_BORROW = { liquidateBorrow: {} };
99
+ LiquidationType.LIQUIDATE_BORROW_FOR_PERP_PNL = {
100
+ liquidateBorrowForPerpPnl: {},
101
+ };
102
+ LiquidationType.LIQUIDATE_PERP_PNL_FOR_DEPOSIT = {
103
+ liquidatePerpPnlForDeposit: {},
104
+ };
94
105
  exports.DefaultOrderParams = {
95
106
  orderType: OrderType.MARKET,
96
107
  userOrderId: 0,
@@ -4,7 +4,7 @@ exports.findComputeUnitConsumption = void 0;
4
4
  async function findComputeUnitConsumption(programId, connection, txSignature, commitment = 'confirmed') {
5
5
  const tx = await connection.getTransaction(txSignature, { commitment });
6
6
  const computeUnits = [];
7
- const regex = new RegExp(`Program ${programId.toString()} consumed ([0-9]{0,6}) of 200000 compute units`);
7
+ const regex = new RegExp(`Program ${programId.toString()} consumed ([0-9]{0,6}) of ([0-9]{0,7}) compute units`);
8
8
  tx.meta.logMessages.forEach((logMessage) => {
9
9
  const match = logMessage.match(regex);
10
10
  if (match && match[1]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "0.2.0-master.8",
3
+ "version": "0.2.0-temp.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",