@gearbox-protocol/sdk 15.1.0-next.1 → 15.1.0-next.2

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 (65) hide show
  1. package/dist/cjs/abi/iExpirable.js +15 -0
  2. package/dist/cjs/dev/AccountOpener.js +0 -1
  3. package/dist/cjs/sdk/MultichainSDK.js +3 -4
  4. package/dist/cjs/sdk/OnchainSDK.js +42 -13
  5. package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +29 -18
  6. package/dist/cjs/sdk/base/TokensMeta.js +78 -27
  7. package/dist/cjs/sdk/index.js +2 -0
  8. package/dist/cjs/sdk/market/MarketRegister.js +16 -7
  9. package/dist/cjs/sdk/market/ZapperRegister.js +56 -25
  10. package/dist/cjs/sdk/market/rwa/RWARegistry.js +22 -0
  11. package/dist/cjs/sdk/options.js +1 -5
  12. package/dist/cjs/sdk/utils/viem/executeMulticallBatches.js +32 -0
  13. package/dist/cjs/sdk/utils/viem/index.js +2 -0
  14. package/dist/esm/abi/iExpirable.js +14 -0
  15. package/dist/esm/dev/AccountOpener.js +1 -2
  16. package/dist/esm/dev/withdrawalUtils.js +1 -1
  17. package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +1 -1
  18. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  19. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  20. package/dist/esm/sdk/MultichainSDK.js +3 -4
  21. package/dist/esm/sdk/OnchainSDK.js +42 -13
  22. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
  23. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
  24. package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +29 -18
  25. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  26. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  27. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  28. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  29. package/dist/esm/sdk/base/TokensMeta.js +80 -29
  30. package/dist/esm/sdk/chain/detectNetwork.js +1 -1
  31. package/dist/esm/sdk/core/createAddressProvider.js +1 -1
  32. package/dist/esm/sdk/index.js +2 -1
  33. package/dist/esm/sdk/market/MarketRegister.js +16 -7
  34. package/dist/esm/sdk/market/ZapperRegister.js +56 -25
  35. package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
  36. package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
  37. package/dist/esm/sdk/market/rwa/RWARegistry.js +22 -0
  38. package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
  39. package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
  40. package/dist/esm/sdk/options.js +1 -5
  41. package/dist/esm/sdk/pools/PoolService.js +1 -1
  42. package/dist/esm/sdk/utils/viem/executeMulticallBatches.js +31 -0
  43. package/dist/esm/sdk/utils/viem/index.js +2 -1
  44. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
  45. package/dist/types/abi/iExpirable.d.ts +14 -0
  46. package/dist/types/sdk/MultichainSDK.d.ts +0 -5
  47. package/dist/types/sdk/OnchainSDK.d.ts +1 -5
  48. package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +6 -0
  49. package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +18 -0
  50. package/dist/types/sdk/base/TokensMeta.d.ts +44 -1
  51. package/dist/types/sdk/base/index.d.ts +2 -2
  52. package/dist/types/sdk/base/token-types.d.ts +12 -1
  53. package/dist/types/sdk/index.d.ts +12 -11
  54. package/dist/types/sdk/market/MarketRegister.d.ts +7 -3
  55. package/dist/types/sdk/market/ZapperRegister.d.ts +20 -2
  56. package/dist/types/sdk/market/index.d.ts +2 -2
  57. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -2
  58. package/dist/types/sdk/market/oracle/types.d.ts +2 -2
  59. package/dist/types/sdk/market/rwa/RWARegistry.d.ts +13 -0
  60. package/dist/types/sdk/market/types.d.ts +5 -1
  61. package/dist/types/sdk/options.d.ts +0 -1
  62. package/dist/types/sdk/types/state.d.ts +6 -0
  63. package/dist/types/sdk/utils/viem/executeMulticallBatches.d.ts +39 -0
  64. package/dist/types/sdk/utils/viem/index.d.ts +3 -2
  65. package/package.json +1 -1
@@ -0,0 +1,32 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/sdk/utils/viem/executeMulticallBatches.ts
3
+ /**
4
+ * Executes the calls of several {@link MulticallBatch}es as a single multicall
5
+ * aggregate and dispatches each batch its own slice of the results.
6
+ *
7
+ * Failures are allowed per call: loaders in a batch decide themselves how to
8
+ * treat a reverted call (e.g. `contractType()` reverting on a plain ERC-20 is
9
+ * expected). Use {@link executeDelegatedMulticalls} instead when the calls need
10
+ * price updates applied first.
11
+ *
12
+ * @param client - Viem public client.
13
+ * @param batches - Batches to execute together, empty ones are allowed.
14
+ * @param opts - Block number forwarded to the multicall.
15
+ **/
16
+ async function executeMulticallBatches(client, batches, opts = {}) {
17
+ const contracts = batches.flatMap((b) => b.contracts);
18
+ if (!contracts.length) return;
19
+ const results = await client.multicall({
20
+ contracts,
21
+ allowFailure: true,
22
+ batchSize: 0,
23
+ blockNumber: opts.blockNumber
24
+ });
25
+ let offset = 0;
26
+ for (const batch of batches) {
27
+ batch.onResults(results.slice(offset, offset + batch.contracts.length));
28
+ offset += batch.contracts.length;
29
+ }
30
+ }
31
+ //#endregion
32
+ exports.executeMulticallBatches = executeMulticallBatches;
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_sdk_utils_viem_cast = require("./cast.js");
3
3
  const require_sdk_utils_viem_simulateCall = require("./simulateCall.js");
4
+ const require_sdk_utils_viem_executeMulticallBatches = require("./executeMulticallBatches.js");
4
5
  const require_sdk_utils_viem_simulateMulticall = require("./simulateMulticall.js");
5
6
  const require_sdk_utils_viem_simulateWithPriceUpdates = require("./simulateWithPriceUpdates.js");
6
7
  const require_sdk_utils_viem_executeDelegatedMulticalls = require("./executeDelegatedMulticalls.js");
@@ -10,6 +11,7 @@ exports.SimulateWithPriceUpdatesError = require_sdk_utils_viem_simulateWithPrice
10
11
  exports.SimulationError = require_sdk_utils_viem_simulateCall.SimulationError;
11
12
  exports.estimateRawTxGas = require_sdk_utils_viem_sendRawTx.estimateRawTxGas;
12
13
  exports.executeDelegatedMulticalls = require_sdk_utils_viem_executeDelegatedMulticalls.executeDelegatedMulticalls;
14
+ exports.executeMulticallBatches = require_sdk_utils_viem_executeMulticallBatches.executeMulticallBatches;
13
15
  exports.generateCastTraceCall = require_sdk_utils_viem_cast.generateCastTraceCall;
14
16
  exports.getCastTraceArgs = require_sdk_utils_viem_cast.getCastTraceArgs;
15
17
  exports.getSimulateWithPriceUpdatesError = require_sdk_utils_viem_simulateWithPriceUpdates.getSimulateWithPriceUpdatesError;
@@ -0,0 +1,14 @@
1
+ //#region src/abi/iExpirable.ts
2
+ const iExpirableAbi = [{
3
+ type: "function",
4
+ inputs: [],
5
+ name: "isExpired",
6
+ outputs: [{
7
+ name: "",
8
+ internalType: "bool",
9
+ type: "bool"
10
+ }],
11
+ stateMutability: "view"
12
+ }];
13
+ //#endregion
14
+ export { iExpirableAbi };
@@ -1,9 +1,9 @@
1
+ import { ierc20Abi } from "../abi/iERC20.js";
1
2
  import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
2
3
  import { AddressMap } from "../sdk/utils/AddressMap.js";
3
4
  import { AddressSet } from "../sdk/utils/AddressSet.js";
4
5
  import { AssetsMap } from "../sdk/utils/AssetsMap.js";
5
6
  import { childLogger } from "../sdk/utils/childLogger.js";
6
- import { ierc20Abi } from "../abi/iERC20.js";
7
7
  import "../sdk/constants/addresses.js";
8
8
  import { MAX_UINT256, PERCENTAGE_FACTOR } from "../sdk/constants/math.js";
9
9
  import { SDKConstruct } from "../sdk/base/SDKConstruct.js";
@@ -86,7 +86,6 @@ var AccountOpener = class extends SDKConstruct {
86
86
  depositIntoPools,
87
87
  claimFromFaucet
88
88
  }, "opening credit accounts");
89
- await Promise.all([this.sdk.tokensMeta.loadTokenData(), this.sdk.marketRegister.loadZappers()]);
90
89
  let deposits = [];
91
90
  if (depositIntoPools) try {
92
91
  deposits = await this.#depositIntoPools(targets);
@@ -1,6 +1,6 @@
1
+ import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
1
2
  import { getNetworkType } from "../sdk/chain/chains.js";
2
3
  import { getWithdrawalCompressorAddress } from "../sdk/accounts/withdrawal-compressor/addresses.js";
3
- import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
4
4
  import "../sdk/index.js";
5
5
  import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
6
6
  import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
@@ -1,5 +1,5 @@
1
- import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
2
1
  import { ierc4626AdapterAbi } from "../../../abi/ierc4626Adapter.js";
2
+ import { MissingSerializedParamsError } from "../../../sdk/base/errors.js";
3
3
  import "../../../sdk/index.js";
4
4
  import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
5
5
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
@@ -1,5 +1,5 @@
1
- import { iPoolV310Abi } from "../../abi/310/generated.js";
2
1
  import { iZapperAbi } from "../../abi/iZapper.js";
2
+ import { iPoolV310Abi } from "../../abi/310/generated.js";
3
3
  import { asPreviewSimulationError } from "./errors.js";
4
4
  //#region src/preview/simulate/simulatePoolOperation.ts
5
5
  function previewRead(operation) {
@@ -1,6 +1,6 @@
1
+ import { ierc20Abi } from "../../abi/iERC20.js";
1
2
  import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
2
3
  import { AddressMap } from "../../sdk/utils/AddressMap.js";
3
- import { ierc20Abi } from "../../abi/iERC20.js";
4
4
  import "../../sdk/index.js";
5
5
  import { UnexpectedFacadeEventOrderError } from "./errors.js";
6
6
  import { getAddress, isAddressEqual, parseEventLogs } from "viem";
@@ -68,7 +68,6 @@ var MultichainSDK = class {
68
68
  const perChainOpts = options?.perChain?.[network] ?? {};
69
69
  return sdk.attach({
70
70
  ...perChainOpts,
71
- loadZappers: perChainOpts.loadZappers ?? options?.loadZappers,
72
71
  redstone: {
73
72
  ...options?.redstone,
74
73
  cache: this.#redstoneCache,
@@ -88,7 +87,7 @@ var MultichainSDK = class {
88
87
  * state and `allowMissingChains` is not set.
89
88
  */
90
89
  hydrate(state, options) {
91
- if (state.version !== 1) throw new SdkStateVersionMismatchError(1, state.version);
90
+ if (state.version !== 2) throw new SdkStateVersionMismatchError(2, state.version);
92
91
  if (options?.redstone) this.#redstoneCache = new PriceUpdatesCache({
93
92
  ttl: options.redstone.cacheTTL ?? 225e3,
94
93
  historical: !!options.redstone.historicTimestamp
@@ -168,7 +167,7 @@ var MultichainSDK = class {
168
167
  **/
169
168
  get state() {
170
169
  return {
171
- version: 1,
170
+ version: 2,
172
171
  chains: [...this.#chains.values()].map((sdk) => sdk.state)
173
172
  };
174
173
  }
@@ -178,7 +177,7 @@ var MultichainSDK = class {
178
177
  */
179
178
  stateHuman(raw) {
180
179
  return {
181
- version: 1,
180
+ version: 2,
182
181
  chains: [...this.#chains.values()].map((sdk) => sdk.stateHuman(raw))
183
182
  };
184
183
  }
@@ -7,6 +7,7 @@ import "./constants/index.js";
7
7
  import { formatTimestamp } from "./utils/formatter.js";
8
8
  import { toAddress } from "./utils/toAddress.js";
9
9
  import "./utils/index.js";
10
+ import { executeMulticallBatches } from "./utils/viem/executeMulticallBatches.js";
10
11
  import { ChainContractsRegister } from "./base/ChainContractsRegister.js";
11
12
  import "./base/index.js";
12
13
  import { executeDelegatedMulticalls } from "./utils/viem/executeDelegatedMulticalls.js";
@@ -40,7 +41,7 @@ import { createPublicClient, fallback, http, parseEventLogs } from "viem";
40
41
  * Serialised state format version, checked during hydration to detect
41
42
  * incompatible snapshots.
42
43
  **/
43
- const STATE_VERSION = 1;
44
+ const STATE_VERSION = 2;
44
45
  /**
45
46
  * @internal
46
47
  * Creates a viem `PublicClient` from the given connection options.
@@ -150,7 +151,7 @@ var OnchainSDK = class extends ChainContractsRegister {
150
151
  */
151
152
  async attach(options) {
152
153
  if (this.#attached) throw new SdkAlreadyAttachedError();
153
- const { addressProvider = ADDRESS_PROVIDER_V310, blockNumber, ignoreUpdateablePrices, ignoreMarkets, marketConfigurators: mcs, redstone, loadZappers } = options ?? {};
154
+ const { addressProvider = ADDRESS_PROVIDER_V310, blockNumber, ignoreUpdateablePrices, ignoreMarkets, marketConfigurators: mcs, redstone } = options ?? {};
154
155
  const marketConfigurators = mcs ?? TypedObjectUtils.keys(this.client.chain.defaultMarketConfigurators);
155
156
  const rwaFactories = options?.rwaFactories ?? this.client.chain.rwaFactories;
156
157
  this.logger?.info({
@@ -174,19 +175,15 @@ var OnchainSDK = class extends ChainContractsRegister {
174
175
  this.#marketRegister = new MarketRegister(this, ignoreMarkets);
175
176
  if (!marketConfigurators.length) this.logger?.warn("no market configurators provided, skipping market loading");
176
177
  else {
178
+ const priceUpdates = await this.#getPriceUpdateTxs(marketConfigurators, ignoreUpdateablePrices);
179
+ this.logger?.debug({ configurators: marketConfigurators }, `calling getMarkets with ${priceUpdates.length} price updates in block ${this.currentBlock}`);
177
180
  const delegated = [...this.#marketRegister.getLoadMulticalls(marketConfigurators), ...this.#rwa.getLoadMulticalls(marketConfigurators, rwaFactories)];
178
- let txs = [];
179
- if (!ignoreUpdateablePrices) {
180
- const updatables = await this.#priceFeeds.getPartialUpdatablePriceFeeds(marketConfigurators);
181
- txs = (await this.#priceFeeds.generatePriceFeedsUpdateTxs(updatables)).txs;
182
- }
183
- this.logger?.debug({ configurators: marketConfigurators }, `calling getMarkets with ${txs.length} price updates in block ${this.currentBlock}`);
184
181
  await executeDelegatedMulticalls(this.client, delegated, {
185
- priceUpdates: txs,
182
+ priceUpdates,
186
183
  blockNumber: this.currentBlock,
187
184
  gas: this.gasLimit
188
185
  });
189
- if (loadZappers) await this.#marketRegister.loadZappers();
186
+ await this.#warmup();
190
187
  }
191
188
  const pluginsList = TypedObjectUtils.entries(this.plugins);
192
189
  (await Promise.allSettled(pluginsList.map(([name, plugin]) => {
@@ -203,6 +200,36 @@ var OnchainSDK = class extends ChainContractsRegister {
203
200
  this.#attached = true;
204
201
  }
205
202
  /**
203
+ * @internal
204
+ * Pass 0 of attach: resolves the price updates that the market reads of
205
+ * pass 1 are simulated with.
206
+ *
207
+ * @param configurators - Market configurators whose feeds are considered.
208
+ * @param ignoreUpdateablePrices - When `true`, no updates are fetched.
209
+ **/
210
+ async #getPriceUpdateTxs(configurators, ignoreUpdateablePrices) {
211
+ if (ignoreUpdateablePrices) return [];
212
+ const updatables = await this.priceFeeds.getPartialUpdatablePriceFeeds(configurators);
213
+ const { txs } = await this.priceFeeds.generatePriceFeedsUpdateTxs(updatables);
214
+ return txs;
215
+ }
216
+ /**
217
+ * @internal
218
+ * Pass 2 of attach: loads the data that is read synchronously afterwards
219
+ * (zappers, withdrawable assets, extended token data) in a single multicall.
220
+ *
221
+ * Also re-run after a sync that reloaded the markets these caches derive from.
222
+ *
223
+ * @param force - Reload caches that are already populated.
224
+ **/
225
+ async #warmup(force = false) {
226
+ await executeMulticallBatches(this.client, [
227
+ this.marketRegister.getLoadZappersMulticall(force),
228
+ ...this.#withdrawalCompressor ? [this.#withdrawalCompressor.getLoadWithdrawableAssetsMulticall(force)] : [],
229
+ this.tokensMeta.getLoadTokenDataMulticall()
230
+ ], { blockNumber: this.currentBlock });
231
+ }
232
+ /**
206
233
  * Restores SDK state from a previously serialised {@link GearboxState}
207
234
  * snapshot, without making any on-chain calls.
208
235
  *
@@ -214,7 +241,7 @@ var OnchainSDK = class extends ChainContractsRegister {
214
241
  */
215
242
  hydrate(state, options) {
216
243
  if (this.#attached) throw new SdkAlreadyAttachedError();
217
- if (state.version !== 1) throw new SdkStateVersionMismatchError(1, state.version);
244
+ if (state.version !== 2) throw new SdkStateVersionMismatchError(2, state.version);
218
245
  if (state.network !== this.networkType) throw new SdkChainMismatchError(this.networkType, state.network);
219
246
  const { ignoreMarkets, redstone } = options ?? {};
220
247
  this.logger?.info({ networkType: this.networkType }, "hydrating sdk state");
@@ -228,6 +255,7 @@ var OnchainSDK = class extends ChainContractsRegister {
228
255
  this.#rwa = new RWARegistry(this);
229
256
  this.#rwa.setState(state.rwa);
230
257
  if (state.withdrawals) this.#withdrawalCompressor?.hydrate(state.withdrawals);
258
+ if (state.tokens) this.tokensMeta.hydrate(state.tokens);
231
259
  for (const [name, plugin] of TypedObjectUtils.entries(this.plugins)) {
232
260
  const pluginState = state.plugins[name];
233
261
  if (plugin.hydrate && pluginState) {
@@ -273,13 +301,14 @@ var OnchainSDK = class extends ChainContractsRegister {
273
301
  /** Serialisable snapshot of the current SDK state. */
274
302
  get state() {
275
303
  return {
276
- version: 1,
304
+ version: 2,
277
305
  network: this.networkType,
278
306
  chainId: this.chainId,
279
307
  currentBlock: this.currentBlock,
280
308
  timestamp: this.timestamp,
281
309
  addressProvider: this.addressProvider.state,
282
310
  ...this.marketRegister.state,
311
+ tokens: this.tokensMeta.state,
283
312
  rwa: this.#rwa.state,
284
313
  withdrawals: this.#withdrawalCompressor?.state,
285
314
  plugins: Object.fromEntries(TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [name, plugin.loaded ? {
@@ -338,7 +367,7 @@ var OnchainSDK = class extends ChainContractsRegister {
338
367
  }
339
368
  this.#currentBlock = blockNumber;
340
369
  this.#timestamp = timestamp;
341
- await this.marketRegister.syncState(ignoreUpdateablePrices);
370
+ if (await this.marketRegister.syncState(ignoreUpdateablePrices, this.#rwa.getSyncMulticalls())) await this.#warmup(true);
342
371
  const pluginsList = TypedObjectUtils.entries(this.plugins);
343
372
  (await Promise.allSettled(pluginsList.map(([name, plugin]) => {
344
373
  if (plugin.syncState) {
@@ -1,3 +1,5 @@
1
+ import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
2
+ import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
1
3
  import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
2
4
  import { ADDRESS_0X0 } from "../constants/addresses.js";
3
5
  import { MAX_UINT256 } from "../constants/math.js";
@@ -8,8 +10,6 @@ import "../base/index.js";
8
10
  import { AccountBotsService } from "./bots/AccountBotsService.js";
9
11
  import "./bots/index.js";
10
12
  import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
11
- import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
12
- import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
13
13
  import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
14
14
  import "../market/index.js";
15
15
  import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
@@ -1,3 +1,4 @@
1
+ import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
1
2
  import { AddressSet } from "../../utils/AddressSet.js";
2
3
  import { bytes32ToString } from "../../utils/bytes32ToString.js";
3
4
  import { ADDRESS_0X0 } from "../../constants/addresses.js";
@@ -19,7 +20,6 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
19
20
  import "../../market/rwa/securitize/index.js";
20
21
  import "../../market/index.js";
21
22
  import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
22
- import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
23
23
  //#region src/sdk/accounts/liquidations/LiquidationsService.ts
24
24
  /**
25
25
  * Service for discovering liquidatable credit accounts and previewing manual
@@ -3,8 +3,10 @@ import "../../constants/addresses.js";
3
3
  import "../../constants/index.js";
4
4
  import { hexEq } from "../../utils/hex.js";
5
5
  import "../../utils/index.js";
6
+ import { executeMulticallBatches } from "../../utils/viem/executeMulticallBatches.js";
6
7
  import { BaseContract } from "../../base/BaseContract.js";
7
8
  import "../../base/index.js";
9
+ import "../../utils/viem/index.js";
8
10
  import { decodeDelayedIntent } from "./intent-codec.js";
9
11
  import { isAddressEqual } from "viem";
10
12
  //#region src/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.ts
@@ -57,37 +59,46 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
57
59
  **/
58
60
  getWithdrawableAssets(...creditManagers) {
59
61
  const cache = this.#withdrawableAssets;
60
- if (!cache) throw new Error("withdrawable assets are not loaded, call loadWithdrawableAssets first");
62
+ if (!cache) throw new Error("withdrawable assets are not loaded, check if the sdk was properly attached or hydrated");
61
63
  if (creditManagers.length === 0) return cache.values().flat();
62
64
  return creditManagers.flatMap((cm) => cache.get(cm) ?? []);
63
65
  }
64
66
  /**
65
- * {@inheritDoc IWithdrawalCompressorContract.loadWithdrawableAssets}
67
+ * {@inheritDoc IWithdrawalCompressorContract.getLoadWithdrawableAssetsMulticall}
66
68
  **/
67
- async loadWithdrawableAssets(force, blockNumber) {
68
- if (this.#withdrawableAssets && !force) return this.getWithdrawableAssets();
69
+ getLoadWithdrawableAssetsMulticall(force) {
70
+ if (this.#withdrawableAssets && !force) return {
71
+ contracts: [],
72
+ onResults: () => {}
73
+ };
69
74
  const cms = this.#sdk.marketRegister.creditManagers.map((cm) => cm.creditManager.address);
70
- const resp = await this.client.multicall({
75
+ return {
71
76
  contracts: cms.map((cm) => ({
72
77
  address: this.address,
73
78
  abi: this.abi,
74
79
  functionName: "getWithdrawableAssets",
75
80
  args: [cm]
76
81
  })),
77
- allowFailure: true,
78
- batchSize: 0,
79
- blockNumber
80
- });
81
- const cache = new AddressMap(void 0, MAP_LABEL);
82
- for (let i = 0; i < resp.length; i++) {
83
- const r = resp[i];
84
- if (r.status !== "success") {
85
- this.logger?.warn(`failed to get withdrawable assets of credit manager ${cms[i]}: ${r.error}`);
86
- continue;
82
+ onResults: (resps) => {
83
+ const cache = new AddressMap(void 0, MAP_LABEL);
84
+ for (let i = 0; i < resps.length; i++) {
85
+ const r = resps[i];
86
+ if (r.status !== "success") {
87
+ this.logger?.warn(`failed to get withdrawable assets of credit manager ${cms[i]}: ${r.error}`);
88
+ continue;
89
+ }
90
+ const assets = r.result;
91
+ if (assets.length > 0) cache.upsert(cms[i], assets.map((a) => toWithdrawableAsset(a, cms[i])));
92
+ }
93
+ this.#withdrawableAssets = cache;
87
94
  }
88
- if (r.result.length > 0) cache.upsert(cms[i], r.result.map((a) => toWithdrawableAsset(a, cms[i])));
89
- }
90
- this.#withdrawableAssets = cache;
95
+ };
96
+ }
97
+ /**
98
+ * {@inheritDoc IWithdrawalCompressorContract.loadWithdrawableAssets}
99
+ **/
100
+ async loadWithdrawableAssets(force, blockNumber) {
101
+ await executeMulticallBatches(this.client, [this.getLoadWithdrawableAssetsMulticall(force)], { blockNumber });
91
102
  return this.getWithdrawableAssets();
92
103
  }
93
104
  /**
@@ -1,7 +1,7 @@
1
+ import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
1
2
  import { BaseContract } from "../../base/BaseContract.js";
2
3
  import "../../base/index.js";
3
4
  import { decodeDelayedIntent } from "./intent-codec.js";
4
- import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
5
5
  import { InvalidDelayedIntentError } from "./errors.js";
6
6
  //#region src/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
7
7
  const abi = iRedemptionLoggerV310Abi;
@@ -1,5 +1,5 @@
1
- import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
2
1
  import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
2
+ import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
3
3
  //#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
4
4
  const abi = iWithdrawalCompressorV310Abi;
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
2
1
  import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
2
+ import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
3
3
  //#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
4
4
  const abi = iWithdrawalCompressorV311Abi;
5
5
  /**
@@ -1,6 +1,6 @@
1
+ import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
1
2
  import { encodeDelayedIntent } from "./intent-codec.js";
2
3
  import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
3
- import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
4
4
  import { toWithdrawalStatus } from "./types.js";
5
5
  //#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
6
6
  const abi = iWithdrawalCompressorV313Abi;
@@ -1,11 +1,13 @@
1
+ import { iExpirableAbi } from "../../abi/iExpirable.js";
2
+ import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
3
+ import { iVersionAbi } from "../../abi/iVersion.js";
1
4
  import { AddressMap } from "../utils/AddressMap.js";
2
5
  import { AddressSet } from "../utils/AddressSet.js";
3
6
  import { bytes32ToString } from "../utils/bytes32ToString.js";
4
7
  import { getAssetType } from "../chain/chains.js";
5
8
  import { formatBN } from "../utils/formatter.js";
6
9
  import "../utils/index.js";
7
- import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
8
- import { iVersionAbi } from "../../abi/iVersion.js";
10
+ import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
9
11
  //#region src/sdk/base/TokensMeta.ts
10
12
  /**
11
13
  * Registry of token metadata (symbol, decimals, phantom type) keyed by address.
@@ -62,7 +64,7 @@ var TokensMeta = class extends AddressMap {
62
64
  * @returns
63
65
  */
64
66
  isPhantomToken(t) {
65
- if (!this.#tokenDataLoaded.has(t.addr)) throw new Error(`extended token data not loaded for ${t.symbol} (${t.addr})`);
67
+ if (!this.#tokenDataLoaded.has(t.addr)) throw new Error(`extended token data not loaded for ${t.symbol} (${t.addr}), check if the sdk was properly attached or hydrated`);
66
68
  return !!t.contractType?.startsWith("PHANTOM_TOKEN::");
67
69
  }
68
70
  /**
@@ -167,44 +169,93 @@ var TokensMeta = class extends AddressMap {
167
169
  return meta;
168
170
  }
169
171
  /**
172
+ * @internal
173
+ *
174
+ * Returns the multicall batch that loads extended token data (`contractType`
175
+ * and `serialize()`) for the tokens that do not have it yet. Used by the SDK
176
+ * to warm this cache together with other loaders in a single multicall.
177
+ *
178
+ * @param tokens - tokens to load data for, defaults to all tokens
179
+ **/
180
+ getLoadTokenDataMulticall(...tokens) {
181
+ const tokenz = new AddressSet(tokens.length > 0 ? tokens : this.keys());
182
+ const tokensToLoad = Array.from(tokenz.difference(this.#tokenDataLoaded));
183
+ return {
184
+ contracts: tokensToLoad.flatMap((t) => [
185
+ {
186
+ address: t,
187
+ abi: iVersionAbi,
188
+ functionName: "contractType"
189
+ },
190
+ {
191
+ address: t,
192
+ abi: iStateSerializerAbi,
193
+ functionName: "serialize"
194
+ },
195
+ {
196
+ address: t,
197
+ abi: iExpirableAbi,
198
+ functionName: "isExpired"
199
+ }
200
+ ]),
201
+ onResults: (resps) => {
202
+ this.#logger?.debug(`loaded data of ${tokensToLoad.length} tokens`);
203
+ for (let i = 0; i < tokensToLoad.length; i++) {
204
+ this.#overrideTokenMeta(tokensToLoad[i], resps[3 * i], resps[3 * i + 1], resps[3 * i + 2]);
205
+ this.#tokenDataLoaded.add(tokensToLoad[i]);
206
+ }
207
+ }
208
+ };
209
+ }
210
+ /**
170
211
  * Loads token information about phantom tokens
171
212
  * In future other custom tokens types that do not have compressors might be handled here
172
213
  *
214
+ * Tokens loaded during SDK attach or restored by {@link hydrate} are skipped,
215
+ * so calling this after either is a no-op.
216
+ *
173
217
  * @param tokens - tokens to load data for, defaults to all tokens
174
218
  */
175
219
  async loadTokenData(...tokens) {
176
- const tokenz = new AddressSet(tokens.length > 0 ? tokens : this.keys());
177
- const tokensToLoad = Array.from(tokenz.difference(this.#tokenDataLoaded));
178
- if (tokensToLoad.length === 0) return;
179
- const resp = await this.#client.multicall({
180
- contracts: tokensToLoad.flatMap((t) => [{
181
- address: t,
182
- abi: iVersionAbi,
183
- functionName: "contractType"
184
- }, {
185
- address: t,
186
- abi: iStateSerializerAbi,
187
- functionName: "serialize"
188
- }]),
189
- allowFailure: true,
190
- batchSize: 0
191
- });
192
- this.#logger?.debug(`loaded ${resp.length} contract types`);
193
- for (let i = 0; i < tokensToLoad.length; i++) {
194
- this.#overrideTokenMeta(tokensToLoad[i], resp[2 * i], resp[2 * i + 1]);
195
- this.#tokenDataLoaded.add(tokensToLoad[i]);
196
- }
220
+ await executeMulticallBatches(this.#client, [this.getLoadTokenDataMulticall(...tokens)]);
221
+ }
222
+ /**
223
+ * Serializable snapshot of all token metadata, suitable for hydration.
224
+ **/
225
+ get state() {
226
+ return {
227
+ tokens: this.values(),
228
+ extendedLoaded: this.#tokenDataLoaded.asArray()
229
+ };
197
230
  }
198
- #overrideTokenMeta(token, contractTypeResp, _serializeResp) {
231
+ /**
232
+ * Restores token metadata from a previously serialized snapshot,
233
+ * bypassing on-chain reads.
234
+ *
235
+ * Entries are merged into the ones already registered by markets, zappers and
236
+ * the RWA registry (see {@link upsert}), so the snapshot must be applied last
237
+ * for its augmented fields to win.
238
+ *
239
+ * @param state - Token metadata snapshot.
240
+ **/
241
+ hydrate(state) {
242
+ for (const token of state.tokens) this.upsert(token.addr, token);
243
+ for (const token of state.extendedLoaded) this.#tokenDataLoaded.add(token);
244
+ }
245
+ #overrideTokenMeta(token, contractTypeResp, serializeResp, isExpiredResp) {
199
246
  const meta = this.mustGet(token);
247
+ const update = { ...meta };
200
248
  if (contractTypeResp.status === "success") {
201
249
  const contractType = bytes32ToString(contractTypeResp.result);
202
- this.upsert(token, {
203
- ...meta,
204
- contractType
205
- });
250
+ update.contractType = contractType;
251
+ update.serializedParams = serializeResp.status === "success" ? serializeResp.result : void 0;
206
252
  this.#logger?.debug(`token ${meta.symbol} is ${contractType}`);
207
253
  }
254
+ if (isExpiredResp.status === "success") {
255
+ update.isExpired = isExpiredResp.result;
256
+ this.#logger?.debug(`token ${meta.symbol} is expirable, expired: ${isExpiredResp.result}`);
257
+ }
258
+ if (contractTypeResp.status === "success" || isExpiredResp.status === "success") this.upsert(token, update);
208
259
  return this.mustGet(token);
209
260
  }
210
261
  };
@@ -1,5 +1,5 @@
1
- import { chains } from "./chains.js";
2
1
  import { ierc20Abi } from "../../abi/iERC20.js";
2
+ import { chains } from "./chains.js";
3
3
  //#region src/sdk/chain/detectNetwork.ts
4
4
  /**
5
5
  * Detects the network type from the given client.
@@ -1,8 +1,8 @@
1
+ import { iVersionAbi } from "../../abi/iVersion.js";
1
2
  import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
2
3
  import { isV310 } from "../constants/versions.js";
3
4
  import "../constants/index.js";
4
5
  import { hexEq } from "../utils/hex.js";
5
- import { iVersionAbi } from "../../abi/iVersion.js";
6
6
  import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
7
7
  //#region src/sdk/core/createAddressProvider.ts
8
8
  const OVERRIDE_ADDRESSES = { Mainnet: {
@@ -30,6 +30,7 @@ import { ZodAddress, ZodBigInt, ZodHex } from "./utils/zod.js";
30
30
  import "./utils/index.js";
31
31
  import { generateCastTraceCall, getCastTraceArgs } from "./utils/viem/cast.js";
32
32
  import { SimulationError, simulateCall } from "./utils/viem/simulateCall.js";
33
+ import { executeMulticallBatches } from "./utils/viem/executeMulticallBatches.js";
33
34
  import { TokensMeta } from "./base/TokensMeta.js";
34
35
  import { ChainContractsRegister } from "./base/ChainContractsRegister.js";
35
36
  import { Construct } from "./base/Construct.js";
@@ -147,4 +148,4 @@ import { OnchainSDK, STATE_VERSION } from "./OnchainSDK.js";
147
148
  import { MultichainSDK } from "./MultichainSDK.js";
148
149
  import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
149
150
  import "./types/index.js";
150
- export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, expectedBalanceDeltas, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, positionLeverage, primaryInstantOutput, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };
151
+ export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, positionLeverage, primaryInstantOutput, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };