@gearbox-protocol/sdk 13.6.0-kyc.7 → 13.6.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 (155) hide show
  1. package/dist/cjs/dev/AccountOpener.js +5 -45
  2. package/dist/cjs/dev/logSplitterTransport.js +10 -1
  3. package/dist/cjs/plugins/adapters/abi/actionAbi.js +1 -1
  4. package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +1 -1
  5. package/dist/cjs/plugins/adapters/createAdapter.js +1 -1
  6. package/dist/cjs/plugins/adapters/types.js +1 -1
  7. package/dist/cjs/plugins/apy/ApyPlugin.js +266 -0
  8. package/dist/cjs/plugins/apy/apy-cache.js +120 -0
  9. package/dist/cjs/plugins/apy/apy-parser.js +169 -0
  10. package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/constants.js +6 -3
  11. package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/index.js +14 -6
  12. package/dist/cjs/{sdk/market/kyc/securitize/types.js → plugins/apy/pool-apy-types.js} +2 -2
  13. package/dist/cjs/plugins/apy/pool-apy-utils.js +141 -0
  14. package/dist/cjs/rewards/rewards/extra-apy.js +10 -8
  15. package/dist/cjs/sdk/GearboxSDK.js +5 -52
  16. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +16 -324
  17. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1 -7
  18. package/dist/cjs/sdk/base/TokensMeta.js +43 -32
  19. package/dist/cjs/sdk/base/token-types.js +0 -9
  20. package/dist/cjs/sdk/chain/chains.js +32 -17
  21. package/dist/cjs/sdk/constants/address-provider.js +0 -3
  22. package/dist/cjs/sdk/market/MarketRegister.js +116 -70
  23. package/dist/cjs/sdk/market/MarketSuite.js +0 -3
  24. package/dist/cjs/sdk/market/index.js +0 -2
  25. package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
  26. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -11
  27. package/dist/cjs/sdk/market/pool/index.js +0 -2
  28. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
  29. package/dist/cjs/sdk/options.js +1 -7
  30. package/dist/cjs/sdk/pools/PoolService.js +12 -104
  31. package/dist/cjs/sdk/utils/viem/index.js +0 -2
  32. package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +39 -2
  33. package/dist/esm/dev/AccountOpener.js +6 -47
  34. package/dist/esm/dev/logSplitterTransport.js +10 -1
  35. package/dist/esm/plugins/adapters/abi/actionAbi.js +1 -1
  36. package/dist/esm/plugins/adapters/abi/conctructorAbi.js +1 -1
  37. package/dist/esm/plugins/adapters/createAdapter.js +1 -1
  38. package/dist/esm/plugins/adapters/types.js +1 -1
  39. package/dist/esm/plugins/apy/ApyPlugin.js +255 -0
  40. package/dist/esm/plugins/apy/apy-cache.js +86 -0
  41. package/dist/esm/plugins/apy/apy-parser.js +143 -0
  42. package/dist/esm/plugins/apy/constants.js +6 -0
  43. package/dist/esm/plugins/apy/index.js +7 -0
  44. package/dist/esm/plugins/apy/pool-apy-utils.js +113 -0
  45. package/dist/esm/rewards/rewards/extra-apy.js +10 -8
  46. package/dist/esm/sdk/GearboxSDK.js +6 -56
  47. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +17 -328
  48. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1 -7
  49. package/dist/esm/sdk/base/TokensMeta.js +45 -32
  50. package/dist/esm/sdk/base/token-types.js +0 -6
  51. package/dist/esm/sdk/chain/chains.js +32 -17
  52. package/dist/esm/sdk/constants/address-provider.js +0 -2
  53. package/dist/esm/sdk/market/MarketRegister.js +118 -74
  54. package/dist/esm/sdk/market/MarketSuite.js +0 -3
  55. package/dist/esm/sdk/market/index.js +0 -1
  56. package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
  57. package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -11
  58. package/dist/esm/sdk/market/pool/index.js +0 -1
  59. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
  60. package/dist/esm/sdk/options.js +1 -7
  61. package/dist/esm/sdk/pools/PoolService.js +13 -109
  62. package/dist/esm/sdk/utils/viem/index.js +0 -1
  63. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +41 -2
  64. package/dist/types/dev/logSplitterTransport.d.ts +3 -1
  65. package/dist/types/plugins/adapters/types.d.ts +2 -2
  66. package/dist/types/plugins/apy/ApyPlugin.d.ts +46 -0
  67. package/dist/types/plugins/apy/apy-cache.d.ts +28 -0
  68. package/dist/types/plugins/apy/apy-parser.d.ts +5 -0
  69. package/dist/types/plugins/apy/constants.d.ts +2 -0
  70. package/dist/types/plugins/apy/index.d.ts +7 -0
  71. package/dist/types/plugins/apy/pool-apy-types.d.ts +41 -0
  72. package/dist/types/plugins/apy/pool-apy-utils.d.ts +73 -0
  73. package/dist/types/plugins/apy/types.d.ts +37 -0
  74. package/dist/types/rewards/rewards/api.d.ts +10 -1
  75. package/dist/types/rewards/rewards/common.d.ts +0 -10
  76. package/dist/types/rewards/rewards/extra-apy.d.ts +4 -6
  77. package/dist/types/sdk/GearboxSDK.d.ts +0 -7
  78. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +2 -52
  79. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
  80. package/dist/types/sdk/accounts/types.d.ts +13 -93
  81. package/dist/types/sdk/base/TokensMeta.d.ts +3 -14
  82. package/dist/types/sdk/base/token-types.d.ts +4 -44
  83. package/dist/types/sdk/base/types.d.ts +11 -116
  84. package/dist/types/sdk/chain/chains.d.ts +5 -5
  85. package/dist/types/sdk/constants/address-provider.d.ts +0 -1
  86. package/dist/types/sdk/market/MarketRegister.d.ts +9 -6
  87. package/dist/types/sdk/market/MarketSuite.d.ts +0 -2
  88. package/dist/types/sdk/market/index.d.ts +0 -1
  89. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -3
  90. package/dist/types/sdk/market/oracle/types.d.ts +10 -3
  91. package/dist/types/sdk/market/pool/PoolSuite.d.ts +0 -2
  92. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
  93. package/dist/types/sdk/market/pool/index.d.ts +0 -1
  94. package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +1 -1
  95. package/dist/types/sdk/market/types.d.ts +1 -1
  96. package/dist/types/sdk/options.d.ts +0 -1
  97. package/dist/types/sdk/pools/PoolService.d.ts +8 -8
  98. package/dist/types/sdk/pools/types.d.ts +1 -1
  99. package/dist/types/sdk/types/state-human.d.ts +0 -2
  100. package/dist/types/sdk/types/state.d.ts +0 -5
  101. package/dist/types/sdk/utils/viem/index.d.ts +0 -1
  102. package/package.json +2 -3
  103. package/dist/cjs/abi/kyc/iDSRegistryService.js +0 -70
  104. package/dist/cjs/abi/kyc/iDSToken.js +0 -71
  105. package/dist/cjs/abi/kyc/iKYCCompressor.js +0 -196
  106. package/dist/cjs/abi/kyc/iKYCFactory.js +0 -122
  107. package/dist/cjs/abi/kyc/iKYCUnderlying.js +0 -401
  108. package/dist/cjs/abi/kyc/iSecuritizeDegenNFT.js +0 -326
  109. package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +0 -319
  110. package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +0 -108
  111. package/dist/cjs/plugins/pools-history/index.js +0 -24
  112. package/dist/cjs/sdk/market/kyc/KYCRegistry.js +0 -269
  113. package/dist/cjs/sdk/market/kyc/index.js +0 -26
  114. package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -244
  115. package/dist/cjs/sdk/market/kyc/types.js +0 -34
  116. package/dist/cjs/sdk/utils/viem/executeDelegatedMulticalls.js +0 -38
  117. package/dist/esm/abi/kyc/iDSRegistryService.js +0 -46
  118. package/dist/esm/abi/kyc/iDSToken.js +0 -47
  119. package/dist/esm/abi/kyc/iKYCCompressor.js +0 -172
  120. package/dist/esm/abi/kyc/iKYCFactory.js +0 -98
  121. package/dist/esm/abi/kyc/iKYCUnderlying.js +0 -377
  122. package/dist/esm/abi/kyc/iSecuritizeDegenNFT.js +0 -302
  123. package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +0 -295
  124. package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +0 -90
  125. package/dist/esm/plugins/pools-history/index.js +0 -2
  126. package/dist/esm/sdk/market/kyc/KYCRegistry.js +0 -253
  127. package/dist/esm/sdk/market/kyc/index.js +0 -3
  128. package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -220
  129. package/dist/esm/sdk/market/kyc/securitize/constants.js +0 -4
  130. package/dist/esm/sdk/market/kyc/securitize/index.js +0 -3
  131. package/dist/esm/sdk/market/kyc/types.js +0 -9
  132. package/dist/esm/sdk/utils/viem/executeDelegatedMulticalls.js +0 -14
  133. package/dist/types/abi/kyc/iDSRegistryService.d.ts +0 -71
  134. package/dist/types/abi/kyc/iDSToken.d.ts +0 -67
  135. package/dist/types/abi/kyc/iKYCCompressor.d.ts +0 -228
  136. package/dist/types/abi/kyc/iKYCFactory.d.ts +0 -139
  137. package/dist/types/abi/kyc/iKYCUnderlying.d.ts +0 -548
  138. package/dist/types/abi/kyc/iSecuritizeDegenNFT.d.ts +0 -404
  139. package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +0 -376
  140. package/dist/types/plugins/pools-history/Pools7DAgoPlugin.d.ts +0 -20
  141. package/dist/types/plugins/pools-history/index.d.ts +0 -2
  142. package/dist/types/plugins/pools-history/types.d.ts +0 -9
  143. package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +0 -52
  144. package/dist/types/sdk/market/kyc/index.d.ts +0 -3
  145. package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +0 -428
  146. package/dist/types/sdk/market/kyc/securitize/constants.d.ts +0 -1
  147. package/dist/types/sdk/market/kyc/securitize/index.d.ts +0 -3
  148. package/dist/types/sdk/market/kyc/securitize/types.d.ts +0 -127
  149. package/dist/types/sdk/market/kyc/types.d.ts +0 -170
  150. package/dist/types/sdk/utils/viem/executeDelegatedMulticalls.d.ts +0 -28
  151. /package/dist/cjs/plugins/{pools-history → apy}/package.json +0 -0
  152. /package/dist/cjs/plugins/{pools-history → apy}/types.js +0 -0
  153. /package/dist/esm/plugins/{pools-history → apy}/package.json +0 -0
  154. /package/dist/esm/plugins/{pools-history/types.js → apy/pool-apy-types.js} +0 -0
  155. /package/dist/esm/{sdk/market/kyc/securitize → plugins/apy}/types.js +0 -0
@@ -79,15 +79,15 @@ const chains = {
79
79
  "0x601067eba24bb5b558a184fc082525637e96a42d": "Gami Labs"
80
80
  },
81
81
  testMarketConfigurators: {
82
- "0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit",
83
- "0xE0527dE5908B3fc2e054B7eEE0DeF6c9965AbF24": "Securitize"
82
+ "0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit"
84
83
  },
85
84
  isPublic: true,
86
85
  wellKnownToken: {
87
86
  address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
88
87
  symbol: "USDC"
89
88
  },
90
- firstBlock: 22358644n
89
+ firstBlock: 22358644n,
90
+ gasLimit: 550000000n
91
91
  },
92
92
  "ethereum-rpc"
93
93
  ),
@@ -103,7 +103,8 @@ const chains = {
103
103
  address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
104
104
  symbol: "USDC"
105
105
  },
106
- firstBlock: 184650310n
106
+ firstBlock: 184650310n,
107
+ gasLimit: 550000000n
107
108
  },
108
109
  "arbitrum-one-rpc"
109
110
  ),
@@ -120,7 +121,8 @@ const chains = {
120
121
  address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
121
122
  symbol: "USDC"
122
123
  },
123
- firstBlock: 118410666n
124
+ firstBlock: 118410666n,
125
+ gasLimit: 550000000n
124
126
  },
125
127
  "optimism-rpc"
126
128
  ),
@@ -133,7 +135,8 @@ const chains = {
133
135
  wellKnownToken: {
134
136
  address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
135
137
  symbol: "USDC"
136
- }
138
+ },
139
+ gasLimit: 550000000n
137
140
  },
138
141
  "base-rpc"
139
142
  ),
@@ -156,6 +159,7 @@ const chains = {
156
159
  address: "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
157
160
  symbol: "USDC"
158
161
  },
162
+ gasLimit: 550000000n,
159
163
  firstBlock: 9779380n
160
164
  }),
161
165
  "sonic-rpc"
@@ -168,7 +172,8 @@ const chains = {
168
172
  wellKnownToken: {
169
173
  address: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",
170
174
  symbol: "USDm"
171
- }
175
+ },
176
+ gasLimit: 550000000n
172
177
  }),
173
178
  // NOTE: Monad chain configs should be updated once the public mainnet is available
174
179
  Monad: (0, import_viem.defineChain)({
@@ -189,7 +194,8 @@ const chains = {
189
194
  address: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
190
195
  symbol: "USDT0"
191
196
  },
192
- firstBlock: 34650262n
197
+ firstBlock: 34650262n,
198
+ gasLimit: 200000000n
193
199
  }),
194
200
  Berachain: withPublicNode(
195
201
  {
@@ -207,7 +213,8 @@ const chains = {
207
213
  wellKnownToken: {
208
214
  address: "0x549943e04f40284185054145c6e4e9568c1d3241",
209
215
  symbol: "USDC.e"
210
- }
216
+ },
217
+ gasLimit: 550000000n
211
218
  },
212
219
  "berachain-rpc"
213
220
  ),
@@ -220,7 +227,8 @@ const chains = {
220
227
  wellKnownToken: {
221
228
  address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
222
229
  symbol: "USDC"
223
- }
230
+ },
231
+ gasLimit: 550000000n
224
232
  },
225
233
  "avalanche-c-chain-rpc"
226
234
  ),
@@ -238,7 +246,8 @@ const chains = {
238
246
  address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
239
247
  symbol: "USDC"
240
248
  },
241
- firstBlock: 48761804n
249
+ firstBlock: 48761804n,
250
+ gasLimit: 550000000n
242
251
  },
243
252
  "bsc-rpc"
244
253
  ),
@@ -250,8 +259,9 @@ const chains = {
250
259
  wellKnownToken: {
251
260
  address: "0x79a02482a880bce3f13e09da970dc34db4cd24d1",
252
261
  symbol: "USDC"
253
- }
262
+ },
254
263
  // TODO: has no block explorer API
264
+ gasLimit: 550000000n
255
265
  }),
256
266
  Etherlink: (0, import_viem.defineChain)({
257
267
  ...import_chains.etherlink,
@@ -264,7 +274,8 @@ const chains = {
264
274
  address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9",
265
275
  symbol: "USDC"
266
276
  },
267
- firstBlock: 16672963n
277
+ firstBlock: 16672963n,
278
+ gasLimit: 550000000n
268
279
  }),
269
280
  Hemi: (0, import_viem.defineChain)({
270
281
  ...import_chains.hemi,
@@ -282,7 +293,8 @@ const chains = {
282
293
  address: "0xcA11bde05977b3631167028862bE2a173976CA11",
283
294
  blockCreated: 484490
284
295
  }
285
- }
296
+ },
297
+ gasLimit: 550000000n
286
298
  }),
287
299
  Lisk: (0, import_viem.defineChain)({
288
300
  ...import_chains.lisk,
@@ -294,7 +306,8 @@ const chains = {
294
306
  wellKnownToken: {
295
307
  address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
296
308
  symbol: "USDC.e"
297
- }
309
+ },
310
+ gasLimit: 550000000n
298
311
  }),
299
312
  Plasma: (0, import_viem.defineChain)({
300
313
  ...import_chains.plasma,
@@ -315,7 +328,8 @@ const chains = {
315
328
  address: "0xcA11bde05977b3631167028862bE2a173976CA11"
316
329
  }
317
330
  },
318
- firstBlock: 670913n
331
+ firstBlock: 670913n,
332
+ gasLimit: 550000000n
319
333
  }),
320
334
  Somnia: (0, import_viem.defineChain)({
321
335
  ...import_chains.somnia,
@@ -335,7 +349,8 @@ const chains = {
335
349
  address: "0x67B302E35Aef5EEE8c32D934F5856869EF428330",
336
350
  symbol: "USDT"
337
351
  },
338
- firstBlock: 147687380n
352
+ firstBlock: 147687380n,
353
+ gasLimit: 550000000n
339
354
  })
340
355
  };
341
356
  const networkByChainId = Object.values(chains).reduce((acc, chain) => {
@@ -36,7 +36,6 @@ __export(address_provider_exports, {
36
36
  AP_GEAR_TOKEN: () => AP_GEAR_TOKEN,
37
37
  AP_INFLATION_ATTACK_BLOCKER: () => AP_INFLATION_ATTACK_BLOCKER,
38
38
  AP_INSOLVENCY_CHECKER: () => AP_INSOLVENCY_CHECKER,
39
- AP_KYC_COMPRESSOR: () => AP_KYC_COMPRESSOR,
40
39
  AP_MARKET_COMPRESSOR: () => AP_MARKET_COMPRESSOR,
41
40
  AP_MARKET_CONFIGURATOR: () => AP_MARKET_CONFIGURATOR,
42
41
  AP_PARTIAL_LIQUIDATION_BOT: () => AP_PARTIAL_LIQUIDATION_BOT,
@@ -88,7 +87,6 @@ const AP_WETH_GATEWAY = "WETH_GATEWAY";
88
87
  const AP_WETH_TOKEN = "WETH_TOKEN";
89
88
  const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
90
89
  const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
91
- const AP_KYC_COMPRESSOR = "GLOBAL::KYC_COMPRESSOR";
92
90
  const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
93
91
  // Annotate the CommonJS export names for ESM import in node:
94
92
  0 && (module.exports = {
@@ -110,7 +108,6 @@ const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
110
108
  AP_GEAR_TOKEN,
111
109
  AP_INFLATION_ATTACK_BLOCKER,
112
110
  AP_INSOLVENCY_CHECKER,
113
- AP_KYC_COMPRESSOR,
114
111
  AP_MARKET_COMPRESSOR,
115
112
  AP_MARKET_CONFIGURATOR,
116
113
  AP_PARTIAL_LIQUIDATION_BOT,
@@ -29,9 +29,6 @@ var import_MarketConfiguratorContract = require("./MarketConfiguratorContract.js
29
29
  var import_MarketSuite = require("./MarketSuite.js");
30
30
  var import_ZapperRegister = require("./ZapperRegister.js");
31
31
  class MarketRegister extends import_ZapperRegister.ZapperRegister {
32
- /**
33
- * Mapping pool.address -> MarketSuite
34
- */
35
32
  #markets = new import_utils.AddressMap(void 0, "markets");
36
33
  #marketFilter;
37
34
  #marketConfigurators = new import_utils.AddressMap(
@@ -45,7 +42,9 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
45
42
  **/
46
43
  constructor(sdk, ignoreMarkets = []) {
47
44
  super(sdk);
48
- this.#ignoreMarkets = new import_utils.AddressSet(ignoreMarkets);
45
+ this.#ignoreMarkets = new Set(
46
+ ignoreMarkets.map((m) => m.toLowerCase())
47
+ );
49
48
  }
50
49
  /**
51
50
  * Restores market state from a previously serialized snapshot,
@@ -53,41 +52,40 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
53
52
  * @param state - Array of market data snapshots.
54
53
  **/
55
54
  hydrate(state) {
55
+ this.#markets.clear();
56
56
  const configurators = new Set(state.map((m) => m.configurator));
57
57
  this.#setMarketFilter([...configurators]);
58
- this.#setMarkets(state);
58
+ for (const data of state) {
59
+ const pool = data.pool.baseParams.addr;
60
+ if (this.#ignoreMarkets.has(pool.toLowerCase())) {
61
+ this.logger?.debug(
62
+ `ignoring market of pool ${pool} (${data.pool.name})`
63
+ );
64
+ continue;
65
+ }
66
+ this.#markets.upsert(
67
+ data.pool.baseParams.addr,
68
+ new import_MarketSuite.MarketSuite(this.sdk, data)
69
+ );
70
+ }
59
71
  }
60
72
  /**
61
- * @internal
62
- * Returns delegated multicalls for loading all markets from the on-chain
63
- * market compressor. Used by the SDK to compose batched RPC calls.
73
+ * Fetches all markets from the on-chain for the given market configurators.
64
74
  *
65
- * @param configurators - Addresses of market configurator contracts to query.
75
+ * @param marketConfigurators - Addresses of market configurator contracts to query.
76
+ * @param ignoreUpdateablePrices - When `true`, skips generating off-chain
77
+ * price updates before loading
66
78
  **/
67
- getLoadMulticalls(configurators) {
68
- this.#setMarketFilter(configurators);
69
- const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
70
- import_constants.AP_MARKET_COMPRESSOR,
71
- import_constants.VERSION_RANGE_310
72
- );
73
- return [
74
- {
75
- call: {
76
- abi: import_marketCompressor.marketCompressorAbi,
77
- address: marketCompressorAddress,
78
- functionName: "getMarkets",
79
- args: [this.marketFilter]
80
- },
81
- onResult: (resp) => {
82
- this.#setMarkets(resp);
83
- this.logger?.info(
84
- `loaded ${this.#markets.size} markets in block ${this.sdk.currentBlock}`
85
- );
86
- }
87
- }
88
- ];
79
+ async loadMarkets(marketConfigurators, ignoreUpdateablePrices) {
80
+ if (!marketConfigurators.length) {
81
+ this.logger?.warn(
82
+ "no market configurators provided, skipping loadMarkets"
83
+ );
84
+ return;
85
+ }
86
+ await this.#loadMarkets(marketConfigurators, [], ignoreUpdateablePrices);
89
87
  }
90
- #setMarketFilter(configurators) {
88
+ #setMarketFilter(configurators, pools = []) {
91
89
  for (const c of configurators) {
92
90
  this.#marketConfigurators.upsert(
93
91
  c,
@@ -96,7 +94,7 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
96
94
  }
97
95
  this.#marketFilter = {
98
96
  configurators,
99
- pools: [],
97
+ pools,
100
98
  underlying: import_constants.ADDRESS_0X0
101
99
  };
102
100
  }
@@ -123,45 +121,106 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
123
121
  **/
124
122
  async syncState(ignoreUpdateablePrices) {
125
123
  const dirty = this.markets.some((m) => m.dirty) || this.marketConfigurators.some((c) => c.dirty);
126
- let multicalls;
127
- let txs = [];
128
124
  if (dirty) {
129
125
  this.logger?.debug(
130
126
  "some markets or market configurators are dirty, reloading everything"
131
127
  );
132
- multicalls = this.getLoadMulticalls([...this.marketFilter.configurators]);
133
- if (!ignoreUpdateablePrices) {
134
- const updatables = await this.sdk.priceFeeds.getPartialUpdatablePriceFeeds([
135
- ...this.marketFilter.configurators
136
- ]);
137
- const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(updatables);
138
- txs = updates.txs;
139
- }
128
+ await this.#loadMarkets(
129
+ [...this.marketFilter.configurators],
130
+ [...this.marketFilter.pools],
131
+ ignoreUpdateablePrices
132
+ );
140
133
  } else if (!ignoreUpdateablePrices) {
141
- multicalls = this.#getOracleSyncMulticalls();
142
- if (!multicalls.length) {
143
- return;
144
- }
145
- this.logger?.debug(`syncing prices on ${multicalls.length} oracles`);
146
- const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
134
+ await this.updatePrices();
135
+ }
136
+ }
137
+ async #loadMarkets(configurators, pools, ignoreUpdateablePrices) {
138
+ this.#setMarketFilter(configurators, pools);
139
+ const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
140
+ import_constants.AP_MARKET_COMPRESSOR,
141
+ import_constants.VERSION_RANGE_310
142
+ );
143
+ let txs = [];
144
+ if (!ignoreUpdateablePrices) {
145
+ const updatables = await this.sdk.priceFeeds.getPartialUpdatablePriceFeeds(
146
+ configurators,
147
+ pools
148
+ );
149
+ const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(updatables);
147
150
  txs = updates.txs;
151
+ }
152
+ this.logger?.debug(
153
+ { configurators, pools },
154
+ `calling getMarkets with ${txs.length} price updates in block ${this.sdk.currentBlock}`
155
+ );
156
+ let markets = [];
157
+ if (txs.length) {
158
+ const [resp] = await (0, import_viem.simulateWithPriceUpdates)(this.client, {
159
+ priceUpdates: txs,
160
+ contracts: [
161
+ {
162
+ abi: import_marketCompressor.marketCompressorAbi,
163
+ address: marketCompressorAddress,
164
+ functionName: "getMarkets",
165
+ args: [this.marketFilter]
166
+ }
167
+ ],
168
+ blockNumber: this.sdk.currentBlock,
169
+ gas: this.sdk.gasLimit
170
+ });
171
+ markets = resp;
148
172
  } else {
149
- return;
173
+ markets = await this.client.readContract({
174
+ abi: import_marketCompressor.marketCompressorAbi,
175
+ address: marketCompressorAddress,
176
+ functionName: "getMarkets",
177
+ args: [this.marketFilter],
178
+ blockNumber: this.sdk.currentBlock,
179
+ // @ts-expect-error
180
+ gas: this.sdk.gasLimit
181
+ });
150
182
  }
151
- await (0, import_viem.executeDelegatedMulticalls)(this.client, multicalls, {
152
- priceUpdates: txs,
153
- blockNumber: this.sdk.currentBlock,
154
- gas: this.sdk.gasLimit
155
- });
183
+ for (const data of markets) {
184
+ const pool = data.pool.baseParams.addr;
185
+ if (this.#ignoreMarkets.has(pool.toLowerCase())) {
186
+ this.logger?.debug(
187
+ `ignoring market of pool ${pool} (${data.pool.name})`
188
+ );
189
+ continue;
190
+ }
191
+ this.#markets.upsert(pool, new import_MarketSuite.MarketSuite(this.sdk, data));
192
+ }
193
+ this.logger?.info(
194
+ `loaded ${this.#markets.size} markets in block ${this.sdk.currentBlock}`
195
+ );
156
196
  }
157
- #getOracleSyncMulticalls(oracles) {
197
+ /**
198
+ * Loads new prices and price feeds for given oracles from PriceFeedCompressor, defaults to all oracles
199
+ */
200
+ async updatePrices(oracles) {
158
201
  const uniqOracles = new import_utils.AddressMap();
159
202
  for (const m of this.markets) {
160
203
  if (!oracles || oracles.includes(m.priceOracle.address)) {
161
204
  uniqOracles.upsert(m.priceOracle.address, m.priceOracle);
162
205
  }
163
206
  }
164
- return uniqOracles.values().map((o) => o.syncStateMulticall());
207
+ const multicalls = uniqOracles.values().map((o) => o.syncStateMulticall());
208
+ if (!multicalls.length) {
209
+ return;
210
+ }
211
+ this.logger?.debug(`syncing prices on ${multicalls.length} oracles`);
212
+ const { txs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
213
+ const oraclesStates = await (0, import_viem.simulateWithPriceUpdates)(this.client, {
214
+ priceUpdates: txs,
215
+ contracts: multicalls.map((mc) => mc.call),
216
+ gas: this.sdk.gasLimit,
217
+ blockNumber: this.sdk.currentBlock
218
+ });
219
+ for (let i = 0; i < multicalls.length; i++) {
220
+ const handler = multicalls[i].onResult;
221
+ const result = oraclesStates[i];
222
+ handler(result);
223
+ }
165
224
  }
166
225
  get watchAddresses() {
167
226
  return /* @__PURE__ */ new Set([
@@ -282,19 +341,6 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
282
341
  get markets() {
283
342
  return this.#markets.values();
284
343
  }
285
- #setMarkets(markets) {
286
- this.#markets.clear();
287
- for (const data of markets) {
288
- const pool = data.pool.baseParams.addr;
289
- if (this.#ignoreMarkets.has(pool)) {
290
- this.logger?.debug(
291
- `ignoring market of pool ${pool} (${data.pool.name})`
292
- );
293
- continue;
294
- }
295
- this.#markets.upsert(pool, new import_MarketSuite.MarketSuite(this.sdk, data));
296
- }
297
- }
298
344
  }
299
345
  // Annotate the CommonJS export names for ESM import in node:
300
346
  0 && (module.exports = {
@@ -65,9 +65,6 @@ class MarketSuite extends import_base.SDKConstruct {
65
65
  get underlying() {
66
66
  return this.pool.underlying;
67
67
  }
68
- get kycFactory() {
69
- return this.pool.kycFactory;
70
- }
71
68
  get dirty() {
72
69
  return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
73
70
  }
@@ -17,7 +17,6 @@ var market_exports = {};
17
17
  module.exports = __toCommonJS(market_exports);
18
18
  __reExport(market_exports, require("./adapters/index.js"), module.exports);
19
19
  __reExport(market_exports, require("./credit/index.js"), module.exports);
20
- __reExport(market_exports, require("./kyc/index.js"), module.exports);
21
20
  __reExport(market_exports, require("./MarketRegister.js"), module.exports);
22
21
  __reExport(market_exports, require("./MarketSuite.js"), module.exports);
23
22
  __reExport(market_exports, require("./oracle/index.js"), module.exports);
@@ -28,7 +27,6 @@ __reExport(market_exports, require("./types.js"), module.exports);
28
27
  0 && (module.exports = {
29
28
  ...require("./adapters/index.js"),
30
29
  ...require("./credit/index.js"),
31
- ...require("./kyc/index.js"),
32
30
  ...require("./MarketRegister.js"),
33
31
  ...require("./MarketSuite.js"),
34
32
  ...require("./oracle/index.js"),
@@ -88,9 +88,6 @@ class PoolSuite extends import_base.SDKConstruct {
88
88
  get underlying() {
89
89
  return this.pool.underlying;
90
90
  }
91
- get kycFactory() {
92
- return this.pool.kycFactory;
93
- }
94
91
  get dirty() {
95
92
  return this.pool.dirty || this.rateKeeper.dirty || this.pqk.dirty || this.interestRateModel.dirty;
96
93
  }
@@ -28,15 +28,13 @@ var import_utils = require("../../utils/index.js");
28
28
  const abi = [...import_generated.iPoolV310Abi, ...import_iPausable.iPausableAbi];
29
29
  class PoolV310Contract extends import_base.BaseContract {
30
30
  creditManagerDebtParams;
31
- #sdk;
32
- constructor(sdk, data) {
31
+ constructor(options, data) {
33
32
  const { baseParams, creditManagerDebtParams, ...rest } = data;
34
- super(sdk, {
33
+ super(options, {
35
34
  ...data.baseParams,
36
35
  name: `PoolV3(${data.name})`,
37
36
  abi
38
37
  });
39
- this.#sdk = sdk;
40
38
  Object.assign(this, rest);
41
39
  this.creditManagerDebtParams = new import_utils.AddressMap(
42
40
  creditManagerDebtParams.map((p) => [p.creditManager, p])
@@ -48,13 +46,6 @@ class PoolV310Contract extends import_base.BaseContract {
48
46
  symbol: data.symbol
49
47
  });
50
48
  }
51
- get kycFactory() {
52
- const meta = this.#sdk.tokensMeta.mustGet(this.underlying);
53
- if (this.#sdk.tokensMeta.isKYCUnderlying(meta)) {
54
- return this.#sdk.mustGetContract(meta.kycFactory);
55
- }
56
- return void 0;
57
- }
58
49
  stateHuman(raw = true) {
59
50
  return {
60
51
  ...super.stateHuman(raw),
@@ -18,13 +18,11 @@ module.exports = __toCommonJS(pool_exports);
18
18
  __reExport(pool_exports, require("./GaugeContract.js"), module.exports);
19
19
  __reExport(pool_exports, require("./LinearInterestRateModelContract.js"), module.exports);
20
20
  __reExport(pool_exports, require("./PoolSuite.js"), module.exports);
21
- __reExport(pool_exports, require("./PoolV310Contract.js"), module.exports);
22
21
  __reExport(pool_exports, require("./types.js"), module.exports);
23
22
  // Annotate the CommonJS export names for ESM import in node:
24
23
  0 && (module.exports = {
25
24
  ...require("./GaugeContract.js"),
26
25
  ...require("./LinearInterestRateModelContract.js"),
27
26
  ...require("./PoolSuite.js"),
28
- ...require("./PoolV310Contract.js"),
29
27
  ...require("./types.js")
30
28
  });
@@ -237,13 +237,13 @@ class PriceFeedRegister extends import_base.SDKConstruct {
237
237
  * Loads PARTIAL information about all updatable price feeds from MarketCompressor
238
238
  * Discovered price feeds are not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
239
239
  */
240
- async getPartialUpdatablePriceFeeds(configurators) {
240
+ async getPartialUpdatablePriceFeeds(configurators, pools) {
241
241
  const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
242
242
  import_constants.AP_PRICE_FEED_COMPRESSOR,
243
243
  import_constants.VERSION_RANGE_310
244
244
  );
245
245
  this.logger?.debug(
246
- { configurators },
246
+ { configurators, pools },
247
247
  `calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`
248
248
  );
249
249
  const result = await this.client.readContract({
@@ -253,7 +253,7 @@ class PriceFeedRegister extends import_base.SDKConstruct {
253
253
  args: [
254
254
  {
255
255
  configurators,
256
- pools: [],
256
+ pools: pools ?? [],
257
257
  underlying: import_constants.ADDRESS_0X0
258
258
  }
259
259
  ],
@@ -36,12 +36,6 @@ const SDKOptions = import_v4.z.object({
36
36
  * (from {@link GearboxChain.defaultMarketConfigurators})
37
37
  **/
38
38
  marketConfigurators: import_v4.z.array((0, import_utils.ZodAddress)()).optional(),
39
- /**
40
- * Addresses of KYC factory contracts to load.
41
- * If not set, all default KYC factories for the chain are loaded
42
- * (from {@link GearboxChain.kycFactories})
43
- **/
44
- kycFactories: import_v4.z.array((0, import_utils.ZodAddress)()).optional(),
45
39
  /**
46
40
  * Pin SDK to a specific block number during attach.
47
41
  * When set, all on-chain reads use this block instead of `latest`.
@@ -80,7 +74,7 @@ const SDKOptions = import_v4.z.object({
80
74
  /**
81
75
  * Explicit gas limit for read-only `eth_call` requests.
82
76
  * `null` disables the gas limit entirely; `undefined` uses the SDK default.
83
- * Default gas limit is 550_000_000 (550M).
77
+ * Default to value from {@link GearboxChain.gasLimit}
84
78
  **/
85
79
  gasLimit: import_v4.z.bigint().nonnegative().nullable().optional()
86
80
  });