@gearbox-protocol/sdk 13.6.0-kyc.7 → 13.6.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 (152) hide show
  1. package/dist/cjs/dev/AccountOpener.js +5 -45
  2. package/dist/cjs/plugins/adapters/abi/actionAbi.js +1 -1
  3. package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +1 -1
  4. package/dist/cjs/plugins/adapters/createAdapter.js +1 -1
  5. package/dist/cjs/plugins/adapters/types.js +1 -1
  6. package/dist/cjs/plugins/apy/ApyPlugin.js +266 -0
  7. package/dist/cjs/plugins/apy/apy-cache.js +120 -0
  8. package/dist/cjs/plugins/apy/apy-parser.js +169 -0
  9. package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/constants.js +6 -3
  10. package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/index.js +14 -6
  11. package/dist/cjs/{sdk/market/kyc/securitize/types.js → plugins/apy/pool-apy-types.js} +2 -2
  12. package/dist/cjs/plugins/apy/pool-apy-utils.js +141 -0
  13. package/dist/cjs/rewards/rewards/extra-apy.js +10 -8
  14. package/dist/cjs/sdk/GearboxSDK.js +5 -52
  15. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +16 -324
  16. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1 -7
  17. package/dist/cjs/sdk/base/TokensMeta.js +43 -32
  18. package/dist/cjs/sdk/base/token-types.js +0 -9
  19. package/dist/cjs/sdk/chain/chains.js +32 -17
  20. package/dist/cjs/sdk/constants/address-provider.js +0 -3
  21. package/dist/cjs/sdk/market/MarketRegister.js +116 -70
  22. package/dist/cjs/sdk/market/MarketSuite.js +0 -3
  23. package/dist/cjs/sdk/market/index.js +0 -2
  24. package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
  25. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -11
  26. package/dist/cjs/sdk/market/pool/index.js +0 -2
  27. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
  28. package/dist/cjs/sdk/options.js +1 -7
  29. package/dist/cjs/sdk/pools/PoolService.js +12 -104
  30. package/dist/cjs/sdk/utils/viem/index.js +0 -2
  31. package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +39 -2
  32. package/dist/esm/dev/AccountOpener.js +6 -47
  33. package/dist/esm/plugins/adapters/abi/actionAbi.js +1 -1
  34. package/dist/esm/plugins/adapters/abi/conctructorAbi.js +1 -1
  35. package/dist/esm/plugins/adapters/createAdapter.js +1 -1
  36. package/dist/esm/plugins/adapters/types.js +1 -1
  37. package/dist/esm/plugins/apy/ApyPlugin.js +255 -0
  38. package/dist/esm/plugins/apy/apy-cache.js +86 -0
  39. package/dist/esm/plugins/apy/apy-parser.js +143 -0
  40. package/dist/esm/plugins/apy/constants.js +6 -0
  41. package/dist/esm/plugins/apy/index.js +7 -0
  42. package/dist/esm/plugins/apy/pool-apy-utils.js +113 -0
  43. package/dist/esm/rewards/rewards/extra-apy.js +10 -8
  44. package/dist/esm/sdk/GearboxSDK.js +6 -56
  45. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +17 -328
  46. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1 -7
  47. package/dist/esm/sdk/base/TokensMeta.js +45 -32
  48. package/dist/esm/sdk/base/token-types.js +0 -6
  49. package/dist/esm/sdk/chain/chains.js +32 -17
  50. package/dist/esm/sdk/constants/address-provider.js +0 -2
  51. package/dist/esm/sdk/market/MarketRegister.js +118 -74
  52. package/dist/esm/sdk/market/MarketSuite.js +0 -3
  53. package/dist/esm/sdk/market/index.js +0 -1
  54. package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
  55. package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -11
  56. package/dist/esm/sdk/market/pool/index.js +0 -1
  57. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
  58. package/dist/esm/sdk/options.js +1 -7
  59. package/dist/esm/sdk/pools/PoolService.js +13 -109
  60. package/dist/esm/sdk/utils/viem/index.js +0 -1
  61. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +41 -2
  62. package/dist/types/plugins/adapters/types.d.ts +2 -2
  63. package/dist/types/plugins/apy/ApyPlugin.d.ts +46 -0
  64. package/dist/types/plugins/apy/apy-cache.d.ts +28 -0
  65. package/dist/types/plugins/apy/apy-parser.d.ts +5 -0
  66. package/dist/types/plugins/apy/constants.d.ts +2 -0
  67. package/dist/types/plugins/apy/index.d.ts +7 -0
  68. package/dist/types/plugins/apy/pool-apy-types.d.ts +41 -0
  69. package/dist/types/plugins/apy/pool-apy-utils.d.ts +73 -0
  70. package/dist/types/plugins/apy/types.d.ts +37 -0
  71. package/dist/types/rewards/rewards/api.d.ts +10 -1
  72. package/dist/types/rewards/rewards/common.d.ts +0 -10
  73. package/dist/types/rewards/rewards/extra-apy.d.ts +4 -6
  74. package/dist/types/sdk/GearboxSDK.d.ts +0 -7
  75. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +2 -52
  76. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
  77. package/dist/types/sdk/accounts/types.d.ts +13 -93
  78. package/dist/types/sdk/base/TokensMeta.d.ts +3 -14
  79. package/dist/types/sdk/base/token-types.d.ts +4 -44
  80. package/dist/types/sdk/base/types.d.ts +11 -116
  81. package/dist/types/sdk/chain/chains.d.ts +5 -5
  82. package/dist/types/sdk/constants/address-provider.d.ts +0 -1
  83. package/dist/types/sdk/market/MarketRegister.d.ts +9 -6
  84. package/dist/types/sdk/market/MarketSuite.d.ts +0 -2
  85. package/dist/types/sdk/market/index.d.ts +0 -1
  86. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -3
  87. package/dist/types/sdk/market/oracle/types.d.ts +10 -3
  88. package/dist/types/sdk/market/pool/PoolSuite.d.ts +0 -2
  89. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
  90. package/dist/types/sdk/market/pool/index.d.ts +0 -1
  91. package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +1 -1
  92. package/dist/types/sdk/market/types.d.ts +1 -1
  93. package/dist/types/sdk/options.d.ts +0 -1
  94. package/dist/types/sdk/pools/PoolService.d.ts +8 -8
  95. package/dist/types/sdk/pools/types.d.ts +1 -1
  96. package/dist/types/sdk/types/state-human.d.ts +0 -2
  97. package/dist/types/sdk/types/state.d.ts +0 -5
  98. package/dist/types/sdk/utils/viem/index.d.ts +0 -1
  99. package/package.json +2 -3
  100. package/dist/cjs/abi/kyc/iDSRegistryService.js +0 -70
  101. package/dist/cjs/abi/kyc/iDSToken.js +0 -71
  102. package/dist/cjs/abi/kyc/iKYCCompressor.js +0 -196
  103. package/dist/cjs/abi/kyc/iKYCFactory.js +0 -122
  104. package/dist/cjs/abi/kyc/iKYCUnderlying.js +0 -401
  105. package/dist/cjs/abi/kyc/iSecuritizeDegenNFT.js +0 -326
  106. package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +0 -319
  107. package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +0 -108
  108. package/dist/cjs/plugins/pools-history/index.js +0 -24
  109. package/dist/cjs/sdk/market/kyc/KYCRegistry.js +0 -269
  110. package/dist/cjs/sdk/market/kyc/index.js +0 -26
  111. package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -244
  112. package/dist/cjs/sdk/market/kyc/types.js +0 -34
  113. package/dist/cjs/sdk/utils/viem/executeDelegatedMulticalls.js +0 -38
  114. package/dist/esm/abi/kyc/iDSRegistryService.js +0 -46
  115. package/dist/esm/abi/kyc/iDSToken.js +0 -47
  116. package/dist/esm/abi/kyc/iKYCCompressor.js +0 -172
  117. package/dist/esm/abi/kyc/iKYCFactory.js +0 -98
  118. package/dist/esm/abi/kyc/iKYCUnderlying.js +0 -377
  119. package/dist/esm/abi/kyc/iSecuritizeDegenNFT.js +0 -302
  120. package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +0 -295
  121. package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +0 -90
  122. package/dist/esm/plugins/pools-history/index.js +0 -2
  123. package/dist/esm/sdk/market/kyc/KYCRegistry.js +0 -253
  124. package/dist/esm/sdk/market/kyc/index.js +0 -3
  125. package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -220
  126. package/dist/esm/sdk/market/kyc/securitize/constants.js +0 -4
  127. package/dist/esm/sdk/market/kyc/securitize/index.js +0 -3
  128. package/dist/esm/sdk/market/kyc/types.js +0 -9
  129. package/dist/esm/sdk/utils/viem/executeDelegatedMulticalls.js +0 -14
  130. package/dist/types/abi/kyc/iDSRegistryService.d.ts +0 -71
  131. package/dist/types/abi/kyc/iDSToken.d.ts +0 -67
  132. package/dist/types/abi/kyc/iKYCCompressor.d.ts +0 -228
  133. package/dist/types/abi/kyc/iKYCFactory.d.ts +0 -139
  134. package/dist/types/abi/kyc/iKYCUnderlying.d.ts +0 -548
  135. package/dist/types/abi/kyc/iSecuritizeDegenNFT.d.ts +0 -404
  136. package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +0 -376
  137. package/dist/types/plugins/pools-history/Pools7DAgoPlugin.d.ts +0 -20
  138. package/dist/types/plugins/pools-history/index.d.ts +0 -2
  139. package/dist/types/plugins/pools-history/types.d.ts +0 -9
  140. package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +0 -52
  141. package/dist/types/sdk/market/kyc/index.d.ts +0 -3
  142. package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +0 -428
  143. package/dist/types/sdk/market/kyc/securitize/constants.d.ts +0 -1
  144. package/dist/types/sdk/market/kyc/securitize/index.d.ts +0 -3
  145. package/dist/types/sdk/market/kyc/securitize/types.d.ts +0 -127
  146. package/dist/types/sdk/market/kyc/types.d.ts +0 -170
  147. package/dist/types/sdk/utils/viem/executeDelegatedMulticalls.d.ts +0 -28
  148. /package/dist/cjs/plugins/{pools-history → apy}/package.json +0 -0
  149. /package/dist/cjs/plugins/{pools-history → apy}/types.js +0 -0
  150. /package/dist/esm/plugins/{pools-history → apy}/package.json +0 -0
  151. /package/dist/esm/plugins/{pools-history/types.js → apy/pool-apy-types.js} +0 -0
  152. /package/dist/esm/{sdk/market/kyc/securitize → plugins/apy}/types.js +0 -0
@@ -18,11 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var constants_exports = {};
20
20
  __export(constants_exports, {
21
- KYC_FACTORY_SECURITIZE: () => KYC_FACTORY_SECURITIZE
21
+ APY_STATE_CACHE_URL: () => APY_STATE_CACHE_URL,
22
+ DEFAULT_APY_INTERVAL_MS: () => DEFAULT_APY_INTERVAL_MS
22
23
  });
23
24
  module.exports = __toCommonJS(constants_exports);
24
- const KYC_FACTORY_SECURITIZE = "KYC_FACTORY::SECURITIZE";
25
+ const APY_STATE_CACHE_URL = "https://state-cache.gearbox.foundation/apy-server/latest.json";
26
+ const DEFAULT_APY_INTERVAL_MS = 10 * 60 * 1e3;
25
27
  // Annotate the CommonJS export names for ESM import in node:
26
28
  0 && (module.exports = {
27
- KYC_FACTORY_SECURITIZE
29
+ APY_STATE_CACHE_URL,
30
+ DEFAULT_APY_INTERVAL_MS
28
31
  });
@@ -13,14 +13,22 @@ var __copyProps = (to, from, except, desc) => {
13
13
  };
14
14
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var securitize_exports = {};
17
- module.exports = __toCommonJS(securitize_exports);
18
- __reExport(securitize_exports, require("./constants.js"), module.exports);
19
- __reExport(securitize_exports, require("./SecuritizeKYCFactory.js"), module.exports);
20
- __reExport(securitize_exports, require("./types.js"), module.exports);
16
+ var apy_exports = {};
17
+ module.exports = __toCommonJS(apy_exports);
18
+ __reExport(apy_exports, require("./ApyPlugin.js"), module.exports);
19
+ __reExport(apy_exports, require("./apy-cache.js"), module.exports);
20
+ __reExport(apy_exports, require("./apy-parser.js"), module.exports);
21
+ __reExport(apy_exports, require("./constants.js"), module.exports);
22
+ __reExport(apy_exports, require("./pool-apy-types.js"), module.exports);
23
+ __reExport(apy_exports, require("./pool-apy-utils.js"), module.exports);
24
+ __reExport(apy_exports, require("./types.js"), module.exports);
21
25
  // Annotate the CommonJS export names for ESM import in node:
22
26
  0 && (module.exports = {
27
+ ...require("./ApyPlugin.js"),
28
+ ...require("./apy-cache.js"),
29
+ ...require("./apy-parser.js"),
23
30
  ...require("./constants.js"),
24
- ...require("./SecuritizeKYCFactory.js"),
31
+ ...require("./pool-apy-types.js"),
32
+ ...require("./pool-apy-utils.js"),
25
33
  ...require("./types.js")
26
34
  });
@@ -12,5 +12,5 @@ var __copyProps = (to, from, except, desc) => {
12
12
  return to;
13
13
  };
14
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var types_exports = {};
16
- module.exports = __toCommonJS(types_exports);
15
+ var pool_apy_types_exports = {};
16
+ module.exports = __toCommonJS(pool_apy_types_exports);
@@ -0,0 +1,141 @@
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 pool_apy_utils_exports = {};
20
+ __export(pool_apy_utils_exports, {
21
+ calculatePoolFullAPY: () => calculatePoolFullAPY,
22
+ calculatePoolFullAPY7DAgo: () => calculatePoolFullAPY7DAgo,
23
+ calculatePoolPoints: () => calculatePoolPoints,
24
+ calculateSupplyApy7d: () => calculateSupplyApy7d,
25
+ getPoolExtraAPY: () => getPoolExtraAPY
26
+ });
27
+ module.exports = __toCommonJS(pool_apy_utils_exports);
28
+ var import_constants = require("../../sdk/constants/index.js");
29
+ var import_formatter = require("../../sdk/utils/formatter.js");
30
+ const SCALE = 1000000n;
31
+ const WEEKS_PER_YEAR = 54n;
32
+ function getPoolExtraAPY(lookupAddresses, poolExtraAPYList) {
33
+ if (!poolExtraAPYList) return [];
34
+ const result = [];
35
+ for (const addr of lookupAddresses) {
36
+ const extra = poolExtraAPYList[addr.toLowerCase()];
37
+ if (extra) {
38
+ result.push(...extra);
39
+ }
40
+ }
41
+ return result;
42
+ }
43
+ function calculateSupplyApy7d(currentDieselRate, currentSupplyRate, dieselRate7DAgo) {
44
+ if (dieselRate7DAgo > currentDieselRate) {
45
+ return (0, import_formatter.rayToNumber)(currentSupplyRate * SCALE) / Number(import_constants.PERCENTAGE_FACTOR);
46
+ }
47
+ const apy = (currentDieselRate * import_constants.RAY / dieselRate7DAgo - import_constants.RAY) * WEEKS_PER_YEAR;
48
+ return (0, import_formatter.rayToNumber)(apy * SCALE) / Number(import_constants.PERCENTAGE_FACTOR);
49
+ }
50
+ function calculatePoolFullAPY({
51
+ depositAPY,
52
+ underlyingAPY,
53
+ extraAPY,
54
+ currentExternalList
55
+ }) {
56
+ const baseAPY = [
57
+ { type: "supplyAPY", apy: depositAPY },
58
+ ...underlyingAPY > 0 ? [
59
+ {
60
+ type: "tokenYield",
61
+ apy: Number(underlyingAPY) / Number(import_constants.PERCENTAGE_FACTOR)
62
+ }
63
+ ] : []
64
+ ];
65
+ const filteredExtra = [...extraAPY ?? []].filter((r) => r.apy > 0);
66
+ const baseAPYTotal = baseAPY.reduce((s, r) => s + (r.apy || 0), 0);
67
+ const extraAPYTotal = filteredExtra.reduce((s, r) => s + (r.apy || 0), 0);
68
+ const total = baseAPYTotal + extraAPYTotal;
69
+ const externalAPY = resolveExternalAPY(currentExternalList, total);
70
+ return {
71
+ totalAPY: total,
72
+ baseAPY,
73
+ extraAPY: filteredExtra,
74
+ extraAPYTotal,
75
+ externalAPY
76
+ };
77
+ }
78
+ function resolveExternalAPY(list, baseTotal) {
79
+ const first = list?.[0];
80
+ if (!first) return void 0;
81
+ return {
82
+ ...first,
83
+ totalValue: baseTotal + first.value
84
+ };
85
+ }
86
+ function calculatePoolFullAPY7DAgo({
87
+ supplyAPY7DAgo,
88
+ depositAPY,
89
+ poolAPY
90
+ }) {
91
+ const {
92
+ baseAPY = [],
93
+ extraAPYTotal = 0,
94
+ extraAPY = [],
95
+ externalAPY
96
+ } = poolAPY ?? {};
97
+ const base = [
98
+ { apy: supplyAPY7DAgo || depositAPY, type: "supplyAPY" },
99
+ ...baseAPY.filter((r) => r.type !== "supplyAPY")
100
+ ];
101
+ const baseTotal = base.reduce((acc, r) => acc + r.apy, 0);
102
+ const total = baseTotal + extraAPYTotal;
103
+ return {
104
+ totalAPY: total,
105
+ extraAPYTotal,
106
+ baseAPY: base,
107
+ extraAPY,
108
+ externalAPY,
109
+ loading7DAgo: supplyAPY7DAgo === void 0
110
+ };
111
+ }
112
+ function calculatePoolPoints({
113
+ poolTokenSymbol,
114
+ points,
115
+ tokensList
116
+ }) {
117
+ return points?.map(({ info, points: pts }) => {
118
+ const { decimals = 18 } = tokensList.get(info.token) || {};
119
+ const amount = (0, import_formatter.formatBN)(pts, decimals);
120
+ const { name = "Points", duration } = info ?? {};
121
+ return {
122
+ reward: info,
123
+ name,
124
+ amount,
125
+ tokenTitle: poolTokenSymbol,
126
+ fullTip: [
127
+ `${amount} ${name}`,
128
+ ...duration ? [duration] : [],
129
+ ...poolTokenSymbol ? [poolTokenSymbol] : []
130
+ ].join(" per ")
131
+ };
132
+ });
133
+ }
134
+ // Annotate the CommonJS export names for ESM import in node:
135
+ 0 && (module.exports = {
136
+ calculatePoolFullAPY,
137
+ calculatePoolFullAPY7DAgo,
138
+ calculatePoolPoints,
139
+ calculateSupplyApy7d,
140
+ getPoolExtraAPY
141
+ });
@@ -82,11 +82,13 @@ class PoolPointsAPI {
82
82
  tokensList
83
83
  }) {
84
84
  const r = pools.reduce((acc, p) => {
85
- const pointsInfo = poolRewards[p.address] || [];
85
+ const poolAddress = p.pool.pool.address.toLowerCase();
86
+ const pointsInfo = poolRewards[poolAddress] || [];
86
87
  const poolPointsList = pointsInfo.reduce(
87
88
  (acc2, pointsInfo2) => {
88
- const { address: tokenAddress } = tokensList[pointsInfo2.token] || {};
89
- const tokenBalance = totalTokenBalances[tokenAddress || ""];
89
+ const { addr: tokenAddress } = tokensList.get(pointsInfo2.token) || {};
90
+ const tokenAddressLower = (tokenAddress || "").toLowerCase();
91
+ const tokenBalance = totalTokenBalances[tokenAddressLower];
90
92
  const points = PoolPointsAPI.getPoolTokenPoints(
91
93
  tokenBalance,
92
94
  p,
@@ -104,22 +106,22 @@ class PoolPointsAPI {
104
106
  },
105
107
  []
106
108
  );
107
- acc[p.address] = poolPointsList;
109
+ acc[poolAddress] = poolPointsList;
108
110
  return acc;
109
111
  }, {});
110
112
  return r;
111
113
  }
112
114
  static getPoolTokenPoints(tokenBalanceInPool, pool, tokensList, pointsInfo) {
113
- if (pool.expectedLiquidity <= 0) return 0n;
115
+ if (pool.pool.pool.expectedLiquidity <= 0) return 0n;
114
116
  if (pointsInfo.estimation === "relative" && !tokenBalanceInPool)
115
117
  return null;
116
- const { decimals = 18 } = tokensList[pointsInfo.token] || {};
118
+ const { decimals = 18 } = tokensList.get(pointsInfo.token) || {};
117
119
  const targetFactor = 10n ** BigInt(decimals);
118
120
  const defaultPoints = pointsInfo.amount * targetFactor / import_sdk.PERCENTAGE_FACTOR;
119
121
  if (pointsInfo.estimation === "absolute") return defaultPoints;
120
- const { decimals: underlyingDecimals = 18 } = tokensList[pool.underlyingToken] || {};
122
+ const { decimals: underlyingDecimals = 18 } = tokensList.get(pool.pool.pool.underlying) || {};
121
123
  const underlyingFactor = 10n ** BigInt(underlyingDecimals);
122
- const points = (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.expectedLiquidity * targetFactor / underlyingFactor);
124
+ const points = (tokenBalanceInPool?.balance || 0n) * defaultPoints / (pool.pool.pool.expectedLiquidity * targetFactor / underlyingFactor);
123
125
  return import_common_utils.BigIntMath.min(points, defaultPoints);
124
126
  }
125
127
  }
@@ -27,7 +27,6 @@ var import_base = require("./base/index.js");
27
27
  var import_chain = require("./chain/index.js");
28
28
  var import_constants = require("./constants/index.js");
29
29
  var import_core = require("./core/index.js");
30
- var import_kyc = require("./market/kyc/index.js");
31
30
  var import_MarketRegister = require("./market/MarketRegister.js");
32
31
  var import_pricefeeds = require("./market/pricefeeds/index.js");
33
32
  var import_plugins = require("./plugins/index.js");
@@ -87,7 +86,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
87
86
  #addressProvider;
88
87
  #attachConfig;
89
88
  #marketRegister;
90
- #kyc;
91
89
  #priceFeeds;
92
90
  /**
93
91
  * Gas limit applied to read-only `eth_call` requests.
@@ -132,7 +130,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
132
130
  ignoreUpdateablePrices,
133
131
  ignoreMarkets,
134
132
  marketConfigurators: mcs,
135
- kycFactories: kfs,
136
133
  strictContractTypes,
137
134
  gasLimit
138
135
  } = options;
@@ -142,7 +139,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
142
139
  addressProvider = import_constants.ADDRESS_PROVIDER_V310;
143
140
  }
144
141
  const marketConfigurators = mcs ?? import_utils.TypedObjectUtils.keys(client.chain.defaultMarketConfigurators);
145
- const kycFactories = kfs ?? client.chain.kycFactories;
146
142
  return new GearboxSDK({
147
143
  client,
148
144
  logger,
@@ -155,7 +151,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
155
151
  ignoreUpdateablePrices,
156
152
  ignoreMarkets,
157
153
  marketConfigurators,
158
- kycFactories,
159
154
  redstone,
160
155
  pyth
161
156
  });
@@ -195,7 +190,7 @@ class GearboxSDK extends import_base.ChainContractsRegister {
195
190
  plugin.sdk = this;
196
191
  }
197
192
  if (options.gasLimit !== null) {
198
- this.gasLimit = options.gasLimit || 550000000n;
193
+ this.gasLimit = options.gasLimit || (0, import_chain.getChain)(this.networkType).gasLimit;
199
194
  }
200
195
  }
201
196
  async #attach(opts) {
@@ -205,7 +200,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
205
200
  ignoreUpdateablePrices,
206
201
  ignoreMarkets,
207
202
  marketConfigurators,
208
- kycFactories,
209
203
  redstone,
210
204
  pyth
211
205
  } = opts;
@@ -216,7 +210,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
216
210
  chainId: this.chainId,
217
211
  addressProvider,
218
212
  marketConfigurators,
219
- kycFactories,
220
213
  blockNumber,
221
214
  ignoreMarkets
222
215
  },
@@ -251,34 +244,10 @@ class GearboxSDK extends import_base.ChainContractsRegister {
251
244
  );
252
245
  await this.#addressProvider.syncState(this.currentBlock);
253
246
  this.#marketRegister = new import_MarketRegister.MarketRegister(this, ignoreMarkets);
254
- this.#kyc = new import_kyc.KYCRegistry(this);
255
- if (!marketConfigurators.length) {
256
- this.logger?.warn(
257
- "no market configurators provided, skipping market loading"
258
- );
259
- } else {
260
- const delegated = [
261
- ...this.#marketRegister.getLoadMulticalls(marketConfigurators),
262
- ...this.#kyc.getLoadMulticalls(marketConfigurators, kycFactories)
263
- ];
264
- let txs = [];
265
- if (!ignoreUpdateablePrices) {
266
- const updatables = await this.#priceFeeds.getPartialUpdatablePriceFeeds(
267
- marketConfigurators
268
- );
269
- const updates = await this.#priceFeeds.generatePriceFeedsUpdateTxs(updatables);
270
- txs = updates.txs;
271
- }
272
- this.logger?.debug(
273
- { configurators: marketConfigurators },
274
- `calling getMarkets with ${txs.length} price updates in block ${this.currentBlock}`
275
- );
276
- await (0, import_viem2.executeDelegatedMulticalls)(this.client, delegated, {
277
- priceUpdates: txs,
278
- blockNumber: this.currentBlock,
279
- gas: this.gasLimit
280
- });
281
- }
247
+ await this.#marketRegister.loadMarkets(
248
+ marketConfigurators,
249
+ ignoreUpdateablePrices
250
+ );
282
251
  const pluginsList = import_utils.TypedObjectUtils.entries(this.plugins);
283
252
  const pluginResponse = await Promise.allSettled(
284
253
  pluginsList.map(([name, plugin]) => {
@@ -324,15 +293,12 @@ class GearboxSDK extends import_base.ChainContractsRegister {
324
293
  );
325
294
  this.#marketRegister = new import_MarketRegister.MarketRegister(this, ignoreMarkets);
326
295
  this.#marketRegister.hydrate(state.markets);
327
- this.#kyc = new import_kyc.KYCRegistry(this);
328
- this.#kyc.setState(state.kyc);
329
296
  this.#attachConfig = {
330
297
  ...opts,
331
298
  addressProvider: this.addressProvider.address,
332
299
  marketConfigurators: this.marketRegister.marketConfigurators.map(
333
300
  (m) => m.address
334
301
  ),
335
- kycFactories: this.kyc.factories.map((f) => f.address),
336
302
  blockNumber: this.currentBlock
337
303
  };
338
304
  for (const [name, plugin] of import_utils.TypedObjectUtils.entries(this.plugins)) {
@@ -416,7 +382,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
416
382
  addressProviderV3: this.addressProvider.stateHuman(raw)
417
383
  },
418
384
  tokens: this.tokensMeta.values(),
419
- kyc: this.kyc.stateHuman(raw),
420
385
  plugins: Object.fromEntries(
421
386
  import_utils.TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
422
387
  name,
@@ -442,7 +407,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
442
407
  timestamp: this.timestamp,
443
408
  addressProvider: this.addressProvider.state,
444
409
  markets: this.marketRegister.state,
445
- kyc: this.kyc.state,
446
410
  plugins: Object.fromEntries(
447
411
  import_utils.TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
448
412
  name,
@@ -639,17 +603,6 @@ class GearboxSDK extends import_base.ChainContractsRegister {
639
603
  }
640
604
  return this.#marketRegister;
641
605
  }
642
- /**
643
- * KYC register for KYC-wrapped underlying tokens and factories.
644
- *
645
- * @throws If the SDK has not been attached or hydrated yet.
646
- **/
647
- get kyc() {
648
- if (this.#kyc === void 0) {
649
- throw ERR_NOT_ATTACHED;
650
- }
651
- return this.#kyc;
652
- }
653
606
  /**
654
607
  * Resolves the appropriate router contract for a given credit manager,
655
608
  * credit facade, or explicit version range.