@gearbox-protocol/sdk 14.5.9 → 14.6.0-next.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 (100) hide show
  1. package/dist/cjs/abi/kyc/iDSToken.js +1907 -20
  2. package/dist/cjs/common-utils/utils/apy/bonus-apy-from-points.js +28 -0
  3. package/dist/cjs/common-utils/utils/apy/calculate-effective-borrow-rate.js +35 -0
  4. package/dist/cjs/common-utils/utils/apy/get-complex-apy-list.js +45 -0
  5. package/dist/cjs/common-utils/utils/apy/get-rate-with-fee.js +31 -0
  6. package/dist/cjs/common-utils/utils/apy/get-single-quota-borrow-rate.js +33 -0
  7. package/dist/cjs/common-utils/utils/apy/index.js +32 -0
  8. package/dist/cjs/common-utils/utils/apy/max-apy-formula.js +40 -0
  9. package/dist/cjs/common-utils/utils/index.js +5 -1
  10. package/dist/cjs/common-utils/utils/strategies/__test-utils.js +95 -0
  11. package/dist/cjs/common-utils/utils/strategies/availability/check-boolean.js +33 -0
  12. package/dist/cjs/common-utils/utils/strategies/availability/check-degen-nft.js +35 -0
  13. package/dist/cjs/common-utils/utils/strategies/availability/index.js +28 -0
  14. package/dist/cjs/common-utils/utils/strategies/availability/validate-open-account-pool-quota-status.js +40 -0
  15. package/dist/cjs/common-utils/utils/strategies/availability/validate-open-account-pool-status.js +76 -0
  16. package/dist/cjs/common-utils/utils/strategies/index.js +28 -0
  17. package/dist/cjs/common-utils/utils/strategies/leverage/calculate-loss-coefficient.js +31 -0
  18. package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +45 -0
  19. package/dist/cjs/common-utils/utils/strategies/leverage/get-factor-from-leverage.js +31 -0
  20. package/dist/cjs/common-utils/utils/strategies/leverage/get-leverage-from-factor.js +31 -0
  21. package/dist/cjs/common-utils/utils/strategies/leverage/index.js +32 -0
  22. package/dist/cjs/common-utils/utils/strategies/leverage/max-leverage-threshold.js +42 -0
  23. package/dist/cjs/common-utils/utils/strategies/leverage/max-leverage.js +35 -0
  24. package/dist/cjs/common-utils/utils/strategies/sort-strategy-cms-by-availability/index.js +22 -0
  25. package/dist/cjs/common-utils/utils/strategies/sort-strategy-cms-by-availability/sort-strategy-cms-by-availability.js +64 -0
  26. package/dist/cjs/common-utils/utils/strategies/strategy-info/cm-availability-condition.js +63 -0
  27. package/dist/cjs/common-utils/utils/strategies/strategy-info/get-strategy-info.js +98 -0
  28. package/dist/cjs/common-utils/utils/strategies/strategy-info/get-strategy-max-apy.js +102 -0
  29. package/dist/cjs/common-utils/utils/strategies/strategy-info/index.js +30 -0
  30. package/dist/cjs/common-utils/utils/strategies/strategy-info/is-strategy-cm-disabled.js +33 -0
  31. package/dist/cjs/common-utils/utils/strategies/strategy-info/types.js +16 -0
  32. package/dist/cjs/plugins/adapters/abi/securitize/iBaseOnRamp.js +351 -0
  33. package/dist/cjs/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +2 -1
  34. package/dist/esm/abi/kyc/iDSToken.js +1907 -20
  35. package/dist/esm/common-utils/utils/apy/bonus-apy-from-points.js +4 -0
  36. package/dist/esm/common-utils/utils/apy/calculate-effective-borrow-rate.js +11 -0
  37. package/dist/esm/common-utils/utils/apy/get-complex-apy-list.js +21 -0
  38. package/dist/esm/common-utils/utils/apy/get-rate-with-fee.js +7 -0
  39. package/dist/esm/common-utils/utils/apy/get-single-quota-borrow-rate.js +9 -0
  40. package/dist/esm/common-utils/utils/apy/index.js +6 -0
  41. package/dist/esm/common-utils/utils/apy/max-apy-formula.js +16 -0
  42. package/dist/esm/common-utils/utils/index.js +2 -0
  43. package/dist/esm/common-utils/utils/strategies/__test-utils.js +65 -0
  44. package/dist/esm/common-utils/utils/strategies/availability/check-boolean.js +9 -0
  45. package/dist/esm/common-utils/utils/strategies/availability/check-degen-nft.js +11 -0
  46. package/dist/esm/common-utils/utils/strategies/availability/index.js +4 -0
  47. package/dist/esm/common-utils/utils/strategies/availability/validate-open-account-pool-quota-status.js +16 -0
  48. package/dist/esm/common-utils/utils/strategies/availability/validate-open-account-pool-status.js +52 -0
  49. package/dist/esm/common-utils/utils/strategies/index.js +4 -0
  50. package/dist/esm/common-utils/utils/strategies/leverage/calculate-loss-coefficient.js +7 -0
  51. package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +21 -0
  52. package/dist/esm/common-utils/utils/strategies/leverage/get-factor-from-leverage.js +7 -0
  53. package/dist/esm/common-utils/utils/strategies/leverage/get-leverage-from-factor.js +7 -0
  54. package/dist/esm/common-utils/utils/strategies/leverage/index.js +6 -0
  55. package/dist/esm/common-utils/utils/strategies/leverage/max-leverage-threshold.js +18 -0
  56. package/dist/esm/common-utils/utils/strategies/leverage/max-leverage.js +11 -0
  57. package/dist/esm/common-utils/utils/strategies/sort-strategy-cms-by-availability/index.js +1 -0
  58. package/dist/esm/common-utils/utils/strategies/sort-strategy-cms-by-availability/sort-strategy-cms-by-availability.js +43 -0
  59. package/dist/esm/common-utils/utils/strategies/strategy-info/cm-availability-condition.js +43 -0
  60. package/dist/esm/common-utils/utils/strategies/strategy-info/get-strategy-info.js +74 -0
  61. package/dist/esm/common-utils/utils/strategies/strategy-info/get-strategy-max-apy.js +85 -0
  62. package/dist/esm/common-utils/utils/strategies/strategy-info/index.js +5 -0
  63. package/dist/esm/common-utils/utils/strategies/strategy-info/is-strategy-cm-disabled.js +9 -0
  64. package/dist/esm/common-utils/utils/strategies/strategy-info/types.js +0 -0
  65. package/dist/esm/plugins/adapters/abi/securitize/iBaseOnRamp.js +327 -0
  66. package/dist/esm/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +2 -1
  67. package/dist/types/abi/kyc/iDSToken.d.ts +1446 -13
  68. package/dist/types/common-utils/utils/apy/bonus-apy-from-points.d.ts +4 -0
  69. package/dist/types/common-utils/utils/apy/calculate-effective-borrow-rate.d.ts +6 -0
  70. package/dist/types/common-utils/utils/apy/get-complex-apy-list.d.ts +5 -0
  71. package/dist/types/common-utils/utils/apy/get-rate-with-fee.d.ts +7 -0
  72. package/dist/types/common-utils/utils/apy/get-single-quota-borrow-rate.d.ts +9 -0
  73. package/dist/types/common-utils/utils/apy/index.d.ts +6 -0
  74. package/dist/types/common-utils/utils/apy/max-apy-formula.d.ts +6 -0
  75. package/dist/types/common-utils/utils/index.d.ts +2 -0
  76. package/dist/types/common-utils/utils/strategies/__test-utils.d.ts +11 -0
  77. package/dist/types/common-utils/utils/strategies/availability/check-boolean.d.ts +1 -0
  78. package/dist/types/common-utils/utils/strategies/availability/check-degen-nft.d.ts +5 -0
  79. package/dist/types/common-utils/utils/strategies/availability/index.d.ts +4 -0
  80. package/dist/types/common-utils/utils/strategies/availability/validate-open-account-pool-quota-status.d.ts +6 -0
  81. package/dist/types/common-utils/utils/strategies/availability/validate-open-account-pool-status.d.ts +24 -0
  82. package/dist/types/common-utils/utils/strategies/index.d.ts +4 -0
  83. package/dist/types/common-utils/utils/strategies/leverage/calculate-loss-coefficient.d.ts +1 -0
  84. package/dist/types/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.d.ts +12 -0
  85. package/dist/types/common-utils/utils/strategies/leverage/get-factor-from-leverage.d.ts +4 -0
  86. package/dist/types/common-utils/utils/strategies/leverage/get-leverage-from-factor.d.ts +2 -0
  87. package/dist/types/common-utils/utils/strategies/leverage/index.d.ts +6 -0
  88. package/dist/types/common-utils/utils/strategies/leverage/max-leverage-threshold.d.ts +5 -0
  89. package/dist/types/common-utils/utils/strategies/leverage/max-leverage.d.ts +9 -0
  90. package/dist/types/common-utils/utils/strategies/sort-strategy-cms-by-availability/index.d.ts +1 -0
  91. package/dist/types/common-utils/utils/strategies/sort-strategy-cms-by-availability/sort-strategy-cms-by-availability.d.ts +13 -0
  92. package/dist/types/common-utils/utils/strategies/strategy-info/cm-availability-condition.d.ts +3 -0
  93. package/dist/types/common-utils/utils/strategies/strategy-info/get-strategy-info.d.ts +2 -0
  94. package/dist/types/common-utils/utils/strategies/strategy-info/get-strategy-max-apy.d.ts +13 -0
  95. package/dist/types/common-utils/utils/strategies/strategy-info/index.d.ts +5 -0
  96. package/dist/types/common-utils/utils/strategies/strategy-info/is-strategy-cm-disabled.d.ts +2 -0
  97. package/dist/types/common-utils/utils/strategies/strategy-info/types.d.ts +80 -0
  98. package/dist/types/plugins/adapters/abi/securitize/iBaseOnRamp.d.ts +255 -0
  99. package/dist/types/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.d.ts +254 -0
  100. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var bonus_apy_from_points_exports = {};
20
+ __export(bonus_apy_from_points_exports, {
21
+ BONUS_APY_FROM_POINTS: () => BONUS_APY_FROM_POINTS
22
+ });
23
+ module.exports = __toCommonJS(bonus_apy_from_points_exports);
24
+ const BONUS_APY_FROM_POINTS = {};
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ BONUS_APY_FROM_POINTS
28
+ });
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var calculate_effective_borrow_rate_exports = {};
20
+ __export(calculate_effective_borrow_rate_exports, {
21
+ calculateEffectiveBorrowRate: () => calculateEffectiveBorrowRate
22
+ });
23
+ module.exports = __toCommonJS(calculate_effective_borrow_rate_exports);
24
+ function calculateEffectiveBorrowRate({
25
+ underlyingTokenAddress,
26
+ baseRateWithFee = 0,
27
+ apyList
28
+ }) {
29
+ const apy = underlyingTokenAddress ? apyList?.[underlyingTokenAddress] || 0 : 0;
30
+ return apy > 0 ? baseRateWithFee + apy : baseRateWithFee;
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ calculateEffectiveBorrowRate
35
+ });
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var get_complex_apy_list_exports = {};
20
+ __export(get_complex_apy_list_exports, {
21
+ getComplexAPYList: () => getComplexAPYList
22
+ });
23
+ module.exports = __toCommonJS(get_complex_apy_list_exports);
24
+ var import_sdk = require("../../../sdk/index.js");
25
+ function getComplexAPYList(baseAPYList, extraCollateralAPYList, pool) {
26
+ if (!pool) return baseAPYList;
27
+ const poolExtraCollateralAPY = extraCollateralAPYList?.[pool];
28
+ if (!poolExtraCollateralAPY) return baseAPYList;
29
+ const baseCopy = { ...baseAPYList };
30
+ import_sdk.TypedObjectUtils.entries(poolExtraCollateralAPY).forEach(
31
+ ([token, extraAPY]) => {
32
+ const baseAPY = baseCopy[token];
33
+ if (extraAPY.type === "relative" && baseAPY !== void 0) {
34
+ baseCopy[token] = baseAPY + extraAPY.value;
35
+ } else if (extraAPY.type === "absolute") {
36
+ baseCopy[token] = extraAPY.value;
37
+ }
38
+ }
39
+ );
40
+ return baseCopy;
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ getComplexAPYList
45
+ });
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var get_rate_with_fee_exports = {};
20
+ __export(get_rate_with_fee_exports, {
21
+ getRateWithFee: () => getRateWithFee
22
+ });
23
+ module.exports = __toCommonJS(get_rate_with_fee_exports);
24
+ var import_sdk = require("../../../sdk/index.js");
25
+ function getRateWithFee(rate, feeInterest) {
26
+ return (0, import_sdk.toBigInt)(rate) * (BigInt(feeInterest) + import_sdk.PERCENTAGE_FACTOR) / import_sdk.PERCENTAGE_FACTOR;
27
+ }
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ getRateWithFee
31
+ });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var get_single_quota_borrow_rate_exports = {};
20
+ __export(get_single_quota_borrow_rate_exports, {
21
+ getSingleQuotaBorrowRate: () => getSingleQuotaBorrowRate
22
+ });
23
+ module.exports = __toCommonJS(get_single_quota_borrow_rate_exports);
24
+ var import_calc_quota_borrow_rate = require("../creditAccount/calc-quota-borrow-rate.js");
25
+ var import_get_rate_with_fee = require("./get-rate-with-fee.js");
26
+ function getSingleQuotaBorrowRate(props) {
27
+ const qr = (0, import_calc_quota_borrow_rate.calcQuotaBorrowRate)(props);
28
+ return (0, import_get_rate_with_fee.getRateWithFee)(qr, props.feeInterest);
29
+ }
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ getSingleQuotaBorrowRate
33
+ });
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var apy_exports = {};
17
+ module.exports = __toCommonJS(apy_exports);
18
+ __reExport(apy_exports, require("./bonus-apy-from-points.js"), module.exports);
19
+ __reExport(apy_exports, require("./calculate-effective-borrow-rate.js"), module.exports);
20
+ __reExport(apy_exports, require("./get-complex-apy-list.js"), module.exports);
21
+ __reExport(apy_exports, require("./get-rate-with-fee.js"), module.exports);
22
+ __reExport(apy_exports, require("./get-single-quota-borrow-rate.js"), module.exports);
23
+ __reExport(apy_exports, require("./max-apy-formula.js"), module.exports);
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ ...require("./bonus-apy-from-points.js"),
27
+ ...require("./calculate-effective-borrow-rate.js"),
28
+ ...require("./get-complex-apy-list.js"),
29
+ ...require("./get-rate-with-fee.js"),
30
+ ...require("./get-single-quota-borrow-rate.js"),
31
+ ...require("./max-apy-formula.js")
32
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var max_apy_formula_exports = {};
20
+ __export(max_apy_formula_exports, {
21
+ maxAPYFormula: () => maxAPYFormula
22
+ });
23
+ module.exports = __toCommonJS(max_apy_formula_exports);
24
+ var import_sdk = require("../../../sdk/index.js");
25
+ var import_leverage = require("../strategies/leverage/index.js");
26
+ function maxAPYFormula({
27
+ apy,
28
+ leverage,
29
+ baseRateWithFee,
30
+ quotaRateWithFee
31
+ }) {
32
+ const collateralTerm = apy - quotaRateWithFee;
33
+ const leverageFactor = (0, import_leverage.getFactorFromLeverage)(leverage);
34
+ const debtTerm = (apy - baseRateWithFee - quotaRateWithFee) * Number(leverageFactor) / Number(import_sdk.LEVERAGE_DECIMALS);
35
+ return collateralTerm + Math.floor(debtTerm);
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ maxAPYFormula
40
+ });
@@ -15,14 +15,18 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
16
  var utils_exports = {};
17
17
  module.exports = __toCommonJS(utils_exports);
18
+ __reExport(utils_exports, require("./apy/index.js"), module.exports);
18
19
  __reExport(utils_exports, require("./assets-math.js"), module.exports);
19
20
  __reExport(utils_exports, require("./bigint-math.js"), module.exports);
20
21
  __reExport(utils_exports, require("./creditAccount/index.js"), module.exports);
21
22
  __reExport(utils_exports, require("./price-math.js"), module.exports);
23
+ __reExport(utils_exports, require("./strategies/index.js"), module.exports);
22
24
  // Annotate the CommonJS export names for ESM import in node:
23
25
  0 && (module.exports = {
26
+ ...require("./apy/index.js"),
24
27
  ...require("./assets-math.js"),
25
28
  ...require("./bigint-math.js"),
26
29
  ...require("./creditAccount/index.js"),
27
- ...require("./price-math.js")
30
+ ...require("./price-math.js"),
31
+ ...require("./strategies/index.js")
28
32
  });
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var test_utils_exports = {};
20
+ __export(test_utils_exports, {
21
+ buildCreditManager: () => buildCreditManager,
22
+ buildPool: () => buildPool,
23
+ buildQuota: () => buildQuota,
24
+ mockToken1: () => mockToken1,
25
+ mockToken2: () => mockToken2,
26
+ mockTokenData: () => mockTokenData,
27
+ mockUnderlyingToken: () => mockUnderlyingToken
28
+ });
29
+ module.exports = __toCommonJS(test_utils_exports);
30
+ const mockToken1 = "0x1111111111111111111111111111111111111111";
31
+ const mockToken2 = "0x2222222222222222222222222222222222222222";
32
+ const mockUnderlyingToken = "0x9999999999999999999999999999999999999999";
33
+ const mockTokenData = {
34
+ [mockToken1]: { address: mockToken1, decimals: 18, title: "T1" },
35
+ [mockToken2]: { address: mockToken2, decimals: 18, title: "T2" },
36
+ [mockUnderlyingToken]: {
37
+ address: mockUnderlyingToken,
38
+ decimals: 18,
39
+ title: "UNDER"
40
+ }
41
+ };
42
+ function buildQuota(overrides) {
43
+ return {
44
+ rate: 0n,
45
+ quotaIncreaseFee: 0n,
46
+ totalQuoted: 0n,
47
+ limit: 0n,
48
+ isActive: true,
49
+ ...overrides
50
+ };
51
+ }
52
+ function buildPool(overrides = {}) {
53
+ const address = overrides.address ?? "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
54
+ return {
55
+ address,
56
+ totalDebtLimit: 0n,
57
+ totalBorrowed: 0n,
58
+ ...overrides
59
+ };
60
+ }
61
+ function buildCreditManager(overrides = {}) {
62
+ const address = overrides.address ?? "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
63
+ const pool = overrides.pool ?? "0xcccccccccccccccccccccccccccccccccccccccc";
64
+ const underlyingToken = overrides.underlyingToken ?? mockUnderlyingToken;
65
+ const quotas = overrides.quotas ?? {};
66
+ return {
67
+ address,
68
+ underlyingToken,
69
+ pool,
70
+ chainId: 1,
71
+ baseBorrowRate: 0,
72
+ feeInterest: 0,
73
+ availableToBorrow: 0n,
74
+ minDebt: 0n,
75
+ maxDebt: 0n,
76
+ totalDebt: 0n,
77
+ totalDebtLimit: 0n,
78
+ isDegenMode: false,
79
+ degenNFT: "0x0000000000000000000000000000000000000000",
80
+ liquidationThresholds: {},
81
+ quotas,
82
+ collateralTokens: [],
83
+ ...overrides
84
+ };
85
+ }
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ buildCreditManager,
89
+ buildPool,
90
+ buildQuota,
91
+ mockToken1,
92
+ mockToken2,
93
+ mockTokenData,
94
+ mockUnderlyingToken
95
+ });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var check_boolean_exports = {};
20
+ __export(check_boolean_exports, {
21
+ checkBoolean: () => checkBoolean
22
+ });
23
+ module.exports = __toCommonJS(check_boolean_exports);
24
+ function checkBoolean(a, b) {
25
+ if (a && b) return 0;
26
+ if (a) return -1;
27
+ if (b) return 1;
28
+ return 0;
29
+ }
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ checkBoolean
33
+ });
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var check_degen_nft_exports = {};
20
+ __export(check_degen_nft_exports, {
21
+ checkDegenNFT: () => checkDegenNFT
22
+ });
23
+ module.exports = __toCommonJS(check_degen_nft_exports);
24
+ var import_sdk = require("../../../../sdk/index.js");
25
+ function checkDegenNFT(creditManager) {
26
+ const nftAddress = creditManager.isDegenMode ? creditManager.degenNFT : import_sdk.ADDRESS_0X0;
27
+ return {
28
+ nftAddress,
29
+ freeOfNFT: nftAddress === import_sdk.ADDRESS_0X0
30
+ };
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ checkDegenNFT
35
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var availability_exports = {};
17
+ module.exports = __toCommonJS(availability_exports);
18
+ __reExport(availability_exports, require("./check-boolean.js"), module.exports);
19
+ __reExport(availability_exports, require("./check-degen-nft.js"), module.exports);
20
+ __reExport(availability_exports, require("./validate-open-account-pool-quota-status.js"), module.exports);
21
+ __reExport(availability_exports, require("./validate-open-account-pool-status.js"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./check-boolean.js"),
25
+ ...require("./check-degen-nft.js"),
26
+ ...require("./validate-open-account-pool-quota-status.js"),
27
+ ...require("./validate-open-account-pool-status.js")
28
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var validate_open_account_pool_quota_status_exports = {};
20
+ __export(validate_open_account_pool_quota_status_exports, {
21
+ validateOpenAccountPoolQuotaStatus: () => validateOpenAccountPoolQuotaStatus
22
+ });
23
+ module.exports = __toCommonJS(validate_open_account_pool_quota_status_exports);
24
+ function validateOpenAccountPoolQuotaStatus(targetToken, creditManager, amountToBorrow) {
25
+ const quota = creditManager.quotas[targetToken];
26
+ if (quota) {
27
+ const realLimit = quota.isActive ? quota.limit : 0n;
28
+ const quotaLeft = realLimit - quota.totalQuoted;
29
+ if (quotaLeft < amountToBorrow)
30
+ return {
31
+ message: "insufficientQuota",
32
+ token: targetToken
33
+ };
34
+ }
35
+ return null;
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ validateOpenAccountPoolQuotaStatus
40
+ });
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var validate_open_account_pool_status_exports = {};
20
+ __export(validate_open_account_pool_status_exports, {
21
+ validateOpenAccountPoolStatus: () => validateOpenAccountPoolStatus
22
+ });
23
+ module.exports = __toCommonJS(validate_open_account_pool_status_exports);
24
+ var import_bigint_math = require("../../bigint-math.js");
25
+ var import_validate_open_account_pool_quota_status = require("./validate-open-account-pool-quota-status.js");
26
+ function validateOpenAccountPoolStatus(props) {
27
+ const { debt, creditManager, pool, targetToken } = props;
28
+ const effectiveDebt = import_bigint_math.BigIntMath.max(creditManager.minDebt, debt);
29
+ const hasDebtLimit = creditManager.totalDebtLimit >= 0n;
30
+ const debtLimitLeft = import_bigint_math.BigIntMath.max(
31
+ creditManager.totalDebtLimit - creditManager.totalDebt,
32
+ 0n
33
+ );
34
+ const { totalDebtLimit = 0n, totalBorrowed = 0n } = pool || {};
35
+ const hasPoolDebtLimit = totalDebtLimit > 0n;
36
+ const poolDebtLimitLeft = totalDebtLimit - totalBorrowed;
37
+ const canOpenMinDebt = creditManager.minDebt <= debtLimitLeft && creditManager.minDebt <= poolDebtLimitLeft && creditManager.minDebt <= creditManager.availableToBorrow;
38
+ const minPositionSize = import_bigint_math.BigIntMath.min(
39
+ import_bigint_math.BigIntMath.min(debtLimitLeft, poolDebtLimitLeft),
40
+ creditManager.availableToBorrow
41
+ );
42
+ if (hasDebtLimit && effectiveDebt > debtLimitLeft) {
43
+ return {
44
+ message: "insufficientDebtLimit",
45
+ amount: debtLimitLeft,
46
+ solutionAmount: canOpenMinDebt ? minPositionSize : void 0
47
+ };
48
+ }
49
+ if (hasPoolDebtLimit && effectiveDebt > poolDebtLimitLeft) {
50
+ return {
51
+ message: "insufficientPoolDebtLimit",
52
+ amount: poolDebtLimitLeft,
53
+ solutionAmount: canOpenMinDebt ? minPositionSize : void 0
54
+ };
55
+ }
56
+ if (effectiveDebt > creditManager.availableToBorrow) {
57
+ return {
58
+ message: "insufficientPoolLiquidity",
59
+ amount: creditManager.availableToBorrow,
60
+ solutionAmount: canOpenMinDebt ? minPositionSize : void 0
61
+ };
62
+ }
63
+ if (targetToken !== null) {
64
+ const quotaError = (0, import_validate_open_account_pool_quota_status.validateOpenAccountPoolQuotaStatus)(
65
+ targetToken,
66
+ creditManager,
67
+ effectiveDebt
68
+ );
69
+ if (quotaError) return quotaError;
70
+ }
71
+ return null;
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ validateOpenAccountPoolStatus
76
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var strategies_exports = {};
17
+ module.exports = __toCommonJS(strategies_exports);
18
+ __reExport(strategies_exports, require("./availability/index.js"), module.exports);
19
+ __reExport(strategies_exports, require("./leverage/index.js"), module.exports);
20
+ __reExport(strategies_exports, require("./sort-strategy-cms-by-availability/index.js"), module.exports);
21
+ __reExport(strategies_exports, require("./strategy-info/index.js"), module.exports);
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./availability/index.js"),
25
+ ...require("./leverage/index.js"),
26
+ ...require("./sort-strategy-cms-by-availability/index.js"),
27
+ ...require("./strategy-info/index.js")
28
+ });
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var calculate_loss_coefficient_exports = {};
20
+ __export(calculate_loss_coefficient_exports, {
21
+ calculateLossCoefficient: () => calculateLossCoefficient
22
+ });
23
+ module.exports = __toCommonJS(calculate_loss_coefficient_exports);
24
+ var import_sdk = require("../../../../sdk/index.js");
25
+ function calculateLossCoefficient(slippage, constantLoss = 30n) {
26
+ return 100n * import_sdk.SLIPPAGE_DECIMALS - (0, import_sdk.toBigInt)(slippage) - constantLoss;
27
+ }
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ calculateLossCoefficient
31
+ });