@suilend/sdk 1.1.85 → 1.1.87

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 (43) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -11
  2. package/_generated/_dependencies/source/0x1/option/structs.d.ts +4 -6
  3. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +6 -10
  4. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +8 -15
  5. package/_generated/_dependencies/source/0x2/balance/structs.d.ts +6 -10
  6. package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -14
  7. package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +8 -15
  8. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +4 -7
  9. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +12 -23
  10. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +30 -58
  11. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -6
  12. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +75 -146
  13. package/_generated/_framework/util.d.ts +4 -16
  14. package/_generated/_framework/vector.d.ts +12 -5
  15. package/_generated/suilend/cell/structs.d.ts +6 -10
  16. package/_generated/suilend/decimal/structs.d.ts +3 -5
  17. package/_generated/suilend/lending-market/structs.d.ts +392 -368
  18. package/_generated/suilend/liquidity-mining/structs.d.ts +160 -134
  19. package/_generated/suilend/obligation/structs.d.ts +217 -332
  20. package/_generated/suilend/rate-limiter/structs.d.ts +17 -32
  21. package/_generated/suilend/reserve/structs.d.ts +393 -383
  22. package/_generated/suilend/reserve-config/structs.d.ts +40 -76
  23. package/client.d.ts +1 -1
  24. package/client.js +15 -7
  25. package/lib/initialize.d.ts +1 -2
  26. package/lib/initialize.js +67 -54
  27. package/lib/liquidityMining.d.ts +2 -2
  28. package/lib/liquidityMining.js +3 -3
  29. package/lib/strategyOwnerCap.js +24 -16
  30. package/lib/types.d.ts +0 -1
  31. package/mmt.d.ts +2 -0
  32. package/mmt.js +5 -0
  33. package/package.json +1 -1
  34. package/parsers/lendingMarket.d.ts +0 -1
  35. package/parsers/lendingMarket.js +2 -3
  36. package/strategies.d.ts +86 -1
  37. package/strategies.js +1788 -1
  38. package/swap/quote.js +0 -35
  39. package/swap/transaction.js +0 -35
  40. package/utils/index.d.ts +10 -0
  41. package/utils/index.js +34 -1
  42. package/utils/obligation.d.ts +2 -0
  43. package/utils/obligation.js +8 -0
package/swap/quote.js CHANGED
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -48,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
48
15
  exports.getAggSortedQuotesAll = exports.getAggQuotes = exports.QUOTE_PROVIDER_NAME_MAP = exports.QuoteProvider = void 0;
49
16
  const cjs_1 = require("@7kprotocol/sdk-ts/cjs");
50
17
  const utils_1 = require("@mysten/sui/utils");
51
- const Sentry = __importStar(require("@sentry/nextjs"));
52
18
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
53
19
  const bn_js_1 = __importDefault(require("bn.js"));
54
20
  const uuid_1 = require("uuid");
@@ -88,7 +54,6 @@ const getAggQuoteWrapper = (provider, getAggQuote, timeoutMs) => __awaiter(void
88
54
  return standardizedQuote;
89
55
  }
90
56
  catch (err) {
91
- Sentry.captureException(err, { provider });
92
57
  console.error(err);
93
58
  return null;
94
59
  }
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -45,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
45
12
  exports.getSwapTransaction = void 0;
46
13
  const cjs_1 = require("@7kprotocol/sdk-ts/cjs");
47
14
  const sdk_1 = require("@flowx-finance/sdk");
48
- const Sentry = __importStar(require("@sentry/nextjs"));
49
15
  const sui_fe_1 = require("@suilend/sui-fe");
50
16
  const quote_1 = require("./quote");
51
17
  const getSwapTransactionWrapper = (provider, getSwapTransaction) => __awaiter(void 0, void 0, void 0, function* () {
@@ -56,7 +22,6 @@ const getSwapTransactionWrapper = (provider, getSwapTransaction) => __awaiter(vo
56
22
  return res;
57
23
  }
58
24
  catch (err) {
59
- Sentry.captureException(err, { provider });
60
25
  console.error(err);
61
26
  throw err;
62
27
  }
package/utils/index.d.ts CHANGED
@@ -6,3 +6,13 @@ export * from "./simulate";
6
6
  export declare const toHexString: (bytes: number[]) => string;
7
7
  export declare const reserveSort: (reserves: ParsedReserve[], aCoinType: string, bCoinType: string) => number;
8
8
  export declare const linearlyInterpolate: (array: any[], xKey: string, yKey: string, _xValue: number | BigNumber) => BigNumber;
9
+ /**
10
+ * Bisection method to find the optimal value that satisfies a condition
11
+ * @param left - Left boundary of the search range
12
+ * @param right - Right boundary of the search range
13
+ * @param condition - Function that takes a value and returns true if the condition is satisfied
14
+ * @param maxIterations - Maximum number of iterations (default: 50)
15
+ * @param tolerance - Convergence tolerance (default: 0.000001)
16
+ * @returns The optimal value that satisfies the condition
17
+ */
18
+ export declare const bisectionMethod: (left: BigNumber, right: BigNumber, condition: (value: BigNumber) => boolean, maxIterations?: number, tolerance?: BigNumber) => BigNumber;
package/utils/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.linearlyInterpolate = exports.reserveSort = exports.toHexString = void 0;
20
+ exports.bisectionMethod = exports.linearlyInterpolate = exports.reserveSort = exports.toHexString = void 0;
21
21
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
22
22
  __exportStar(require("./events"), exports);
23
23
  __exportStar(require("./obligation"), exports);
@@ -55,3 +55,36 @@ const linearlyInterpolate = (array, xKey, yKey, _xValue) => {
55
55
  return new bignumber_js_1.default(0);
56
56
  };
57
57
  exports.linearlyInterpolate = linearlyInterpolate;
58
+ /**
59
+ * Bisection method to find the optimal value that satisfies a condition
60
+ * @param left - Left boundary of the search range
61
+ * @param right - Right boundary of the search range
62
+ * @param condition - Function that takes a value and returns true if the condition is satisfied
63
+ * @param maxIterations - Maximum number of iterations (default: 50)
64
+ * @param tolerance - Convergence tolerance (default: 0.000001)
65
+ * @returns The optimal value that satisfies the condition
66
+ */
67
+ const bisectionMethod = (left, right, condition, maxIterations = 50, tolerance = new bignumber_js_1.default(0.000001)) => {
68
+ let currentLeft = left;
69
+ let currentRight = right;
70
+ let bestValue = new bignumber_js_1.default(0);
71
+ for (let i = 0; i < maxIterations; i++) {
72
+ const mid = currentLeft.plus(currentRight).div(2);
73
+ if (mid.eq(currentLeft) && mid.eq(currentRight)) {
74
+ break;
75
+ }
76
+ if (condition(mid)) {
77
+ bestValue = mid;
78
+ currentRight = mid;
79
+ }
80
+ else {
81
+ currentLeft = mid;
82
+ }
83
+ // Check if we've converged
84
+ if (currentRight.minus(currentLeft).lte(tolerance)) {
85
+ break;
86
+ }
87
+ }
88
+ return bestValue;
89
+ };
90
+ exports.bisectionMethod = bisectionMethod;
@@ -1,5 +1,6 @@
1
1
  import { SuiClient } from "@mysten/sui/client";
2
2
  import { Obligation } from "../_generated/suilend/obligation/structs";
3
+ import { ParsedObligation } from "../parsers";
3
4
  export declare function fetchAllObligationsForMarketWithHandler(client: SuiClient, lendingMarketId: string, lendingMarketType: string, chunkHandler: (obligations: Obligation<string>[]) => Promise<void>): Promise<void>;
4
5
  export declare function fetchAllObligationsForMarket(client: SuiClient, lendingMarketId: string, lendingMarketType: string): Promise<Obligation<string>[]>;
5
6
  export type FormattedObligationHistory = NonLiquidationHistoryEvent | LiquidationHistoryEvent;
@@ -23,3 +24,4 @@ export declare function getObligationHistoryPage(client: SuiClient, obligationId
23
24
  cursor: string | null | undefined;
24
25
  history: FormattedObligationHistory[];
25
26
  }>;
27
+ export declare const getWeightedBorrowsUsd: (obligation: ParsedObligation) => BigNumber;
@@ -45,10 +45,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
45
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.getWeightedBorrowsUsd = void 0;
48
49
  exports.fetchAllObligationsForMarketWithHandler = fetchAllObligationsForMarketWithHandler;
49
50
  exports.fetchAllObligationsForMarket = fetchAllObligationsForMarket;
50
51
  exports.getObligationHistoryPage = getObligationHistoryPage;
51
52
  const utils_1 = require("@mysten/sui/utils");
53
+ const bignumber_js_1 = require("bignumber.js");
52
54
  const p_limit_1 = __importDefault(require("p-limit"));
53
55
  const reified_1 = require("../_generated/_framework/reified");
54
56
  const suilend_1 = require("../_generated/suilend");
@@ -305,3 +307,9 @@ function formatEventsToHistory(obligationId, data, events) {
305
307
  }
306
308
  return formattedEvents;
307
309
  }
310
+ const getWeightedBorrowsUsd = (obligation) => {
311
+ return obligation.maxPriceWeightedBorrowsUsd.gt(obligation.minPriceBorrowLimitUsd)
312
+ ? bignumber_js_1.BigNumber.max(obligation.weightedBorrowsUsd, obligation.minPriceBorrowLimitUsd)
313
+ : obligation.maxPriceWeightedBorrowsUsd;
314
+ };
315
+ exports.getWeightedBorrowsUsd = getWeightedBorrowsUsd;