@drift-labs/sdk 2.24.0 → 2.25.0-beta.1

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 (124) hide show
  1. package/README.md +1 -1
  2. package/lib/accounts/fetch.d.ts +1 -1
  3. package/lib/accounts/pollingDriftClientAccountSubscriber.d.ts +1 -1
  4. package/lib/accounts/pollingOracleAccountSubscriber.d.ts +1 -1
  5. package/lib/accounts/pollingTokenAccountSubscriber.d.ts +1 -1
  6. package/lib/accounts/pollingUserAccountSubscriber.d.ts +1 -1
  7. package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +1 -1
  8. package/lib/accounts/webSocketAccountSubscriber.d.ts +1 -1
  9. package/lib/accounts/webSocketDriftClientAccountSubscriber.d.ts +1 -1
  10. package/lib/accounts/webSocketUserAccountSubscriber.d.ts +1 -1
  11. package/lib/accounts/webSocketUserStatsAccountSubsriber.d.ts +1 -1
  12. package/lib/addresses/pda.d.ts +1 -2
  13. package/lib/addresses/pda.js +1 -1
  14. package/lib/adminClient.d.ts +1 -2
  15. package/lib/adminClient.js +2 -2
  16. package/lib/constants/numericConstants.d.ts +59 -61
  17. package/lib/constants/perpMarkets.js +10 -0
  18. package/lib/constants/spotMarkets.d.ts +0 -1
  19. package/lib/dlob/DLOB.d.ts +0 -1
  20. package/lib/dlob/DLOBNode.d.ts +0 -1
  21. package/lib/dlob/DLOBOrders.d.ts +1 -1
  22. package/lib/dlob/DLOBOrders.js +1 -1
  23. package/lib/dlob/NodeList.d.ts +0 -1
  24. package/lib/driftClient.d.ts +38 -23
  25. package/lib/driftClient.js +85 -131
  26. package/lib/events/eventSubscriber.d.ts +1 -1
  27. package/lib/events/eventSubscriber.js +3 -2
  28. package/lib/events/fetchLogs.d.ts +1 -1
  29. package/lib/events/fetchLogs.js +3 -2
  30. package/lib/examples/loadDlob.js +1 -1
  31. package/lib/examples/makeTradeExample.js +1 -1
  32. package/lib/factory/bigNum.d.ts +8 -9
  33. package/lib/factory/bigNum.js +1 -1
  34. package/lib/factory/oracleClient.js +1 -1
  35. package/lib/idl/drift.json +181 -14
  36. package/lib/index.d.ts +1 -1
  37. package/lib/index.js +1 -1
  38. package/lib/math/amm.d.ts +2 -3
  39. package/lib/math/amm.js +1 -1
  40. package/lib/math/auction.d.ts +0 -1
  41. package/lib/math/conversion.d.ts +1 -2
  42. package/lib/math/funding.d.ts +1 -2
  43. package/lib/math/funding.js +1 -1
  44. package/lib/math/insurance.d.ts +1 -1
  45. package/lib/math/insurance.js +17 -1
  46. package/lib/math/margin.d.ts +1 -2
  47. package/lib/math/margin.js +1 -1
  48. package/lib/math/market.d.ts +1 -2
  49. package/lib/math/market.js +1 -1
  50. package/lib/math/oracles.d.ts +0 -1
  51. package/lib/math/oracles.js +2 -3
  52. package/lib/math/orders.d.ts +1 -2
  53. package/lib/math/orders.js +1 -1
  54. package/lib/math/position.d.ts +0 -1
  55. package/lib/math/repeg.d.ts +1 -2
  56. package/lib/math/repeg.js +1 -1
  57. package/lib/math/spotBalance.d.ts +1 -2
  58. package/lib/math/spotBalance.js +1 -1
  59. package/lib/math/spotMarket.d.ts +1 -2
  60. package/lib/math/spotMarket.js +1 -1
  61. package/lib/math/spotPosition.d.ts +1 -2
  62. package/lib/math/trade.d.ts +1 -2
  63. package/lib/math/trade.js +1 -1
  64. package/lib/math/utils.d.ts +0 -1
  65. package/lib/oracles/pythClient.d.ts +2 -3
  66. package/lib/oracles/pythClient.js +1 -1
  67. package/lib/oracles/quoteAssetOracleClient.js +1 -1
  68. package/lib/oracles/types.d.ts +1 -2
  69. package/lib/orderParams.d.ts +1 -2
  70. package/lib/serum/serumSubscriber.d.ts +1 -2
  71. package/lib/serum/serumSubscriber.js +1 -1
  72. package/lib/tokenFaucet.d.ts +2 -3
  73. package/lib/tokenFaucet.js +2 -2
  74. package/lib/tx/retryTxSender.d.ts +1 -1
  75. package/lib/tx/types.d.ts +1 -1
  76. package/lib/types.d.ts +8 -3
  77. package/lib/types.js +2 -1
  78. package/lib/user.d.ts +0 -1
  79. package/package.json +2 -2
  80. package/src/accounts/fetch.ts +1 -1
  81. package/src/accounts/pollingDriftClientAccountSubscriber.ts +1 -1
  82. package/src/accounts/pollingOracleAccountSubscriber.ts +1 -1
  83. package/src/accounts/pollingTokenAccountSubscriber.ts +1 -1
  84. package/src/accounts/pollingUserAccountSubscriber.ts +1 -1
  85. package/src/accounts/pollingUserStatsAccountSubscriber.ts +1 -1
  86. package/src/accounts/webSocketAccountSubscriber.ts +1 -1
  87. package/src/accounts/webSocketDriftClientAccountSubscriber.ts +1 -1
  88. package/src/accounts/webSocketUserAccountSubscriber.ts +1 -1
  89. package/src/accounts/webSocketUserStatsAccountSubsriber.ts +1 -1
  90. package/src/addresses/pda.ts +2 -2
  91. package/src/adminClient.ts +2 -2
  92. package/src/constants/perpMarkets.ts +10 -0
  93. package/src/dlob/DLOBOrders.ts +2 -2
  94. package/src/driftClient.ts +136 -153
  95. package/src/events/eventSubscriber.ts +7 -3
  96. package/src/events/fetchLogs.ts +7 -3
  97. package/src/examples/loadDlob.ts +1 -1
  98. package/src/examples/makeTradeExample.ts +1 -1
  99. package/src/factory/bigNum.ts +1 -1
  100. package/src/factory/oracleClient.ts +1 -1
  101. package/src/idl/drift.json +181 -14
  102. package/src/index.ts +1 -1
  103. package/src/math/amm.ts +1 -1
  104. package/src/math/funding.ts +1 -1
  105. package/src/math/insurance.ts +29 -0
  106. package/src/math/margin.ts +1 -1
  107. package/src/math/market.ts +1 -1
  108. package/src/math/oracles.ts +2 -3
  109. package/src/math/orders.ts +1 -1
  110. package/src/math/repeg.ts +1 -1
  111. package/src/math/spotBalance.ts +1 -1
  112. package/src/math/spotMarket.ts +1 -1
  113. package/src/math/spotPosition.ts +1 -1
  114. package/src/math/trade.ts +1 -1
  115. package/src/oracles/pythClient.ts +1 -1
  116. package/src/oracles/quoteAssetOracleClient.ts +1 -1
  117. package/src/oracles/types.ts +1 -1
  118. package/src/orderParams.ts +1 -1
  119. package/src/serum/serumSubscriber.ts +1 -1
  120. package/src/tokenFaucet.ts +2 -2
  121. package/src/tx/retryTxSender.ts +1 -1
  122. package/src/tx/types.ts +1 -1
  123. package/src/types.ts +6 -1
  124. package/src/userMap/userStatsMap.ts +1 -1
@@ -27,11 +27,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.DriftClient = void 0;
30
- const anchor_1 = require("@project-serum/anchor");
30
+ const anchor_1 = require("@coral-xyz/anchor");
31
31
  const bs58_1 = __importDefault(require("bs58"));
32
32
  const spl_token_1 = require("@solana/spl-token");
33
33
  const types_1 = require("./types");
34
- const anchor = __importStar(require("@project-serum/anchor"));
34
+ const anchor = __importStar(require("@coral-xyz/anchor"));
35
35
  const drift_json_1 = __importDefault(require("./idl/drift.json"));
36
36
  const web3_js_1 = require("@solana/web3.js");
37
37
  const pda_1 = require("./addresses/pda");
@@ -2000,153 +2000,107 @@ class DriftClient {
2000
2000
  /**
2001
2001
  * Modifies an open order (spot or perp) by closing it and replacing it with a new order.
2002
2002
  * @param orderId: The open order to modify
2003
- * @param newBaseAmount: The new base amount for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
2004
- * @param newLimitPice: The new limit price for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
2005
- * @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
2006
- * @param newOrderType: Optional - New order type for the order.
2003
+ * @param newDirection: The new direction for the order
2004
+ * @param newBaseAmount: The new base amount for the order
2005
+ * @param newLimitPice: The new limit price for the order
2006
+ * @param newOraclePriceOffset: The new oracle price offset for the order
2007
2007
  * @param newTriggerPrice: Optional - Thew new trigger price for the order.
2008
- * @param isSpot: Optional - Set to true if the order is a spot order
2009
- * @param auctionDuration: Only required if order type changed to market from something else
2010
- * @param auctionStartPrice: Only required if order type changed to market from something else
2011
- * @param auctionEndPrice: Only required if order type changed to market from something else
2008
+ * @param auctionDuration:
2009
+ * @param auctionStartPrice:
2010
+ * @param auctionEndPrice:
2011
+ * @param reduceOnly:
2012
+ * @param postOnly:
2013
+ * @param immediateOrCancel:
2014
+ * @param maxTs:
2012
2015
  * @returns
2013
2016
  */
2014
- async modifyOrder({ orderId, newBaseAmount, newLimitPrice, newOraclePriceOffset, newOrderType, newTriggerPrice, newTriggerCondition, isSpot, auctionDuration, auctionStartPrice, auctionEndPrice, }) {
2015
- if (!newBaseAmount && !newLimitPrice && !newOraclePriceOffset) {
2016
- throw new Error(`Must provide newBaseAmount or newLimitPrice or newOraclePriceOffset to modify order`);
2017
- }
2018
- const openOrder = this.getUser().getOrder(orderId);
2019
- if (!openOrder) {
2020
- throw new Error(`No open order with id ${orderId.toString()}`);
2021
- }
2022
- const cancelOrderIx = await this.getCancelOrderIx(orderId);
2023
- const orderTypeHasTrigger = newOrderType
2024
- ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerlimit', 'triggerMarket'])
2025
- : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
2026
- const orderTypeHasLimitPrice = newOrderType
2027
- ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerLimit', 'limit'])
2028
- : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'limit']);
2029
- const newOrderParams = {
2030
- orderType: newOrderType || openOrder.orderType,
2031
- marketType: openOrder.marketType,
2032
- direction: openOrder.direction,
2033
- baseAssetAmount: newBaseAmount || openOrder.baseAssetAmount,
2034
- price: orderTypeHasLimitPrice
2035
- ? newLimitPrice || openOrder.price
2036
- : undefined,
2037
- marketIndex: openOrder.marketIndex,
2038
- reduceOnly: openOrder.reduceOnly,
2039
- postOnly: openOrder.postOnly
2040
- ? types_1.PostOnlyParams.MUST_POST_ONLY
2041
- : types_1.PostOnlyParams.NONE,
2042
- immediateOrCancel: openOrder.immediateOrCancel,
2043
- triggerPrice: orderTypeHasTrigger
2044
- ? newTriggerPrice || openOrder.triggerPrice
2045
- : undefined,
2046
- triggerCondition: orderTypeHasTrigger
2047
- ? newTriggerCondition || openOrder.triggerCondition
2048
- : undefined,
2049
- oraclePriceOffset: newOraclePriceOffset || openOrder.oraclePriceOffset,
2050
- auctionDuration: auctionDuration !== null && auctionDuration !== void 0 ? auctionDuration : openOrder.auctionDuration,
2051
- maxTs: openOrder.maxTs,
2052
- auctionStartPrice: auctionStartPrice || openOrder.auctionStartPrice,
2053
- auctionEndPrice: auctionEndPrice || openOrder.auctionEndPrice,
2054
- userOrderId: openOrder.userOrderId,
2017
+ async modifyOrder({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, txParams, }) {
2018
+ const orderParams = {
2019
+ baseAssetAmount: newBaseAmount || null,
2020
+ direction: newDirection || null,
2021
+ price: newLimitPrice || null,
2022
+ oraclePriceOffset: newOraclePriceOffset || null,
2023
+ triggerPrice: newTriggerPrice || null,
2024
+ triggerCondition: newTriggerCondition || null,
2025
+ auctionDuration: auctionDuration || null,
2026
+ auctionStartPrice: auctionStartPrice || null,
2027
+ auctionEndPrice: auctionEndPrice || null,
2028
+ reduceOnly: reduceOnly || null,
2029
+ postOnly: postOnly || null,
2030
+ immediateOrCancel: immediateOrCancel || null,
2031
+ maxTs: maxTs || null,
2055
2032
  };
2056
- const placeOrderIx = isSpot
2057
- ? await this.getPlaceSpotOrderIx(newOrderParams)
2058
- : await this.getPlacePerpOrderIx(newOrderParams);
2059
- const tx = new web3_js_1.Transaction();
2060
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
2061
- units: 1000000,
2062
- }));
2063
- tx.add(cancelOrderIx);
2064
- tx.add(placeOrderIx);
2065
- const { txSig, slot } = await this.sendTransaction(tx, [], this.opts);
2066
- if (isSpot) {
2067
- this.spotMarketLastSlotCache.set(newOrderParams.marketIndex, slot);
2068
- this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
2069
- }
2070
- else {
2071
- this.perpMarketLastSlotCache.set(newOrderParams.marketIndex, slot);
2072
- }
2033
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getModifyOrderIx(orderId, orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2073
2034
  return txSig;
2074
2035
  }
2036
+ async getModifyOrderIx(orderId, orderParams) {
2037
+ const userAccountPublicKey = await this.getUserAccountPublicKey();
2038
+ const remainingAccounts = this.getRemainingAccounts({
2039
+ userAccounts: [this.getUserAccount()],
2040
+ useMarketLastSlotCache: true,
2041
+ });
2042
+ return await this.program.instruction.modifyOrder(orderId, orderParams, {
2043
+ accounts: {
2044
+ state: await this.getStatePublicKey(),
2045
+ user: userAccountPublicKey,
2046
+ userStats: this.getUserStatsAccountPublicKey(),
2047
+ authority: this.wallet.publicKey,
2048
+ },
2049
+ remainingAccounts,
2050
+ });
2051
+ }
2075
2052
  /**
2076
2053
  * Modifies an open order by closing it and replacing it with a new order.
2077
2054
  * @param userOrderId: The open order to modify
2078
- * @param newBaseAmount: The new base amount for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
2079
- * @param newLimitPice: The new limit price for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
2080
- * @param newOraclePriceOffset: The new oracle price offset for the order. One of [newBaseAmount|newLimitPrice|newOraclePriceOffset] must be provided.
2081
- * @param newOrderType: Optional - New order type for the order.
2055
+ * @param newDirection: The new direction for the order
2056
+ * @param newBaseAmount: The new base amount for the order
2057
+ * @param newLimitPice: The new limit price for the order
2058
+ * @param newOraclePriceOffset: The new oracle price offset for the order
2082
2059
  * @param newTriggerPrice: Optional - Thew new trigger price for the order.
2083
- * @param isSpot: Set to true if the order is a spot order
2084
2060
  * @param auctionDuration: Only required if order type changed to market from something else
2085
2061
  * @param auctionStartPrice: Only required if order type changed to market from something else
2086
2062
  * @param auctionEndPrice: Only required if order type changed to market from something else
2063
+ * @param reduceOnly:
2064
+ * @param postOnly:
2065
+ * @param immediateOrCancel:
2066
+ * @param maxTs:
2087
2067
  * @returns
2088
2068
  */
2089
- async modifyOrderByUserOrderId({ userOrderId, newBaseAmount, newLimitPrice, newOraclePriceOffset, newOrderType, newTriggerPrice, newTriggerCondition, isSpot, auctionDuration, auctionStartPrice, auctionEndPrice, }) {
2090
- if (!newBaseAmount && !newLimitPrice && !newOraclePriceOffset) {
2091
- throw new Error(`Must provide newBaseAmount or newLimitPrice or newOraclePriceOffset to modify order`);
2092
- }
2093
- const openOrder = this.getUser().getOrderByUserOrderId(userOrderId);
2094
- if (!openOrder) {
2095
- throw new Error(`No open order with user order id ${userOrderId.toString()}`);
2096
- }
2097
- const cancelOrderIx = await this.getCancelOrderByUserIdIx(userOrderId);
2098
- const orderTypeHasTrigger = newOrderType
2099
- ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerlimit', 'triggerMarket'])
2100
- : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'triggerMarket']);
2101
- const orderTypeHasLimitPrice = newOrderType
2102
- ? (0, types_1.isOneOfVariant)(newOrderType, ['triggerLimit', 'limit'])
2103
- : (0, types_1.isOneOfVariant)(openOrder.orderType, ['triggerLimit', 'limit']);
2104
- const newOrderParams = {
2105
- orderType: newOrderType || openOrder.orderType,
2106
- marketType: openOrder.marketType,
2107
- direction: openOrder.direction,
2108
- baseAssetAmount: newBaseAmount || openOrder.baseAssetAmount,
2109
- price: orderTypeHasLimitPrice
2110
- ? newLimitPrice || openOrder.price
2111
- : undefined,
2112
- marketIndex: openOrder.marketIndex,
2113
- reduceOnly: openOrder.reduceOnly,
2114
- postOnly: openOrder.postOnly
2115
- ? types_1.PostOnlyParams.MUST_POST_ONLY
2116
- : types_1.PostOnlyParams.NONE,
2117
- immediateOrCancel: openOrder.immediateOrCancel,
2118
- triggerPrice: orderTypeHasTrigger
2119
- ? newTriggerPrice || openOrder.triggerPrice
2120
- : undefined,
2121
- triggerCondition: orderTypeHasTrigger
2122
- ? newTriggerCondition || openOrder.triggerCondition
2123
- : undefined,
2124
- oraclePriceOffset: newOraclePriceOffset || openOrder.oraclePriceOffset,
2125
- auctionDuration: auctionDuration || openOrder.auctionDuration,
2126
- maxTs: openOrder.maxTs,
2127
- auctionStartPrice: auctionStartPrice || openOrder.auctionStartPrice,
2128
- auctionEndPrice: auctionEndPrice || openOrder.auctionEndPrice,
2129
- userOrderId: openOrder.userOrderId,
2069
+ async modifyOrderByUserOrderId({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, txParams, }) {
2070
+ const orderParams = {
2071
+ baseAssetAmount: newBaseAmount || null,
2072
+ direction: newDirection || null,
2073
+ price: newLimitPrice || null,
2074
+ oraclePriceOffset: newOraclePriceOffset || null,
2075
+ triggerPrice: newTriggerPrice || null,
2076
+ triggerCondition: newTriggerCondition || null,
2077
+ auctionDuration: auctionDuration || null,
2078
+ auctionStartPrice: auctionStartPrice || null,
2079
+ auctionEndPrice: auctionEndPrice || null,
2080
+ reduceOnly: reduceOnly || null,
2081
+ postOnly: postOnly || null,
2082
+ immediateOrCancel: immediateOrCancel || null,
2083
+ maxTs: maxTs || null,
2130
2084
  };
2131
- const placeOrderIx = isSpot
2132
- ? await this.getPlaceSpotOrderIx(newOrderParams)
2133
- : await this.getPlacePerpOrderIx(newOrderParams);
2134
- const tx = new web3_js_1.Transaction();
2135
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
2136
- units: 1000000,
2137
- }));
2138
- tx.add(cancelOrderIx);
2139
- tx.add(placeOrderIx);
2140
- const { txSig, slot } = await this.sendTransaction(tx, [], this.opts);
2141
- if (isSpot) {
2142
- this.spotMarketLastSlotCache.set(newOrderParams.marketIndex, slot);
2143
- this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
2144
- }
2145
- else {
2146
- this.perpMarketLastSlotCache.set(newOrderParams.marketIndex, slot);
2147
- }
2085
+ const { txSig } = await this.sendTransaction((0, utils_1.wrapInTx)(await this.getModifyOrderByUserIdIx(userOrderId, orderParams), txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice), [], this.opts);
2148
2086
  return txSig;
2149
2087
  }
2088
+ async getModifyOrderByUserIdIx(userOrderId, orderParams) {
2089
+ const userAccountPublicKey = await this.getUserAccountPublicKey();
2090
+ const remainingAccounts = this.getRemainingAccounts({
2091
+ userAccounts: [this.getUserAccount()],
2092
+ useMarketLastSlotCache: true,
2093
+ });
2094
+ return await this.program.instruction.modifyOrderByUserId(userOrderId, orderParams, {
2095
+ accounts: {
2096
+ state: await this.getStatePublicKey(),
2097
+ user: userAccountPublicKey,
2098
+ userStats: this.getUserStatsAccountPublicKey(),
2099
+ authority: this.wallet.publicKey,
2100
+ },
2101
+ remainingAccounts,
2102
+ });
2103
+ }
2150
2104
  async settlePNLs(users, marketIndexes) {
2151
2105
  const ixs = [];
2152
2106
  for (const { settleeUserAccountPublicKey, settleeUserAccount } of users) {
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { Connection, TransactionSignature } from '@solana/web3.js';
3
- import { Program } from '@project-serum/anchor';
3
+ import { Program } from '@coral-xyz/anchor';
4
4
  import { EventSubscriptionOptions, EventType, WrappedEvents, EventMap, EventSubscriberEvents } from './types';
5
5
  import { EventList } from './eventList';
6
6
  import { EventEmitter } from 'events';
@@ -97,7 +97,8 @@ class EventSubscriber {
97
97
  parseEventsFromLogs(txSig, slot, logs) {
98
98
  const records = [];
99
99
  // @ts-ignore
100
- this.program._events._eventParser.parseLogs(logs, (event) => {
100
+ const eventGenerator = this.program._events._eventParser.parseLogs(logs, false);
101
+ for (const event of eventGenerator) {
101
102
  const expectRecordType = this.eventListMap.has(event.name);
102
103
  if (expectRecordType) {
103
104
  event.data.txSig = txSig;
@@ -105,7 +106,7 @@ class EventSubscriber {
105
106
  event.data.eventType = event.name;
106
107
  records.push(event.data);
107
108
  }
108
- });
109
+ }
109
110
  return records;
110
111
  }
111
112
  awaitTx(txSig) {
@@ -1,4 +1,4 @@
1
- import { Program } from '@project-serum/anchor';
1
+ import { Program } from '@coral-xyz/anchor';
2
2
  import { Connection, Finality, PublicKey, TransactionResponse, TransactionSignature } from '@solana/web3.js';
3
3
  import { WrappedEvents } from './types';
4
4
  type Log = {
@@ -61,12 +61,13 @@ class LogParser {
61
61
  parseEventsFromLogs(event) {
62
62
  const records = [];
63
63
  // @ts-ignore
64
- this.program._events._eventParser.parseLogs(event.logs, (eventLog) => {
64
+ const eventGenerator = this.program._events._eventParser.parseLogs(event.logs, false);
65
+ for (const eventLog of eventGenerator) {
65
66
  eventLog.data.txSig = event.txSig;
66
67
  eventLog.data.slot = event.slot;
67
68
  eventLog.data.eventType = eventLog.name;
68
69
  records.push(eventLog.data);
69
- });
70
+ }
70
71
  return records;
71
72
  }
72
73
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const anchor_1 = require("@project-serum/anchor");
3
+ const anchor_1 = require("@coral-xyz/anchor");
4
4
  const __1 = require("..");
5
5
  const web3_js_1 = require("@solana/web3.js");
6
6
  const __2 = require("..");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTokenAddress = void 0;
4
- const anchor_1 = require("@project-serum/anchor");
4
+ const anchor_1 = require("@coral-xyz/anchor");
5
5
  const __1 = require("..");
6
6
  const spl_token_1 = require("@solana/spl-token");
7
7
  const web3_js_1 = require("@solana/web3.js");
@@ -1,5 +1,4 @@
1
- /// <reference types="bn.js" />
2
- import { BN } from '@project-serum/anchor';
1
+ import { BN } from '@coral-xyz/anchor';
3
2
  export declare class BigNum {
4
3
  val: BN;
5
4
  precision: BN;
@@ -44,11 +43,11 @@ export declare class BigNum {
44
43
  gte(bn: BigNum | BN, ignorePrecision?: boolean): boolean;
45
44
  lte(bn: BigNum | BN, ignorePrecision?: boolean): boolean;
46
45
  eq(bn: BigNum | BN, ignorePrecision?: boolean): boolean;
47
- eqZero(): boolean;
48
- gtZero(): boolean;
49
- ltZero(): boolean;
50
- gteZero(): boolean;
51
- lteZero(): boolean;
46
+ eqZero(): any;
47
+ gtZero(): any;
48
+ ltZero(): any;
49
+ gteZero(): any;
50
+ lteZero(): any;
52
51
  abs(): BigNum;
53
52
  neg(): BigNum;
54
53
  toString: (base?: number | 'hex', length?: number) => string;
@@ -88,8 +87,8 @@ export declare class BigNum {
88
87
  toNotional(useTradePrecision?: boolean, precisionOverride?: number): string;
89
88
  toMillified(precision?: number, rounded?: boolean): string;
90
89
  toJSON(): {
91
- val: string;
92
- precision: string;
90
+ val: any;
91
+ precision: any;
93
92
  };
94
93
  isNeg(): boolean;
95
94
  isPos(): boolean;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BigNum = void 0;
4
- const anchor_1 = require("@project-serum/anchor");
4
+ const anchor_1 = require("@coral-xyz/anchor");
5
5
  const assert_1 = require("../assert/assert");
6
6
  const numericConstants_1 = require("./../constants/numericConstants");
7
7
  class BigNum {
@@ -5,7 +5,7 @@ const types_1 = require("../types");
5
5
  const pythClient_1 = require("../oracles/pythClient");
6
6
  // import { SwitchboardClient } from '../oracles/switchboardClient';
7
7
  const quoteAssetOracleClient_1 = require("../oracles/quoteAssetOracleClient");
8
- const anchor_1 = require("@project-serum/anchor");
8
+ const anchor_1 = require("@coral-xyz/anchor");
9
9
  function getOracleClient(oracleSource, connection) {
10
10
  if ((0, types_1.isVariant)(oracleSource, 'pyth')) {
11
11
  return new pythClient_1.PythClient(connection);
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.24.0",
2
+ "version": "2.25.0-beta.1",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -428,6 +428,72 @@
428
428
  }
429
429
  ]
430
430
  },
431
+ {
432
+ "name": "modifyOrder",
433
+ "accounts": [
434
+ {
435
+ "name": "state",
436
+ "isMut": false,
437
+ "isSigner": false
438
+ },
439
+ {
440
+ "name": "user",
441
+ "isMut": true,
442
+ "isSigner": false
443
+ },
444
+ {
445
+ "name": "authority",
446
+ "isMut": false,
447
+ "isSigner": true
448
+ }
449
+ ],
450
+ "args": [
451
+ {
452
+ "name": "orderId",
453
+ "type": {
454
+ "option": "u32"
455
+ }
456
+ },
457
+ {
458
+ "name": "modifyOrderParams",
459
+ "type": {
460
+ "defined": "ModifyOrderParams"
461
+ }
462
+ }
463
+ ]
464
+ },
465
+ {
466
+ "name": "modifyOrderByUserId",
467
+ "accounts": [
468
+ {
469
+ "name": "state",
470
+ "isMut": false,
471
+ "isSigner": false
472
+ },
473
+ {
474
+ "name": "user",
475
+ "isMut": true,
476
+ "isSigner": false
477
+ },
478
+ {
479
+ "name": "authority",
480
+ "isMut": false,
481
+ "isSigner": true
482
+ }
483
+ ],
484
+ "args": [
485
+ {
486
+ "name": "userOrderId",
487
+ "type": "u8"
488
+ },
489
+ {
490
+ "name": "modifyOrderParams",
491
+ "type": {
492
+ "defined": "ModifyOrderParams"
493
+ }
494
+ }
495
+ ]
496
+ },
431
497
  {
432
498
  "name": "placeAndTakePerpOrder",
433
499
  "accounts": [
@@ -4882,6 +4948,98 @@
4882
4948
  ]
4883
4949
  }
4884
4950
  },
4951
+ {
4952
+ "name": "ModifyOrderParams",
4953
+ "type": {
4954
+ "kind": "struct",
4955
+ "fields": [
4956
+ {
4957
+ "name": "direction",
4958
+ "type": {
4959
+ "option": {
4960
+ "defined": "PositionDirection"
4961
+ }
4962
+ }
4963
+ },
4964
+ {
4965
+ "name": "baseAssetAmount",
4966
+ "type": {
4967
+ "option": "u64"
4968
+ }
4969
+ },
4970
+ {
4971
+ "name": "price",
4972
+ "type": {
4973
+ "option": "u64"
4974
+ }
4975
+ },
4976
+ {
4977
+ "name": "reduceOnly",
4978
+ "type": {
4979
+ "option": "bool"
4980
+ }
4981
+ },
4982
+ {
4983
+ "name": "postOnly",
4984
+ "type": {
4985
+ "option": {
4986
+ "defined": "PostOnlyParam"
4987
+ }
4988
+ }
4989
+ },
4990
+ {
4991
+ "name": "immediateOrCancel",
4992
+ "type": {
4993
+ "option": "bool"
4994
+ }
4995
+ },
4996
+ {
4997
+ "name": "maxTs",
4998
+ "type": {
4999
+ "option": "i64"
5000
+ }
5001
+ },
5002
+ {
5003
+ "name": "triggerPrice",
5004
+ "type": {
5005
+ "option": "u64"
5006
+ }
5007
+ },
5008
+ {
5009
+ "name": "triggerCondition",
5010
+ "type": {
5011
+ "option": {
5012
+ "defined": "OrderTriggerCondition"
5013
+ }
5014
+ }
5015
+ },
5016
+ {
5017
+ "name": "oraclePriceOffset",
5018
+ "type": {
5019
+ "option": "i32"
5020
+ }
5021
+ },
5022
+ {
5023
+ "name": "auctionDuration",
5024
+ "type": {
5025
+ "option": "u8"
5026
+ }
5027
+ },
5028
+ {
5029
+ "name": "auctionStartPrice",
5030
+ "type": {
5031
+ "option": "i64"
5032
+ }
5033
+ },
5034
+ {
5035
+ "name": "auctionEndPrice",
5036
+ "type": {
5037
+ "option": "i64"
5038
+ }
5039
+ }
5040
+ ]
5041
+ }
5042
+ },
4885
5043
  {
4886
5044
  "name": "LiquidatePerpRecord",
4887
5045
  "type": {
@@ -5157,7 +5315,7 @@
5157
5315
  "fields": [
5158
5316
  {
5159
5317
  "name": "revenueWithdrawSinceLastSettle",
5160
- "type": "u64"
5318
+ "type": "i64"
5161
5319
  },
5162
5320
  {
5163
5321
  "name": "maxRevenueWithdrawPerPeriod",
@@ -6011,31 +6169,35 @@
6011
6169
  }
6012
6170
  },
6013
6171
  {
6014
- "name": "PositionDirection",
6172
+ "name": "ModifyOrderId",
6015
6173
  "type": {
6016
6174
  "kind": "enum",
6017
6175
  "variants": [
6018
6176
  {
6019
- "name": "Long"
6177
+ "name": "UserOrderId",
6178
+ "fields": [
6179
+ "u8"
6180
+ ]
6020
6181
  },
6021
6182
  {
6022
- "name": "Short"
6183
+ "name": "OrderId",
6184
+ "fields": [
6185
+ "u32"
6186
+ ]
6023
6187
  }
6024
6188
  ]
6025
6189
  }
6026
6190
  },
6027
6191
  {
6028
- "name": "FulfillmentParams",
6192
+ "name": "PositionDirection",
6029
6193
  "type": {
6030
6194
  "kind": "enum",
6031
6195
  "variants": [
6032
6196
  {
6033
- "name": "SerumFulfillmentParams",
6034
- "fields": [
6035
- {
6036
- "defined": "SerumFulfillmentParams<'a,'b>"
6037
- }
6038
- ]
6197
+ "name": "Long"
6198
+ },
6199
+ {
6200
+ "name": "Short"
6039
6201
  }
6040
6202
  ]
6041
6203
  }
@@ -6049,7 +6211,7 @@
6049
6211
  "name": "SerumV3"
6050
6212
  },
6051
6213
  {
6052
- "name": "None"
6214
+ "name": "Match"
6053
6215
  }
6054
6216
  ]
6055
6217
  }
@@ -6410,7 +6572,7 @@
6410
6572
  "kind": "enum",
6411
6573
  "variants": [
6412
6574
  {
6413
- "name": "SerumV3"
6575
+ "name": "ExternalMarket"
6414
6576
  },
6415
6577
  {
6416
6578
  "name": "Match"
@@ -8861,6 +9023,11 @@
8861
9023
  "code": 6240,
8862
9024
  "name": "InvalidMarketAccountforDeletion",
8863
9025
  "msg": "Invalid MarketAccount for Deletion"
9026
+ },
9027
+ {
9028
+ "code": 6241,
9029
+ "name": "InvalidSpotFulfillmentParams",
9030
+ "msg": "Invalid Spot Fulfillment Params"
8864
9031
  }
8865
9032
  ]
8866
9033
  }
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BN } from '@project-serum/anchor';
1
+ import { BN } from '@coral-xyz/anchor';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import pyth from '@pythnetwork/client';
4
4
  export * from './tokenFaucet';
package/lib/index.js CHANGED
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.pyth = exports.PublicKey = exports.BN = void 0;
21
- const anchor_1 = require("@project-serum/anchor");
21
+ const anchor_1 = require("@coral-xyz/anchor");
22
22
  Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return anchor_1.BN; } });
23
23
  const web3_js_1 = require("@solana/web3.js");
24
24
  Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return web3_js_1.PublicKey; } });