@drift-labs/sdk 0.1.18-orders.3 → 0.1.18-orders.4

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 (48) hide show
  1. package/lib/accounts/bulkAccountLoader.d.ts +3 -4
  2. package/lib/accounts/bulkAccountLoader.js +23 -4
  3. package/lib/accounts/types.d.ts +4 -0
  4. package/lib/accounts/webSocketAccountSubscriber.d.ts +6 -2
  5. package/lib/accounts/webSocketAccountSubscriber.js +43 -12
  6. package/lib/clearingHouse.d.ts +4 -0
  7. package/lib/clearingHouse.js +40 -0
  8. package/lib/clearingHouseUser.d.ts +3 -3
  9. package/lib/clearingHouseUser.js +16 -20
  10. package/lib/config.js +1 -1
  11. package/lib/constants/markets.d.ts +2 -1
  12. package/lib/constants/markets.js +20 -15
  13. package/lib/constants/numericConstants.d.ts +3 -1
  14. package/lib/constants/numericConstants.js +15 -17
  15. package/lib/examples/makeTradeExample.js +1 -1
  16. package/lib/idl/clearing_house.json +6 -2
  17. package/lib/math/conversion.d.ts +1 -1
  18. package/lib/math/insuranceFund.d.ts +2 -1
  19. package/lib/math/insuranceFund.js +3 -6
  20. package/lib/math/position.d.ts +2 -1
  21. package/lib/math/position.js +2 -5
  22. package/lib/math/utils.d.ts +2 -1
  23. package/lib/math/utils.js +3 -6
  24. package/lib/mockUSDCFaucet.d.ts +2 -1
  25. package/lib/orderParams.d.ts +2 -2
  26. package/lib/orderParams.js +7 -7
  27. package/lib/orders.d.ts +2 -1
  28. package/lib/types.d.ts +7 -5
  29. package/lib/types.js +2 -2
  30. package/package.json +9 -1
  31. package/src/accounts/bulkAccountLoader.ts +35 -15
  32. package/src/accounts/types.ts +5 -0
  33. package/src/accounts/webSocketAccountSubscriber.ts +67 -17
  34. package/src/clearingHouse.ts +56 -0
  35. package/src/clearingHouseUser.ts +2 -2
  36. package/src/config.ts +1 -1
  37. package/src/constants/markets.ts +9 -1
  38. package/src/constants/numericConstants.ts +2 -1
  39. package/src/examples/makeTradeExample.ts +4 -1
  40. package/src/idl/clearing_house.json +6 -2
  41. package/src/math/conversion.ts +1 -1
  42. package/src/math/insuranceFund.ts +1 -1
  43. package/src/math/position.ts +1 -1
  44. package/src/math/utils.ts +1 -1
  45. package/src/mockUSDCFaucet.ts +1 -1
  46. package/src/orderParams.ts +4 -4
  47. package/src/orders.ts +1 -1
  48. package/src/types.ts +4 -3
@@ -17,7 +17,7 @@ import {
17
17
  TransactionInstruction,
18
18
  TransactionSignature,
19
19
  } from '@solana/web3.js';
20
- import BN from 'bn.js';
20
+ import { BN } from '.';
21
21
  import mockUSDCFaucetIDL from './idl/mock_usdc_faucet.json';
22
22
  import { IWallet } from './types';
23
23
 
@@ -41,7 +41,7 @@ export function getLimitOrderParams(
41
41
  };
42
42
  }
43
43
 
44
- export function getStopOrderParams(
44
+ export function getTriggerMarketOrderParams(
45
45
  marketIndex: BN,
46
46
  direction: PositionDirection,
47
47
  baseAssetAmount: BN,
@@ -53,7 +53,7 @@ export function getStopOrderParams(
53
53
  userOrderId = 0
54
54
  ): OrderParams {
55
55
  return {
56
- orderType: OrderType.STOP,
56
+ orderType: OrderType.TRIGGER_MARKET,
57
57
  userOrderId,
58
58
  marketIndex,
59
59
  direction,
@@ -76,7 +76,7 @@ export function getStopOrderParams(
76
76
  };
77
77
  }
78
78
 
79
- export function getStopLimitOrderParams(
79
+ export function getTriggerLimitOrderParams(
80
80
  marketIndex: BN,
81
81
  direction: PositionDirection,
82
82
  baseAssetAmount: BN,
@@ -89,7 +89,7 @@ export function getStopLimitOrderParams(
89
89
  userOrderId = 0
90
90
  ): OrderParams {
91
91
  return {
92
- orderType: OrderType.STOP_LIMIT,
92
+ orderType: OrderType.TRIGGER_LIMIT,
93
93
  userOrderId,
94
94
  marketIndex,
95
95
  direction,
package/src/orders.ts CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  UserAccount,
7
7
  UserPosition,
8
8
  } from './types';
9
- import BN from 'bn.js';
9
+ import { BN } from '.';
10
10
  import {
11
11
  calculateMarkPrice,
12
12
  calculateNewMarketAfterTrade,
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PublicKey, Transaction } from '@solana/web3.js';
2
- import BN from 'bn.js';
2
+ import { BN } from '.';
3
3
 
4
4
  // # Utility Types / Enums / Constants
5
5
  export class SwapDirection {
@@ -19,8 +19,8 @@ export class OracleSource {
19
19
 
20
20
  export class OrderType {
21
21
  static readonly LIMIT = { limit: {} };
22
- static readonly STOP = { stop: {} };
23
- static readonly STOP_LIMIT = { stopLimit: {} };
22
+ static readonly TRIGGER_MARKET = { triggerMarket: {} };
23
+ static readonly TRIGGER_LIMIT = { triggerLimit: {} };
24
24
  static readonly MARKET = { market: {} };
25
25
  }
26
26
 
@@ -345,6 +345,7 @@ export type Order = {
345
345
  userOrderId: number;
346
346
  marketIndex: BN;
347
347
  price: BN;
348
+ userBaseAssetAmount: BN;
348
349
  baseAssetAmount: BN;
349
350
  baseAssetAmountFilled: BN;
350
351
  quoteAssetAmount: BN;