@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.
- package/lib/accounts/bulkAccountLoader.d.ts +3 -4
- package/lib/accounts/bulkAccountLoader.js +23 -4
- package/lib/accounts/types.d.ts +4 -0
- package/lib/accounts/webSocketAccountSubscriber.d.ts +6 -2
- package/lib/accounts/webSocketAccountSubscriber.js +43 -12
- package/lib/clearingHouse.d.ts +4 -0
- package/lib/clearingHouse.js +40 -0
- package/lib/clearingHouseUser.d.ts +3 -3
- package/lib/clearingHouseUser.js +16 -20
- package/lib/config.js +1 -1
- package/lib/constants/markets.d.ts +2 -1
- package/lib/constants/markets.js +20 -15
- package/lib/constants/numericConstants.d.ts +3 -1
- package/lib/constants/numericConstants.js +15 -17
- package/lib/examples/makeTradeExample.js +1 -1
- package/lib/idl/clearing_house.json +6 -2
- package/lib/math/conversion.d.ts +1 -1
- package/lib/math/insuranceFund.d.ts +2 -1
- package/lib/math/insuranceFund.js +3 -6
- package/lib/math/position.d.ts +2 -1
- package/lib/math/position.js +2 -5
- package/lib/math/utils.d.ts +2 -1
- package/lib/math/utils.js +3 -6
- package/lib/mockUSDCFaucet.d.ts +2 -1
- package/lib/orderParams.d.ts +2 -2
- package/lib/orderParams.js +7 -7
- package/lib/orders.d.ts +2 -1
- package/lib/types.d.ts +7 -5
- package/lib/types.js +2 -2
- package/package.json +9 -1
- package/src/accounts/bulkAccountLoader.ts +35 -15
- package/src/accounts/types.ts +5 -0
- package/src/accounts/webSocketAccountSubscriber.ts +67 -17
- package/src/clearingHouse.ts +56 -0
- package/src/clearingHouseUser.ts +2 -2
- package/src/config.ts +1 -1
- package/src/constants/markets.ts +9 -1
- package/src/constants/numericConstants.ts +2 -1
- package/src/examples/makeTradeExample.ts +4 -1
- package/src/idl/clearing_house.json +6 -2
- package/src/math/conversion.ts +1 -1
- package/src/math/insuranceFund.ts +1 -1
- package/src/math/position.ts +1 -1
- package/src/math/utils.ts +1 -1
- package/src/mockUSDCFaucet.ts +1 -1
- package/src/orderParams.ts +4 -4
- package/src/orders.ts +1 -1
- package/src/types.ts +4 -3
package/src/mockUSDCFaucet.ts
CHANGED
package/src/orderParams.ts
CHANGED
|
@@ -41,7 +41,7 @@ export function getLimitOrderParams(
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export function
|
|
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.
|
|
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
|
|
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.
|
|
92
|
+
orderType: OrderType.TRIGGER_LIMIT,
|
|
93
93
|
userOrderId,
|
|
94
94
|
marketIndex,
|
|
95
95
|
direction,
|
package/src/orders.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicKey, Transaction } from '@solana/web3.js';
|
|
2
|
-
import BN from '
|
|
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
|
|
23
|
-
static readonly
|
|
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;
|