@drift-labs/sdk 2.103.0-beta.9 → 2.104.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/spotMarkets.d.ts +1 -0
- package/lib/browser/constants/spotMarkets.js +66 -0
- package/lib/browser/dlob/DLOB.d.ts +2 -2
- package/lib/browser/dlob/DLOB.js +11 -9
- package/lib/browser/dlob/DLOBNode.d.ts +4 -2
- package/lib/browser/dlob/DLOBNode.js +8 -7
- package/lib/browser/dlob/NodeList.d.ts +1 -1
- package/lib/browser/dlob/NodeList.js +3 -2
- package/lib/browser/driftClient.d.ts +2 -2
- package/lib/browser/driftClient.js +2 -2
- package/lib/browser/idl/drift.json +142 -6
- package/lib/browser/math/userStatus.d.ts +2 -0
- package/lib/browser/math/userStatus.js +8 -0
- package/lib/browser/orderSubscriber/OrderSubscriber.js +3 -1
- package/lib/browser/types.d.ts +6 -8
- package/lib/browser/types.js +6 -5
- package/lib/browser/user.js +8 -23
- package/lib/browser/userStats.d.ts +3 -0
- package/lib/browser/userStats.js +26 -0
- package/lib/node/constants/spotMarkets.d.ts +1 -0
- package/lib/node/constants/spotMarkets.js +66 -0
- package/lib/node/dlob/DLOB.d.ts +2 -2
- package/lib/node/dlob/DLOB.js +11 -9
- package/lib/node/dlob/DLOBNode.d.ts +4 -2
- package/lib/node/dlob/DLOBNode.js +8 -7
- package/lib/node/dlob/NodeList.d.ts +1 -1
- package/lib/node/dlob/NodeList.js +3 -2
- package/lib/node/driftClient.d.ts +2 -2
- package/lib/node/driftClient.js +2 -2
- package/lib/node/idl/drift.json +142 -6
- package/lib/node/math/userStatus.d.ts +2 -0
- package/lib/node/math/userStatus.js +8 -0
- package/lib/node/orderSubscriber/OrderSubscriber.js +3 -1
- package/lib/node/types.d.ts +6 -8
- package/lib/node/types.js +6 -5
- package/lib/node/user.js +8 -23
- package/lib/node/userStats.d.ts +3 -0
- package/lib/node/userStats.js +26 -0
- package/package.json +1 -1
- package/src/constants/spotMarkets.ts +71 -0
- package/src/dlob/DLOB.ts +17 -7
- package/src/dlob/DLOBNode.ts +23 -8
- package/src/dlob/NodeList.ts +9 -2
- package/src/driftClient.ts +5 -4
- package/src/idl/drift.json +142 -6
- package/src/math/userStatus.ts +5 -0
- package/src/orderSubscriber/OrderSubscriber.ts +3 -1
- package/src/types.ts +5 -3
- package/src/user.ts +20 -61
- package/src/userStats.ts +68 -1
- package/tests/dlob/helpers.ts +3 -0
- package/tests/user/helpers.ts +1 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.104.0-beta.0
|
|
@@ -9,6 +9,7 @@ exports.DevnetSpotMarkets = [
|
|
|
9
9
|
{
|
|
10
10
|
symbol: 'USDC',
|
|
11
11
|
marketIndex: 0,
|
|
12
|
+
poolId: 0,
|
|
12
13
|
oracle: new web3_js_1.PublicKey('En8hkHLkRe9d9DraYmBTrus518BvmVH448YcvmrFM6Ce'),
|
|
13
14
|
oracleSource: __1.OracleSource.PYTH_STABLE_COIN_PULL,
|
|
14
15
|
mint: new web3_js_1.PublicKey('8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2'),
|
|
@@ -19,6 +20,7 @@ exports.DevnetSpotMarkets = [
|
|
|
19
20
|
{
|
|
20
21
|
symbol: 'SOL',
|
|
21
22
|
marketIndex: 1,
|
|
23
|
+
poolId: 0,
|
|
22
24
|
oracle: new web3_js_1.PublicKey('BAtFj4kQttZRVep3UZS2aZRDixkGYgWsbqTBVDbnSsPF'),
|
|
23
25
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
24
26
|
mint: new web3_js_1.PublicKey(exports.WRAPPED_SOL_MINT),
|
|
@@ -31,6 +33,7 @@ exports.DevnetSpotMarkets = [
|
|
|
31
33
|
{
|
|
32
34
|
symbol: 'BTC',
|
|
33
35
|
marketIndex: 2,
|
|
36
|
+
poolId: 0,
|
|
34
37
|
oracle: new web3_js_1.PublicKey('486kr3pmFPfTsS4aZgcsQ7kS4i9rjMsYYZup6HQNSTT4'),
|
|
35
38
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
36
39
|
mint: new web3_js_1.PublicKey('3BZPwbcqB5kKScF3TEXxwNfx5ipV13kbRVDvfVp5c6fv'),
|
|
@@ -42,6 +45,7 @@ exports.DevnetSpotMarkets = [
|
|
|
42
45
|
{
|
|
43
46
|
symbol: 'PYUSD',
|
|
44
47
|
marketIndex: 3,
|
|
48
|
+
poolId: 0,
|
|
45
49
|
oracle: new web3_js_1.PublicKey('HpMoKp3TCd3QT4MWYUKk2zCBwmhr5Df45fB6wdxYqEeh'),
|
|
46
50
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
47
51
|
mint: new web3_js_1.PublicKey('GLfF72ZCUnS6N9iDJw8kedHzd6WFVf3VbpwdKKy76FRk'),
|
|
@@ -49,11 +53,45 @@ exports.DevnetSpotMarkets = [
|
|
|
49
53
|
precisionExp: numericConstants_1.SIX,
|
|
50
54
|
pythFeedId: '0xc1da1b73d7f01e7ddd54b3766cf7fcd644395ad14f70aa706ec5384c59e76692',
|
|
51
55
|
},
|
|
56
|
+
{
|
|
57
|
+
symbol: 'Bonk',
|
|
58
|
+
marketIndex: 4,
|
|
59
|
+
poolId: 0,
|
|
60
|
+
oracle: new web3_js_1.PublicKey('GojbSnJuPdKDT1ZuHuAM5t9oz6bxTo1xhUKpTua2F72p'),
|
|
61
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
62
|
+
mint: new web3_js_1.PublicKey('7SekVZDmKCCDgTP8m6Hk4CfexFSru9RkwDCczmcwcsP6'),
|
|
63
|
+
precision: new __1.BN(10).pow(numericConstants_1.FIVE),
|
|
64
|
+
precisionExp: numericConstants_1.FIVE,
|
|
65
|
+
pythFeedId: '0x72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
symbol: 'JLP',
|
|
69
|
+
marketIndex: 5,
|
|
70
|
+
poolId: 1,
|
|
71
|
+
oracle: new web3_js_1.PublicKey('5Mb11e5rt1Sp6A286B145E4TmgMzsM2UX9nCF2vas5bs'),
|
|
72
|
+
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
73
|
+
mint: new web3_js_1.PublicKey('HGe9FejFyhWSx6zdvx2RjynX7rmoEXFiJiLU437NXemZ'),
|
|
74
|
+
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
75
|
+
precisionExp: numericConstants_1.SIX,
|
|
76
|
+
pythFeedId: '0xc811abc82b4bad1f9bd711a2773ccaa935b03ecef974236942cec5e0eb845a3a',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
symbol: 'USDC',
|
|
80
|
+
marketIndex: 6,
|
|
81
|
+
poolId: 1,
|
|
82
|
+
oracle: new web3_js_1.PublicKey('En8hkHLkRe9d9DraYmBTrus518BvmVH448YcvmrFM6Ce'),
|
|
83
|
+
oracleSource: __1.OracleSource.PYTH_STABLE_COIN_PULL,
|
|
84
|
+
mint: new web3_js_1.PublicKey('8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2'),
|
|
85
|
+
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
86
|
+
precisionExp: numericConstants_1.SIX,
|
|
87
|
+
pythFeedId: '0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
|
|
88
|
+
},
|
|
52
89
|
];
|
|
53
90
|
exports.MainnetSpotMarkets = [
|
|
54
91
|
{
|
|
55
92
|
symbol: 'USDC',
|
|
56
93
|
marketIndex: 0,
|
|
94
|
+
poolId: 0,
|
|
57
95
|
oracle: new web3_js_1.PublicKey('En8hkHLkRe9d9DraYmBTrus518BvmVH448YcvmrFM6Ce'),
|
|
58
96
|
oracleSource: __1.OracleSource.PYTH_STABLE_COIN_PULL,
|
|
59
97
|
mint: new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
|
|
@@ -64,6 +102,7 @@ exports.MainnetSpotMarkets = [
|
|
|
64
102
|
{
|
|
65
103
|
symbol: 'SOL',
|
|
66
104
|
marketIndex: 1,
|
|
105
|
+
poolId: 0,
|
|
67
106
|
oracle: new web3_js_1.PublicKey('BAtFj4kQttZRVep3UZS2aZRDixkGYgWsbqTBVDbnSsPF'),
|
|
68
107
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
69
108
|
mint: new web3_js_1.PublicKey(exports.WRAPPED_SOL_MINT),
|
|
@@ -77,6 +116,7 @@ exports.MainnetSpotMarkets = [
|
|
|
77
116
|
{
|
|
78
117
|
symbol: 'mSOL',
|
|
79
118
|
marketIndex: 2,
|
|
119
|
+
poolId: 0,
|
|
80
120
|
oracle: new web3_js_1.PublicKey('FAq7hqjn7FWGXKDwJHzsXGgBcydGTcK4kziJpAGWXjDb'),
|
|
81
121
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
82
122
|
mint: new web3_js_1.PublicKey('mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'),
|
|
@@ -88,6 +128,7 @@ exports.MainnetSpotMarkets = [
|
|
|
88
128
|
{
|
|
89
129
|
symbol: 'wBTC',
|
|
90
130
|
marketIndex: 3,
|
|
131
|
+
poolId: 0,
|
|
91
132
|
oracle: new web3_js_1.PublicKey('9Tq8iN5WnMX2PcZGj4iSFEAgHCi8cM6x8LsDUbuzq8uw'),
|
|
92
133
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
93
134
|
mint: new web3_js_1.PublicKey('3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh'),
|
|
@@ -99,6 +140,7 @@ exports.MainnetSpotMarkets = [
|
|
|
99
140
|
{
|
|
100
141
|
symbol: 'wETH',
|
|
101
142
|
marketIndex: 4,
|
|
143
|
+
poolId: 0,
|
|
102
144
|
oracle: new web3_js_1.PublicKey('6bEp2MiyoiiiDxcVqE8rUHQWwHirXUXtKfAEATTVqNzT'),
|
|
103
145
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
104
146
|
mint: new web3_js_1.PublicKey('7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs'),
|
|
@@ -112,6 +154,7 @@ exports.MainnetSpotMarkets = [
|
|
|
112
154
|
{
|
|
113
155
|
symbol: 'USDT',
|
|
114
156
|
marketIndex: 5,
|
|
157
|
+
poolId: 0,
|
|
115
158
|
oracle: new web3_js_1.PublicKey('BekJ3P5G3iFeC97sXHuKnUHofCFj9Sbo7uyF2fkKwvit'),
|
|
116
159
|
oracleSource: __1.OracleSource.PYTH_STABLE_COIN_PULL,
|
|
117
160
|
mint: new web3_js_1.PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'),
|
|
@@ -123,6 +166,7 @@ exports.MainnetSpotMarkets = [
|
|
|
123
166
|
{
|
|
124
167
|
symbol: 'jitoSOL',
|
|
125
168
|
marketIndex: 6,
|
|
169
|
+
poolId: 0,
|
|
126
170
|
oracle: new web3_js_1.PublicKey('9QE1P5EfzthYDgoQ9oPeTByCEKaRJeZbVVqKJfgU9iau'),
|
|
127
171
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
128
172
|
mint: new web3_js_1.PublicKey('J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn'),
|
|
@@ -135,6 +179,7 @@ exports.MainnetSpotMarkets = [
|
|
|
135
179
|
{
|
|
136
180
|
symbol: 'PYTH',
|
|
137
181
|
marketIndex: 7,
|
|
182
|
+
poolId: 0,
|
|
138
183
|
oracle: new web3_js_1.PublicKey('GqkCu7CbsPVz1H6W6AAHuReqbJckYG59TXz7Y5HDV7hr'),
|
|
139
184
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
140
185
|
mint: new web3_js_1.PublicKey('HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3'),
|
|
@@ -147,6 +192,7 @@ exports.MainnetSpotMarkets = [
|
|
|
147
192
|
{
|
|
148
193
|
symbol: 'bSOL',
|
|
149
194
|
marketIndex: 8,
|
|
195
|
+
poolId: 0,
|
|
150
196
|
oracle: new web3_js_1.PublicKey('BmDWPMsytWmYkh9n6o7m79eVshVYf2B5GVaqQ2EWKnGH'),
|
|
151
197
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
152
198
|
mint: new web3_js_1.PublicKey('bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1'),
|
|
@@ -158,6 +204,7 @@ exports.MainnetSpotMarkets = [
|
|
|
158
204
|
{
|
|
159
205
|
symbol: 'JTO',
|
|
160
206
|
marketIndex: 9,
|
|
207
|
+
poolId: 0,
|
|
161
208
|
oracle: new web3_js_1.PublicKey('Ffq6ACJ17NAgaxC6ocfMzVXL3K61qxB2xHg6WUawWPfP'),
|
|
162
209
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
163
210
|
mint: new web3_js_1.PublicKey('jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL'),
|
|
@@ -170,6 +217,7 @@ exports.MainnetSpotMarkets = [
|
|
|
170
217
|
{
|
|
171
218
|
symbol: 'WIF',
|
|
172
219
|
marketIndex: 10,
|
|
220
|
+
poolId: 0,
|
|
173
221
|
oracle: new web3_js_1.PublicKey('6x6KfE7nY2xoLCRSMPT1u83wQ5fpGXoKNBqFjrCwzsCQ'),
|
|
174
222
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
175
223
|
mint: new web3_js_1.PublicKey('EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm'),
|
|
@@ -183,6 +231,7 @@ exports.MainnetSpotMarkets = [
|
|
|
183
231
|
{
|
|
184
232
|
symbol: 'JUP',
|
|
185
233
|
marketIndex: 11,
|
|
234
|
+
poolId: 0,
|
|
186
235
|
oracle: new web3_js_1.PublicKey('AwqRpfJ36jnSZQykyL1jYY35mhMteeEAjh7o8LveRQin'),
|
|
187
236
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
188
237
|
mint: new web3_js_1.PublicKey('JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN'),
|
|
@@ -195,6 +244,7 @@ exports.MainnetSpotMarkets = [
|
|
|
195
244
|
{
|
|
196
245
|
symbol: 'RENDER',
|
|
197
246
|
marketIndex: 12,
|
|
247
|
+
poolId: 0,
|
|
198
248
|
oracle: new web3_js_1.PublicKey('8TQztfGcNjHGRusX4ejQQtPZs3Ypczt9jWF6pkgQMqUX'),
|
|
199
249
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
200
250
|
mint: new web3_js_1.PublicKey('rndrizKT3MK1iimdxRdWabcF7Zg7AR5T4nud4EkHBof'),
|
|
@@ -207,6 +257,7 @@ exports.MainnetSpotMarkets = [
|
|
|
207
257
|
{
|
|
208
258
|
symbol: 'W',
|
|
209
259
|
marketIndex: 13,
|
|
260
|
+
poolId: 0,
|
|
210
261
|
oracle: new web3_js_1.PublicKey('4HbitGsdcFbtFotmYscikQFAAKJ3nYx4t7sV7fTvsk8U'),
|
|
211
262
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
212
263
|
mint: new web3_js_1.PublicKey('85VBFQZC9TZkfaptBWjvUw7YbZjy52A6mjtPGjstQAmQ'),
|
|
@@ -219,6 +270,7 @@ exports.MainnetSpotMarkets = [
|
|
|
219
270
|
{
|
|
220
271
|
symbol: 'TNSR',
|
|
221
272
|
marketIndex: 14,
|
|
273
|
+
poolId: 0,
|
|
222
274
|
oracle: new web3_js_1.PublicKey('13jpjpVyU5hGpjsZ4HzCcmBo85wze4N8Au7U6cC3GMip'),
|
|
223
275
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
224
276
|
mint: new web3_js_1.PublicKey('TNSRxcUxoT9xBG3de7PiJyTDYu7kskLqcpddxnEJAS6'),
|
|
@@ -231,6 +283,7 @@ exports.MainnetSpotMarkets = [
|
|
|
231
283
|
{
|
|
232
284
|
symbol: 'DRIFT',
|
|
233
285
|
marketIndex: 15,
|
|
286
|
+
poolId: 0,
|
|
234
287
|
oracle: new web3_js_1.PublicKey('23KmX7SNikmUr2axSCy6Zer7XPBnvmVcASALnDGqBVRR'),
|
|
235
288
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
236
289
|
mint: new web3_js_1.PublicKey('DriFtupJYLTosbwoN8koMbEYSx54aFAVLddWsbksjwg7'),
|
|
@@ -243,6 +296,7 @@ exports.MainnetSpotMarkets = [
|
|
|
243
296
|
{
|
|
244
297
|
symbol: 'INF',
|
|
245
298
|
marketIndex: 16,
|
|
299
|
+
poolId: 0,
|
|
246
300
|
oracle: new web3_js_1.PublicKey('B7RUYg2zF6UdUSHv2RmpnriPVJccYWojgFydNS1NY5F8'),
|
|
247
301
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
248
302
|
mint: new web3_js_1.PublicKey('5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm'),
|
|
@@ -254,6 +308,7 @@ exports.MainnetSpotMarkets = [
|
|
|
254
308
|
{
|
|
255
309
|
symbol: 'dSOL',
|
|
256
310
|
marketIndex: 17,
|
|
311
|
+
poolId: 0,
|
|
257
312
|
oracle: new web3_js_1.PublicKey('7QJ6e57t3yM8HYVg6bAnJiCiZ3wQQ5CSVsa6GA16nJuK'),
|
|
258
313
|
oracleSource: __1.OracleSource.SWITCHBOARD_ON_DEMAND,
|
|
259
314
|
mint: new web3_js_1.PublicKey('Dso1bDeDjCQxTrWHqUUi63oBvV7Mdm6WaobLbQ7gnPQ'),
|
|
@@ -264,6 +319,7 @@ exports.MainnetSpotMarkets = [
|
|
|
264
319
|
{
|
|
265
320
|
symbol: 'USDY',
|
|
266
321
|
marketIndex: 18,
|
|
322
|
+
poolId: 0,
|
|
267
323
|
oracle: new web3_js_1.PublicKey('BPTQgHV4y2x4jvKPPkkd9aS8jY7L3DGZBwjEZC8Vm27o'),
|
|
268
324
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
269
325
|
mint: new web3_js_1.PublicKey('A1KLoBrKBde8Ty9qtNQUtq3C2ortoC3u7twggz7sEto6'),
|
|
@@ -275,6 +331,7 @@ exports.MainnetSpotMarkets = [
|
|
|
275
331
|
{
|
|
276
332
|
symbol: 'JLP',
|
|
277
333
|
marketIndex: 19,
|
|
334
|
+
poolId: 0,
|
|
278
335
|
oracle: new web3_js_1.PublicKey('5Mb11e5rt1Sp6A286B145E4TmgMzsM2UX9nCF2vas5bs'),
|
|
279
336
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
280
337
|
mint: new web3_js_1.PublicKey('27G8MtK7VtTcCHkpASjSDdkWWYfoqT6ggEuKidVJidD4'),
|
|
@@ -286,6 +343,7 @@ exports.MainnetSpotMarkets = [
|
|
|
286
343
|
{
|
|
287
344
|
symbol: 'POPCAT',
|
|
288
345
|
marketIndex: 20,
|
|
346
|
+
poolId: 0,
|
|
289
347
|
oracle: new web3_js_1.PublicKey('H3pn43tkNvsG5z3qzmERguSvKoyHZvvY6VPmNrJqiW5X'),
|
|
290
348
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
291
349
|
mint: new web3_js_1.PublicKey('7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr'),
|
|
@@ -298,6 +356,7 @@ exports.MainnetSpotMarkets = [
|
|
|
298
356
|
{
|
|
299
357
|
symbol: 'CLOUD',
|
|
300
358
|
marketIndex: 21,
|
|
359
|
+
poolId: 0,
|
|
301
360
|
oracle: new web3_js_1.PublicKey('FNFejcXENaPgKaCTfstew9vSSvdQPnXjGTkJjUnnYvHU'),
|
|
302
361
|
oracleSource: __1.OracleSource.SWITCHBOARD_ON_DEMAND,
|
|
303
362
|
mint: new web3_js_1.PublicKey('CLoUDKc4Ane7HeQcPpE3YHnznRxhMimJ4MyaUqyHFzAu'),
|
|
@@ -308,6 +367,7 @@ exports.MainnetSpotMarkets = [
|
|
|
308
367
|
{
|
|
309
368
|
symbol: 'PYUSD',
|
|
310
369
|
marketIndex: 22,
|
|
370
|
+
poolId: 0,
|
|
311
371
|
oracle: new web3_js_1.PublicKey('HpMoKp3TCd3QT4MWYUKk2zCBwmhr5Df45fB6wdxYqEeh'),
|
|
312
372
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
313
373
|
mint: new web3_js_1.PublicKey('2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo'),
|
|
@@ -318,6 +378,7 @@ exports.MainnetSpotMarkets = [
|
|
|
318
378
|
{
|
|
319
379
|
symbol: 'USDe',
|
|
320
380
|
marketIndex: 23,
|
|
381
|
+
poolId: 0,
|
|
321
382
|
oracle: new web3_js_1.PublicKey('BXej5boX2nWudwAfZQedo212B9XJxhjTeeF3GbCwXmYa'),
|
|
322
383
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
323
384
|
mint: new web3_js_1.PublicKey('DEkqHyPN7GMRJ5cArtQFAWefqbZb33Hyf6s5iCwjEonT'),
|
|
@@ -328,6 +389,7 @@ exports.MainnetSpotMarkets = [
|
|
|
328
389
|
{
|
|
329
390
|
symbol: 'sUSDe',
|
|
330
391
|
marketIndex: 24,
|
|
392
|
+
poolId: 0,
|
|
331
393
|
oracle: new web3_js_1.PublicKey('BRuNuzLAPHHGSSVAJPKMcmJMdgDfrekvnSxkxPDGdeqp'),
|
|
332
394
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
333
395
|
mint: new web3_js_1.PublicKey('Eh6XEPhSwoLv5wFApukmnaVSHQ6sAnoD9BmgmwQoN2sN'),
|
|
@@ -338,6 +400,7 @@ exports.MainnetSpotMarkets = [
|
|
|
338
400
|
{
|
|
339
401
|
symbol: 'BNSOL',
|
|
340
402
|
marketIndex: 25,
|
|
403
|
+
poolId: 0,
|
|
341
404
|
oracle: new web3_js_1.PublicKey('8DmXTfhhtb9kTcpTVfb6Ygx8WhZ8wexGqcpxfn23zooe'),
|
|
342
405
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
343
406
|
mint: new web3_js_1.PublicKey('BNso1VUJnh4zcfpZa6986Ea66P6TCp59hvtNJ8b1X85'),
|
|
@@ -348,6 +411,7 @@ exports.MainnetSpotMarkets = [
|
|
|
348
411
|
{
|
|
349
412
|
symbol: 'MOTHER',
|
|
350
413
|
marketIndex: 26,
|
|
414
|
+
poolId: 0,
|
|
351
415
|
oracle: new web3_js_1.PublicKey('56ap2coZG7FPWUigVm9XrpQs3xuCwnwQaWtjWZcffEUG'),
|
|
352
416
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
353
417
|
mint: new web3_js_1.PublicKey('3S8qX1MsMqRbiwKg2cQyx7nis1oHMgaCuc9c4VfvVdPN'),
|
|
@@ -358,6 +422,7 @@ exports.MainnetSpotMarkets = [
|
|
|
358
422
|
{
|
|
359
423
|
symbol: 'cbBTC',
|
|
360
424
|
marketIndex: 27,
|
|
425
|
+
poolId: 0,
|
|
361
426
|
oracle: new web3_js_1.PublicKey('486kr3pmFPfTsS4aZgcsQ7kS4i9rjMsYYZup6HQNSTT4'),
|
|
362
427
|
oracleSource: __1.OracleSource.PYTH_PULL,
|
|
363
428
|
mint: new web3_js_1.PublicKey('cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij'),
|
|
@@ -369,6 +434,7 @@ exports.MainnetSpotMarkets = [
|
|
|
369
434
|
{
|
|
370
435
|
symbol: 'USDS',
|
|
371
436
|
marketIndex: 28,
|
|
437
|
+
poolId: 0,
|
|
372
438
|
oracle: new web3_js_1.PublicKey('7pT9mxKXyvfaZKeKy1oe2oV2K1RFtF7tPEJHUY3h2vVV'),
|
|
373
439
|
oracleSource: __1.OracleSource.PYTH_STABLE_COIN_PULL,
|
|
374
440
|
mint: new web3_js_1.PublicKey('USDSwr9ApdHk5bvJKMjzff41FfuX8bSxdKcR81vTwcA'),
|
|
@@ -58,10 +58,10 @@ export declare class DLOB {
|
|
|
58
58
|
initFromOrders(dlobOrders: DLOBOrders, slot: number): boolean;
|
|
59
59
|
handleOrderRecord(record: OrderRecord, slot: number): void;
|
|
60
60
|
handleOrderActionRecord(record: OrderActionRecord, slot: number): void;
|
|
61
|
-
insertOrder(order: Order, userAccount: string, slot: number, onInsert?: OrderBookCallback): void;
|
|
61
|
+
insertOrder(order: Order, userAccount: string, slot: number, isUserProtectedMaker: boolean, onInsert?: OrderBookCallback): void;
|
|
62
62
|
addOrderList(marketType: MarketTypeStr, marketIndex: number): void;
|
|
63
63
|
updateOrder(order: Order, userAccount: PublicKey, slot: number, cumulativeBaseAssetAmountFilled: BN, onUpdate?: OrderBookCallback): void;
|
|
64
|
-
trigger(order: Order, userAccount: PublicKey, slot: number, onTrigger?: OrderBookCallback): void;
|
|
64
|
+
trigger(order: Order, userAccount: PublicKey, slot: number, isUserProtectedMaker: boolean, onTrigger?: OrderBookCallback): void;
|
|
65
65
|
delete(order: Order, userAccount: PublicKey, slot: number, onDelete?: OrderBookCallback): void;
|
|
66
66
|
getListForOrder(order: Order, slot: number): NodeList<any> | undefined;
|
|
67
67
|
updateRestingLimitOrders(slot: number): void;
|
package/lib/browser/dlob/DLOB.js
CHANGED
|
@@ -6,6 +6,7 @@ const __1 = require("..");
|
|
|
6
6
|
const web3_js_1 = require("@solana/web3.js");
|
|
7
7
|
const exchangeStatus_1 = require("../math/exchangeStatus");
|
|
8
8
|
const orderBookLevels_1 = require("./orderBookLevels");
|
|
9
|
+
const userStatus_1 = require("../math/userStatus");
|
|
9
10
|
const SUPPORTED_ORDER_TYPES = [
|
|
10
11
|
'market',
|
|
11
12
|
'limit',
|
|
@@ -62,8 +63,9 @@ class DLOB {
|
|
|
62
63
|
const userAccount = user.getUserAccount();
|
|
63
64
|
const userAccountPubkey = user.getUserAccountPublicKey();
|
|
64
65
|
const userAccountPubkeyString = userAccountPubkey.toString();
|
|
66
|
+
const protectedMaker = (0, userStatus_1.isUserProtectedMaker)(userAccount);
|
|
65
67
|
for (const order of userAccount.orders) {
|
|
66
|
-
this.insertOrder(order, userAccountPubkeyString, slot);
|
|
68
|
+
this.insertOrder(order, userAccountPubkeyString, slot, protectedMaker);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
this.initialized = true;
|
|
@@ -74,13 +76,13 @@ class DLOB {
|
|
|
74
76
|
return false;
|
|
75
77
|
}
|
|
76
78
|
for (const { user, order } of dlobOrders) {
|
|
77
|
-
this.insertOrder(order, user.toString(), slot);
|
|
79
|
+
this.insertOrder(order, user.toString(), slot, false);
|
|
78
80
|
}
|
|
79
81
|
this.initialized = true;
|
|
80
82
|
return true;
|
|
81
83
|
}
|
|
82
84
|
handleOrderRecord(record, slot) {
|
|
83
|
-
this.insertOrder(record.order, record.user.toString(), slot);
|
|
85
|
+
this.insertOrder(record.order, record.user.toString(), slot, false);
|
|
84
86
|
}
|
|
85
87
|
handleOrderActionRecord(record, slot) {
|
|
86
88
|
if ((0, __1.isOneOfVariant)(record.action, ['place', 'expire'])) {
|
|
@@ -90,13 +92,13 @@ class DLOB {
|
|
|
90
92
|
if (record.taker !== null) {
|
|
91
93
|
const takerOrder = this.getOrder(record.takerOrderId, record.taker);
|
|
92
94
|
if (takerOrder) {
|
|
93
|
-
this.trigger(takerOrder, record.taker, slot);
|
|
95
|
+
this.trigger(takerOrder, record.taker, slot, false);
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
if (record.maker !== null) {
|
|
97
99
|
const makerOrder = this.getOrder(record.makerOrderId, record.maker);
|
|
98
100
|
if (makerOrder) {
|
|
99
|
-
this.trigger(makerOrder, record.maker, slot);
|
|
101
|
+
this.trigger(makerOrder, record.maker, slot, false);
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -129,7 +131,7 @@ class DLOB {
|
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
|
-
insertOrder(order, userAccount, slot, onInsert) {
|
|
134
|
+
insertOrder(order, userAccount, slot, isUserProtectedMaker, onInsert) {
|
|
133
135
|
var _a;
|
|
134
136
|
if ((0, __1.isVariant)(order.status, 'init')) {
|
|
135
137
|
return;
|
|
@@ -146,7 +148,7 @@ class DLOB {
|
|
|
146
148
|
.get(marketType)
|
|
147
149
|
.add((0, NodeList_1.getOrderSignature)(order.orderId, userAccount));
|
|
148
150
|
}
|
|
149
|
-
(_a = this.getListForOrder(order, slot)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount);
|
|
151
|
+
(_a = this.getListForOrder(order, slot)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount, isUserProtectedMaker);
|
|
150
152
|
if (onInsert) {
|
|
151
153
|
onInsert();
|
|
152
154
|
}
|
|
@@ -194,7 +196,7 @@ class DLOB {
|
|
|
194
196
|
onUpdate();
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
|
-
trigger(order, userAccount, slot, onTrigger) {
|
|
199
|
+
trigger(order, userAccount, slot, isUserProtectedMaker, onTrigger) {
|
|
198
200
|
var _a;
|
|
199
201
|
if ((0, __1.isVariant)(order.status, 'init')) {
|
|
200
202
|
return;
|
|
@@ -207,7 +209,7 @@ class DLOB {
|
|
|
207
209
|
const triggerList = this.orderLists.get(marketType).get(order.marketIndex)
|
|
208
210
|
.trigger[(0, __1.isVariant)(order.triggerCondition, 'above') ? 'above' : 'below'];
|
|
209
211
|
triggerList.remove(order, userAccount.toString());
|
|
210
|
-
(_a = this.getListForOrder(order, slot)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount.toString());
|
|
212
|
+
(_a = this.getListForOrder(order, slot)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount.toString(), isUserProtectedMaker);
|
|
211
213
|
if (onTrigger) {
|
|
212
214
|
onTrigger();
|
|
213
215
|
}
|
|
@@ -7,6 +7,7 @@ export interface DLOBNode {
|
|
|
7
7
|
isBaseFilled(): boolean;
|
|
8
8
|
haveFilled: boolean;
|
|
9
9
|
userAccount: string | undefined;
|
|
10
|
+
isUserProtectedMaker: boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare abstract class OrderNode implements DLOBNode {
|
|
12
13
|
order: Order;
|
|
@@ -14,7 +15,8 @@ export declare abstract class OrderNode implements DLOBNode {
|
|
|
14
15
|
sortValue: BN;
|
|
15
16
|
haveFilled: boolean;
|
|
16
17
|
haveTrigger: boolean;
|
|
17
|
-
|
|
18
|
+
isUserProtectedMaker: boolean;
|
|
19
|
+
constructor(order: Order, userAccount: string, isUserProtectedMaker: boolean);
|
|
18
20
|
abstract getSortValue(order: Order): BN;
|
|
19
21
|
getLabel(): string;
|
|
20
22
|
getPrice(oraclePriceData: OraclePriceData, slot: number): BN;
|
|
@@ -54,4 +56,4 @@ export type DLOBNodeMap = {
|
|
|
54
56
|
trigger: TriggerOrderNode;
|
|
55
57
|
};
|
|
56
58
|
export type DLOBNodeType = 'restingLimit' | 'takingLimit' | 'floatingLimit' | 'market' | ('trigger' & keyof DLOBNodeMap);
|
|
57
|
-
export declare function createNode<T extends DLOBNodeType>(nodeType: T, order: Order, userAccount: string): DLOBNodeMap[T];
|
|
59
|
+
export declare function createNode<T extends DLOBNodeType>(nodeType: T, order: Order, userAccount: string, isUserProtectedMaker: boolean): DLOBNodeMap[T];
|
|
@@ -5,13 +5,14 @@ const __1 = require("..");
|
|
|
5
5
|
// import { PublicKey } from '@solana/web3.js';
|
|
6
6
|
const NodeList_1 = require("./NodeList");
|
|
7
7
|
class OrderNode {
|
|
8
|
-
constructor(order, userAccount) {
|
|
8
|
+
constructor(order, userAccount, isUserProtectedMaker) {
|
|
9
9
|
this.haveFilled = false;
|
|
10
10
|
this.haveTrigger = false;
|
|
11
11
|
// Copy the order over to the node
|
|
12
12
|
this.order = { ...order };
|
|
13
13
|
this.userAccount = userAccount;
|
|
14
14
|
this.sortValue = this.getSortValue(order);
|
|
15
|
+
this.isUserProtectedMaker = isUserProtectedMaker;
|
|
15
16
|
}
|
|
16
17
|
getLabel() {
|
|
17
18
|
let msg = `Order ${(0, NodeList_1.getOrderSignature)(this.order.orderId, this.userAccount)}`;
|
|
@@ -67,18 +68,18 @@ class TriggerOrderNode extends OrderNode {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
exports.TriggerOrderNode = TriggerOrderNode;
|
|
70
|
-
function createNode(nodeType, order, userAccount) {
|
|
71
|
+
function createNode(nodeType, order, userAccount, isUserProtectedMaker) {
|
|
71
72
|
switch (nodeType) {
|
|
72
73
|
case 'floatingLimit':
|
|
73
|
-
return new FloatingLimitOrderNode(order, userAccount);
|
|
74
|
+
return new FloatingLimitOrderNode(order, userAccount, isUserProtectedMaker);
|
|
74
75
|
case 'restingLimit':
|
|
75
|
-
return new RestingLimitOrderNode(order, userAccount);
|
|
76
|
+
return new RestingLimitOrderNode(order, userAccount, isUserProtectedMaker);
|
|
76
77
|
case 'takingLimit':
|
|
77
|
-
return new TakingLimitOrderNode(order, userAccount);
|
|
78
|
+
return new TakingLimitOrderNode(order, userAccount, isUserProtectedMaker);
|
|
78
79
|
case 'market':
|
|
79
|
-
return new MarketOrderNode(order, userAccount);
|
|
80
|
+
return new MarketOrderNode(order, userAccount, isUserProtectedMaker);
|
|
80
81
|
case 'trigger':
|
|
81
|
-
return new TriggerOrderNode(order, userAccount);
|
|
82
|
+
return new TriggerOrderNode(order, userAccount, isUserProtectedMaker);
|
|
82
83
|
default:
|
|
83
84
|
throw Error(`Unknown DLOBNode type ${nodeType}`);
|
|
84
85
|
}
|
|
@@ -14,7 +14,7 @@ export declare class NodeList<NodeType extends keyof DLOBNodeMap> implements DLO
|
|
|
14
14
|
nodeMap: Map<string, DLOBNodeMap[NodeType]>;
|
|
15
15
|
constructor(nodeType: NodeType, sortDirection: SortDirection);
|
|
16
16
|
clear(): void;
|
|
17
|
-
insert(order: Order, marketType: MarketTypeStr, userAccount: string): void;
|
|
17
|
+
insert(order: Order, marketType: MarketTypeStr, userAccount: string, isUserProtectedMaker: boolean): void;
|
|
18
18
|
prependNode(currentNode: DLOBNodeMap[NodeType], newNode: DLOBNodeMap[NodeType]): boolean;
|
|
19
19
|
update(order: Order, userAccount: string): void;
|
|
20
20
|
remove(order: Order, userAccount: string): void;
|
|
@@ -20,11 +20,11 @@ class NodeList {
|
|
|
20
20
|
this.length = 0;
|
|
21
21
|
this.nodeMap.clear();
|
|
22
22
|
}
|
|
23
|
-
insert(order, marketType, userAccount) {
|
|
23
|
+
insert(order, marketType, userAccount, isUserProtectedMaker) {
|
|
24
24
|
if ((0, __1.isVariant)(order.status, 'init')) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
const newNode = (0, DLOBNode_1.createNode)(this.nodeType, order, userAccount);
|
|
27
|
+
const newNode = (0, DLOBNode_1.createNode)(this.nodeType, order, userAccount, isUserProtectedMaker);
|
|
28
28
|
const orderSignature = getOrderSignature(order.orderId, userAccount);
|
|
29
29
|
if (this.nodeMap.has(orderSignature)) {
|
|
30
30
|
return;
|
|
@@ -134,6 +134,7 @@ function* getVammNodeGenerator(price) {
|
|
|
134
134
|
isVammNode: () => true,
|
|
135
135
|
order: undefined,
|
|
136
136
|
userAccount: undefined,
|
|
137
|
+
isUserProtectedMaker: false,
|
|
137
138
|
isBaseFilled: () => false,
|
|
138
139
|
haveFilled: false,
|
|
139
140
|
};
|
|
@@ -623,7 +623,7 @@ export declare class DriftClient {
|
|
|
623
623
|
postOnly?: boolean;
|
|
624
624
|
immediateOrCancel?: boolean;
|
|
625
625
|
maxTs?: BN;
|
|
626
|
-
policy?:
|
|
626
|
+
policy?: number;
|
|
627
627
|
}, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
628
628
|
getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, policy, }: {
|
|
629
629
|
orderId: number;
|
|
@@ -640,7 +640,7 @@ export declare class DriftClient {
|
|
|
640
640
|
postOnly?: boolean;
|
|
641
641
|
immediateOrCancel?: boolean;
|
|
642
642
|
maxTs?: BN;
|
|
643
|
-
policy?:
|
|
643
|
+
policy?: number;
|
|
644
644
|
}, subAccountId?: number): Promise<TransactionInstruction>;
|
|
645
645
|
/**
|
|
646
646
|
* Modifies an open order by closing it and replacing it with a new order.
|
|
@@ -962,13 +962,13 @@ class DriftClient {
|
|
|
962
962
|
isWritable: true,
|
|
963
963
|
pubkey: spotMarket.vault,
|
|
964
964
|
});
|
|
965
|
-
const
|
|
965
|
+
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
966
|
+
const keeperVault = await this.getAssociatedTokenAccount(spotPosition.marketIndex, false, tokenProgram);
|
|
966
967
|
remainingAccounts.push({
|
|
967
968
|
isSigner: false,
|
|
968
969
|
isWritable: true,
|
|
969
970
|
pubkey: keeperVault,
|
|
970
971
|
});
|
|
971
|
-
const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket);
|
|
972
972
|
tokenPrograms.add(tokenProgram.toBase58());
|
|
973
973
|
}
|
|
974
974
|
for (const tokenProgram of tokenPrograms) {
|