@gearbox-protocol/sdk 17.9.0 → 17.10.1-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/cjs/dev/AccountOpener.js +3 -3
  2. package/dist/cjs/onchain/accounts/index.js +2 -0
  3. package/dist/cjs/onchain/accounts/intents/guards.js +4 -2
  4. package/dist/cjs/onchain/accounts/intents/index.js +41 -7
  5. package/dist/cjs/onchain/accounts/intents/math.js +3 -44
  6. package/dist/cjs/onchain/accounts/intents/maxBorrow.js +7 -1
  7. package/dist/cjs/onchain/accounts/intents/open-strategy.js +12 -7
  8. package/dist/cjs/onchain/accounts/intents/plan.js +4 -4
  9. package/dist/cjs/onchain/accounts/intents/realize.js +11 -5
  10. package/dist/cjs/onchain/accounts/intents/strategyLimits.js +159 -0
  11. package/dist/cjs/onchain/accounts/intents/tail.js +5 -1
  12. package/dist/cjs/onchain/accounts/intents/testing/market.js +5 -1
  13. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +5 -0
  14. package/dist/cjs/onchain/accounts/intents/utils/index.js +2 -0
  15. package/dist/cjs/onchain/accounts/intents/utils/quotas-for-update.js +69 -0
  16. package/dist/cjs/onchain/accounts/quota-utils.js +15 -0
  17. package/dist/cjs/onchain/chain/chains.js +12 -0
  18. package/dist/cjs/onchain/chain/index.js +1 -0
  19. package/dist/cjs/onchain/index.js +3 -0
  20. package/dist/cjs/onchain/market/oracle/PriceOracleBaseContract.js +8 -6
  21. package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +2 -3
  22. package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +3 -4
  23. package/dist/cjs/onchain/validation/checks/checkQuotaLimit.js +2 -1
  24. package/dist/esm/dev/AccountOpener.js +2 -2
  25. package/dist/esm/dev/withdrawalUtils.js +1 -1
  26. package/dist/esm/history/trace/extractTransfers.js +1 -1
  27. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  28. package/dist/esm/onchain/accounts/index.js +2 -2
  29. package/dist/esm/onchain/accounts/intents/guards.js +4 -2
  30. package/dist/esm/onchain/accounts/intents/index.js +41 -7
  31. package/dist/esm/onchain/accounts/intents/math.js +5 -45
  32. package/dist/esm/onchain/accounts/intents/maxBorrow.js +7 -1
  33. package/dist/esm/onchain/accounts/intents/open-strategy.js +13 -8
  34. package/dist/esm/onchain/accounts/intents/plan.js +4 -4
  35. package/dist/esm/onchain/accounts/intents/realize.js +12 -6
  36. package/dist/esm/onchain/accounts/intents/strategyLimits.js +158 -0
  37. package/dist/esm/onchain/accounts/intents/tail.js +5 -1
  38. package/dist/esm/onchain/accounts/intents/testing/market.js +5 -1
  39. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +5 -0
  40. package/dist/esm/onchain/accounts/intents/utils/index.js +2 -2
  41. package/dist/esm/onchain/accounts/intents/utils/quotas-for-update.js +70 -3
  42. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  43. package/dist/esm/onchain/accounts/quota-utils.js +14 -1
  44. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  45. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  46. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  47. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  48. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  49. package/dist/esm/onchain/chain/chains.js +12 -1
  50. package/dist/esm/onchain/chain/index.js +2 -2
  51. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  52. package/dist/esm/onchain/index.js +3 -3
  53. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  54. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  55. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  56. package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +8 -6
  57. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  58. package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
  59. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  60. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  61. package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
  62. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  63. package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +2 -3
  64. package/dist/esm/onchain/validation/checks/checkDebtLimits.js +3 -4
  65. package/dist/esm/onchain/validation/checks/checkQuotaLimit.js +2 -1
  66. package/dist/types/model/errors/index.d.ts +2 -2
  67. package/dist/types/model/errors/liquidation-errors.d.ts +4 -0
  68. package/dist/types/model/errors/operation-errors.d.ts +38 -14
  69. package/dist/types/model/errors/oracle-errors.d.ts +2 -0
  70. package/dist/types/model/index.d.ts +2 -2
  71. package/dist/types/onchain/accounts/index.d.ts +2 -2
  72. package/dist/types/onchain/accounts/intents/guards.d.ts +12 -12
  73. package/dist/types/onchain/accounts/intents/math.d.ts +7 -16
  74. package/dist/types/onchain/accounts/intents/plan.d.ts +2 -0
  75. package/dist/types/onchain/accounts/intents/realize.d.ts +3 -0
  76. package/dist/types/onchain/accounts/intents/strategyLimits.d.ts +33 -0
  77. package/dist/types/onchain/accounts/intents/tail.d.ts +13 -9
  78. package/dist/types/onchain/accounts/intents/testing/market.d.ts +4 -0
  79. package/dist/types/onchain/accounts/intents/utils/index.d.ts +2 -2
  80. package/dist/types/onchain/accounts/intents/utils/quotas-for-update.d.ts +21 -1
  81. package/dist/types/onchain/accounts/quota-utils.d.ts +16 -1
  82. package/dist/types/onchain/chain/chains.d.ts +15 -1
  83. package/dist/types/onchain/chain/index.d.ts +2 -2
  84. package/dist/types/onchain/index.d.ts +3 -3
  85. package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +0 -3
  86. package/dist/types/onchain/market/oracle/types.d.ts +4 -3
  87. package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +2 -3
  88. package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +2 -3
  89. package/dist/types/onchain/validation/checks/checkQuotaLimit.d.ts +2 -2
  90. package/package.json +1 -1
@@ -2,12 +2,13 @@ import { insufficientBalance } from "../../../model/errors/operation-errors.js";
2
2
  import "../../../model/index.js";
3
3
  import { IntentPreviewError } from "../../validation/raise.js";
4
4
  import { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaAvailable } from "./guards.js";
5
- import { assertDebtLimits, assertLeverageAtLeastOne, debtForLeverage, openCollateralForDebtLimits } from "./math.js";
5
+ import { assertDebtLimits, assertLeverageAtLeastOne, debtForLeverage } from "./math.js";
6
6
  import { unopenedAccountSlice } from "./utils/credit-account-slice.js";
7
7
  import { collectPriceImpact } from "./utils/price-impact.js";
8
8
  import { getQuotasForUpdate } from "./utils/quotas-for-update.js";
9
9
  import { createRouterPaths } from "./utils/router-path.js";
10
10
  import "./utils/index.js";
11
+ import { strategyLimits } from "./strategyLimits.js";
11
12
  //#region src/onchain/accounts/intents/open-strategy.ts
12
13
  /**
13
14
  * Builds the state opening a leveraged position out of wallet collateral would
@@ -44,17 +45,20 @@ async function buildOpenStrategyState(props) {
44
45
  creditFacade: suite.creditFacade.address,
45
46
  underlying
46
47
  });
47
- const getCollateralLimits = () => openCollateralForDebtLimits({
48
+ const options = leftoverBalances.length || existing?.tokens.some((t) => t.balance > 0n) ? void 0 : strategyLimits({
49
+ type: "OPEN",
48
50
  suite,
49
51
  collateral,
50
- leverage
52
+ leverage,
53
+ targetToken,
54
+ quotaReserve
51
55
  });
52
56
  assertDebtLimits(sdk, debt, suite.creditFacade, underlying, {
57
+ ...options,
53
58
  allowZero: false,
54
- maxBorrowAmount: suite.maxBorrowAmount(),
55
- getCollateralLimits
59
+ maxBorrowAmount: suite.maxBorrowAmount()
56
60
  });
57
- assertCanBorrow(sdk, suite, debt, { getCollateralLimits });
61
+ assertCanBorrow(sdk, suite, debt, options);
58
62
  const paths = createRouterPaths({
59
63
  sdk,
60
64
  creditAccount: account,
@@ -123,9 +127,10 @@ async function buildOpenStrategyState(props) {
123
127
  suite,
124
128
  market,
125
129
  before: [],
126
- after: averageAssets
130
+ after: averageAssets,
131
+ limits: options
127
132
  });
128
- assertQuotaAvailable(sdk, market, averageQuota);
133
+ assertQuotaAvailable(sdk, market, averageQuota, options);
129
134
  const projection = reached ?? settle();
130
135
  assertCollateralised(projection.healthFactor, false);
131
136
  const priceImpact = await collectPriceImpact(leg.probe ? [leg.probe] : [], {
@@ -42,7 +42,7 @@ function planDeposit(intent, view) {
42
42
  const aU = view.price(intent.token, U, intent.amount);
43
43
  const debtDelta = intent.targetLeverage === void 0 ? proportionalDebt(view, aU) : debtForLeverage(view.collateral + aU, intent.targetLeverage) - view.debt;
44
44
  if (debtDelta < 0n) throw new IntentPreviewError(leverageOutOfRange(), `deposit: target leverage ${intent.targetLeverage} would require repaying debt`);
45
- assertDebtLimits(view.sdk, view.debt + debtDelta, view.debtLimits, U);
45
+ assertDebtLimits(view.sdk, view.debt + debtDelta, view.debtLimits, U, view.limits);
46
46
  const T = intent.positionToken ?? positionToken(view, "deposit");
47
47
  const depositStays = eq(intent.token, T);
48
48
  return [
@@ -77,7 +77,7 @@ function planRepay(intent, view) {
77
77
  }), "repay: the account owes nothing");
78
78
  const funding = everything(intent.amount) ? view.price(U, intent.token, withMargin(view.debt)) : intent.amount;
79
79
  const repaid = min(view.price(intent.token, U, funding), view.debt);
80
- assertDebtLimits(view.sdk, view.debt - repaid, view.debtLimits, view.underlying);
80
+ assertDebtLimits(view.sdk, view.debt - repaid, view.debtLimits, view.underlying, view.limits);
81
81
  return [
82
82
  add(intent.token, funding, intent.value),
83
83
  ...fundsInU ? [] : [convert(intent.token, U, funding)],
@@ -306,7 +306,7 @@ function withdrawShape(intent, view) {
306
306
  };
307
307
  }
308
308
  const dD = proportionalDebt(view, WU);
309
- assertDebtLimits(view.sdk, view.debt - dD, view.debtLimits, view.underlying);
309
+ assertDebtLimits(view.sdk, view.debt - dD, view.debtLimits, view.underlying, view.limits);
310
310
  return {
311
311
  U,
312
312
  T,
@@ -325,7 +325,7 @@ function leverageShape(intent, view) {
325
325
  assertLeverageAtLeastOne(intent.targetLeverage);
326
326
  if (view.collateral <= 0n) throw new IntentPreviewError(insufficientBalance(), "adjustLeverage: account has no collateral to lever");
327
327
  const target = debtForLeverage(view.collateral, intent.targetLeverage);
328
- assertDebtLimits(view.sdk, target, view.debtLimits, view.underlying);
328
+ assertDebtLimits(view.sdk, target, view.debtLimits, view.underlying, view.limits);
329
329
  return {
330
330
  U: view.underlying,
331
331
  delta: target - view.debt
@@ -1,3 +1,4 @@
1
+ import { getDirectTransferToken } from "../../chain/chains.js";
1
2
  import { PERCENTAGE_FACTOR_1KK } from "../../constants/math.js";
2
3
  import { insufficientBalance } from "../../../model/errors/operation-errors.js";
3
4
  import { multipleDelayedWithdrawals, noDelayedRoute, withdrawalInProgress } from "../../../model/errors/prepare-errors.js";
@@ -9,7 +10,7 @@ import { isRedemptionPhantomToken } from "./utils/pick-token.js";
9
10
  import { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertQuotaAvailable } from "./guards.js";
10
11
  import { OperationLedger } from "./utils/ledger.js";
11
12
  import { collectPriceImpact } from "./utils/price-impact.js";
12
- import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate } from "./utils/quotas-for-update.js";
13
+ import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate, withDirectTransferQuota } from "./utils/quotas-for-update.js";
13
14
  import { createRouterPaths } from "./utils/router-path.js";
14
15
  import { buildAddCollateralOperation, buildClaimDelayedWithdrawalOperation, buildCloseSwapOperation, buildDecreaseDebtOperation, buildIncreaseDebtOperation, buildQuotaUpdateOperation, buildStartDelayedWithdrawalOperation, buildSwapOperation, buildUnwrapRwaCollateralOperation, buildWithdrawCollateralOperation, buildWrapRwaCollateralOperation, instantOutput } from "./operations.js";
15
16
  import { withdrawLimits } from "./withdraw-limits.js";
@@ -106,6 +107,8 @@ async function realize(steps, props) {
106
107
  * judge the closing collateral check at safe prices.
107
108
  */
108
109
  let withdrawsCollateral = false;
110
+ /** Token a sold collateral later transfers to the account; needs a quota. */
111
+ let directTransfer;
109
112
  const amountOf = (a) => typeof a === "bigint" ? a : min(raised, a.max ?? raised);
110
113
  const assertHolds = (token, amount, what) => {
111
114
  const held = ledger.balanceOf(token);
@@ -127,7 +130,7 @@ async function realize(steps, props) {
127
130
  }));
128
131
  break;
129
132
  case "borrow":
130
- assertCanBorrow(sdk, suite, step.amount);
133
+ assertCanBorrow(sdk, suite, step.amount, props.limits);
131
134
  push(buildIncreaseDebtOperation({
132
135
  amount: step.amount,
133
136
  creditAccount,
@@ -178,6 +181,7 @@ async function realize(steps, props) {
178
181
  raised = amountOut;
179
182
  break;
180
183
  }
184
+ directTransfer ??= getDirectTransferToken(step.from, sdk.networkType);
181
185
  const held = ledger.balanceOf(step.from);
182
186
  const leg = await paths.swap({
183
187
  tokenIn: step.from,
@@ -258,6 +262,7 @@ async function realize(steps, props) {
258
262
  const asset = await delayedConfig(sdk, creditAccount, step.token);
259
263
  if (ledger.balanceOf(asset.withdrawalPhantomToken) > 0n) throw new IntentPreviewError(withdrawalInProgress(toTokenAmount(sdk, asset.withdrawalPhantomToken, ledger.balanceOf(asset.withdrawalPhantomToken))), `request: ${asset.withdrawalPhantomToken} already holds a pending withdrawal`);
260
264
  assertHolds(step.token, step.amount + step.reserve, "request");
265
+ if (step.record.type !== "CLOSE_ACCOUNT") directTransfer ??= getDirectTransferToken(step.token, sdk.networkType);
261
266
  const preview = await sdk.accounts.previewDelayedWithdrawal({
262
267
  creditAccount: creditAccount.creditAccount,
263
268
  token: step.token,
@@ -329,7 +334,7 @@ async function realize(steps, props) {
329
334
  const floor = ledger.snapshot();
330
335
  const { assets, debt } = floor;
331
336
  const projected = expected.snapshot();
332
- const quotas = cleared ?? getQuotasForUpdate({
337
+ const quotas = cleared ?? withDirectTransferQuota(getQuotasForUpdate({
333
338
  assetsBefore: creditAccount.tokens,
334
339
  assetsAfter: assets,
335
340
  initialQuotas: creditAccount.tokens,
@@ -339,7 +344,7 @@ async function realize(steps, props) {
339
344
  quotas: market.pool.pqk.quotas,
340
345
  maxDebt: suite.creditFacade.maxDebt,
341
346
  convert: price
342
- });
347
+ }), debt > 0n ? directTransfer : void 0, creditAccount.tokens, market.pool.pqk.quotas, suite.creditManager.maxEnabledTokens, suite.creditManager.collateralTokens);
343
348
  const quotasAfter = quotasAfterUpdate(creditAccount.tokens, quotas.desiredQuota);
344
349
  const quoted = Object.values(quotasAfter);
345
350
  const snapshot = {
@@ -389,10 +394,11 @@ async function realize(steps, props) {
389
394
  suite,
390
395
  market,
391
396
  before: creditAccount.tokens,
392
- after: projected.assets
397
+ after: projected.assets,
398
+ limits: props.limits
393
399
  });
394
400
  if (!cleared && quotas.quotaIncrease.length + quotas.quotaDecrease.length > 0) {
395
- assertQuotaAvailable(sdk, market, quotas.quotaIncrease);
401
+ assertQuotaAvailable(sdk, market, quotas.quotaIncrease, props.limits);
396
402
  push(buildQuotaUpdateOperation({
397
403
  update: quotas,
398
404
  creditAccount,
@@ -0,0 +1,158 @@
1
+ import { BigIntMath } from "../../utils/bigint-math.js";
2
+ import { LEVERAGE_DECIMALS, MAX_UINT256 } from "../../constants/math.js";
3
+ import "../../constants/index.js";
4
+ import { quotaIncreaseLimit } from "./utils/quotas-for-update.js";
5
+ //#region src/onchain/accounts/intents/strategyLimits.ts
6
+ /** Independent input bounds supplied to debt, liquidity and quota errors. */
7
+ function strategyLimits(props) {
8
+ const { suite, quotaReserve } = props;
9
+ const { market } = suite;
10
+ const { priceOracle: oracle } = market;
11
+ switch (props.type) {
12
+ case "OPEN": {
13
+ const { collateral, leverage, targetToken } = props;
14
+ if (collateral.length !== 1 || leverage <= 100n) return {};
15
+ const [{ token }] = collateral;
16
+ const minDebt = suite.creditFacade.minDebt;
17
+ const maxDebt = suite.maxBorrowAmount().amount.value;
18
+ if (maxDebt < minDebt) return {};
19
+ const minCollateralForDebt = (debt) => {
20
+ const collateralUnderlying = BigIntMath.ceilDiv(debt * LEVERAGE_DECIMALS, leverage - LEVERAGE_DECIMALS);
21
+ const result = oracle.safeConvert(market.pool.underlying, token, collateralUnderlying - 1n);
22
+ if (result.error) return void 0;
23
+ const valuation = oracle.safeConvert(token, market.pool.underlying, result.value);
24
+ if (valuation.error) return void 0;
25
+ const collateral = result.value + (valuation.value < collateralUnderlying ? 1n : 0n);
26
+ const checked = oracle.safeConvert(token, market.pool.underlying, collateral);
27
+ return checked.error || checked.value < collateralUnderlying ? void 0 : collateral;
28
+ };
29
+ if (oracle.safeConvert(token, market.pool.underlying, 1n).error) return {};
30
+ const minCollateral = minCollateralForDebt(BigIntMath.max(minDebt, 1n));
31
+ const excessCollateral = minCollateralForDebt(maxDebt + 1n);
32
+ if (minCollateral === void 0 || excessCollateral === void 0 || minCollateral > 115792089237316195423570985008687907853269984665640564039457584007913129639935n) return {};
33
+ const maxCollateral = BigIntMath.min(MAX_UINT256, excessCollateral - 1n);
34
+ let maxCollateralByQuota;
35
+ if (!market.isUnderlyingLike(targetToken) && !market.pool.pqk.hasActiveQuota(targetToken)) maxCollateralByQuota = 0n;
36
+ else {
37
+ const quotaResult = quotaIncreaseLimit({
38
+ suite,
39
+ token: targetToken,
40
+ balance: 0n,
41
+ initialQuotas: [],
42
+ quotaReserve
43
+ });
44
+ if (!quotaResult.error && quotaResult.value !== void 0) {
45
+ const excessUnderlying = BigIntMath.ceilDiv((BigIntMath.max(quotaResult.value, 0n) + 1n) * LEVERAGE_DECIMALS, leverage);
46
+ const result = oracle.safeConvert(market.pool.underlying, token, excessUnderlying - 1n);
47
+ if (!result.error) {
48
+ const valuation = oracle.safeConvert(token, market.pool.underlying, result.value);
49
+ if (!valuation.error) {
50
+ const collateral = result.value - (valuation.value >= excessUnderlying ? 1n : 0n);
51
+ maxCollateralByQuota = BigIntMath.min(MAX_UINT256, BigIntMath.max(collateral, 0n));
52
+ }
53
+ }
54
+ }
55
+ }
56
+ return {
57
+ collateralLimits: minCollateral <= maxCollateral ? {
58
+ min: oracle.toTokenAmount(token, minCollateral),
59
+ max: oracle.toTokenAmount(token, maxCollateral)
60
+ } : void 0,
61
+ quotaLimits: maxCollateralByQuota === void 0 ? void 0 : { collateralMax: oracle.toTokenAmount(token, maxCollateralByQuota) }
62
+ };
63
+ }
64
+ case "DEPOSIT": {
65
+ const { view, token, positionToken, initialQuotas, targetLeverage } = props;
66
+ if (targetLeverage !== void 0 || view.collateral <= 0n) return {};
67
+ const minDebt = BigIntMath.max(view.debt, suite.creditFacade.minDebt);
68
+ const maxDebt = BigIntMath.min(suite.creditFacade.maxDebt, view.debt + suite.maxBorrowAmount().amount.value);
69
+ const minCollateralForDebt = (debt) => {
70
+ if (debt <= view.debt) return 0n;
71
+ if (view.debt === 0n) return void 0;
72
+ const collateralUnderlying = BigIntMath.ceilDiv((debt - view.debt) * view.collateral, view.debt);
73
+ const result = oracle.safeConvert(view.underlying, token, collateralUnderlying - 1n);
74
+ if (result.error) return void 0;
75
+ const valuation = oracle.safeConvert(token, view.underlying, result.value);
76
+ if (valuation.error) return void 0;
77
+ const collateral = result.value + (valuation.value < collateralUnderlying ? 1n : 0n);
78
+ const checked = oracle.safeConvert(token, view.underlying, collateral);
79
+ return checked.error || checked.value < collateralUnderlying ? void 0 : collateral;
80
+ };
81
+ const debtFloorCollateral = minCollateralForDebt(minDebt);
82
+ const minCollateral = debtFloorCollateral === void 0 ? void 0 : BigIntMath.max(1n, debtFloorCollateral);
83
+ const excessCollateral = debtFloorCollateral === void 0 ? void 0 : minCollateralForDebt(maxDebt + 1n);
84
+ const maxCollateral = excessCollateral === void 0 ? MAX_UINT256 : BigIntMath.min(MAX_UINT256, excessCollateral - 1n);
85
+ const position = positionToken ?? view.fattest([view.underlying]);
86
+ let maxCollateralByQuota;
87
+ if (position) {
88
+ if (!market.isUnderlyingLike(position) && !market.pool.pqk.hasActiveQuota(position)) maxCollateralByQuota = 0n;
89
+ else {
90
+ const quotaResult = quotaIncreaseLimit({
91
+ suite,
92
+ token: position,
93
+ balance: view.balanceOf(position),
94
+ initialQuotas,
95
+ quotaReserve,
96
+ rwaAsset: view.rwaAsset
97
+ });
98
+ maxCollateralByQuota = MAX_UINT256;
99
+ if (!quotaResult.error && quotaResult.value !== void 0) {
100
+ const excessUnderlying = BigIntMath.ceilDiv((quotaResult.value + 1n) * view.collateral, view.collateral + view.debt);
101
+ const result = oracle.safeConvert(view.underlying, token, BigIntMath.max(excessUnderlying - 1n, 0n));
102
+ maxCollateralByQuota = void 0;
103
+ if (!result.error) {
104
+ const valuation = oracle.safeConvert(token, view.underlying, result.value);
105
+ if (!valuation.error) {
106
+ const collateral = result.value - (valuation.value >= excessUnderlying ? 1n : 0n);
107
+ maxCollateralByQuota = BigIntMath.min(MAX_UINT256, BigIntMath.max(collateral, 0n));
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+ return {
114
+ collateralLimits: minCollateral !== void 0 && minCollateral <= maxCollateral ? {
115
+ min: oracle.toTokenAmount(token, minCollateral),
116
+ max: oracle.toTokenAmount(token, maxCollateral)
117
+ } : void 0,
118
+ quotaLimits: maxCollateralByQuota === void 0 ? void 0 : { collateralMax: oracle.toTokenAmount(token, maxCollateralByQuota) }
119
+ };
120
+ }
121
+ case "ADJUST_LEVERAGE": {
122
+ const { view, token, initialQuotas, targetLeverage, maxLeverage = MAX_UINT256 } = props;
123
+ if (view.collateral <= 0n || targetLeverage < 100n) return {};
124
+ const maxDebt = BigIntMath.min(suite.creditFacade.maxDebt, view.debt + suite.maxBorrowAmount().amount.value);
125
+ const minLeverage = BigIntMath.max(LEVERAGE_DECIMALS + 1n, LEVERAGE_DECIMALS + BigIntMath.ceilDiv(suite.creditFacade.minDebt * LEVERAGE_DECIMALS, view.collateral));
126
+ const debtMaxLeverage = BigIntMath.min(maxLeverage, LEVERAGE_DECIMALS + BigIntMath.ceilDiv((maxDebt + 1n) * LEVERAGE_DECIMALS, view.collateral) - 1n);
127
+ const position = token ?? view.fattest([view.underlying]);
128
+ let maxLeverageByQuota;
129
+ if (position) {
130
+ if (!market.isUnderlyingLike(position) && !market.pool.pqk.hasActiveQuota(position)) maxLeverageByQuota = LEVERAGE_DECIMALS;
131
+ else {
132
+ const quotaResult = quotaIncreaseLimit({
133
+ suite,
134
+ token: position,
135
+ balance: view.balanceOf(position),
136
+ initialQuotas,
137
+ quotaReserve,
138
+ rwaAsset: view.rwaAsset
139
+ });
140
+ maxLeverageByQuota = maxLeverage;
141
+ if (!quotaResult.error && quotaResult.value !== void 0) {
142
+ const quotaMaxDebt = view.debt + quotaResult.value;
143
+ maxLeverageByQuota = BigIntMath.min(maxLeverage, LEVERAGE_DECIMALS + BigIntMath.ceilDiv((quotaMaxDebt + 1n) * LEVERAGE_DECIMALS, view.collateral) - 1n);
144
+ }
145
+ }
146
+ }
147
+ return {
148
+ leverageLimits: minLeverage <= debtMaxLeverage ? {
149
+ min: minLeverage,
150
+ max: debtMaxLeverage
151
+ } : void 0,
152
+ quotaLimits: maxLeverageByQuota === void 0 ? void 0 : { leverageMax: maxLeverageByQuota }
153
+ };
154
+ }
155
+ }
156
+ }
157
+ //#endregion
158
+ export { strategyLimits };
@@ -168,13 +168,17 @@ async function projectTail(args) {
168
168
  const { steps } = planTail({
169
169
  intent: delayed.record,
170
170
  claimable: projectedClaimable(request, queued.token, queued.amount, claim),
171
- view: accountView(next, sdk)
171
+ view: {
172
+ ...accountView(next, sdk),
173
+ limits: args.limits
174
+ }
172
175
  });
173
176
  const { state, operations } = await realize(steps, {
174
177
  creditAccount: next,
175
178
  sdk,
176
179
  slippage: 0,
177
180
  quotaReserve,
181
+ limits: args.limits,
178
182
  paths: createOraclePaths({
179
183
  sdk,
180
184
  creditAccount: next
@@ -90,7 +90,10 @@ function buildMarketSdk(extras) {
90
90
  ...extras?.extraDecimals
91
91
  },
92
92
  quotas: extras?.quotas ?? QUOTAS,
93
- liquidationThresholds: LIQUIDATION_THRESHOLDS,
93
+ liquidationThresholds: {
94
+ ...LIQUIDATION_THRESHOLDS,
95
+ ...extras?.extraLiquidationThresholds
96
+ },
94
97
  maxDebt: MAX_DEBT,
95
98
  minDebt: extras?.minDebt,
96
99
  creditManager: CREDIT_MANAGER,
@@ -102,6 +105,7 @@ function buildMarketSdk(extras) {
102
105
  phantoms: extras?.phantoms,
103
106
  creditAccounts: extras?.creditAccounts,
104
107
  delayed: extras?.delayed,
108
+ maxEnabledTokens: extras?.maxEnabledTokens,
105
109
  facadePaused: extras?.facadePaused,
106
110
  poolPaused: extras?.poolPaused,
107
111
  expirationDate: extras?.expirationDate,
@@ -148,6 +148,10 @@ function buildMockSdk(args) {
148
148
  });
149
149
  const market = {
150
150
  toUnderlyingAmount,
151
+ isUnderlyingLike: (token) => {
152
+ const address = token.toLowerCase();
153
+ return address === args.underlying.toLowerCase() || address === args.rwaAssets?.[args.underlying.toLowerCase()]?.toLowerCase();
154
+ },
151
155
  /** {@inheritDoc MarketSuite.curator} */
152
156
  curator: MOCK_CURATOR,
153
157
  /** {@inheritDoc MarketSuite.underlying} */
@@ -319,6 +323,7 @@ function buildMockSdk(args) {
319
323
  });
320
324
  const sdk = {
321
325
  chainId: 1,
326
+ networkType: "Mainnet",
322
327
  currentBlock: 1n,
323
328
  timestamp: args.timestamp ?? 0,
324
329
  withdrawalCompressor,
@@ -6,6 +6,6 @@ import { calcBorrowedAmountPlusInterestAndFees } from "./borrowed-amount-plus-in
6
6
  import { fetchCreditAccountSlice, toCreditAccountSlice, unopenedAccountSlice } from "./credit-account-slice.js";
7
7
  import { OperationLedger } from "./ledger.js";
8
8
  import { collectPriceImpact, lossRate, startProbe } from "./price-impact.js";
9
- import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate } from "./quotas-for-update.js";
9
+ import { clearedQuotas, getQuotasForUpdate, quotaIncreaseLimit, quotasAfterUpdate, withDirectTransferQuota } from "./quotas-for-update.js";
10
10
  import { createOraclePaths, createRouterPaths } from "./router-path.js";
11
- export { OperationLedger, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, resolveCreditManager, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals, unopenedAccountSlice };
11
+ export { OperationLedger, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotaIncreaseLimit, quotasAfterUpdate, rankAccountTokens, resolveCreditManager, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals, unopenedAccountSlice, withDirectTransferQuota };
@@ -1,6 +1,8 @@
1
- import { MIN_INT96 } from "../../../constants/math.js";
1
+ import { BigIntMath } from "../../../utils/bigint-math.js";
2
+ import { MAX_UINT256, MIN_INT96 } from "../../../constants/math.js";
2
3
  import { TypedObjectUtils } from "../../../utils/mappers.js";
3
- import { calcQuotaUpdate } from "../../quota-utils.js";
4
+ import "../../../constants/index.js";
5
+ import { DIRECT_TRANSFERS_QUOTA, calcQuotaUpdate, maxAmountForQuota, roundUpQuota } from "../../quota-utils.js";
4
6
  //#region src/onchain/accounts/intents/utils/quotas-for-update.ts
5
7
  function getQuotasForUpdate({ assetsBefore, assetsAfter, initialQuotas, quotaReserve = 0, liquidationThresholds: liquidationThresholdsMap, quotas: quotasMap, maxDebt, underlyingToken, convert }) {
6
8
  const underlyingTokenLc = underlyingToken.toLowerCase();
@@ -78,6 +80,35 @@ function clearedQuotas(initialQuotas) {
78
80
  };
79
81
  }
80
82
  /**
83
+ * Raises `directTransfer`'s quota to at least {@link DIRECT_TRANSFERS_QUOTA};
84
+ * skips a token absent from the credit manager, one the pool can't quote, or
85
+ * one the account has no free enabled token slot for.
86
+ */
87
+ function withDirectTransferQuota(update, directTransfer, initialQuotas, quotas, maxEnabledTokens, collateralTokens) {
88
+ if (!directTransfer) return update;
89
+ const token = directTransfer.toLowerCase();
90
+ const quota = quotas.get(token);
91
+ const initial = initialQuotas.find((q) => q.token.toLowerCase() === token)?.quota ?? 0n;
92
+ const change = DIRECT_TRANSFERS_QUOTA - initial;
93
+ if (!collateralTokens.some((t) => t.toLowerCase() === token) || !quota?.isActive || quota.limit - quota.totalQuoted < change || (update.desiredQuota[token]?.balance ?? initial) >= DIRECT_TRANSFERS_QUOTA || Object.keys(quotasAfterUpdate(initialQuotas, update.desiredQuota)).length >= maxEnabledTokens) return update;
94
+ const rest = (list) => list.filter((a) => a.token !== token);
95
+ const entry = {
96
+ token,
97
+ balance: change
98
+ };
99
+ return {
100
+ desiredQuota: {
101
+ ...update.desiredQuota,
102
+ [token]: {
103
+ token,
104
+ balance: DIRECT_TRANSFERS_QUOTA
105
+ }
106
+ },
107
+ quotaIncrease: change > 0n ? [...rest(update.quotaIncrease), entry] : rest(update.quotaIncrease),
108
+ quotaDecrease: change < 0n ? [...rest(update.quotaDecrease), entry] : rest(update.quotaDecrease)
109
+ };
110
+ }
111
+ /**
81
112
  * The quotas the account stands at once an update lands: the ones it came with,
82
113
  * with the ones the update names written over them.
83
114
  *
@@ -165,5 +196,41 @@ function constructAssetRecord(a) {
165
196
  return acc;
166
197
  }, {});
167
198
  }
199
+ /** Largest additional underlying amount whose purchase fits this token's quota. */
200
+ function quotaIncreaseLimit({ suite, token, balance, initialQuotas, quotaReserve = 0, rwaAsset }) {
201
+ const { market } = suite;
202
+ if (market.isUnderlyingLike(token)) return { value: void 0 };
203
+ const oracle = market.priceOracle;
204
+ const purchaseResult = oracle.safeConvert(market.pool.underlying, token, MAX_UINT256);
205
+ if (purchaseResult.error) return purchaseResult;
206
+ const valuationResult = oracle.safeConvert(token, market.pool.underlying, MAX_UINT256);
207
+ if (valuationResult.error) return valuationResult;
208
+ if (purchaseResult.value === 0n || valuationResult.value === 0n) return { value: void 0 };
209
+ const maxQuotaValue = maxAmountForQuota({
210
+ available: market.pool.pqk.quotaAvailable(token),
211
+ initialQuota: initialQuotas.find((q) => q.token.toLowerCase() === token.toLowerCase())?.quota ?? 0n,
212
+ totalInitialQuota: initialQuotas.reduce((sum, q) => sum + roundUpQuota(q.quota), 0n),
213
+ maxDebt: suite.creditFacade.maxDebt,
214
+ lt: BigInt(suite.creditManager.liquidationThresholds.get(token) ?? 0),
215
+ quotaReserve: BigInt(quotaReserve)
216
+ });
217
+ if (maxQuotaValue === void 0) return { value: void 0 };
218
+ const quotaBalanceResult = oracle.safeConvert(market.pool.underlying, token, maxQuotaValue);
219
+ if (quotaBalanceResult.error) return quotaBalanceResult;
220
+ const quotaValueResult = oracle.safeConvert(token, market.pool.underlying, quotaBalanceResult.value);
221
+ if (quotaValueResult.error) return quotaValueResult;
222
+ const availableTokenIncrease = quotaBalanceResult.value - (quotaValueResult.value > maxQuotaValue ? 1n : 0n) - balance;
223
+ const excessTokenIncrease = BigIntMath.max(availableTokenIncrease, 0n) + 1n;
224
+ if (rwaAsset?.toLowerCase() === token.toLowerCase()) {
225
+ const underlyingScale = 10n ** BigInt(suite.sdk.tokensMeta.decimals(market.pool.underlying));
226
+ const tokenScale = 10n ** BigInt(suite.sdk.tokensMeta.decimals(token));
227
+ return { value: BigIntMath.ceilDiv(excessTokenIncrease * underlyingScale, tokenScale) - 1n };
228
+ }
229
+ const increaseResult = oracle.safeConvert(token, market.pool.underlying, excessTokenIncrease - 1n);
230
+ if (increaseResult.error) return increaseResult;
231
+ const purchaseValue = oracle.safeConvert(market.pool.underlying, token, increaseResult.value);
232
+ if (purchaseValue.error) return purchaseValue;
233
+ return { value: increaseResult.value - (purchaseValue.value >= excessTokenIncrease ? 1n : 0n) };
234
+ }
168
235
  //#endregion
169
- export { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate };
236
+ export { clearedQuotas, getQuotasForUpdate, quotaIncreaseLimit, quotasAfterUpdate, withDirectTransferQuota };
@@ -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
  import { skipLiquidatableAccount } from "./skipLiquidatableAccount.js";
24
24
  //#region src/onchain/accounts/liquidations/LiquidationsService.ts
25
25
  /**
@@ -2,6 +2,11 @@ import { BigIntMath } from "../utils/bigint-math.js";
2
2
  import { MIN_INT96, PERCENTAGE_FACTOR } from "../constants/math.js";
3
3
  //#region src/onchain/accounts/quota-utils.ts
4
4
  /**
5
+ * Quota that keeps a directly transferred token enabled, so a liquidation
6
+ * counts it.
7
+ */
8
+ const DIRECT_TRANSFERS_QUOTA = PERCENTAGE_FACTOR;
9
+ /**
5
10
  * Rounds quota deltas to protocol precision step (`PERCENTAGE_FACTOR`).
6
11
  *
7
12
  * The `MIN_INT96` sentinel is preserved as-is because it encodes
@@ -37,6 +42,14 @@ function calcRecommendedQuota({ amount, debt, lt, quotaReserve }) {
37
42
  function calcDefaultQuota({ amount, lt, quotaReserve }) {
38
43
  return roundUpQuota(amount * lt / PERCENTAGE_FACTOR * (PERCENTAGE_FACTOR + quotaReserve) / PERCENTAGE_FACTOR);
39
44
  }
45
+ /** Inverse of default quota rounding, including the account-wide increase cap. */
46
+ function maxAmountForQuota({ available, initialQuota, totalInitialQuota, maxDebt, lt, quotaReserve }) {
47
+ const increaseCap = roundUpQuota(BigIntMath.max(roundUpQuota(maxDebt * 2n) - totalInitialQuota, 0n));
48
+ if (lt === 0n || increaseCap <= available) return void 0;
49
+ const desired = roundUpQuota(initialQuota) + roundUpQuota(available) + PERCENTAGE_FACTOR - 1n;
50
+ const base = BigIntMath.ceilDiv((desired + 1n) * PERCENTAGE_FACTOR, PERCENTAGE_FACTOR + quotaReserve) - 1n;
51
+ return BigIntMath.ceilDiv((base + 1n) * PERCENTAGE_FACTOR, lt) - 1n;
52
+ }
40
53
  /**
41
54
  * Produces desired quota state and explicit increase/decrease actions.
42
55
  *
@@ -137,4 +150,4 @@ function getSingleQuotaChange(token, unsafeMaxQuotaIncrease, props) {
137
150
  };
138
151
  }
139
152
  //#endregion
140
- export { calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota };
153
+ export { DIRECT_TRANSFERS_QUOTA, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, maxAmountForQuota, roundUpQuota };
@@ -1,9 +1,9 @@
1
+ import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
1
2
  import { BaseContract } from "../../base/BaseContract.js";
2
3
  import "../../base/index.js";
3
4
  import { sdkErr, sdkOk } from "../../../model/result.js";
4
5
  import "../../../model/index.js";
5
6
  import { decodeDelayedIntent } from "./intent-codec.js";
6
- import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
7
7
  //#region src/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
8
8
  const abi = iRedemptionLoggerV310Abi;
9
9
  /**
@@ -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/onchain/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/onchain/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/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
6
6
  const abi = iWithdrawalCompressorV313Abi;
@@ -1,12 +1,12 @@
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 { iExpirableAbi } from "../../abi/iExpirable.js";
8
- import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
9
- import { iVersionAbi } from "../../abi/iVersion.js";
10
10
  import { SdkRWADataNotLoadedError } from "../core/errors.js";
11
11
  import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
12
12
  //#region src/onchain/base/TokensMeta.ts
@@ -77,6 +77,7 @@ const chains = {
77
77
  "0x238a700eD6165261Cf8b2e544ba797BC11e466Ba",
78
78
  "0x7433806912Eae67919e66aea853d46Fa0aef98A8"
79
79
  ]),
80
+ directTransfers: AddressMap.fromRecord({ "0x7433806912Eae67919e66aea853d46Fa0aef98A8": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" }),
80
81
  legacyStrategyTargets: AddressMap.fromRecord({
81
82
  "0x1293a69e4ad4a93293a06b6303104be35bdd83af": "0x1a711a5bc48b5c1352c1882fa65dc14b5b9e829d",
82
83
  "0x29350a3c2627fb78c7e915cd59af754edf8998c5": "0xe1d9b789da5b5375eacf66f036022b019a2af307",
@@ -544,6 +545,16 @@ function isSunsetStrategy(creditManager, network) {
544
545
  return !!chains[network].sunsetStrategies?.has(creditManager);
545
546
  }
546
547
  /**
548
+ * Token a collateral's sale later transfers directly to the credit account,
549
+ * or `undefined` when the collateral is not in the table.
550
+ *
551
+ * @param collateral - Collateral token address.
552
+ * @param network - Chain id or {@link NetworkType} label.
553
+ **/
554
+ function getDirectTransferToken(collateral, network) {
555
+ return getChain(network).directTransfers?.get(collateral);
556
+ }
557
+ /**
547
558
  * Hardcoded target collateral of a legacy credit manager, or `undefined` when
548
559
  * the manager is not in the table and the on-chain rule should apply.
549
560
  *
@@ -565,4 +576,4 @@ function getAccountTargetCollateral(creditAccount, network) {
565
576
  return getChain(network).accountTargetCollaterals?.get(creditAccount);
566
577
  }
567
578
  //#endregion
568
- export { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
579
+ export { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getDirectTransferToken, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
@@ -1,3 +1,3 @@
1
- import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds } from "./chains.js";
1
+ import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getDirectTransferToken, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds } from "./chains.js";
2
2
  import { detectNetwork } from "./detectNetwork.js";
3
- export { NetworkType, SUPPORTED_NETWORKS, chains, detectNetwork, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
3
+ export { NetworkType, SUPPORTED_NETWORKS, chains, detectNetwork, findCuratorMarketConfigurator, getAccountTargetCollateral, getAssetType, getChain, getCuratorName, getDirectTransferToken, getLegacyStrategyTarget, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
@@ -1,8 +1,8 @@
1
+ import { iVersionAbi } from "../../abi/iVersion.js";
1
2
  import "../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/onchain/core/createAddressProvider.ts
8
8
  const OVERRIDE_ADDRESSES = {};