@drift-labs/sdk 2.115.0-beta.8 → 2.116.0-beta.0
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/VERSION +1 -1
- package/lib/browser/constants/perpMarkets.js +12 -8
- package/lib/browser/constants/spotMarkets.js +6 -4
- package/lib/browser/dlob/DLOB.d.ts +3 -3
- package/lib/browser/dlob/DLOB.js +8 -5
- package/lib/browser/dlob/DLOBNode.d.ts +5 -5
- package/lib/browser/dlob/DLOBNode.js +12 -13
- package/lib/browser/dlob/DLOBSubscriber.d.ts +2 -1
- package/lib/browser/dlob/DLOBSubscriber.js +8 -2
- package/lib/browser/dlob/NodeList.d.ts +2 -2
- package/lib/browser/dlob/NodeList.js +2 -2
- package/lib/browser/dlob/types.d.ts +6 -1
- package/lib/browser/driftClient.d.ts +5 -5
- package/lib/browser/driftClient.js +16 -15
- package/lib/browser/idl/drift.json +57 -2
- package/lib/browser/index.d.ts +0 -1
- package/lib/browser/index.js +0 -1
- package/lib/browser/math/orders.d.ts +3 -2
- package/lib/browser/math/orders.js +22 -10
- package/lib/browser/math/protectedMakerParams.d.ts +4 -0
- package/lib/browser/math/protectedMakerParams.js +32 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +3 -2
- package/lib/browser/orderSubscriber/OrderSubscriber.js +4 -4
- package/lib/browser/swift/swiftOrderSubscriber.js +16 -0
- package/lib/browser/types.d.ts +15 -0
- package/lib/browser/userMap/userMap.d.ts +2 -2
- package/lib/browser/userMap/userMap.js +2 -2
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +12 -8
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +6 -4
- package/lib/node/dlob/DLOB.d.ts +3 -3
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +8 -5
- package/lib/node/dlob/DLOBNode.d.ts +5 -5
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.js +12 -13
- package/lib/node/dlob/DLOBSubscriber.d.ts +2 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +8 -2
- package/lib/node/dlob/NodeList.d.ts +2 -2
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.js +2 -2
- package/lib/node/dlob/types.d.ts +6 -1
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/driftClient.d.ts +5 -5
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +16 -15
- package/lib/node/idl/drift.json +57 -2
- package/lib/node/index.d.ts +0 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -1
- package/lib/node/math/orders.d.ts +3 -2
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +22 -10
- package/lib/node/math/protectedMakerParams.d.ts +5 -0
- package/lib/node/math/protectedMakerParams.d.ts.map +1 -0
- package/lib/node/math/protectedMakerParams.js +32 -0
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +3 -2
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +4 -4
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +16 -0
- package/lib/node/types.d.ts +15 -0
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/userMap/userMap.d.ts +2 -2
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +2 -2
- package/package.json +1 -1
- package/src/constants/perpMarkets.ts +12 -8
- package/src/constants/spotMarkets.ts +6 -4
- package/src/dlob/DLOB.ts +14 -6
- package/src/dlob/DLOBNode.ts +25 -15
- package/src/dlob/DLOBSubscriber.ts +10 -2
- package/src/dlob/NodeList.ts +3 -3
- package/src/dlob/types.ts +10 -1
- package/src/driftClient.ts +35 -18
- package/src/idl/drift.json +58 -3
- package/src/index.ts +0 -1
- package/src/math/orders.ts +39 -9
- package/src/math/protectedMakerParams.ts +37 -0
- package/src/orderSubscriber/OrderSubscriber.ts +5 -5
- package/src/swift/swiftOrderSubscriber.ts +22 -0
- package/src/types.ts +17 -0
- package/src/userMap/userMap.ts +3 -2
- package/tests/dlob/helpers.ts +6 -0
- package/tests/dlob/test.ts +4 -0
- package/lib/browser/fastlane/fastlaneOrderSubscriber.d.ts +0 -33
- package/lib/browser/fastlane/fastlaneOrderSubscriber.js +0 -137
- package/lib/browser/fastlane/grpcSignedMsgUserAccountSubscriber.d.ts +0 -22
- package/lib/browser/fastlane/grpcSignedMsgUserAccountSubscriber.js +0 -57
- package/lib/browser/fastlane/index.d.ts +0 -3
- package/lib/browser/fastlane/index.js +0 -19
- package/lib/browser/fastlane/signedMsgUserAccountSubscriber.d.ts +0 -43
- package/lib/browser/fastlane/signedMsgUserAccountSubscriber.js +0 -116
- package/lib/node/fastlane/fastlaneOrderSubscriber.d.ts +0 -34
- package/lib/node/fastlane/fastlaneOrderSubscriber.d.ts.map +0 -1
- package/lib/node/fastlane/fastlaneOrderSubscriber.js +0 -137
- package/lib/node/fastlane/grpcSignedMsgUserAccountSubscriber.d.ts +0 -23
- package/lib/node/fastlane/grpcSignedMsgUserAccountSubscriber.d.ts.map +0 -1
- package/lib/node/fastlane/grpcSignedMsgUserAccountSubscriber.js +0 -57
- package/lib/node/fastlane/index.d.ts +0 -4
- package/lib/node/fastlane/index.d.ts.map +0 -1
- package/lib/node/fastlane/index.js +0 -19
- package/lib/node/fastlane/signedMsgUserAccountSubscriber.d.ts +0 -44
- package/lib/node/fastlane/signedMsgUserAccountSubscriber.d.ts.map +0 -1
- package/lib/node/fastlane/signedMsgUserAccountSubscriber.js +0 -116
- package/src/fastlane/fastlaneOrderSubscriber.ts +0 -230
- package/src/fastlane/grpcSignedMsgUserAccountSubscriber.ts +0 -95
- package/src/fastlane/index.ts +0 -3
- package/src/fastlane/signedMsgUserAccountSubscriber.ts +0 -234
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.116.0-beta.0
|
|
@@ -708,10 +708,11 @@ exports.MainnetPerpMarkets = [
|
|
|
708
708
|
symbol: 'DRIFT-PERP',
|
|
709
709
|
baseAssetSymbol: 'DRIFT',
|
|
710
710
|
marketIndex: 30,
|
|
711
|
-
oracle: new web3_js_1.PublicKey('
|
|
711
|
+
oracle: new web3_js_1.PublicKey('5VJou4ufN2vE11zyZUaLsKLTXhyzCTgiq6QDsts2YnnD'),
|
|
712
712
|
launchTs: 1716595200000,
|
|
713
|
-
oracleSource: __1.OracleSource.
|
|
713
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
714
714
|
pythFeedId: '0x5c1690b27bb02446db17cdda13ccc2c1d609ad6d2ef5bf4983a85ea8b6f19d07',
|
|
715
|
+
pythLazerId: 249,
|
|
715
716
|
},
|
|
716
717
|
{
|
|
717
718
|
fullName: 'Sanctum',
|
|
@@ -1103,10 +1104,11 @@ exports.MainnetPerpMarkets = [
|
|
|
1103
1104
|
symbol: 'BERA-PERP',
|
|
1104
1105
|
baseAssetSymbol: 'BERA',
|
|
1105
1106
|
marketIndex: 66,
|
|
1106
|
-
oracle: new web3_js_1.PublicKey('
|
|
1107
|
+
oracle: new web3_js_1.PublicKey('r8eNLQ8jysUyk9rrWXuicwAoKZ7V3YngAB6737zfxmv'),
|
|
1107
1108
|
launchTs: 1738850177000,
|
|
1108
|
-
oracleSource: __1.OracleSource.
|
|
1109
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
1109
1110
|
pythFeedId: '0x962088abcfdbdb6e30db2e340c8cf887d9efb311b1f2f17b155a63dbb6d40265',
|
|
1111
|
+
pythLazerId: 308,
|
|
1110
1112
|
},
|
|
1111
1113
|
{
|
|
1112
1114
|
fullName: 'NBAFINALS25-OKC',
|
|
@@ -1134,10 +1136,11 @@ exports.MainnetPerpMarkets = [
|
|
|
1134
1136
|
symbol: 'KAITO-PERP',
|
|
1135
1137
|
baseAssetSymbol: 'KAITO',
|
|
1136
1138
|
marketIndex: 69,
|
|
1137
|
-
oracle: new web3_js_1.PublicKey('
|
|
1139
|
+
oracle: new web3_js_1.PublicKey('8M8mjNJ42k2Xi12Q1zRnQRC3xhggu3WGuftiu5VZZmsF'),
|
|
1138
1140
|
launchTs: 1739545901000,
|
|
1139
|
-
oracleSource: __1.OracleSource.
|
|
1141
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
1140
1142
|
pythFeedId: '0x7302dee641a08507c297a7b0c8b3efa74a48a3baa6c040acab1e5209692b7e59',
|
|
1143
|
+
pythLazerId: 306,
|
|
1141
1144
|
},
|
|
1142
1145
|
{
|
|
1143
1146
|
fullName: 'Story Protocol',
|
|
@@ -1145,10 +1148,11 @@ exports.MainnetPerpMarkets = [
|
|
|
1145
1148
|
symbol: 'IP-PERP',
|
|
1146
1149
|
baseAssetSymbol: 'IP',
|
|
1147
1150
|
marketIndex: 70,
|
|
1148
|
-
oracle: new web3_js_1.PublicKey('
|
|
1151
|
+
oracle: new web3_js_1.PublicKey('AZVVDFve8ijzLAm9z6W53GFsoWbcycFsdxCL7WUjMz8S'),
|
|
1149
1152
|
launchTs: 1740150623000,
|
|
1150
|
-
oracleSource: __1.OracleSource.
|
|
1153
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
1151
1154
|
pythFeedId: '0xb620ba83044577029da7e4ded7a2abccf8e6afc2a0d4d26d89ccdd39ec109025',
|
|
1155
|
+
pythLazerId: 309,
|
|
1152
1156
|
},
|
|
1153
1157
|
];
|
|
1154
1158
|
exports.PerpMarkets = {
|
|
@@ -300,14 +300,15 @@ exports.MainnetSpotMarkets = [
|
|
|
300
300
|
symbol: 'DRIFT',
|
|
301
301
|
marketIndex: 15,
|
|
302
302
|
poolId: 0,
|
|
303
|
-
oracle: new web3_js_1.PublicKey('
|
|
304
|
-
oracleSource: __1.OracleSource.
|
|
303
|
+
oracle: new web3_js_1.PublicKey('5VJou4ufN2vE11zyZUaLsKLTXhyzCTgiq6QDsts2YnnD'),
|
|
304
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
305
305
|
mint: new web3_js_1.PublicKey('DriFtupJYLTosbwoN8koMbEYSx54aFAVLddWsbksjwg7'),
|
|
306
306
|
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
307
307
|
precisionExp: numericConstants_1.SIX,
|
|
308
308
|
phoenixMarket: new web3_js_1.PublicKey('8BV6rrWsUabnTDA3dE6A69oUDJAj3hMhtBHTJyXB7czp'),
|
|
309
309
|
launchTs: 1715860800000,
|
|
310
310
|
pythFeedId: '0x5c1690b27bb02446db17cdda13ccc2c1d609ad6d2ef5bf4983a85ea8b6f19d07',
|
|
311
|
+
pythLazerId: 249,
|
|
311
312
|
},
|
|
312
313
|
{
|
|
313
314
|
symbol: 'INF',
|
|
@@ -337,13 +338,14 @@ exports.MainnetSpotMarkets = [
|
|
|
337
338
|
symbol: 'USDY',
|
|
338
339
|
marketIndex: 18,
|
|
339
340
|
poolId: 0,
|
|
340
|
-
oracle: new web3_js_1.PublicKey('
|
|
341
|
-
oracleSource: __1.OracleSource.
|
|
341
|
+
oracle: new web3_js_1.PublicKey('9PgHM68FNGDK6nHb29ERDBcFrV6gNMD8LyUqwxbyyeb2'),
|
|
342
|
+
oracleSource: __1.OracleSource.PYTH_LAZER,
|
|
342
343
|
mint: new web3_js_1.PublicKey('A1KLoBrKBde8Ty9qtNQUtq3C2ortoC3u7twggz7sEto6'),
|
|
343
344
|
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
344
345
|
precisionExp: numericConstants_1.SIX,
|
|
345
346
|
launchTs: 1718811089000,
|
|
346
347
|
pythFeedId: '0xe393449f6aff8a4b6d3e1165a7c9ebec103685f3b41e60db4277b5b6d10e7326',
|
|
348
|
+
pythLazerId: 276,
|
|
347
349
|
},
|
|
348
350
|
{
|
|
349
351
|
symbol: 'JLP',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { NodeList } from './NodeList';
|
|
3
|
-
import { BN, DLOBNode, DLOBNodeType, DriftClient, MarketType, MarketTypeStr, OraclePriceData, Order, PerpMarketAccount, PositionDirection, SlotSubscriber, SpotMarketAccount, StateAccount, TriggerOrderNode, UserMap } from '..';
|
|
3
|
+
import { BN, DLOBNode, DLOBNodeType, DriftClient, MarketType, MarketTypeStr, OraclePriceData, Order, PerpMarketAccount, PositionDirection, ProtectMakerParamsMap, SlotSubscriber, SpotMarketAccount, StateAccount, TriggerOrderNode, UserMap } from '..';
|
|
4
4
|
import { PublicKey } from '@solana/web3.js';
|
|
5
5
|
import { L2OrderBook, L2OrderBookGenerator, L3OrderBook } from './orderBookLevels';
|
|
6
6
|
export type DLOBOrder = {
|
|
@@ -58,8 +58,8 @@ export declare class DLOB {
|
|
|
58
58
|
orderLists: Map<MarketTypeStr, Map<number, MarketNodeLists>>;
|
|
59
59
|
maxSlotForRestingLimitOrders: number;
|
|
60
60
|
initialized: boolean;
|
|
61
|
-
|
|
62
|
-
constructor(
|
|
61
|
+
protectedMakerParamsMap: ProtectMakerParamsMap;
|
|
62
|
+
constructor(protectedMakerParamsMap?: ProtectMakerParamsMap);
|
|
63
63
|
private init;
|
|
64
64
|
clear(): void;
|
|
65
65
|
/**
|
package/lib/browser/dlob/DLOB.js
CHANGED
|
@@ -14,12 +14,15 @@ const SUPPORTED_ORDER_TYPES = [
|
|
|
14
14
|
'oracle',
|
|
15
15
|
];
|
|
16
16
|
class DLOB {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(protectedMakerParamsMap) {
|
|
18
18
|
this.openOrders = new Map();
|
|
19
19
|
this.orderLists = new Map();
|
|
20
20
|
this.maxSlotForRestingLimitOrders = 0;
|
|
21
21
|
this.initialized = false;
|
|
22
|
-
this.
|
|
22
|
+
this.protectedMakerParamsMap = protectedMakerParamsMap || {
|
|
23
|
+
perp: new Map(),
|
|
24
|
+
spot: new Map(),
|
|
25
|
+
};
|
|
23
26
|
this.init();
|
|
24
27
|
}
|
|
25
28
|
init() {
|
|
@@ -88,7 +91,7 @@ class DLOB {
|
|
|
88
91
|
.get(marketType)
|
|
89
92
|
.add((0, NodeList_1.getOrderSignature)(order.orderId, userAccount));
|
|
90
93
|
}
|
|
91
|
-
(_a = this.getListForOnChainOrder(order, slot, isUserProtectedMaker)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount, isUserProtectedMaker, this.
|
|
94
|
+
(_a = this.getListForOnChainOrder(order, slot, isUserProtectedMaker)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount, isUserProtectedMaker, this.protectedMakerParamsMap[marketType].get(order.marketIndex));
|
|
92
95
|
if (onInsert) {
|
|
93
96
|
onInsert();
|
|
94
97
|
}
|
|
@@ -106,7 +109,7 @@ class DLOB {
|
|
|
106
109
|
this.orderLists
|
|
107
110
|
.get(marketType)
|
|
108
111
|
.get(marketIndex)
|
|
109
|
-
.signedMsg[bidOrAsk].insert(order, marketType, userAccount, isUserProtectedMaker, this.
|
|
112
|
+
.signedMsg[bidOrAsk].insert(order, marketType, userAccount, isUserProtectedMaker, this.protectedMakerParamsMap[marketType].get(order.marketIndex));
|
|
110
113
|
if (onInsert) {
|
|
111
114
|
onInsert();
|
|
112
115
|
}
|
|
@@ -215,7 +218,7 @@ class DLOB {
|
|
|
215
218
|
for (const nodeToUpdate of nodesToUpdate) {
|
|
216
219
|
const { side, node } = nodeToUpdate;
|
|
217
220
|
nodeLists.takingLimit[side].remove(node.order, node.userAccount);
|
|
218
|
-
nodeLists.restingLimit[side].insert(node.order, marketTypeStr, node.userAccount, node.isProtectedMaker, this.
|
|
221
|
+
nodeLists.restingLimit[side].insert(node.order, marketTypeStr, node.userAccount, node.isProtectedMaker, this.protectedMakerParamsMap[marketTypeStr].get(node.order.marketIndex));
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
224
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
|
-
import { BN, OraclePriceData, Order } from '..';
|
|
2
|
+
import { BN, OraclePriceData, Order, ProtectedMakerParams } from '..';
|
|
3
3
|
export interface DLOBNode {
|
|
4
4
|
getPrice(oraclePriceData: OraclePriceData, slot: number): BN;
|
|
5
5
|
isVammNode(): boolean;
|
|
@@ -8,7 +8,7 @@ export interface DLOBNode {
|
|
|
8
8
|
haveFilled: boolean;
|
|
9
9
|
userAccount: string | undefined;
|
|
10
10
|
isProtectedMaker: boolean;
|
|
11
|
-
|
|
11
|
+
protectedMakerParams?: ProtectedMakerParams;
|
|
12
12
|
isSignedMsg: boolean | undefined;
|
|
13
13
|
}
|
|
14
14
|
export declare abstract class OrderNode implements DLOBNode {
|
|
@@ -18,9 +18,9 @@ export declare abstract class OrderNode implements DLOBNode {
|
|
|
18
18
|
haveFilled: boolean;
|
|
19
19
|
haveTrigger: boolean;
|
|
20
20
|
isProtectedMaker: boolean;
|
|
21
|
-
|
|
21
|
+
protectedMakerParams?: ProtectedMakerParams;
|
|
22
22
|
isSignedMsg: boolean;
|
|
23
|
-
constructor(order: Order, userAccount: string, isProtectedMaker: boolean,
|
|
23
|
+
constructor(order: Order, userAccount: string, isProtectedMaker: boolean, protectedMakerParams?: ProtectedMakerParams, isSignedMsg?: boolean);
|
|
24
24
|
abstract getSortValue(order: Order): BN;
|
|
25
25
|
getLabel(): string;
|
|
26
26
|
getPrice(oraclePriceData: OraclePriceData, slot: number): BN;
|
|
@@ -68,4 +68,4 @@ export type DLOBNodeMap = {
|
|
|
68
68
|
signedMsg: SignedMsgOrderNode;
|
|
69
69
|
};
|
|
70
70
|
export type DLOBNodeType = 'signedMsg' | 'restingLimit' | 'takingLimit' | 'floatingLimit' | 'protectedFloatingLimit' | 'market' | ('trigger' & keyof DLOBNodeMap);
|
|
71
|
-
export declare function createNode<T extends DLOBNodeType>(nodeType: T, order: Order, userAccount: string, isProtectedMaker: boolean,
|
|
71
|
+
export declare function createNode<T extends DLOBNodeType>(nodeType: T, order: Order, userAccount: string, isProtectedMaker: boolean, protectedMakerParams?: ProtectedMakerParams): DLOBNodeMap[T];
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNode = exports.SignedMsgOrderNode = exports.TriggerOrderNode = exports.MarketOrderNode = exports.FloatingLimitOrderNode = exports.RestingLimitOrderNode = exports.TakingLimitOrderNode = exports.OrderNode = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
|
-
// import { PublicKey } from '@solana/web3.js';
|
|
6
5
|
const NodeList_1 = require("./NodeList");
|
|
7
6
|
class OrderNode {
|
|
8
|
-
constructor(order, userAccount, isProtectedMaker,
|
|
7
|
+
constructor(order, userAccount, isProtectedMaker, protectedMakerParams, isSignedMsg = false) {
|
|
9
8
|
this.haveFilled = false;
|
|
10
9
|
this.haveTrigger = false;
|
|
11
10
|
// Copy the order over to the node
|
|
@@ -13,7 +12,7 @@ class OrderNode {
|
|
|
13
12
|
this.userAccount = userAccount;
|
|
14
13
|
this.sortValue = this.getSortValue(order);
|
|
15
14
|
this.isProtectedMaker = isProtectedMaker;
|
|
16
|
-
this.
|
|
15
|
+
this.protectedMakerParams = protectedMakerParams;
|
|
17
16
|
this.isSignedMsg = isSignedMsg;
|
|
18
17
|
}
|
|
19
18
|
getLabel() {
|
|
@@ -30,7 +29,7 @@ class OrderNode {
|
|
|
30
29
|
return msg;
|
|
31
30
|
}
|
|
32
31
|
getPrice(oraclePriceData, slot) {
|
|
33
|
-
return (0, __1.getLimitPrice)(this.order, oraclePriceData, slot, undefined, this.
|
|
32
|
+
return (0, __1.getLimitPrice)(this.order, oraclePriceData, slot, undefined, this.isProtectedMaker ? this.protectedMakerParams : undefined);
|
|
34
33
|
}
|
|
35
34
|
isBaseFilled() {
|
|
36
35
|
return this.order.baseAssetAmountFilled.eq(this.order.baseAssetAmount);
|
|
@@ -49,7 +48,7 @@ exports.TakingLimitOrderNode = TakingLimitOrderNode;
|
|
|
49
48
|
class RestingLimitOrderNode extends OrderNode {
|
|
50
49
|
getSortValue(order) {
|
|
51
50
|
let sortValue = order.price;
|
|
52
|
-
if (this.
|
|
51
|
+
if (this.protectedMakerParams && this.isProtectedMaker) {
|
|
53
52
|
const offset = sortValue.divn(1000);
|
|
54
53
|
if ((0, __1.isVariant)(order.direction, 'long')) {
|
|
55
54
|
sortValue = sortValue.sub(offset);
|
|
@@ -83,27 +82,27 @@ exports.TriggerOrderNode = TriggerOrderNode;
|
|
|
83
82
|
// We'll use the signedMsg uuid for the order id since it's not yet on-chain
|
|
84
83
|
class SignedMsgOrderNode extends OrderNode {
|
|
85
84
|
constructor(order, userAccount) {
|
|
86
|
-
super(order, userAccount, false,
|
|
85
|
+
super(order, userAccount, false, undefined, true);
|
|
87
86
|
}
|
|
88
87
|
getSortValue(order) {
|
|
89
88
|
return order.slot;
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
exports.SignedMsgOrderNode = SignedMsgOrderNode;
|
|
93
|
-
function createNode(nodeType, order, userAccount, isProtectedMaker,
|
|
92
|
+
function createNode(nodeType, order, userAccount, isProtectedMaker, protectedMakerParams) {
|
|
94
93
|
switch (nodeType) {
|
|
95
94
|
case 'floatingLimit':
|
|
96
|
-
return new FloatingLimitOrderNode(order, userAccount, isProtectedMaker,
|
|
95
|
+
return new FloatingLimitOrderNode(order, userAccount, isProtectedMaker, protectedMakerParams);
|
|
97
96
|
case 'protectedFloatingLimit':
|
|
98
|
-
return new FloatingLimitOrderNode(order, userAccount, isProtectedMaker,
|
|
97
|
+
return new FloatingLimitOrderNode(order, userAccount, isProtectedMaker, protectedMakerParams);
|
|
99
98
|
case 'restingLimit':
|
|
100
|
-
return new RestingLimitOrderNode(order, userAccount, isProtectedMaker,
|
|
99
|
+
return new RestingLimitOrderNode(order, userAccount, isProtectedMaker, protectedMakerParams);
|
|
101
100
|
case 'takingLimit':
|
|
102
|
-
return new TakingLimitOrderNode(order, userAccount, isProtectedMaker,
|
|
101
|
+
return new TakingLimitOrderNode(order, userAccount, isProtectedMaker, protectedMakerParams);
|
|
103
102
|
case 'market':
|
|
104
|
-
return new MarketOrderNode(order, userAccount, isProtectedMaker,
|
|
103
|
+
return new MarketOrderNode(order, userAccount, isProtectedMaker, undefined);
|
|
105
104
|
case 'trigger':
|
|
106
|
-
return new TriggerOrderNode(order, userAccount, isProtectedMaker,
|
|
105
|
+
return new TriggerOrderNode(order, userAccount, isProtectedMaker, undefined);
|
|
107
106
|
case 'signedMsg':
|
|
108
107
|
return new SignedMsgOrderNode(order, userAccount);
|
|
109
108
|
default:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { DLOB } from './DLOB';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
6
|
-
import { DLOBSource, DLOBSubscriberEvents, DLOBSubscriptionConfig, SlotSource } from './types';
|
|
6
|
+
import { DLOBSource, DLOBSubscriberEvents, DLOBSubscriptionConfig, ProtectMakerParamsMap, SlotSource } from './types';
|
|
7
7
|
import { DriftClient } from '../driftClient';
|
|
8
8
|
import { MarketType } from '../types';
|
|
9
9
|
import { L2OrderBook, L2OrderBookGenerator, L3OrderBook } from './orderBookLevels';
|
|
@@ -18,6 +18,7 @@ export declare class DLOBSubscriber {
|
|
|
18
18
|
protectedMakerView: boolean;
|
|
19
19
|
constructor(config: DLOBSubscriptionConfig);
|
|
20
20
|
subscribe(): Promise<void>;
|
|
21
|
+
getProtectedMakerParamsMap(): ProtectMakerParamsMap | undefined;
|
|
21
22
|
updateDLOB(): Promise<void>;
|
|
22
23
|
getDLOB(): DLOB;
|
|
23
24
|
/**
|
|
@@ -5,6 +5,7 @@ const DLOB_1 = require("./DLOB");
|
|
|
5
5
|
const events_1 = require("events");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
7
|
const orderBookLevels_1 = require("./orderBookLevels");
|
|
8
|
+
const protectedMakerParams_1 = require("../math/protectedMakerParams");
|
|
8
9
|
class DLOBSubscriber {
|
|
9
10
|
constructor(config) {
|
|
10
11
|
this.driftClient = config.driftClient;
|
|
@@ -12,7 +13,7 @@ class DLOBSubscriber {
|
|
|
12
13
|
this.slotSource = config.slotSource;
|
|
13
14
|
this.updateFrequency = config.updateFrequency;
|
|
14
15
|
this.protectedMakerView = config.protectedMakerView || false;
|
|
15
|
-
this.dlob = new DLOB_1.DLOB(this.
|
|
16
|
+
this.dlob = new DLOB_1.DLOB(this.getProtectedMakerParamsMap());
|
|
16
17
|
this.eventEmitter = new events_1.EventEmitter();
|
|
17
18
|
}
|
|
18
19
|
async subscribe() {
|
|
@@ -30,8 +31,13 @@ class DLOBSubscriber {
|
|
|
30
31
|
}
|
|
31
32
|
}, this.updateFrequency);
|
|
32
33
|
}
|
|
34
|
+
getProtectedMakerParamsMap() {
|
|
35
|
+
return this.protectedMakerView
|
|
36
|
+
? (0, protectedMakerParams_1.getProtectedMakerParamsMap)(this.driftClient.getPerpMarketAccounts())
|
|
37
|
+
: undefined;
|
|
38
|
+
}
|
|
33
39
|
async updateDLOB() {
|
|
34
|
-
this.dlob = await this.dlobSource.getDLOB(this.slotSource.getSlot(), this.
|
|
40
|
+
this.dlob = await this.dlobSource.getDLOB(this.slotSource.getSlot(), this.getProtectedMakerParamsMap());
|
|
35
41
|
}
|
|
36
42
|
getDLOB() {
|
|
37
43
|
return this.dlob;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MarketTypeStr, Order } from '..';
|
|
1
|
+
import { MarketTypeStr, Order, ProtectedMakerParams } from '..';
|
|
2
2
|
import { DLOBNode, DLOBNodeMap } from './DLOBNode';
|
|
3
3
|
export type SortDirection = 'asc' | 'desc';
|
|
4
4
|
export declare function getOrderSignature(orderId: number, userAccount: string): string;
|
|
@@ -13,7 +13,7 @@ export declare class NodeList<NodeType extends keyof DLOBNodeMap> implements DLO
|
|
|
13
13
|
nodeMap: Map<string, DLOBNodeMap[NodeType]>;
|
|
14
14
|
constructor(nodeType: NodeType, sortDirection: SortDirection);
|
|
15
15
|
clear(): void;
|
|
16
|
-
insert(order: Order, marketType: MarketTypeStr, userAccount: string, isProtectedMaker: boolean,
|
|
16
|
+
insert(order: Order, marketType: MarketTypeStr, userAccount: string, isProtectedMaker: boolean, protectedMakerParamsMap?: ProtectedMakerParams): void;
|
|
17
17
|
prependNode(currentNode: DLOBNodeMap[NodeType], newNode: DLOBNodeMap[NodeType]): boolean;
|
|
18
18
|
update(order: Order, userAccount: string): void;
|
|
19
19
|
remove(order: Order, userAccount: string): void;
|
|
@@ -19,11 +19,11 @@ class NodeList {
|
|
|
19
19
|
this.length = 0;
|
|
20
20
|
this.nodeMap.clear();
|
|
21
21
|
}
|
|
22
|
-
insert(order, marketType, userAccount, isProtectedMaker,
|
|
22
|
+
insert(order, marketType, userAccount, isProtectedMaker, protectedMakerParamsMap) {
|
|
23
23
|
if (!(0, __1.isVariant)(order.status, 'open')) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const newNode = (0, DLOBNode_1.createNode)(this.nodeType, order, userAccount, isProtectedMaker,
|
|
26
|
+
const newNode = (0, DLOBNode_1.createNode)(this.nodeType, order, userAccount, isProtectedMaker, protectedMakerParamsMap);
|
|
27
27
|
const orderSignature = getOrderSignature(order.orderId, userAccount);
|
|
28
28
|
if (this.nodeMap.has(orderSignature)) {
|
|
29
29
|
return;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DLOB } from './DLOB';
|
|
2
2
|
import { DriftClient } from '../driftClient';
|
|
3
|
+
import { ProtectedMakerParams } from '../types';
|
|
4
|
+
import { MarketTypeStr } from '../types';
|
|
3
5
|
export type DLOBSubscriptionConfig = {
|
|
4
6
|
driftClient: DriftClient;
|
|
5
7
|
dlobSource: DLOBSource;
|
|
@@ -12,8 +14,11 @@ export interface DLOBSubscriberEvents {
|
|
|
12
14
|
error: (e: Error) => void;
|
|
13
15
|
}
|
|
14
16
|
export interface DLOBSource {
|
|
15
|
-
getDLOB(slot: number,
|
|
17
|
+
getDLOB(slot: number, protectedMakerParamsMap?: ProtectMakerParamsMap): Promise<DLOB>;
|
|
16
18
|
}
|
|
17
19
|
export interface SlotSource {
|
|
18
20
|
getSlot(): number;
|
|
19
21
|
}
|
|
22
|
+
export type ProtectMakerParamsMap = {
|
|
23
|
+
[marketType in MarketTypeStr]: Map<number, ProtectedMakerParams>;
|
|
24
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as anchor from '@coral-xyz/anchor';
|
|
6
6
|
import { AnchorProvider, BN, Program, ProgramAccount } from '@coral-xyz/anchor';
|
|
7
7
|
import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30';
|
|
8
|
-
import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SignedMsgOrderParamsMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount, ProtectedMakerModeConfig } from './types';
|
|
8
|
+
import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SignedMsgOrderParamsMessage, TakerInfo, TxParams, UserAccount, UserStatsAccount, ProtectedMakerModeConfig, SignedMsgOrderParamsDelegateMessage } from './types';
|
|
9
9
|
import { AccountMeta, AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
|
|
10
10
|
import { TokenFaucet } from './tokenFaucet';
|
|
11
11
|
import { EventEmitter } from 'events';
|
|
@@ -245,8 +245,8 @@ export declare class DriftClient {
|
|
|
245
245
|
* Forces a fetch to rpc before returning accounts. Useful for anchor tests.
|
|
246
246
|
* @param subAccountId
|
|
247
247
|
*/
|
|
248
|
-
forceGetUserAccount(subAccountId?: number): Promise<UserAccount | undefined>;
|
|
249
|
-
getUserAccountAndSlot(subAccountId?: number): DataAndSlot<UserAccount> | undefined;
|
|
248
|
+
forceGetUserAccount(subAccountId?: number, authority?: PublicKey): Promise<UserAccount | undefined>;
|
|
249
|
+
getUserAccountAndSlot(subAccountId?: number, authority?: PublicKey): DataAndSlot<UserAccount> | undefined;
|
|
250
250
|
getSpotPosition(marketIndex: number, subAccountId?: number): SpotPosition | undefined;
|
|
251
251
|
getQuoteAssetTokenAmount(): BN;
|
|
252
252
|
/**
|
|
@@ -577,8 +577,8 @@ export declare class DriftClient {
|
|
|
577
577
|
getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
578
578
|
placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
579
579
|
getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
|
|
580
|
-
signSignedMsgOrderParamsMessage(orderParamsMessage: SignedMsgOrderParamsMessage): SignedMsgOrderParams;
|
|
581
|
-
encodeSignedMsgOrderParamsMessage(orderParamsMessage: SignedMsgOrderParamsMessage): Buffer;
|
|
580
|
+
signSignedMsgOrderParamsMessage(orderParamsMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, delegateSigner?: boolean): SignedMsgOrderParams;
|
|
581
|
+
encodeSignedMsgOrderParamsMessage(orderParamsMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, delegateSigner?: boolean): Buffer;
|
|
582
582
|
decodeSignedMsgOrderParamsMessage(encodedMessage: Buffer): SignedMsgOrderParamsMessage;
|
|
583
583
|
signMessage(message: Uint8Array, keypair?: Keypair): Buffer;
|
|
584
584
|
placeSignedMsgTakerOrder(signedSignedMsgOrderParams: SignedMsgOrderParams, marketIndex: number, takerInfo: {
|
|
@@ -1195,12 +1195,12 @@ class DriftClient {
|
|
|
1195
1195
|
* Forces a fetch to rpc before returning accounts. Useful for anchor tests.
|
|
1196
1196
|
* @param subAccountId
|
|
1197
1197
|
*/
|
|
1198
|
-
async forceGetUserAccount(subAccountId) {
|
|
1199
|
-
await this.getUser(subAccountId).fetchAccounts();
|
|
1200
|
-
return this.getUser(subAccountId).getUserAccount();
|
|
1198
|
+
async forceGetUserAccount(subAccountId, authority) {
|
|
1199
|
+
await this.getUser(subAccountId, authority).fetchAccounts();
|
|
1200
|
+
return this.getUser(subAccountId, authority).getUserAccount();
|
|
1201
1201
|
}
|
|
1202
|
-
getUserAccountAndSlot(subAccountId) {
|
|
1203
|
-
return this.getUser(subAccountId).getUserAccountAndSlot();
|
|
1202
|
+
getUserAccountAndSlot(subAccountId, authority) {
|
|
1203
|
+
return this.getUser(subAccountId, authority).getUserAccountAndSlot();
|
|
1204
1204
|
}
|
|
1205
1205
|
getSpotPosition(marketIndex, subAccountId) {
|
|
1206
1206
|
return this.getUserAccount(subAccountId).spotPositions.find((spotPosition) => spotPosition.marketIndex === marketIndex);
|
|
@@ -1275,7 +1275,9 @@ class DriftClient {
|
|
|
1275
1275
|
if (params.useMarketLastSlotCache) {
|
|
1276
1276
|
const lastUserSlot = (_a = this.getUserAccountAndSlot(params.userAccounts.length > 0
|
|
1277
1277
|
? params.userAccounts[0].subAccountId
|
|
1278
|
-
: this.activeSubAccountId
|
|
1278
|
+
: this.activeSubAccountId, params.userAccounts.length > 0
|
|
1279
|
+
? params.userAccounts[0].authority
|
|
1280
|
+
: this.authority)) === null || _a === void 0 ? void 0 : _a.slot;
|
|
1279
1281
|
for (const [marketIndex, slot,] of this.perpMarketLastSlotCache.entries()) {
|
|
1280
1282
|
// if cache has more recent slot than user positions account slot, add market to remaining accounts
|
|
1281
1283
|
// otherwise remove from slot
|
|
@@ -1858,8 +1860,8 @@ class DriftClient {
|
|
|
1858
1860
|
return txSig;
|
|
1859
1861
|
}
|
|
1860
1862
|
async getTransferPerpPositionIx(fromSubAccountId, toSubAccountId, marketIndex, amount) {
|
|
1861
|
-
const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.
|
|
1862
|
-
const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.
|
|
1863
|
+
const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.authority, fromSubAccountId);
|
|
1864
|
+
const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.authority, toSubAccountId);
|
|
1863
1865
|
const remainingAccounts = this.getRemainingAccounts({
|
|
1864
1866
|
userAccounts: [
|
|
1865
1867
|
this.getUserAccount(fromSubAccountId),
|
|
@@ -1924,7 +1926,6 @@ class DriftClient {
|
|
|
1924
1926
|
const userAccount = (await this.program.account.user.fetch(userAccountPublicKey));
|
|
1925
1927
|
const remainingAccounts = this.getRemainingAccounts({
|
|
1926
1928
|
userAccounts: [userAccount],
|
|
1927
|
-
useMarketLastSlotCache: true,
|
|
1928
1929
|
writablePerpMarketIndexes: [marketIndex],
|
|
1929
1930
|
});
|
|
1930
1931
|
if (sharesToBurn == undefined) {
|
|
@@ -3380,8 +3381,8 @@ class DriftClient {
|
|
|
3380
3381
|
remainingAccounts,
|
|
3381
3382
|
});
|
|
3382
3383
|
}
|
|
3383
|
-
signSignedMsgOrderParamsMessage(orderParamsMessage) {
|
|
3384
|
-
const borshBuf = this.encodeSignedMsgOrderParamsMessage(orderParamsMessage);
|
|
3384
|
+
signSignedMsgOrderParamsMessage(orderParamsMessage, delegateSigner) {
|
|
3385
|
+
const borshBuf = this.encodeSignedMsgOrderParamsMessage(orderParamsMessage, delegateSigner);
|
|
3385
3386
|
const orderParams = Buffer.from(borshBuf.toString('hex'));
|
|
3386
3387
|
return {
|
|
3387
3388
|
orderParams,
|
|
@@ -3391,12 +3392,14 @@ class DriftClient {
|
|
|
3391
3392
|
/*
|
|
3392
3393
|
* Borsh encode signedMsg taker order params
|
|
3393
3394
|
*/
|
|
3394
|
-
encodeSignedMsgOrderParamsMessage(orderParamsMessage) {
|
|
3395
|
+
encodeSignedMsgOrderParamsMessage(orderParamsMessage, delegateSigner) {
|
|
3395
3396
|
const anchorIxName = 'global' + ':' + 'SignedMsgOrderParamsMessage';
|
|
3396
3397
|
const prefix = Buffer.from((0, sha256_1.sha256)(anchorIxName).slice(0, 8));
|
|
3397
3398
|
const buf = Buffer.concat([
|
|
3398
3399
|
prefix,
|
|
3399
|
-
|
|
3400
|
+
delegateSigner
|
|
3401
|
+
? this.program.coder.types.encode('SignedMsgOrderParamsDelegateMessage', orderParamsMessage)
|
|
3402
|
+
: this.program.coder.types.encode('SignedMsgOrderParamsMessage', orderParamsMessage),
|
|
3400
3403
|
]);
|
|
3401
3404
|
return buf;
|
|
3402
3405
|
}
|
|
@@ -3928,7 +3931,6 @@ class DriftClient {
|
|
|
3928
3931
|
userAccount,
|
|
3929
3932
|
...makerInfos.map((makerInfo) => makerInfo.makerUserAccount),
|
|
3930
3933
|
],
|
|
3931
|
-
useMarketLastSlotCache: true,
|
|
3932
3934
|
writablePerpMarketIndexes: [marketIndex],
|
|
3933
3935
|
});
|
|
3934
3936
|
for (const makerInfo of makerInfos) {
|
|
@@ -4593,7 +4595,6 @@ class DriftClient {
|
|
|
4593
4595
|
async getResolvePerpPnlDeficitIx(spotMarketIndex, perpMarketIndex) {
|
|
4594
4596
|
const remainingAccounts = this.getRemainingAccounts({
|
|
4595
4597
|
userAccounts: [this.getUserAccount()],
|
|
4596
|
-
useMarketLastSlotCache: true,
|
|
4597
4598
|
writablePerpMarketIndexes: [perpMarketIndex],
|
|
4598
4599
|
writableSpotMarketIndexes: [spotMarketIndex],
|
|
4599
4600
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.115.0",
|
|
3
3
|
"name": "drift",
|
|
4
4
|
"instructions": [
|
|
5
5
|
{
|
|
@@ -7697,12 +7697,20 @@
|
|
|
7697
7697
|
"name": "highLeverageMarginRatioMaintenance",
|
|
7698
7698
|
"type": "u16"
|
|
7699
7699
|
},
|
|
7700
|
+
{
|
|
7701
|
+
"name": "protectedMakerLimitPriceDivisor",
|
|
7702
|
+
"type": "u8"
|
|
7703
|
+
},
|
|
7704
|
+
{
|
|
7705
|
+
"name": "protectedMakerDynamicDivisor",
|
|
7706
|
+
"type": "u8"
|
|
7707
|
+
},
|
|
7700
7708
|
{
|
|
7701
7709
|
"name": "padding",
|
|
7702
7710
|
"type": {
|
|
7703
7711
|
"array": [
|
|
7704
7712
|
"u8",
|
|
7705
|
-
|
|
7713
|
+
36
|
|
7706
7714
|
]
|
|
7707
7715
|
}
|
|
7708
7716
|
}
|
|
@@ -9523,6 +9531,53 @@
|
|
|
9523
9531
|
]
|
|
9524
9532
|
}
|
|
9525
9533
|
},
|
|
9534
|
+
{
|
|
9535
|
+
"name": "SignedMsgOrderParamsDelegateMessage",
|
|
9536
|
+
"type": {
|
|
9537
|
+
"kind": "struct",
|
|
9538
|
+
"fields": [
|
|
9539
|
+
{
|
|
9540
|
+
"name": "signedMsgOrderParams",
|
|
9541
|
+
"type": {
|
|
9542
|
+
"defined": "OrderParams"
|
|
9543
|
+
}
|
|
9544
|
+
},
|
|
9545
|
+
{
|
|
9546
|
+
"name": "takerPubkey",
|
|
9547
|
+
"type": "publicKey"
|
|
9548
|
+
},
|
|
9549
|
+
{
|
|
9550
|
+
"name": "slot",
|
|
9551
|
+
"type": "u64"
|
|
9552
|
+
},
|
|
9553
|
+
{
|
|
9554
|
+
"name": "uuid",
|
|
9555
|
+
"type": {
|
|
9556
|
+
"array": [
|
|
9557
|
+
"u8",
|
|
9558
|
+
8
|
|
9559
|
+
]
|
|
9560
|
+
}
|
|
9561
|
+
},
|
|
9562
|
+
{
|
|
9563
|
+
"name": "takeProfitOrderParams",
|
|
9564
|
+
"type": {
|
|
9565
|
+
"option": {
|
|
9566
|
+
"defined": "SignedMsgTriggerOrderParams"
|
|
9567
|
+
}
|
|
9568
|
+
}
|
|
9569
|
+
},
|
|
9570
|
+
{
|
|
9571
|
+
"name": "stopLossOrderParams",
|
|
9572
|
+
"type": {
|
|
9573
|
+
"option": {
|
|
9574
|
+
"defined": "SignedMsgTriggerOrderParams"
|
|
9575
|
+
}
|
|
9576
|
+
}
|
|
9577
|
+
}
|
|
9578
|
+
]
|
|
9579
|
+
}
|
|
9580
|
+
},
|
|
9526
9581
|
{
|
|
9527
9582
|
"name": "SignedMsgTriggerOrderParams",
|
|
9528
9583
|
"type": {
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -87,7 +87,6 @@ export * from './oracles/pythPullClient';
|
|
|
87
87
|
export * from './oracles/pythLazerClient';
|
|
88
88
|
export * from './oracles/switchboardOnDemandClient';
|
|
89
89
|
export * from './oracles/oracleId';
|
|
90
|
-
export * from './fastlane/fastlaneOrderSubscriber';
|
|
91
90
|
export * from './swift/swiftOrderSubscriber';
|
|
92
91
|
export * from './swift/signedMsgUserAccountSubscriber';
|
|
93
92
|
export * from './swift/grpcSignedMsgUserAccountSubscriber';
|
package/lib/browser/index.js
CHANGED
|
@@ -110,7 +110,6 @@ __exportStar(require("./oracles/pythPullClient"), exports);
|
|
|
110
110
|
__exportStar(require("./oracles/pythLazerClient"), exports);
|
|
111
111
|
__exportStar(require("./oracles/switchboardOnDemandClient"), exports);
|
|
112
112
|
__exportStar(require("./oracles/oracleId"), exports);
|
|
113
|
-
__exportStar(require("./fastlane/fastlaneOrderSubscriber"), exports);
|
|
114
113
|
__exportStar(require("./swift/swiftOrderSubscriber"), exports);
|
|
115
114
|
__exportStar(require("./swift/signedMsgUserAccountSubscriber"), exports);
|
|
116
115
|
__exportStar(require("./swift/grpcSignedMsgUserAccountSubscriber"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { User } from '../user';
|
|
3
|
-
import { PerpMarketAccount, AMM, Order, PositionDirection } from '../types';
|
|
3
|
+
import { PerpMarketAccount, AMM, Order, PositionDirection, ProtectedMakerParams } from '../types';
|
|
4
4
|
import { BN } from '@coral-xyz/anchor';
|
|
5
5
|
import { OraclePriceData } from '../oracles/types';
|
|
6
6
|
export declare function isOrderRiskIncreasing(user: User, order: Order): boolean;
|
|
@@ -8,7 +8,8 @@ export declare function isOrderRiskIncreasingInSameDirection(user: User, order:
|
|
|
8
8
|
export declare function isOrderReduceOnly(user: User, order: Order): boolean;
|
|
9
9
|
export declare function standardizeBaseAssetAmount(baseAssetAmount: BN, stepSize: BN): BN;
|
|
10
10
|
export declare function standardizePrice(price: BN, tickSize: BN, direction: PositionDirection): BN;
|
|
11
|
-
export declare function getLimitPrice(order: Order, oraclePriceData: OraclePriceData, slot: number, fallbackPrice?: BN,
|
|
11
|
+
export declare function getLimitPrice(order: Order, oraclePriceData: OraclePriceData, slot: number, fallbackPrice?: BN, protectedMakerParams?: ProtectedMakerParams): BN | undefined;
|
|
12
|
+
export declare function applyProtectedMakerParams(limitPrice: BN, direction: PositionDirection, protectedMakerParams: ProtectedMakerParams): BN;
|
|
12
13
|
export declare function hasLimitPrice(order: Order, slot: number): boolean;
|
|
13
14
|
export declare function hasAuctionPrice(order: Order, slot: number): boolean;
|
|
14
15
|
export declare function isFillableByVAMM(order: Order, market: PerpMarketAccount, oraclePriceData: OraclePriceData, slot: number, ts: number, minAuctionDuration: number): boolean;
|