@drift-labs/sdk 2.104.0-beta.2 → 2.104.0-beta.20

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 (141) hide show
  1. package/VERSION +1 -1
  2. package/bun.lockb +0 -0
  3. package/lib/browser/addresses/pda.d.ts +1 -0
  4. package/lib/browser/addresses/pda.js +12 -1
  5. package/lib/browser/adminClient.d.ts +2 -0
  6. package/lib/browser/adminClient.js +19 -2
  7. package/lib/browser/bankrun/bankrunConnection.d.ts +2 -1
  8. package/lib/browser/bankrun/bankrunConnection.js +14 -0
  9. package/lib/browser/config.d.ts +2 -0
  10. package/lib/browser/config.js +4 -1
  11. package/lib/browser/constants/perpMarkets.js +11 -0
  12. package/lib/browser/constants/spotMarkets.js +22 -1
  13. package/lib/browser/dlob/DLOB.d.ts +15 -13
  14. package/lib/browser/dlob/DLOB.js +46 -147
  15. package/lib/browser/dlob/DLOBNode.d.ts +11 -2
  16. package/lib/browser/dlob/DLOBNode.js +15 -2
  17. package/lib/browser/dlob/NodeList.d.ts +1 -3
  18. package/lib/browser/dlob/NodeList.js +1 -17
  19. package/lib/browser/driftClient.d.ts +6 -2
  20. package/lib/browser/driftClient.js +59 -10
  21. package/lib/browser/factory/oracleClient.js +4 -0
  22. package/lib/browser/idl/drift.json +145 -2
  23. package/lib/browser/index.d.ts +2 -3
  24. package/lib/browser/index.js +2 -3
  25. package/lib/browser/isomorphic/grpc.d.ts +1 -1
  26. package/lib/browser/memcmp.d.ts +1 -0
  27. package/lib/browser/memcmp.js +10 -1
  28. package/lib/browser/oracles/oracleId.js +2 -0
  29. package/lib/browser/oracles/pythLazerClient.d.ts +16 -0
  30. package/lib/browser/oracles/pythLazerClient.js +61 -0
  31. package/lib/browser/tx/baseTxSender.d.ts +3 -1
  32. package/lib/browser/tx/baseTxSender.js +2 -1
  33. package/lib/browser/tx/whileValidTxSender.d.ts +2 -1
  34. package/lib/browser/tx/whileValidTxSender.js +3 -2
  35. package/lib/browser/types.d.ts +4 -0
  36. package/lib/browser/types.js +2 -0
  37. package/lib/browser/userMap/WebsocketSubscription.d.ts +4 -2
  38. package/lib/browser/userMap/WebsocketSubscription.js +5 -1
  39. package/lib/browser/userMap/grpcSubscription.d.ts +4 -1
  40. package/lib/browser/userMap/grpcSubscription.js +5 -1
  41. package/lib/browser/userMap/userMap.d.ts +1 -0
  42. package/lib/browser/userMap/userMap.js +4 -0
  43. package/lib/browser/userMap/userMapConfig.d.ts +2 -1
  44. package/lib/browser/util/computeUnits.js +2 -0
  45. package/lib/browser/util/pythOracleUtils.d.ts +17 -0
  46. package/lib/browser/util/pythOracleUtils.js +107 -0
  47. package/lib/node/addresses/pda.d.ts +1 -0
  48. package/lib/node/addresses/pda.js +12 -1
  49. package/lib/node/adminClient.d.ts +2 -0
  50. package/lib/node/adminClient.js +19 -2
  51. package/lib/node/bankrun/bankrunConnection.d.ts +2 -1
  52. package/lib/node/bankrun/bankrunConnection.js +14 -0
  53. package/lib/node/config.d.ts +2 -0
  54. package/lib/node/config.js +4 -1
  55. package/lib/node/constants/perpMarkets.js +11 -0
  56. package/lib/node/constants/spotMarkets.js +22 -1
  57. package/lib/node/dlob/DLOB.d.ts +15 -13
  58. package/lib/node/dlob/DLOB.js +46 -147
  59. package/lib/node/dlob/DLOBNode.d.ts +11 -2
  60. package/lib/node/dlob/DLOBNode.js +15 -2
  61. package/lib/node/dlob/NodeList.d.ts +1 -3
  62. package/lib/node/dlob/NodeList.js +1 -17
  63. package/lib/node/driftClient.d.ts +6 -2
  64. package/lib/node/driftClient.js +59 -10
  65. package/lib/node/factory/oracleClient.js +4 -0
  66. package/lib/node/idl/drift.json +145 -2
  67. package/lib/node/index.d.ts +2 -3
  68. package/lib/node/index.js +2 -3
  69. package/lib/node/isomorphic/grpc.browser.js +8 -0
  70. package/lib/node/isomorphic/grpc.d.ts +1 -1
  71. package/lib/node/isomorphic/grpc.js +3 -12
  72. package/lib/node/memcmp.d.ts +1 -0
  73. package/lib/node/memcmp.js +10 -1
  74. package/lib/node/oracles/oracleId.js +2 -0
  75. package/lib/node/oracles/pythLazerClient.d.ts +16 -0
  76. package/lib/node/oracles/pythLazerClient.js +61 -0
  77. package/lib/node/tx/baseTxSender.d.ts +3 -1
  78. package/lib/node/tx/baseTxSender.js +2 -1
  79. package/lib/node/tx/whileValidTxSender.d.ts +2 -1
  80. package/lib/node/tx/whileValidTxSender.js +3 -2
  81. package/lib/node/types.d.ts +4 -0
  82. package/lib/node/types.js +2 -0
  83. package/lib/node/userMap/WebsocketSubscription.d.ts +4 -2
  84. package/lib/node/userMap/WebsocketSubscription.js +5 -1
  85. package/lib/node/userMap/grpcSubscription.d.ts +4 -1
  86. package/lib/node/userMap/grpcSubscription.js +5 -1
  87. package/lib/node/userMap/userMap.d.ts +1 -0
  88. package/lib/node/userMap/userMap.js +4 -0
  89. package/lib/node/userMap/userMapConfig.d.ts +2 -1
  90. package/lib/node/util/computeUnits.js +2 -0
  91. package/lib/node/util/pythOracleUtils.d.ts +17 -0
  92. package/lib/node/util/pythOracleUtils.js +107 -0
  93. package/package.json +30 -28
  94. package/scripts/postbuild.js +63 -29
  95. package/src/addresses/pda.ts +18 -0
  96. package/src/adminClient.ts +32 -1
  97. package/src/bankrun/bankrunConnection.ts +21 -0
  98. package/src/config.ts +5 -0
  99. package/src/constants/perpMarkets.ts +12 -0
  100. package/src/constants/spotMarkets.ts +23 -1
  101. package/src/dlob/DLOB.ts +73 -228
  102. package/src/dlob/DLOBNode.ts +24 -1
  103. package/src/dlob/NodeList.ts +1 -19
  104. package/src/driftClient.ts +105 -5
  105. package/src/factory/oracleClient.ts +5 -0
  106. package/src/idl/drift.json +145 -2
  107. package/src/index.ts +2 -3
  108. package/src/memcmp.ts +9 -0
  109. package/src/oracles/oracleId.ts +1 -0
  110. package/src/oracles/pythLazerClient.ts +102 -0
  111. package/src/tx/baseTxSender.ts +4 -0
  112. package/src/tx/whileValidTxSender.ts +4 -1
  113. package/src/types.ts +2 -0
  114. package/src/userMap/WebsocketSubscription.ts +8 -1
  115. package/src/userMap/grpcSubscription.ts +8 -1
  116. package/src/userMap/userMap.ts +6 -1
  117. package/src/userMap/userMapConfig.ts +3 -1
  118. package/src/util/computeUnits.ts +2 -0
  119. package/src/util/pythOracleUtils.ts +136 -0
  120. package/tests/dlob/test.ts +13 -184
  121. package/lib/browser/dlob/DLOBApiClient.d.ts +0 -14
  122. package/lib/browser/dlob/DLOBApiClient.js +0 -34
  123. package/lib/browser/dlob/DLOBOrders.d.ts +0 -17
  124. package/lib/browser/dlob/DLOBOrders.js +0 -40
  125. package/lib/browser/dlob/dlobIdl.json +0 -248
  126. package/lib/browser/isomorphic/grpc.node.d.ts +0 -5
  127. package/lib/browser/util/pythPullOracleUtils.d.ts +0 -2
  128. package/lib/browser/util/pythPullOracleUtils.js +0 -15
  129. package/lib/node/dlob/DLOBApiClient.d.ts +0 -14
  130. package/lib/node/dlob/DLOBApiClient.js +0 -34
  131. package/lib/node/dlob/DLOBOrders.d.ts +0 -17
  132. package/lib/node/dlob/DLOBOrders.js +0 -40
  133. package/lib/node/dlob/dlobIdl.json +0 -248
  134. package/lib/node/isomorphic/grpc.node.d.ts +0 -5
  135. package/lib/node/isomorphic/grpc.node.js +0 -17
  136. package/lib/node/util/pythPullOracleUtils.d.ts +0 -2
  137. package/lib/node/util/pythPullOracleUtils.js +0 -15
  138. package/src/dlob/DLOBApiClient.ts +0 -39
  139. package/src/dlob/DLOBOrders.ts +0 -49
  140. package/src/dlob/dlobIdl.json +0 -248
  141. package/src/util/pythPullOracleUtils.ts +0 -11
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.104.0-beta.2
1
+ 2.104.0-beta.20
package/bun.lockb CHANGED
Binary file
@@ -27,5 +27,6 @@ export declare function getReferrerNamePublicKeySync(programId: PublicKey, nameB
27
27
  export declare function getProtocolIfSharesTransferConfigPublicKey(programId: PublicKey): PublicKey;
28
28
  export declare function getPrelaunchOraclePublicKey(programId: PublicKey, marketIndex: number): PublicKey;
29
29
  export declare function getPythPullOraclePublicKey(progarmId: PublicKey, feedId: Uint8Array): PublicKey;
30
+ export declare function getPythLazerOraclePublicKey(progarmId: PublicKey, feedId: number): PublicKey;
30
31
  export declare function getTokenProgramForSpotMarket(spotMarketAccount: SpotMarketAccount): PublicKey;
31
32
  export declare function getHighLeverageModeConfigPublicKey(programId: PublicKey): PublicKey;
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSwiftUserAccountPublicKey = exports.getRFQUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
26
+ exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSwiftUserAccountPublicKey = exports.getRFQUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
27
27
  const web3_js_1 = require("@solana/web3.js");
28
28
  const anchor = __importStar(require("@coral-xyz/anchor"));
29
29
  const spl_token_1 = require("@solana/spl-token");
@@ -187,6 +187,17 @@ function getPythPullOraclePublicKey(progarmId, feedId) {
187
187
  ], progarmId)[0];
188
188
  }
189
189
  exports.getPythPullOraclePublicKey = getPythPullOraclePublicKey;
190
+ function getPythLazerOraclePublicKey(progarmId, feedId) {
191
+ const buffer = new ArrayBuffer(4);
192
+ const view = new DataView(buffer);
193
+ view.setUint32(0, feedId, true);
194
+ const feedIdBytes = new Uint8Array(buffer);
195
+ return web3_js_1.PublicKey.findProgramAddressSync([
196
+ Buffer.from(anchor.utils.bytes.utf8.encode('pyth_lazer')),
197
+ Buffer.from(feedIdBytes),
198
+ ], progarmId)[0];
199
+ }
200
+ exports.getPythLazerOraclePublicKey = getPythLazerOraclePublicKey;
190
201
  function getTokenProgramForSpotMarket(spotMarketAccount) {
191
202
  if (spotMarketAccount.tokenProgram === 1) {
192
203
  return spl_token_1.TOKEN_2022_PROGRAM_ID;
@@ -197,6 +197,8 @@ export declare class AdminClient extends DriftClient {
197
197
  getInitUserFuelIx(user: PublicKey, authority: PublicKey, fuelBonusDeposits?: number, fuelBonusBorrows?: number, fuelBonusTaker?: number, fuelBonusMaker?: number, fuelBonusInsurance?: number): Promise<TransactionInstruction>;
198
198
  initializePythPullOracle(feedId: string, isAdmin?: boolean): Promise<TransactionSignature>;
199
199
  getInitializePythPullOracleIx(feedId: string, isAdmin?: boolean): Promise<TransactionInstruction>;
200
+ initializePythLazerOracle(feedId: number, isAdmin?: boolean): Promise<TransactionSignature>;
201
+ getInitializePythLazerOracleIx(feedId: number, isAdmin?: boolean): Promise<TransactionInstruction>;
200
202
  initializeHighLeverageModeConfig(maxUsers: number): Promise<TransactionSignature>;
201
203
  getInitializeHighLeverageModeConfigIx(maxUsers: number): Promise<TransactionInstruction>;
202
204
  updateUpdateHighLeverageModeConfig(maxUsers: number, reduceOnly: boolean): Promise<TransactionSignature>;
@@ -38,7 +38,7 @@ const trade_1 = require("./math/trade");
38
38
  const amm_1 = require("./math/amm");
39
39
  const phoenix_sdk_1 = require("@ellipsis-labs/phoenix-sdk");
40
40
  const config_1 = require("./config");
41
- const pythPullOracleUtils_1 = require("./util/pythPullOracleUtils");
41
+ const pythOracleUtils_1 = require("./util/pythOracleUtils");
42
42
  const OPENBOOK_PROGRAM_ID = new web3_js_1.PublicKey('opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb');
43
43
  class AdminClient extends driftClient_1.DriftClient {
44
44
  async initialize(usdcMint, _adminControlsPrices) {
@@ -1790,7 +1790,7 @@ class AdminClient extends driftClient_1.DriftClient {
1790
1790
  return txSig;
1791
1791
  }
1792
1792
  async getInitializePythPullOracleIx(feedId, isAdmin = false) {
1793
- const feedIdBuffer = (0, pythPullOracleUtils_1.getFeedIdUint8Array)(feedId);
1793
+ const feedIdBuffer = (0, pythOracleUtils_1.getFeedIdUint8Array)(feedId);
1794
1794
  return await this.program.instruction.initializePythPullOracle(feedIdBuffer, {
1795
1795
  accounts: {
1796
1796
  admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey,
@@ -1801,6 +1801,23 @@ class AdminClient extends driftClient_1.DriftClient {
1801
1801
  },
1802
1802
  });
1803
1803
  }
1804
+ async initializePythLazerOracle(feedId, isAdmin = false) {
1805
+ const initializePythPullOracleIx = await this.getInitializePythLazerOracleIx(feedId, isAdmin);
1806
+ const tx = await this.buildTransaction(initializePythPullOracleIx);
1807
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
1808
+ return txSig;
1809
+ }
1810
+ async getInitializePythLazerOracleIx(feedId, isAdmin = false) {
1811
+ return await this.program.instruction.initializePythLazerOracle(feedId, {
1812
+ accounts: {
1813
+ admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey,
1814
+ state: await this.getStatePublicKey(),
1815
+ systemProgram: web3_js_1.SystemProgram.programId,
1816
+ lazerOracle: (0, pda_1.getPythLazerOraclePublicKey)(this.program.programId, feedId),
1817
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
1818
+ },
1819
+ });
1820
+ }
1804
1821
  async initializeHighLeverageModeConfig(maxUsers) {
1805
1822
  const initializeHighLeverageModeConfigIx = await this.getInitializeHighLeverageModeConfigIx(maxUsers);
1806
1823
  const tx = await this.buildTransaction(initializeHighLeverageModeConfigIx);
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  /// <reference types="bn.js" />
4
- import { AccountInfo, Keypair, PublicKey, Transaction, RpcResponseAndContext, Commitment, TransactionSignature, SignatureStatusConfig, SignatureStatus, GetVersionedTransactionConfig, GetTransactionConfig, VersionedTransaction, SimulateTransactionConfig, SimulatedTransactionResponse, TransactionError, SignatureResultCallback, ClientSubscriptionId, Connection as SolanaConnection, Blockhash, LogsFilter, LogsCallback, AccountChangeCallback } from '@solana/web3.js';
4
+ import { AccountInfo, Keypair, PublicKey, Transaction, RpcResponseAndContext, Commitment, TransactionSignature, SignatureStatusConfig, SignatureStatus, GetVersionedTransactionConfig, GetTransactionConfig, VersionedTransaction, SimulateTransactionConfig, SimulatedTransactionResponse, TransactionError, SignatureResultCallback, ClientSubscriptionId, Connection as SolanaConnection, Blockhash, LogsFilter, LogsCallback, AccountChangeCallback, AddressLookupTableAccount } from '@solana/web3.js';
5
5
  import { ProgramTestContext, BanksClient } from 'solana-bankrun';
6
6
  import { BankrunProvider } from 'anchor-bankrun';
7
7
  import { BN, Wallet } from '@coral-xyz/anchor';
@@ -54,6 +54,7 @@ export declare class BankrunConnection {
54
54
  blockhash: string;
55
55
  lastValidBlockHeight: number;
56
56
  }>>;
57
+ getAddressLookupTable(accountKey: PublicKey): Promise<RpcResponseAndContext<null | AddressLookupTableAccount>>;
57
58
  getSignatureStatus(signature: string, _config?: SignatureStatusConfig): Promise<RpcResponseAndContext<null | SignatureStatus>>;
58
59
  /**
59
60
  * There's really no direct equivalent to getTransaction exposed by SolanaProgramTest, so we do the best that we can here - it's a little hacky.
@@ -204,6 +204,20 @@ class BankrunConnection {
204
204
  lastValidBlockHeight: Number(blockhashAndBlockheight[1]),
205
205
  };
206
206
  }
207
+ async getAddressLookupTable(accountKey) {
208
+ const { context, value: accountInfo } = await this.getParsedAccountInfo(accountKey);
209
+ let value = null;
210
+ if (accountInfo !== null) {
211
+ value = new web3_js_1.AddressLookupTableAccount({
212
+ key: accountKey,
213
+ state: web3_js_1.AddressLookupTableAccount.deserialize(accountInfo.data),
214
+ });
215
+ }
216
+ return {
217
+ context,
218
+ value,
219
+ };
220
+ }
207
221
  async getSignatureStatus(signature, _config) {
208
222
  const transactionStatus = await this._banksClient.getTransactionStatus(signature);
209
223
  if (transactionStatus === null) {
@@ -27,6 +27,8 @@ export declare const DRIFT_PROGRAM_ID = "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn
27
27
  export declare const DRIFT_ORACLE_RECEIVER_ID = "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha";
28
28
  export declare const SWIFT_ID = "SW1fThqrxLzVprnCMpiybiqYQfoNCdduC5uWsSUKChS";
29
29
  export declare const ANCHOR_TEST_SWIFT_ID = "DpaEdAPW3ZX67fnczT14AoX12Lx9VMkxvtT81nCHy3Nv";
30
+ export declare const PTYH_LAZER_PROGRAM_ID = "pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
31
+ export declare const PYTH_LAZER_STORAGE_ACCOUNT_KEY: PublicKey;
30
32
  export declare const DEFAULT_CONFIRMATION_OPTS: ConfirmOptions;
31
33
  export declare const configs: {
32
34
  [key in DriftEnv]: DriftConfig;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findAllMarketAndOracles = exports.getMarketsAndOraclesForSubscription = exports.initialize = exports.getConfig = exports.configs = exports.DEFAULT_CONFIRMATION_OPTS = exports.ANCHOR_TEST_SWIFT_ID = exports.SWIFT_ID = exports.DRIFT_ORACLE_RECEIVER_ID = exports.DRIFT_PROGRAM_ID = void 0;
3
+ exports.findAllMarketAndOracles = exports.getMarketsAndOraclesForSubscription = exports.initialize = exports.getConfig = exports.configs = exports.DEFAULT_CONFIRMATION_OPTS = exports.PYTH_LAZER_STORAGE_ACCOUNT_KEY = exports.PTYH_LAZER_PROGRAM_ID = exports.ANCHOR_TEST_SWIFT_ID = exports.SWIFT_ID = exports.DRIFT_ORACLE_RECEIVER_ID = exports.DRIFT_PROGRAM_ID = void 0;
4
+ const _1 = require(".");
4
5
  const perpMarkets_1 = require("./constants/perpMarkets");
5
6
  const spotMarkets_1 = require("./constants/spotMarkets");
6
7
  const on_demand_1 = require("@switchboard-xyz/on-demand");
@@ -9,6 +10,8 @@ exports.DRIFT_PROGRAM_ID = 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH';
9
10
  exports.DRIFT_ORACLE_RECEIVER_ID = 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha';
10
11
  exports.SWIFT_ID = 'SW1fThqrxLzVprnCMpiybiqYQfoNCdduC5uWsSUKChS';
11
12
  exports.ANCHOR_TEST_SWIFT_ID = 'DpaEdAPW3ZX67fnczT14AoX12Lx9VMkxvtT81nCHy3Nv';
13
+ exports.PTYH_LAZER_PROGRAM_ID = 'pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt';
14
+ exports.PYTH_LAZER_STORAGE_ACCOUNT_KEY = new _1.PublicKey('3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL');
12
15
  exports.DEFAULT_CONFIRMATION_OPTS = {
13
16
  preflightCommitment: 'confirmed',
14
17
  commitment: 'confirmed',
@@ -979,6 +979,17 @@ exports.MainnetPerpMarkets = [
979
979
  oracleSource: __1.OracleSource.PYTH_PULL,
980
980
  pythFeedId: '0x6e3f3fa8253588df9326580180233eb791e03b443a3ba7a1d892e73874e19a54',
981
981
  },
982
+ {
983
+ fullName: 'Magic Eden',
984
+ category: ['DEX'],
985
+ symbol: 'ME-PERP',
986
+ baseAssetSymbol: 'ME',
987
+ marketIndex: 61,
988
+ oracle: new web3_js_1.PublicKey('FLQjrmEPGwbCKRYZ1eYM5FPccHBrCv2cN4GBu3mWfmPH'),
989
+ launchTs: 1733839936000,
990
+ oracleSource: __1.OracleSource.PYTH_PULL,
991
+ pythFeedId: '0x91519e3e48571e1232a85a938e714da19fe5ce05107f3eebb8a870b2e8020169',
992
+ },
982
993
  ];
983
994
  exports.PerpMarkets = {
984
995
  devnet: exports.DevnetPerpMarkets,
@@ -80,7 +80,7 @@ exports.DevnetSpotMarkets = [
80
80
  marketIndex: 6,
81
81
  poolId: 1,
82
82
  oracle: new web3_js_1.PublicKey('En8hkHLkRe9d9DraYmBTrus518BvmVH448YcvmrFM6Ce'),
83
- oracleSource: __1.OracleSource.PYTH_STABLE_COIN_PULL,
83
+ oracleSource: __1.OracleSource.PYTH_PULL,
84
84
  mint: new web3_js_1.PublicKey('8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2'),
85
85
  precision: new __1.BN(10).pow(numericConstants_1.SIX),
86
86
  precisionExp: numericConstants_1.SIX,
@@ -442,6 +442,27 @@ exports.MainnetSpotMarkets = [
442
442
  precisionExp: numericConstants_1.SIX,
443
443
  pythFeedId: '0x77f0971af11cc8bac224917275c1bf55f2319ed5c654a1ca955c82fa2d297ea1',
444
444
  },
445
+ {
446
+ symbol: 'META',
447
+ marketIndex: 29,
448
+ poolId: 0,
449
+ oracle: new web3_js_1.PublicKey('DwYF1yveo8XTF1oqfsqykj332rjSxAd7bR6Gu6i4iUET'),
450
+ oracleSource: __1.OracleSource.SWITCHBOARD_ON_DEMAND,
451
+ mint: new web3_js_1.PublicKey('METADDFL6wWMWEoKTFJwcThTbUmtarRJZjRpzUvkxhr'),
452
+ precision: new __1.BN(10).pow(numericConstants_1.NINE),
453
+ precisionExp: numericConstants_1.NINE,
454
+ },
455
+ {
456
+ symbol: 'ME',
457
+ marketIndex: 30,
458
+ poolId: 0,
459
+ oracle: new web3_js_1.PublicKey('FLQjrmEPGwbCKRYZ1eYM5FPccHBrCv2cN4GBu3mWfmPH'),
460
+ oracleSource: __1.OracleSource.PYTH_PULL,
461
+ mint: new web3_js_1.PublicKey('MEFNBXixkEbait3xn9bkm8WsJzXtVsaJEn4c8Sam21u'),
462
+ precision: new __1.BN(10).pow(numericConstants_1.SIX),
463
+ precisionExp: numericConstants_1.SIX,
464
+ pythFeedId: '0x91519e3e48571e1232a85a938e714da19fe5ce05107f3eebb8a870b2e8020169',
465
+ },
445
466
  ];
446
467
  exports.SpotMarkets = {
447
468
  devnet: exports.DevnetSpotMarkets,
@@ -1,9 +1,13 @@
1
1
  /// <reference types="bn.js" />
2
2
  import { NodeList } from './NodeList';
3
- import { BN, DLOBNode, DLOBNodeType, DriftClient, MarketType, MarketTypeStr, OraclePriceData, Order, OrderActionRecord, OrderRecord, PerpMarketAccount, PositionDirection, SlotSubscriber, SpotMarketAccount, StateAccount, TriggerOrderNode, UserMap } from '..';
3
+ import { BN, DLOBNode, DLOBNodeType, DriftClient, MarketType, MarketTypeStr, OraclePriceData, Order, PerpMarketAccount, PositionDirection, SlotSubscriber, SpotMarketAccount, StateAccount, TriggerOrderNode, UserMap } from '..';
4
4
  import { PublicKey } from '@solana/web3.js';
5
- import { DLOBOrders } from './DLOBOrders';
6
5
  import { L2OrderBook, L2OrderBookGenerator, L3OrderBook } from './orderBookLevels';
6
+ export type DLOBOrder = {
7
+ user: PublicKey;
8
+ order: Order;
9
+ };
10
+ export type DLOBOrders = DLOBOrder[];
7
11
  export type MarketNodeLists = {
8
12
  restingLimit: {
9
13
  ask: NodeList<'restingLimit'>;
@@ -25,6 +29,10 @@ export type MarketNodeLists = {
25
29
  above: NodeList<'trigger'>;
26
30
  below: NodeList<'trigger'>;
27
31
  };
32
+ swift: {
33
+ ask: NodeList<'swift'>;
34
+ bid: NodeList<'swift'>;
35
+ };
28
36
  };
29
37
  type OrderBookCallback = () => void;
30
38
  /**
@@ -55,15 +63,10 @@ export declare class DLOB {
55
63
  * @returns a promise that resolves when the DLOB is initialized
56
64
  */
57
65
  initFromUserMap(userMap: UserMap, slot: number): Promise<boolean>;
58
- initFromOrders(dlobOrders: DLOBOrders, slot: number): boolean;
59
- handleOrderRecord(record: OrderRecord, slot: number): void;
60
- handleOrderActionRecord(record: OrderActionRecord, slot: number): void;
61
66
  insertOrder(order: Order, userAccount: string, slot: number, isUserProtectedMaker: boolean, onInsert?: OrderBookCallback): void;
67
+ insertSwiftOrder(order: Order, userAccount: string, isUserProtectedMaker: boolean, onInsert?: OrderBookCallback): void;
62
68
  addOrderList(marketType: MarketTypeStr, marketIndex: number): void;
63
- updateOrder(order: Order, userAccount: PublicKey, slot: number, cumulativeBaseAssetAmountFilled: BN, onUpdate?: OrderBookCallback): void;
64
- trigger(order: Order, userAccount: PublicKey, slot: number, isUserProtectedMaker: boolean, onTrigger?: OrderBookCallback): void;
65
- delete(order: Order, userAccount: PublicKey, slot: number, onDelete?: OrderBookCallback): void;
66
- getListForOrder(order: Order, slot: number): NodeList<any> | undefined;
69
+ getListForOnChainOrder(order: Order, slot: number): NodeList<any> | undefined;
67
70
  updateRestingLimitOrders(slot: number): void;
68
71
  updateRestingLimitOrdersForMarketType(slot: number, marketTypeStr: MarketTypeStr): void;
69
72
  getOrder(orderId: number, userAccount: PublicKey): Order | undefined;
@@ -77,8 +80,7 @@ export declare class DLOB {
77
80
  findTakingNodesToFill(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, isAmmPaused: boolean, minAuctionDuration: number, fallbackAsk: BN | undefined, fallbackBid?: BN | undefined): NodeToFill[];
78
81
  findTakingNodesCrossingMakerNodes(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, takerNodeGenerator: Generator<DLOBNode>, makerNodeGeneratorFn: (marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData) => Generator<DLOBNode>, doesCross: (takerPrice: BN | undefined, makerPrice: BN) => boolean): NodeToFill[];
79
82
  findNodesCrossingFallbackLiquidity(marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, nodeGenerator: Generator<DLOBNode>, doesCross: (nodePrice: BN | undefined) => boolean, minAuctionDuration: number): NodeToFill[];
80
- findExpiredNodesToFill(marketIndex: number, ts: number, marketType: MarketType): NodeToFill[];
81
- findJitAuctionNodesToFill(marketIndex: number, slot: number, oraclePriceData: OraclePriceData, marketType: MarketType): NodeToFill[];
83
+ findExpiredNodesToFill(marketIndex: number, ts: number, marketType: MarketType, slot?: BN): NodeToFill[];
82
84
  getTakingBids(marketIndex: number, marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
83
85
  getTakingAsks(marketIndex: number, marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
84
86
  protected getBestNode(generatorList: Array<Generator<DLOBNode>>, oraclePriceData: OraclePriceData, slot: number, compareFcn: (bestDLOBNode: DLOBNode, currentDLOBNode: DLOBNode, slot: number, oraclePriceData: OraclePriceData) => boolean, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
@@ -93,7 +95,7 @@ export declare class DLOB {
93
95
  * @param oraclePriceData
94
96
  * @param filterFcn
95
97
  */
96
- getAsks(marketIndex: number, fallbackAsk: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
98
+ getAsks(marketIndex: number, _fallbackAsk: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
97
99
  /**
98
100
  * This will look at both the taking and resting limit bids
99
101
  * @param marketIndex
@@ -103,7 +105,7 @@ export declare class DLOB {
103
105
  * @param oraclePriceData
104
106
  * @param filterFcn
105
107
  */
106
- getBids(marketIndex: number, fallbackBid: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
108
+ getBids(marketIndex: number, _fallbackBid: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
107
109
  findCrossingRestingLimitOrders(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): NodeToFill[];
108
110
  determineMakerAndTaker(askNode: DLOBNode, bidNode: DLOBNode): {
109
111
  takerNode: DLOBNode;
@@ -6,7 +6,6 @@ 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");
10
9
  const SUPPORTED_ORDER_TYPES = [
11
10
  'market',
12
11
  'limit',
@@ -63,7 +62,7 @@ class DLOB {
63
62
  const userAccount = user.getUserAccount();
64
63
  const userAccountPubkey = user.getUserAccountPublicKey();
65
64
  const userAccountPubkeyString = userAccountPubkey.toString();
66
- const protectedMaker = (0, userStatus_1.isUserProtectedMaker)(userAccount);
65
+ const protectedMaker = (0, __1.isUserProtectedMaker)(userAccount);
67
66
  for (const order of userAccount.orders) {
68
67
  this.insertOrder(order, userAccountPubkeyString, slot, protectedMaker);
69
68
  }
@@ -71,66 +70,6 @@ class DLOB {
71
70
  this.initialized = true;
72
71
  return true;
73
72
  }
74
- initFromOrders(dlobOrders, slot) {
75
- if (this.initialized) {
76
- return false;
77
- }
78
- for (const { user, order } of dlobOrders) {
79
- this.insertOrder(order, user.toString(), slot, false);
80
- }
81
- this.initialized = true;
82
- return true;
83
- }
84
- handleOrderRecord(record, slot) {
85
- this.insertOrder(record.order, record.user.toString(), slot, false);
86
- }
87
- handleOrderActionRecord(record, slot) {
88
- if ((0, __1.isOneOfVariant)(record.action, ['place', 'expire'])) {
89
- return;
90
- }
91
- if ((0, __1.isVariant)(record.action, 'trigger')) {
92
- if (record.taker !== null) {
93
- const takerOrder = this.getOrder(record.takerOrderId, record.taker);
94
- if (takerOrder) {
95
- this.trigger(takerOrder, record.taker, slot, false);
96
- }
97
- }
98
- if (record.maker !== null) {
99
- const makerOrder = this.getOrder(record.makerOrderId, record.maker);
100
- if (makerOrder) {
101
- this.trigger(makerOrder, record.maker, slot, false);
102
- }
103
- }
104
- }
105
- else if ((0, __1.isVariant)(record.action, 'fill')) {
106
- if (record.taker !== null) {
107
- const takerOrder = this.getOrder(record.takerOrderId, record.taker);
108
- if (takerOrder) {
109
- this.updateOrder(takerOrder, record.taker, slot, record.takerOrderCumulativeBaseAssetAmountFilled);
110
- }
111
- }
112
- if (record.maker !== null) {
113
- const makerOrder = this.getOrder(record.makerOrderId, record.maker);
114
- if (makerOrder) {
115
- this.updateOrder(makerOrder, record.maker, slot, record.makerOrderCumulativeBaseAssetAmountFilled);
116
- }
117
- }
118
- }
119
- else if ((0, __1.isVariant)(record.action, 'cancel')) {
120
- if (record.taker !== null) {
121
- const takerOrder = this.getOrder(record.takerOrderId, record.taker);
122
- if (takerOrder) {
123
- this.delete(takerOrder, record.taker, slot);
124
- }
125
- }
126
- if (record.maker !== null) {
127
- const makerOrder = this.getOrder(record.makerOrderId, record.maker);
128
- if (makerOrder) {
129
- this.delete(makerOrder, record.maker, slot);
130
- }
131
- }
132
- }
133
- }
134
73
  insertOrder(order, userAccount, slot, isUserProtectedMaker, onInsert) {
135
74
  var _a;
136
75
  if ((0, __1.isVariant)(order.status, 'init')) {
@@ -148,7 +87,25 @@ class DLOB {
148
87
  .get(marketType)
149
88
  .add((0, NodeList_1.getOrderSignature)(order.orderId, userAccount));
150
89
  }
151
- (_a = this.getListForOrder(order, slot)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount, isUserProtectedMaker);
90
+ (_a = this.getListForOnChainOrder(order, slot)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount, isUserProtectedMaker);
91
+ if (onInsert) {
92
+ onInsert();
93
+ }
94
+ }
95
+ insertSwiftOrder(order, userAccount, isUserProtectedMaker, onInsert) {
96
+ const marketType = (0, __1.getVariant)(order.marketType);
97
+ const marketIndex = order.marketIndex;
98
+ const bidOrAsk = (0, __1.isVariant)(order.direction, 'long') ? 'bid' : 'ask';
99
+ if (!this.orderLists.get(marketType).has(order.marketIndex)) {
100
+ this.addOrderList(marketType, order.marketIndex);
101
+ }
102
+ this.openOrders
103
+ .get(marketType)
104
+ .add((0, NodeList_1.getOrderSignature)(order.orderId, userAccount));
105
+ this.orderLists
106
+ .get(marketType)
107
+ .get(marketIndex)
108
+ .swift[bidOrAsk].insert(order, marketType, userAccount, isUserProtectedMaker);
152
109
  if (onInsert) {
153
110
  onInsert();
154
111
  }
@@ -175,57 +132,13 @@ class DLOB {
175
132
  above: new NodeList_1.NodeList('trigger', 'asc'),
176
133
  below: new NodeList_1.NodeList('trigger', 'desc'),
177
134
  },
135
+ swift: {
136
+ ask: new NodeList_1.NodeList('swift', 'asc'),
137
+ bid: new NodeList_1.NodeList('swift', 'asc'),
138
+ },
178
139
  });
179
140
  }
180
- updateOrder(order, userAccount, slot, cumulativeBaseAssetAmountFilled, onUpdate) {
181
- var _a;
182
- this.updateRestingLimitOrders(slot);
183
- if (order.baseAssetAmount.eq(cumulativeBaseAssetAmountFilled)) {
184
- this.delete(order, userAccount, slot);
185
- return;
186
- }
187
- if (order.baseAssetAmountFilled.eq(cumulativeBaseAssetAmountFilled)) {
188
- return;
189
- }
190
- const newOrder = {
191
- ...order,
192
- };
193
- newOrder.baseAssetAmountFilled = cumulativeBaseAssetAmountFilled;
194
- (_a = this.getListForOrder(order, slot)) === null || _a === void 0 ? void 0 : _a.update(newOrder, userAccount.toString());
195
- if (onUpdate) {
196
- onUpdate();
197
- }
198
- }
199
- trigger(order, userAccount, slot, isUserProtectedMaker, onTrigger) {
200
- var _a;
201
- if ((0, __1.isVariant)(order.status, 'init')) {
202
- return;
203
- }
204
- this.updateRestingLimitOrders(slot);
205
- if ((0, __1.isTriggered)(order)) {
206
- return;
207
- }
208
- const marketType = (0, __1.getVariant)(order.marketType);
209
- const triggerList = this.orderLists.get(marketType).get(order.marketIndex)
210
- .trigger[(0, __1.isVariant)(order.triggerCondition, 'above') ? 'above' : 'below'];
211
- triggerList.remove(order, userAccount.toString());
212
- (_a = this.getListForOrder(order, slot)) === null || _a === void 0 ? void 0 : _a.insert(order, marketType, userAccount.toString(), isUserProtectedMaker);
213
- if (onTrigger) {
214
- onTrigger();
215
- }
216
- }
217
- delete(order, userAccount, slot, onDelete) {
218
- var _a;
219
- if ((0, __1.isVariant)(order.status, 'init')) {
220
- return;
221
- }
222
- this.updateRestingLimitOrders(slot);
223
- (_a = this.getListForOrder(order, slot)) === null || _a === void 0 ? void 0 : _a.remove(order, userAccount.toString());
224
- if (onDelete) {
225
- onDelete();
226
- }
227
- }
228
- getListForOrder(order, slot) {
141
+ getListForOnChainOrder(order, slot) {
229
142
  const isInactiveTriggerOrder = (0, __1.mustBeTriggered)(order) && !(0, __1.isTriggered)(order);
230
143
  let type;
231
144
  if (isInactiveTriggerOrder) {
@@ -309,10 +222,10 @@ class DLOB {
309
222
  ? stateAccount.minPerpAuctionDuration
310
223
  : 0;
311
224
  const { makerRebateNumerator, makerRebateDenominator } = this.getMakerRebate(marketType, stateAccount, marketAccount);
312
- const restingLimitOrderNodesToFill = this.findRestingLimitOrderNodesToFill(marketIndex, slot, marketType, oraclePriceData, isAmmPaused, minAuctionDuration, makerRebateNumerator, makerRebateDenominator, fallbackAsk, fallbackBid);
313
225
  const takingOrderNodesToFill = this.findTakingNodesToFill(marketIndex, slot, marketType, oraclePriceData, isAmmPaused, minAuctionDuration, fallbackAsk, fallbackBid);
226
+ const restingLimitOrderNodesToFill = this.findRestingLimitOrderNodesToFill(marketIndex, slot, marketType, oraclePriceData, isAmmPaused, minAuctionDuration, makerRebateNumerator, makerRebateDenominator, fallbackAsk, fallbackBid);
314
227
  // get expired market nodes
315
- const expiredNodesToFill = this.findExpiredNodesToFill(marketIndex, ts, marketType);
228
+ const expiredNodesToFill = this.findExpiredNodesToFill(marketIndex, ts, marketType, new __1.BN(slot));
316
229
  return this.mergeNodesToFill(restingLimitOrderNodesToFill, takingOrderNodesToFill).concat(expiredNodesToFill);
317
230
  }
318
231
  getMakerRebate(marketType, stateAccount, marketAccount) {
@@ -469,11 +382,11 @@ class DLOB {
469
382
  const newMakerOrder = { ...makerOrder };
470
383
  newMakerOrder.baseAssetAmountFilled =
471
384
  makerOrder.baseAssetAmountFilled.add(baseFilled);
472
- this.getListForOrder(newMakerOrder, slot).update(newMakerOrder, makerNode.userAccount);
385
+ this.getListForOnChainOrder(newMakerOrder, slot).update(newMakerOrder, makerNode.userAccount);
473
386
  const newTakerOrder = { ...takerOrder };
474
387
  newTakerOrder.baseAssetAmountFilled =
475
388
  takerOrder.baseAssetAmountFilled.add(baseFilled);
476
- this.getListForOrder(newTakerOrder, slot).update(newTakerOrder, takerNode.userAccount);
389
+ this.getListForOnChainOrder(newTakerOrder, slot).update(newTakerOrder, takerNode.userAccount);
477
390
  if (newTakerOrder.baseAssetAmountFilled.eq(takerOrder.baseAssetAmount)) {
478
391
  break;
479
392
  }
@@ -507,7 +420,7 @@ class DLOB {
507
420
  }
508
421
  return nodesToFill;
509
422
  }
510
- findExpiredNodesToFill(marketIndex, ts, marketType) {
423
+ findExpiredNodesToFill(marketIndex, ts, marketType, slot) {
511
424
  const nodesToFill = new Array();
512
425
  const marketTypeStr = (0, __1.getVariant)(marketType);
513
426
  const nodeLists = this.orderLists.get(marketTypeStr).get(marketIndex);
@@ -521,16 +434,25 @@ class DLOB {
521
434
  nodeLists.restingLimit.bid.getGenerator(),
522
435
  nodeLists.floatingLimit.bid.getGenerator(),
523
436
  nodeLists.market.bid.getGenerator(),
437
+ nodeLists.swift.bid.getGenerator(),
524
438
  ];
525
439
  const askGenerators = [
526
440
  nodeLists.takingLimit.ask.getGenerator(),
527
441
  nodeLists.restingLimit.ask.getGenerator(),
528
442
  nodeLists.floatingLimit.ask.getGenerator(),
529
443
  nodeLists.market.ask.getGenerator(),
444
+ nodeLists.swift.ask.getGenerator(),
530
445
  ];
531
446
  for (const bidGenerator of bidGenerators) {
532
447
  for (const bid of bidGenerator) {
533
- if ((0, __1.isOrderExpired)(bid.order, ts, true, 25)) {
448
+ if (bid.isSwift &&
449
+ slot.gt(bid.order.slot.addn(bid.order.auctionDuration))) {
450
+ this.orderLists
451
+ .get(marketTypeStr)
452
+ .get(marketIndex)
453
+ .swift.bid.remove(bid.order, bid.userAccount);
454
+ }
455
+ else if ((0, __1.isOrderExpired)(bid.order, ts, true, 25)) {
534
456
  nodesToFill.push({
535
457
  node: bid,
536
458
  makerNodes: [],
@@ -550,23 +472,6 @@ class DLOB {
550
472
  }
551
473
  return nodesToFill;
552
474
  }
553
- findJitAuctionNodesToFill(marketIndex, slot, oraclePriceData, marketType) {
554
- const nodesToFill = new Array();
555
- // Then see if there are orders still in JIT auction
556
- for (const marketBid of this.getTakingBids(marketIndex, marketType, slot, oraclePriceData)) {
557
- nodesToFill.push({
558
- node: marketBid,
559
- makerNodes: [],
560
- });
561
- }
562
- for (const marketAsk of this.getTakingAsks(marketIndex, marketType, slot, oraclePriceData)) {
563
- nodesToFill.push({
564
- node: marketAsk,
565
- makerNodes: [],
566
- });
567
- }
568
- return nodesToFill;
569
- }
570
475
  *getTakingBids(marketIndex, marketType, slot, oraclePriceData, filterFcn) {
571
476
  const marketTypeStr = (0, __1.getVariant)(marketType);
572
477
  const orderLists = this.orderLists.get(marketTypeStr).get(marketIndex);
@@ -577,6 +482,7 @@ class DLOB {
577
482
  const generatorList = [
578
483
  orderLists.market.bid.getGenerator(),
579
484
  orderLists.takingLimit.bid.getGenerator(),
485
+ orderLists.swift.bid.getGenerator(),
580
486
  ];
581
487
  yield* this.getBestNode(generatorList, oraclePriceData, slot, (bestNode, currentNode) => {
582
488
  return bestNode.order.slot.lt(currentNode.order.slot);
@@ -592,6 +498,7 @@ class DLOB {
592
498
  const generatorList = [
593
499
  orderLists.market.ask.getGenerator(),
594
500
  orderLists.takingLimit.ask.getGenerator(),
501
+ orderLists.swift.ask.getGenerator(),
595
502
  ];
596
503
  yield* this.getBestNode(generatorList, oraclePriceData, slot, (bestNode, currentNode) => {
597
504
  return bestNode.order.slot.lt(currentNode.order.slot);
@@ -686,7 +593,7 @@ class DLOB {
686
593
  * @param oraclePriceData
687
594
  * @param filterFcn
688
595
  */
689
- *getAsks(marketIndex, fallbackAsk, slot, marketType, oraclePriceData, filterFcn) {
596
+ *getAsks(marketIndex, _fallbackAsk, slot, marketType, oraclePriceData, filterFcn) {
690
597
  if ((0, __1.isVariant)(marketType, 'spot') && !oraclePriceData) {
691
598
  throw new Error('Must provide OraclePriceData to get spot asks');
692
599
  }
@@ -694,10 +601,6 @@ class DLOB {
694
601
  this.getTakingAsks(marketIndex, marketType, slot, oraclePriceData),
695
602
  this.getRestingLimitAsks(marketIndex, slot, marketType, oraclePriceData),
696
603
  ];
697
- const marketTypeStr = (0, __1.getVariant)(marketType);
698
- if (marketTypeStr === 'perp' && fallbackAsk) {
699
- generatorList.push((0, NodeList_1.getVammNodeGenerator)(fallbackAsk));
700
- }
701
604
  yield* this.getBestNode(generatorList, oraclePriceData, slot, (bestNode, currentNode, slot, oraclePriceData) => {
702
605
  var _a, _b;
703
606
  const bestNodePrice = (_a = bestNode.getPrice(oraclePriceData, slot)) !== null && _a !== void 0 ? _a : __1.ZERO;
@@ -717,7 +620,7 @@ class DLOB {
717
620
  * @param oraclePriceData
718
621
  * @param filterFcn
719
622
  */
720
- *getBids(marketIndex, fallbackBid, slot, marketType, oraclePriceData, filterFcn) {
623
+ *getBids(marketIndex, _fallbackBid, slot, marketType, oraclePriceData, filterFcn) {
721
624
  if ((0, __1.isVariant)(marketType, 'spot') && !oraclePriceData) {
722
625
  throw new Error('Must provide OraclePriceData to get spot bids');
723
626
  }
@@ -725,10 +628,6 @@ class DLOB {
725
628
  this.getTakingBids(marketIndex, marketType, slot, oraclePriceData),
726
629
  this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData),
727
630
  ];
728
- const marketTypeStr = (0, __1.getVariant)(marketType);
729
- if (marketTypeStr === 'perp' && fallbackBid) {
730
- generatorList.push((0, NodeList_1.getVammNodeGenerator)(fallbackBid));
731
- }
732
631
  yield* this.getBestNode(generatorList, oraclePriceData, slot, (bestNode, currentNode, slot, oraclePriceData) => {
733
632
  var _a, _b;
734
633
  const bestNodePrice = (_a = bestNode.getPrice(oraclePriceData, slot)) !== null && _a !== void 0 ? _a : __1.BN_MAX;
@@ -769,12 +668,12 @@ class DLOB {
769
668
  const newBidOrder = { ...bidOrder };
770
669
  newBidOrder.baseAssetAmountFilled =
771
670
  bidOrder.baseAssetAmountFilled.add(baseFilled);
772
- this.getListForOrder(newBidOrder, slot).update(newBidOrder, bidNode.userAccount);
671
+ this.getListForOnChainOrder(newBidOrder, slot).update(newBidOrder, bidNode.userAccount);
773
672
  // ask completely filled
774
673
  const newAskOrder = { ...askOrder };
775
674
  newAskOrder.baseAssetAmountFilled =
776
675
  askOrder.baseAssetAmountFilled.add(baseFilled);
777
- this.getListForOrder(newAskOrder, slot).update(newAskOrder, askNode.userAccount);
676
+ this.getListForOnChainOrder(newAskOrder, slot).update(newAskOrder, askNode.userAccount);
778
677
  nodesToFill.push({
779
678
  node: takerNode,
780
679
  makerNodes: [makerNode],