@drift-labs/sdk 2.13.0 → 2.14.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/lib/accounts/bulkAccountLoader.d.ts +1 -0
  2. package/lib/accounts/bulkAccountLoader.js +3 -3
  3. package/lib/accounts/fetch.js +2 -2
  4. package/lib/accounts/pollingDriftClientAccountSubscriber.js +7 -7
  5. package/lib/accounts/pollingTokenAccountSubscriber.js +2 -2
  6. package/lib/accounts/pollingUserAccountSubscriber.js +2 -2
  7. package/lib/accounts/pollingUserStatsAccountSubscriber.js +2 -2
  8. package/lib/accounts/types.d.ts +1 -0
  9. package/lib/accounts/webSocketAccountSubscriber.js +1 -1
  10. package/lib/accounts/webSocketDriftClientAccountSubscriber.js +3 -3
  11. package/lib/addresses/marketAddresses.js +1 -1
  12. package/lib/addresses/pda.js +5 -1
  13. package/lib/adminClient.js +61 -57
  14. package/lib/dlob/DLOB.js +67 -67
  15. package/lib/dlob/DLOBNode.js +7 -7
  16. package/lib/dlob/NodeList.js +2 -2
  17. package/lib/driftClient.d.ts +33 -33
  18. package/lib/driftClient.js +120 -116
  19. package/lib/events/eventSubscriber.js +2 -2
  20. package/lib/events/pollingLogProvider.js +1 -1
  21. package/lib/events/types.d.ts +1 -0
  22. package/lib/examples/loadDlob.js +2 -2
  23. package/lib/examples/makeTradeExample.js +9 -9
  24. package/lib/factory/bigNum.js +9 -9
  25. package/lib/factory/oracleClient.js +2 -2
  26. package/lib/idl/drift.json +1 -1
  27. package/lib/index.js +5 -1
  28. package/lib/math/amm.js +23 -23
  29. package/lib/math/auction.js +6 -6
  30. package/lib/math/exchangeStatus.js +2 -2
  31. package/lib/math/funding.d.ts +1 -1
  32. package/lib/math/funding.js +8 -8
  33. package/lib/math/margin.js +5 -5
  34. package/lib/math/market.js +13 -13
  35. package/lib/math/oracles.js +1 -1
  36. package/lib/math/orders.js +23 -23
  37. package/lib/math/position.js +5 -5
  38. package/lib/math/repeg.js +1 -1
  39. package/lib/math/spotBalance.js +9 -9
  40. package/lib/math/spotPosition.js +3 -3
  41. package/lib/math/trade.js +42 -42
  42. package/lib/oracles/oracleClientCache.js +1 -1
  43. package/lib/oracles/pythClient.js +1 -1
  44. package/lib/token/index.js +1 -1
  45. package/lib/tokenFaucet.js +5 -1
  46. package/lib/tx/retryTxSender.js +1 -1
  47. package/lib/user.d.ts +8 -9
  48. package/lib/user.js +153 -158
  49. package/lib/userMap/userMap.js +1 -1
  50. package/lib/userMap/userStatsMap.js +3 -3
  51. package/lib/userStats.js +2 -2
  52. package/package.json +3 -3
  53. package/src/driftClient.ts +209 -68
  54. package/src/events/types.ts +15 -0
  55. package/src/idl/drift.json +1 -1
  56. package/src/math/funding.ts +7 -8
  57. package/src/math/spotBalance.ts +14 -7
  58. package/src/token/index.ts +1 -1
  59. package/src/user.ts +187 -184
  60. package/src/assert/assert.js +0 -9
  61. package/src/token/index.js +0 -38
  62. package/src/tx/types.js +0 -2
  63. package/src/tx/utils.js +0 -17
  64. package/src/util/computeUnits.js +0 -27
  65. package/src/util/getTokenAddress.js +0 -9
  66. package/src/util/promiseTimeout.js +0 -14
  67. package/src/util/tps.js +0 -27
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promiseTimeout = void 0;
4
- function promiseTimeout(promise, timeoutMs) {
5
- let timeoutId;
6
- const timeoutPromise = new Promise((resolve) => {
7
- timeoutId = setTimeout(() => resolve(null), timeoutMs);
8
- });
9
- return Promise.race([promise, timeoutPromise]).then((result) => {
10
- clearTimeout(timeoutId);
11
- return result;
12
- });
13
- }
14
- exports.promiseTimeout = promiseTimeout;
package/src/util/tps.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.estimateTps = void 0;
13
- function estimateTps(programId, connection, failed) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- let signatures = yield connection.getSignaturesForAddress(programId, undefined, 'finalized');
16
- if (failed) {
17
- signatures = signatures.filter((signature) => signature.err);
18
- }
19
- const numberOfSignatures = signatures.length;
20
- if (numberOfSignatures === 0) {
21
- return 0;
22
- }
23
- return (numberOfSignatures /
24
- (signatures[0].blockTime - signatures[numberOfSignatures - 1].blockTime));
25
- });
26
- }
27
- exports.estimateTps = estimateTps;