@drift-labs/sdk 2.49.0-beta.8 → 2.52.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/accounts/{mockUserAccountSubscriber.d.ts → basicUserAccountSubscriber.d.ts} +2 -2
- package/lib/accounts/{mockUserAccountSubscriber.js → basicUserAccountSubscriber.js} +9 -6
- package/lib/accounts/pollingInsuranceFundStakeAccountSubscriber.js +0 -1
- package/lib/adminClient.d.ts +1 -0
- package/lib/adminClient.js +8 -0
- package/lib/constants/perpMarkets.js +40 -0
- package/lib/constants/spotMarkets.js +10 -0
- package/lib/decode/user.d.ts +3 -0
- package/lib/decode/user.js +329 -0
- package/lib/driftClient.d.ts +5 -1
- package/lib/driftClient.js +28 -7
- package/lib/examples/loadDlob.js +10 -5
- package/lib/idl/drift.json +32 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/math/state.d.ts +5 -0
- package/lib/math/state.js +27 -0
- package/lib/math/superStake.d.ts +43 -0
- package/lib/math/superStake.js +64 -22
- package/lib/orderSubscriber/OrderSubscriber.d.ts +3 -0
- package/lib/orderSubscriber/OrderSubscriber.js +17 -3
- package/lib/orderSubscriber/WebsocketSubscription.d.ts +1 -1
- package/lib/orderSubscriber/WebsocketSubscription.js +8 -6
- package/lib/orderSubscriber/types.d.ts +4 -1
- package/lib/types.d.ts +2 -1
- package/lib/user.d.ts +2 -1
- package/lib/user.js +13 -5
- package/lib/userMap/PollingSubscription.d.ts +15 -0
- package/lib/userMap/PollingSubscription.js +28 -0
- package/lib/userMap/WebsocketSubscription.d.ts +23 -0
- package/lib/userMap/WebsocketSubscription.js +41 -0
- package/lib/userMap/userMap.d.ts +16 -18
- package/lib/userMap/userMap.js +73 -34
- package/lib/userMap/userMapConfig.d.ts +21 -0
- package/lib/userMap/userMapConfig.js +2 -0
- package/package.json +2 -1
- package/src/accounts/{mockUserAccountSubscriber.ts → basicUserAccountSubscriber.ts} +8 -6
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +0 -1
- package/src/adminClient.ts +14 -0
- package/src/constants/perpMarkets.ts +40 -0
- package/src/constants/spotMarkets.ts +10 -0
- package/src/decode/user.ts +358 -0
- package/src/driftClient.ts +48 -7
- package/src/examples/loadDlob.ts +11 -6
- package/src/idl/drift.json +33 -3
- package/src/index.ts +2 -1
- package/src/math/state.ts +26 -0
- package/src/math/superStake.ts +108 -20
- package/src/orderSubscriber/OrderSubscriber.ts +33 -7
- package/src/orderSubscriber/WebsocketSubscription.ts +17 -16
- package/src/orderSubscriber/types.ts +15 -2
- package/src/types.ts +2 -1
- package/src/user.ts +19 -6
- package/src/userMap/PollingSubscription.ts +48 -0
- package/src/userMap/WebsocketSubscription.ts +76 -0
- package/src/userMap/userMap.ts +103 -70
- package/src/userMap/userMapConfig.ts +34 -0
- package/tests/amm/test.ts +6 -3
- package/tests/decode/test.ts +266 -0
- package/tests/decode/userAccountBufferStrings.ts +102 -0
- package/tests/dlob/helpers.ts +1 -0
- package/tests/dlob/test.ts +10 -8
- package/tests/user/helpers.ts +0 -1
package/tests/dlob/helpers.ts
CHANGED
package/tests/dlob/test.ts
CHANGED
|
@@ -60,7 +60,6 @@ function insertOrderToDLOB(
|
|
|
60
60
|
price,
|
|
61
61
|
baseAssetAmount,
|
|
62
62
|
baseAssetAmountFilled: new BN(0),
|
|
63
|
-
quoteAssetAmount: new BN(0),
|
|
64
63
|
quoteAssetAmountFilled: new BN(0),
|
|
65
64
|
direction,
|
|
66
65
|
reduceOnly: false,
|
|
@@ -111,7 +110,6 @@ function insertTriggerOrderToDLOB(
|
|
|
111
110
|
price,
|
|
112
111
|
baseAssetAmount,
|
|
113
112
|
baseAssetAmountFilled: new BN(0),
|
|
114
|
-
quoteAssetAmount: new BN(0),
|
|
115
113
|
quoteAssetAmountFilled: new BN(0),
|
|
116
114
|
direction,
|
|
117
115
|
reduceOnly: false,
|
|
@@ -206,8 +204,8 @@ function printCrossedNodes(n: NodeToFill, slot: number) {
|
|
|
206
204
|
for (const makerNode of n.makerNodes) {
|
|
207
205
|
console.log(
|
|
208
206
|
`makerNode: (mkt: ${isMarketOrder(
|
|
209
|
-
makerNode.order
|
|
210
|
-
)}, lim: ${isLimitOrder(makerNode.order)})`
|
|
207
|
+
makerNode.order!
|
|
208
|
+
)}, lim: ${isLimitOrder(makerNode.order!)})`
|
|
211
209
|
);
|
|
212
210
|
}
|
|
213
211
|
}
|
|
@@ -2323,7 +2321,9 @@ describe('DLOB Perp Tests', () => {
|
|
|
2323
2321
|
expect(nodesToFillBefore.length).to.equal(0);
|
|
2324
2322
|
|
|
2325
2323
|
// post only bid crosses ask
|
|
2326
|
-
const price = vAsk.add(
|
|
2324
|
+
const price = vAsk.add(
|
|
2325
|
+
vAsk.muln(makerRebateNumerator).divn(makerRebateDenominator)
|
|
2326
|
+
);
|
|
2327
2327
|
insertOrderToDLOB(
|
|
2328
2328
|
dlob,
|
|
2329
2329
|
user0.publicKey,
|
|
@@ -2415,7 +2415,9 @@ describe('DLOB Perp Tests', () => {
|
|
|
2415
2415
|
expect(nodesToFillBefore.length).to.equal(0);
|
|
2416
2416
|
|
|
2417
2417
|
// post only bid crosses ask
|
|
2418
|
-
const price = vBid.sub(
|
|
2418
|
+
const price = vBid.sub(
|
|
2419
|
+
vAsk.muln(makerRebateNumerator).divn(makerRebateDenominator)
|
|
2420
|
+
);
|
|
2419
2421
|
insertOrderToDLOB(
|
|
2420
2422
|
dlob,
|
|
2421
2423
|
user0.publicKey,
|
|
@@ -2738,8 +2740,8 @@ describe('DLOB Perp Tests', () => {
|
|
|
2738
2740
|
);
|
|
2739
2741
|
expect(takingBids.length).to.equal(1);
|
|
2740
2742
|
const triggerLimitBid = takingBids[0];
|
|
2741
|
-
expect(isAuctionComplete(triggerLimitBid.order
|
|
2742
|
-
expect(isRestingLimitOrder(triggerLimitBid.order
|
|
2743
|
+
expect(isAuctionComplete(triggerLimitBid.order!, slot)).to.equal(true);
|
|
2744
|
+
expect(isRestingLimitOrder(triggerLimitBid.order!, slot)).to.equal(false);
|
|
2743
2745
|
});
|
|
2744
2746
|
|
|
2745
2747
|
it('Test will return expired market orders to fill', () => {
|
package/tests/user/helpers.ts
CHANGED