@velocity-exchange/sdk 0.0.3 → 0.0.5

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 (50) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/lib/browser/decode/user.js +5 -5
  3. package/lib/browser/dlob/DLOB.js +1 -1
  4. package/lib/browser/dlob/DLOBNode.js +1 -2
  5. package/lib/browser/idl/drift.d.ts +5 -5
  6. package/lib/browser/idl/drift.json +5 -5
  7. package/lib/browser/math/auction.d.ts +1 -1
  8. package/lib/browser/math/auction.js +2 -9
  9. package/lib/browser/math/orders.js +3 -3
  10. package/lib/browser/types.d.ts +2 -2
  11. package/lib/browser/velocityClient.d.ts +6 -6
  12. package/lib/browser/velocityClient.js +1 -1
  13. package/lib/node/config.d.ts.map +1 -1
  14. package/lib/node/decode/user.js +5 -5
  15. package/lib/node/dlob/DLOB.js +1 -1
  16. package/lib/node/dlob/DLOBNode.js +1 -2
  17. package/lib/node/idl/drift.d.ts +5 -5
  18. package/lib/node/idl/drift.d.ts.map +1 -1
  19. package/lib/node/idl/drift.json +5 -5
  20. package/lib/node/math/auction.d.ts +1 -1
  21. package/lib/node/math/auction.d.ts.map +1 -1
  22. package/lib/node/math/auction.js +2 -9
  23. package/lib/node/math/orders.d.ts.map +1 -1
  24. package/lib/node/math/orders.js +3 -3
  25. package/lib/node/priorityFee/types.d.ts.map +1 -1
  26. package/lib/node/types.d.ts +2 -2
  27. package/lib/node/types.d.ts.map +1 -1
  28. package/lib/node/util/deprecatedAlias.d.ts.map +1 -1
  29. package/lib/node/velocityClient.d.ts +6 -6
  30. package/lib/node/velocityClient.d.ts.map +1 -1
  31. package/lib/node/velocityClient.js +1 -1
  32. package/lib/node/velocityClientConfig.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/config.ts +4 -1
  35. package/src/decode/user.ts +5 -5
  36. package/src/dlob/DLOB.ts +1 -1
  37. package/src/dlob/DLOBNode.ts +1 -1
  38. package/src/idl/drift.json +5 -5
  39. package/src/idl/drift.ts +5 -5
  40. package/src/math/auction.ts +3 -10
  41. package/src/math/orders.ts +3 -6
  42. package/src/priorityFee/types.ts +7 -2
  43. package/src/types.ts +2 -2
  44. package/src/util/deprecatedAlias.ts +1 -5
  45. package/src/velocityClient.ts +6 -6
  46. package/src/velocityClientConfig.ts +3 -1
  47. package/tests/auctions/test.ts +4 -4
  48. package/tests/decode/test.ts +1 -1
  49. package/tests/dlob/test.ts +5 -5
  50. package/tests/user/helpers.ts +1 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## [0.0.5](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.4...sdk-v0.0.5) (2026-05-28)
4
+
5
+
6
+ ### Refactors
7
+
8
+ * increase oracle_price_offset to i64 ([#51](https://github.com/drift-labs/protocol-v2-shadow/issues/51)) ([d04039a](https://github.com/drift-labs/protocol-v2-shadow/commit/d04039a22b2ff37d05afd8fe271b9913d66689e1))
9
+
10
+ ## [0.0.4](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.3...sdk-v0.0.4) (2026-05-28)
11
+
12
+
13
+ ### Refactors
14
+
15
+ * increase oracle_price_offset to i64 ([#51](https://github.com/drift-labs/protocol-v2-shadow/issues/51)) ([d04039a](https://github.com/drift-labs/protocol-v2-shadow/commit/d04039a22b2ff37d05afd8fe271b9913d66689e1))
@@ -120,8 +120,8 @@ function decodeUser(buffer) {
120
120
  const orders = [];
121
121
  for (let i = 0; i < 32; i++) {
122
122
  // skip order if it's not open
123
- if (buffer.readUint8(offset + 82) !== 1) {
124
- offset += 96;
123
+ if (buffer.readUint8(offset + 86) !== 1) {
124
+ offset += 104;
125
125
  continue;
126
126
  }
127
127
  const slot = readUnsignedBigInt64LE(buffer, offset);
@@ -142,8 +142,8 @@ function decodeUser(buffer) {
142
142
  offset += 8;
143
143
  const maxTs = readSignedBigInt64LE(buffer, offset);
144
144
  offset += 8;
145
- const oraclePriceOffset = buffer.readInt32LE(offset);
146
- offset += 4;
145
+ const oraclePriceOffset = readSignedBigInt64LE(buffer, offset);
146
+ offset += 8;
147
147
  const orderId = buffer.readUInt32LE(offset);
148
148
  offset += 4;
149
149
  const marketIndex = buffer.readUInt16LE(offset);
@@ -231,7 +231,7 @@ function decodeUser(buffer) {
231
231
  offset += 1;
232
232
  const bitFlags = buffer.readUint8(offset);
233
233
  offset += 1;
234
- offset += 1; // padding
234
+ offset += 5; // padding
235
235
  orders.push({
236
236
  slot,
237
237
  price,
@@ -181,7 +181,7 @@ class DLOB {
181
181
  else if ((0, types_1.isOneOfVariant)(order.orderType, ['market', 'triggerMarket', 'oracle'])) {
182
182
  type = 'market';
183
183
  }
184
- else if (order.oraclePriceOffset !== 0) {
184
+ else if (!order.oraclePriceOffset.eq(numericConstants_1.ZERO)) {
185
185
  type = 'floatingLimit';
186
186
  }
187
187
  else {
@@ -1,7 +1,6 @@
1
1
  "use strict";
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
- const anchor_1 = require("../isomorphic/anchor");
5
4
  const numericConstants_1 = require("../constants/numericConstants");
6
5
  const orders_1 = require("../math/orders");
7
6
  const types_1 = require("../types");
@@ -56,7 +55,7 @@ class RestingLimitOrderNode extends OrderNode {
56
55
  exports.RestingLimitOrderNode = RestingLimitOrderNode;
57
56
  class FloatingLimitOrderNode extends OrderNode {
58
57
  getSortValue(order) {
59
- return new anchor_1.BN(order.oraclePriceOffset);
58
+ return order.oraclePriceOffset;
60
59
  }
61
60
  }
62
61
  exports.FloatingLimitOrderNode = FloatingLimitOrderNode;
@@ -19780,7 +19780,7 @@ export type Drift = {
19780
19780
  {
19781
19781
  "name": "oraclePriceOffset";
19782
19782
  "type": {
19783
- "option": "i32";
19783
+ "option": "i64";
19784
19784
  };
19785
19785
  },
19786
19786
  {
@@ -20021,7 +20021,7 @@ export type Drift = {
20021
20021
  "If set, the order limit price is the oracle price + this offset",
20022
20022
  "precision: PRICE_PRECISION"
20023
20023
  ];
20024
- "type": "i32";
20024
+ "type": "i64";
20025
20025
  },
20026
20026
  {
20027
20027
  "name": "orderId";
@@ -20158,7 +20158,7 @@ export type Drift = {
20158
20158
  "type": {
20159
20159
  "array": [
20160
20160
  "u8",
20161
- 1
20161
+ 5
20162
20162
  ];
20163
20163
  };
20164
20164
  }
@@ -20684,7 +20684,7 @@ export type Drift = {
20684
20684
  {
20685
20685
  "name": "oraclePriceOffset";
20686
20686
  "type": {
20687
- "option": "i32";
20687
+ "option": "i64";
20688
20688
  };
20689
20689
  },
20690
20690
  {
@@ -21866,7 +21866,7 @@ export type Drift = {
21866
21866
  {
21867
21867
  "name": "bitFlags";
21868
21868
  "docs": [
21869
- "Bit flags (e.g., for high leverage mode)"
21869
+ "Order bit flags"
21870
21870
  ];
21871
21871
  "type": "u8";
21872
21872
  },
@@ -19774,7 +19774,7 @@
19774
19774
  {
19775
19775
  "name": "oracle_price_offset",
19776
19776
  "type": {
19777
- "option": "i32"
19777
+ "option": "i64"
19778
19778
  }
19779
19779
  },
19780
19780
  {
@@ -20015,7 +20015,7 @@
20015
20015
  "If set, the order limit price is the oracle price + this offset",
20016
20016
  "precision: PRICE_PRECISION"
20017
20017
  ],
20018
- "type": "i32"
20018
+ "type": "i64"
20019
20019
  },
20020
20020
  {
20021
20021
  "name": "order_id",
@@ -20152,7 +20152,7 @@
20152
20152
  "type": {
20153
20153
  "array": [
20154
20154
  "u8",
20155
- 1
20155
+ 5
20156
20156
  ]
20157
20157
  }
20158
20158
  }
@@ -20678,7 +20678,7 @@
20678
20678
  {
20679
20679
  "name": "oracle_price_offset",
20680
20680
  "type": {
20681
- "option": "i32"
20681
+ "option": "i64"
20682
20682
  }
20683
20683
  },
20684
20684
  {
@@ -21860,7 +21860,7 @@
21860
21860
  {
21861
21861
  "name": "bit_flags",
21862
21862
  "docs": [
21863
- "Bit flags (e.g., for high leverage mode)"
21863
+ "Order bit flags"
21864
21864
  ],
21865
21865
  "type": "u8"
21866
21866
  },
@@ -35,7 +35,7 @@ export declare function deriveOracleAuctionParams({ direction, oraclePrice, auct
35
35
  }): {
36
36
  auctionStartPrice: BN;
37
37
  auctionEndPrice: BN;
38
- oraclePriceOffset: number;
38
+ oraclePriceOffset: BN;
39
39
  };
40
40
  /**
41
41
  *
@@ -56,7 +56,7 @@ function getAuctionPrice(order, slot, oraclePrice) {
56
56
  return getAuctionPriceForFixedAuction(order, slot);
57
57
  }
58
58
  else if ((0, types_1.isVariant)(order.orderType, 'limit')) {
59
- if (order.oraclePriceOffset != null && order.oraclePriceOffset !== 0) {
59
+ if (order.oraclePriceOffset != null && !order.oraclePriceOffset.eq(numericConstants_1.ZERO)) {
60
60
  return getAuctionPriceForOracleOffsetAuction(order, slot, oraclePrice);
61
61
  }
62
62
  else {
@@ -153,13 +153,6 @@ function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice,
153
153
  ? auctionEndPrice.sub(oraclePrice).add(numericConstants_1.ONE)
154
154
  : auctionEndPrice.sub(oraclePrice).sub(numericConstants_1.ONE);
155
155
  }
156
- let oraclePriceOffsetNum;
157
- try {
158
- oraclePriceOffsetNum = oraclePriceOffset.toNumber();
159
- }
160
- catch (e) {
161
- oraclePriceOffsetNum = 0;
162
- }
163
156
  if (auctionPriceCaps) {
164
157
  auctionStartPrice = anchor_1.BN.min(anchor_1.BN.max(auctionStartPrice, auctionPriceCaps.min), auctionPriceCaps.max);
165
158
  auctionEndPrice = anchor_1.BN.min(anchor_1.BN.max(auctionEndPrice, auctionPriceCaps.min), auctionPriceCaps.max);
@@ -167,7 +160,7 @@ function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice,
167
160
  return {
168
161
  auctionStartPrice: auctionStartPrice.sub(oraclePrice),
169
162
  auctionEndPrice: auctionEndPrice.sub(oraclePrice),
170
- oraclePriceOffset: oraclePriceOffsetNum,
163
+ oraclePriceOffset: oraclePriceOffset,
171
164
  };
172
165
  }
173
166
  exports.deriveOracleAuctionParams = deriveOracleAuctionParams;
@@ -101,8 +101,8 @@ function getLimitPrice(order, oraclePriceData, slot, fallbackPrice) {
101
101
  if (hasAuctionPrice(order, slot)) {
102
102
  return (0, auction_1.getAuctionPrice)(order, slot, oraclePriceData.price);
103
103
  }
104
- else if (order.oraclePriceOffset !== 0) {
105
- return anchor_1.BN.max(oraclePriceData.price.add(new anchor_1.BN(order.oraclePriceOffset)), numericConstants_1.ONE);
104
+ else if (!order.oraclePriceOffset.eq(numericConstants_1.ZERO)) {
105
+ return anchor_1.BN.max(oraclePriceData.price.add(order.oraclePriceOffset), numericConstants_1.ONE);
106
106
  }
107
107
  else if (order.price.eq(numericConstants_1.ZERO)) {
108
108
  return fallbackPrice;
@@ -114,7 +114,7 @@ function getLimitPrice(order, oraclePriceData, slot, fallbackPrice) {
114
114
  exports.getLimitPrice = getLimitPrice;
115
115
  function hasLimitPrice(order, slot) {
116
116
  return (order.price.gt(numericConstants_1.ZERO) ||
117
- order.oraclePriceOffset != 0 ||
117
+ !order.oraclePriceOffset.eq(numericConstants_1.ZERO) ||
118
118
  !(0, auction_1.isAuctionComplete)(order, slot));
119
119
  }
120
120
  exports.hasLimitPrice = hasLimitPrice;
@@ -1182,7 +1182,7 @@ export type Order = {
1182
1182
  existingPositionDirection: PositionDirection;
1183
1183
  postOnly: boolean;
1184
1184
  immediateOrCancel: boolean;
1185
- oraclePriceOffset: number;
1185
+ oraclePriceOffset: BN;
1186
1186
  auctionDuration: number;
1187
1187
  auctionStartPrice: BN;
1188
1188
  auctionEndPrice: BN;
@@ -1203,7 +1203,7 @@ export type OrderParams = {
1203
1203
  bitFlags: number;
1204
1204
  triggerPrice: BN | null;
1205
1205
  triggerCondition: OrderTriggerCondition;
1206
- oraclePriceOffset: number | null;
1206
+ oraclePriceOffset: BN | null;
1207
1207
  auctionDuration: number | null;
1208
1208
  maxTs: BN | null;
1209
1209
  auctionStartPrice: BN | null;
@@ -790,7 +790,7 @@ export declare class VelocityClient {
790
790
  * @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
791
791
  * @returns
792
792
  */
793
- modifyPerpOrder(orderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: number): Promise<TransactionSignature>;
793
+ modifyPerpOrder(orderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: BN): Promise<TransactionSignature>;
794
794
  /**
795
795
  * Modifies an open order by closing it and replacing it with a new order.
796
796
  * @deprecated use modifyOrderByUserOrderId instead
@@ -800,7 +800,7 @@ export declare class VelocityClient {
800
800
  * @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
801
801
  * @returns
802
802
  */
803
- modifyPerpOrderByUserOrderId(userOrderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: number): Promise<TransactionSignature>;
803
+ modifyPerpOrderByUserOrderId(userOrderId: number, newBaseAmount?: BN, newLimitPrice?: BN, newOraclePriceOffset?: BN): Promise<TransactionSignature>;
804
804
  /**
805
805
  * Modifies an open order (spot or perp) by closing it and replacing it with a new order.
806
806
  * @param orderParams.orderId: The open order to modify
@@ -824,7 +824,7 @@ export declare class VelocityClient {
824
824
  newDirection?: PositionDirection;
825
825
  newBaseAmount?: BN;
826
826
  newLimitPrice?: BN;
827
- newOraclePriceOffset?: number;
827
+ newOraclePriceOffset?: BN;
828
828
  newTriggerPrice?: BN;
829
829
  newTriggerCondition?: OrderTriggerCondition;
830
830
  auctionDuration?: number;
@@ -847,7 +847,7 @@ export declare class VelocityClient {
847
847
  newDirection?: PositionDirection;
848
848
  newBaseAmount?: BN;
849
849
  newLimitPrice?: BN;
850
- newOraclePriceOffset?: number;
850
+ newOraclePriceOffset?: BN;
851
851
  newTriggerPrice?: BN;
852
852
  newTriggerCondition?: OrderTriggerCondition;
853
853
  auctionDuration?: number;
@@ -885,7 +885,7 @@ export declare class VelocityClient {
885
885
  newDirection?: PositionDirection;
886
886
  newBaseAmount?: BN;
887
887
  newLimitPrice?: BN;
888
- newOraclePriceOffset?: number;
888
+ newOraclePriceOffset?: BN;
889
889
  newTriggerPrice?: BN;
890
890
  newTriggerCondition?: OrderTriggerCondition;
891
891
  auctionDuration?: number;
@@ -902,7 +902,7 @@ export declare class VelocityClient {
902
902
  newDirection?: PositionDirection;
903
903
  newBaseAmount?: BN;
904
904
  newLimitPrice?: BN;
905
- newOraclePriceOffset?: number;
905
+ newOraclePriceOffset?: BN;
906
906
  newTriggerPrice?: BN;
907
907
  newTriggerCondition?: OrderTriggerCondition;
908
908
  auctionDuration?: number;
@@ -2756,7 +2756,7 @@ class VelocityClient {
2756
2756
  }
2757
2757
  }
2758
2758
  else if (isSignedMsg) {
2759
- // Order hasn't been placed yet, we cant tell if it has a builder or not.
2759
+ // Order hasn't been placed yet, we can't tell if it has a builder or not.
2760
2760
  // Include it optimistically
2761
2761
  withBuilder = true;
2762
2762
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAGN,gBAAgB,EAEhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,gBAAgB,EAIhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAkB,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC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0; i < 32; i++) {
122
122
  // skip order if it's not open
123
- if (buffer.readUint8(offset + 82) !== 1) {
124
- offset += 96;
123
+ if (buffer.readUint8(offset + 86) !== 1) {
124
+ offset += 104;
125
125
  continue;
126
126
  }
127
127
  const slot = readUnsignedBigInt64LE(buffer, offset);
@@ -142,8 +142,8 @@ function decodeUser(buffer) {
142
142
  offset += 8;
143
143
  const maxTs = readSignedBigInt64LE(buffer, offset);
144
144
  offset += 8;
145
- const oraclePriceOffset = buffer.readInt32LE(offset);
146
- offset += 4;
145
+ const oraclePriceOffset = readSignedBigInt64LE(buffer, offset);
146
+ offset += 8;
147
147
  const orderId = buffer.readUInt32LE(offset);
148
148
  offset += 4;
149
149
  const marketIndex = buffer.readUInt16LE(offset);
@@ -231,7 +231,7 @@ function decodeUser(buffer) {
231
231
  offset += 1;
232
232
  const bitFlags = buffer.readUint8(offset);
233
233
  offset += 1;
234
- offset += 1; // padding
234
+ offset += 5; // padding
235
235
  orders.push({
236
236
  slot,
237
237
  price,
@@ -181,7 +181,7 @@ class DLOB {
181
181
  else if ((0, types_1.isOneOfVariant)(order.orderType, ['market', 'triggerMarket', 'oracle'])) {
182
182
  type = 'market';
183
183
  }
184
- else if (order.oraclePriceOffset !== 0) {
184
+ else if (!order.oraclePriceOffset.eq(numericConstants_1.ZERO)) {
185
185
  type = 'floatingLimit';
186
186
  }
187
187
  else {
@@ -1,7 +1,6 @@
1
1
  "use strict";
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
- const anchor_1 = require("../isomorphic/anchor");
5
4
  const numericConstants_1 = require("../constants/numericConstants");
6
5
  const orders_1 = require("../math/orders");
7
6
  const types_1 = require("../types");
@@ -56,7 +55,7 @@ class RestingLimitOrderNode extends OrderNode {
56
55
  exports.RestingLimitOrderNode = RestingLimitOrderNode;
57
56
  class FloatingLimitOrderNode extends OrderNode {
58
57
  getSortValue(order) {
59
- return new anchor_1.BN(order.oraclePriceOffset);
58
+ return order.oraclePriceOffset;
60
59
  }
61
60
  }
62
61
  exports.FloatingLimitOrderNode = FloatingLimitOrderNode;
@@ -19780,7 +19780,7 @@ export type Drift = {
19780
19780
  {
19781
19781
  "name": "oraclePriceOffset";
19782
19782
  "type": {
19783
- "option": "i32";
19783
+ "option": "i64";
19784
19784
  };
19785
19785
  },
19786
19786
  {
@@ -20021,7 +20021,7 @@ export type Drift = {
20021
20021
  "If set, the order limit price is the oracle price + this offset",
20022
20022
  "precision: PRICE_PRECISION"
20023
20023
  ];
20024
- "type": "i32";
20024
+ "type": "i64";
20025
20025
  },
20026
20026
  {
20027
20027
  "name": "orderId";
@@ -20158,7 +20158,7 @@ export type Drift = {
20158
20158
  "type": {
20159
20159
  "array": [
20160
20160
  "u8",
20161
- 1
20161
+ 5
20162
20162
  ];
20163
20163
  };
20164
20164
  }
@@ -20684,7 +20684,7 @@ export type Drift = {
20684
20684
  {
20685
20685
  "name": "oraclePriceOffset";
20686
20686
  "type": {
20687
- "option": "i32";
20687
+ "option": "i64";
20688
20688
  };
20689
20689
  },
20690
20690
  {
@@ -21866,7 +21866,7 @@ export type Drift = {
21866
21866
  {
21867
21867
  "name": "bitFlags";
21868
21868
  "docs": [
21869
- "Bit flags (e.g., for high leverage mode)"
21869
+ "Order bit flags"
21870
21870
  ];
21871
21871
  "type": "u8";
21872
21872
  },