@gearbox-protocol/sdk 16.3.0-next.5 → 17.0.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 (113) hide show
  1. package/dist/cjs/model/errors/operation-errors.js +1 -1
  2. package/dist/cjs/model/index.js +2 -2
  3. package/dist/cjs/model/rwa.js +4 -4
  4. package/dist/cjs/model/rwa.schema.js +4 -4
  5. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
  6. package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +3 -1
  7. package/dist/cjs/onchain/accounts/intents/guards.js +4 -4
  8. package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  9. package/dist/cjs/onchain/index.js +4 -4
  10. package/dist/cjs/onchain/market/credit/CreditSuite.js +12 -26
  11. package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +5 -45
  12. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +12 -56
  13. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +37 -0
  14. package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +2 -8
  15. package/dist/cjs/onchain/opportunities/OpportunitiesService.js +4 -16
  16. package/dist/cjs/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
  17. package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +8 -9
  18. package/dist/cjs/onchain/validation/bundles/checkDraw.js +28 -0
  19. package/dist/cjs/onchain/validation/bundles/{checkIncreaseQuota.js → checkQuotasAsked.js} +3 -3
  20. package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
  21. package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +5 -6
  22. package/dist/cjs/onchain/validation/bundles/index.js +4 -4
  23. package/dist/cjs/onchain/validation/checkSimulation.js +4 -10
  24. package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
  25. package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +5 -2
  26. package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +1 -1
  27. package/dist/cjs/onchain/validation/index.js +4 -4
  28. package/dist/cjs/sdk/execute/ExecuteApi.js +2 -2
  29. package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +3 -9
  30. package/dist/esm/dev/AccountOpener.js +1 -1
  31. package/dist/esm/dev/withdrawalUtils.js +1 -1
  32. package/dist/esm/history/trace/extractTransfers.js +1 -1
  33. package/dist/esm/model/errors/operation-errors.js +1 -1
  34. package/dist/esm/model/index.js +3 -3
  35. package/dist/esm/model/rwa.js +4 -4
  36. package/dist/esm/model/rwa.schema.js +5 -5
  37. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
  38. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +5 -3
  39. package/dist/esm/onchain/accounts/intents/guards.js +4 -4
  40. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +2 -2
  41. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  42. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  43. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  44. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  45. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  46. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  47. package/dist/esm/onchain/index.js +3 -3
  48. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  49. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  50. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  51. package/dist/esm/onchain/market/credit/CreditSuite.js +12 -26
  52. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  53. package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
  54. package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +5 -45
  55. package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +10 -55
  56. package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +37 -0
  57. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  58. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  59. package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +2 -8
  60. package/dist/esm/onchain/opportunities/OpportunitiesService.js +4 -16
  61. package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
  62. package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
  63. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  64. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +8 -9
  65. package/dist/esm/onchain/validation/bundles/checkDraw.js +27 -0
  66. package/dist/esm/onchain/validation/bundles/{checkIncreaseQuota.js → checkQuotasAsked.js} +3 -3
  67. package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
  68. package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +5 -6
  69. package/dist/esm/onchain/validation/bundles/index.js +3 -3
  70. package/dist/esm/onchain/validation/checkSimulation.js +4 -10
  71. package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
  72. package/dist/esm/onchain/validation/checks/checkDebtLimits.js +5 -2
  73. package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +1 -1
  74. package/dist/esm/onchain/validation/index.js +3 -3
  75. package/dist/esm/sdk/execute/ExecuteApi.js +2 -2
  76. package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +3 -9
  77. package/dist/types/model/errors/operation-errors.d.ts +10 -11
  78. package/dist/types/model/index.d.ts +3 -3
  79. package/dist/types/model/opportunities.d.ts +7 -6
  80. package/dist/types/model/rwa.d.ts +27 -47
  81. package/dist/types/model/rwa.schema.d.ts +3 -3
  82. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +2 -1
  83. package/dist/types/offchain/opportunities/types.d.ts +4 -1
  84. package/dist/types/onchain/accounts/types.d.ts +2 -4
  85. package/dist/types/onchain/index.d.ts +4 -4
  86. package/dist/types/onchain/market/credit/CreditSuite.d.ts +3 -8
  87. package/dist/types/onchain/market/credit/types.d.ts +2 -2
  88. package/dist/types/onchain/market/index.d.ts +2 -2
  89. package/dist/types/onchain/market/pool/types.d.ts +1 -1
  90. package/dist/types/onchain/market/rwa/index.d.ts +2 -2
  91. package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +4 -19
  92. package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +4 -24
  93. package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +14 -2
  94. package/dist/types/onchain/market/rwa/types.d.ts +37 -39
  95. package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +1 -5
  96. package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +3 -10
  97. package/dist/types/onchain/opportunities/types.d.ts +1 -6
  98. package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +2 -3
  99. package/dist/types/onchain/validation/bundles/{checkIncreaseDebt.d.ts → checkDraw.d.ts} +7 -7
  100. package/dist/types/onchain/validation/bundles/{checkIncreaseQuota.d.ts → checkQuotasAsked.d.ts} +3 -3
  101. package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +2 -2
  102. package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +3 -3
  103. package/dist/types/onchain/validation/bundles/index.d.ts +3 -3
  104. package/dist/types/onchain/validation/checkSimulation.d.ts +3 -6
  105. package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +1 -1
  106. package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +1 -1
  107. package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +1 -1
  108. package/dist/types/onchain/validation/index.d.ts +3 -3
  109. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +1 -5
  110. package/dist/types/sdk/opportunities/types.d.ts +3 -9
  111. package/package.json +1 -1
  112. package/dist/cjs/onchain/validation/bundles/checkIncreaseDebt.js +0 -28
  113. package/dist/esm/onchain/validation/bundles/checkIncreaseDebt.js +0 -27
@@ -1,8 +1,8 @@
1
1
  import { checkQuotaLimit } from "../checks/checkQuotaLimit.js";
2
2
  import "../checks/index.js";
3
- //#region src/onchain/validation/bundles/checkIncreaseQuota.ts
3
+ //#region src/onchain/validation/bundles/checkQuotasAsked.ts
4
4
  /** Every quota the operation raises, against the room the keeper has left. */
5
- function checkIncreaseQuota(market, preview, underlying) {
5
+ function checkQuotasAsked(market, preview, underlying) {
6
6
  const increases = preview.operation === "AdjustCreditAccount" ? preview.quotasChange : preview.quotas;
7
7
  const { pqk } = market.pool;
8
8
  return increases.filter((q) => q.value > 0n).flatMap((q) => {
@@ -16,4 +16,4 @@ function checkIncreaseQuota(market, preview, underlying) {
16
16
  });
17
17
  }
18
18
  //#endregion
19
- export { checkIncreaseQuota };
19
+ export { checkQuotasAsked };
@@ -5,24 +5,24 @@ import { toToken } from "../helpers/token.js";
5
5
  import "../helpers/index.js";
6
6
  //#region src/onchain/validation/bundles/checkRWAOpenRequirements.ts
7
7
  /**
8
- * The degen NFT is satisfied that `wallet` may open on `token` with the
8
+ * The RWA factory is satisfied that `wallet` may open on `token` with the
9
9
  * registration args already on the transaction.
10
10
  */
11
11
  async function checkRWAOpenRequirements(input) {
12
12
  const { sdk, wallet, creditManager, token, providedArgs } = input;
13
13
  try {
14
- const nft = await sdk.marketRegister.findCreditManager(creditManager).degenNFT();
15
- if (!nft) return [];
16
- const requirements = await nft.getOpenAccountRequirements(wallet, { tokenOutAddress: token });
17
- const missing = nft.getMissingRequirements(requirements, providedArgs);
18
- if (!missing && nft.isRegistered(requirements)) return [];
14
+ const requirements = await sdk.accounts.getOpenAccountRequirements(wallet, creditManager, { tokenOutAddress: token });
15
+ if (!requirements) return [];
16
+ const { rwaFactory } = sdk.marketRegister.findByCreditManager(creditManager);
17
+ if (!rwaFactory) throw new Error(`no RWA factory for credit manager ${creditManager}`);
18
+ const missing = rwaFactory.getMissingRequirements(requirements, providedArgs);
19
+ if (!missing && requirements.securitizeTokensToRegister.length === 0) return [];
19
20
  return [rwaOpenRequirementsNotMet({
20
21
  token: toToken(sdk, token),
21
22
  creditManager,
22
- protocol: nft.protocol,
23
- registrationLink: nft.registrationLink,
23
+ factory: rwaFactory.address,
24
24
  requirements,
25
- missing
25
+ ...missing === void 0 ? {} : { missing }
26
26
  })];
27
27
  } catch (cause) {
28
28
  return [unexpectedFailure(cause, "read the RWA opening requirements")];
@@ -2,22 +2,21 @@ import { AddressSet } from "../../utils/AddressSet.js";
2
2
  import { checkRWAOpenRequirements } from "./checkRWAOpenRequirements.js";
3
3
  //#region src/onchain/validation/bundles/checkRWAOpening.ts
4
4
  /**
5
- * Per KYC-gated token among `collateralAdded ∪ quotas`, whether the
5
+ * Per factory-gated token among `collateralAdded ∪ quotas`, whether the
6
6
  * borrower still has to register or sign before this opening can land.
7
7
  */
8
8
  async function checkRWAOpening(input) {
9
9
  const { sdk, preview, sender } = input;
10
- const nft = await sdk.marketRegister.findCreditManager(preview.creditManager).degenNFT();
11
- if (!nft) return [];
12
- const gated = new AddressSet(await nft.getTokens());
10
+ const { rwaFactory } = sdk.marketRegister.findByCreditManager(preview.creditManager);
11
+ if (!rwaFactory) return [];
12
+ const gated = new AddressSet(rwaFactory.getTokens());
13
13
  const candidates = new AddressSet([...preview.collateralAdded.map((a) => a.token.address), ...preview.quotas.map((q) => q.token.address)]);
14
- const providedArgs = preview.operation === "RWAOpenCreditAccount" ? preview.rwaArgs : void 0;
15
14
  return (await Promise.all([...candidates].filter((token) => gated.has(token)).map((token) => checkRWAOpenRequirements({
16
15
  sdk,
17
16
  wallet: sender,
18
17
  creditManager: preview.creditManager,
19
18
  token,
20
- providedArgs
19
+ providedArgs: preview.rwaArgs
21
20
  })))).flat();
22
21
  }
23
22
  //#endregion
@@ -2,11 +2,11 @@ import { checkAccountQuotas } from "./checkAccountQuotas.js";
2
2
  import { checkWalletAllowance } from "./checkWalletAllowance.js";
3
3
  import { checkWalletBalance } from "./checkWalletBalance.js";
4
4
  import { checkCollateralFunding } from "./checkCollateralFunding.js";
5
+ import { checkDraw } from "./checkDraw.js";
5
6
  import { checkHealthFactors } from "./checkHealthFactors.js";
6
- import { checkIncreaseDebt } from "./checkIncreaseDebt.js";
7
- import { checkIncreaseQuota } from "./checkIncreaseQuota.js";
8
7
  import { checkMarket } from "./checkMarket.js";
9
8
  import { checkObtained } from "./checkObtained.js";
9
+ import { checkQuotasAsked } from "./checkQuotasAsked.js";
10
10
  import { checkRWAOpenRequirements } from "./checkRWAOpenRequirements.js";
11
11
  import { checkRWAOpening } from "./checkRWAOpening.js";
12
12
  import { checkCreditOperation } from "./checkCreditOperation.js";
@@ -15,4 +15,4 @@ import { checkLiquidationFunding } from "./checkLiquidationFunding.js";
15
15
  import { checkWallet } from "./checkWallet.js";
16
16
  import { checkPoolFunding } from "./checkPoolFunding.js";
17
17
  import { checkPoolOperation } from "./checkPoolOperation.js";
18
- export { checkAccountQuotas, checkCollateralFunding, checkCreditOperation, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLiquidationEligibility, checkLiquidationFunding, checkMarket, checkObtained, checkPoolFunding, checkPoolOperation, checkRWAOpenRequirements, checkRWAOpening, checkWallet, checkWalletAllowance, checkWalletBalance };
18
+ export { checkAccountQuotas, checkCollateralFunding, checkCreditOperation, checkDraw, checkHealthFactors, checkLiquidationEligibility, checkLiquidationFunding, checkMarket, checkObtained, checkPoolFunding, checkPoolOperation, checkQuotasAsked, checkRWAOpenRequirements, checkRWAOpening, checkWallet, checkWalletAllowance, checkWalletBalance };
@@ -1,7 +1,6 @@
1
1
  import { toToken } from "./helpers/token.js";
2
2
  import "./helpers/index.js";
3
3
  import { checkDebtLimits } from "./checks/checkDebtLimits.js";
4
- import { checkQuotaCount } from "./checks/checkQuotaCount.js";
5
4
  import "./checks/index.js";
6
5
  import { checkAccountQuotas } from "./bundles/checkAccountQuotas.js";
7
6
  import { checkHealthFactors } from "./bundles/checkHealthFactors.js";
@@ -27,10 +26,8 @@ import { checkMarket } from "./bundles/checkMarket.js";
27
26
  * touched. The engine performed all three during the walk, so a simulation that
28
27
  * came back `ok` has already passed them.
29
28
  *
30
- * A credit account only, opened or adjusted: a pool operation has no account
31
- * to weigh, and the three things its own state decides are read by `prepare`
32
- * before it answers. An opening names its quotas `averageQuota` — the branch
33
- * the planner already weighed it as.
29
+ * A credit account only: a pool operation has no account to weigh, and the
30
+ * three things its own state decides are read by `prepare` before it answers.
34
31
  */
35
32
  function checkSimulation(sdk, input, options = {}) {
36
33
  const { state } = input;
@@ -43,12 +40,9 @@ function checkSimulation(sdk, input, options = {}) {
43
40
  maxDebt: suite.creditFacade.maxDebt,
44
41
  underlying: toToken(sdk, suite.market.pool.underlying),
45
42
  allowZero: true,
46
- maxBorrowAmount: suite.maxBorrowAmount()
43
+ ceiling: suite.maxBorrowAmount()
47
44
  }),
48
- ..."averageQuota" in state ? checkQuotaCount({
49
- count: state.averageQuota.filter((q) => q.balance > 0n).length,
50
- max: suite.creditManager.maxEnabledTokens
51
- }) : checkAccountQuotas(suite, state),
45
+ ...checkAccountQuotas(suite, state),
52
46
  ...checkHealthFactors(state, options)
53
47
  ];
54
48
  }
@@ -4,7 +4,7 @@ import { amountOf } from "../helpers/amount.js";
4
4
  import "../helpers/index.js";
5
5
  //#region src/onchain/validation/checks/checkBorrowLimit.ts
6
6
  /**
7
- * What the pool will hand over, against the amount requested.
7
+ * What the pool will hand over, against what is asked for.
8
8
  *
9
9
  * `available` and `limit` are the caller's reading of which limit is in the
10
10
  * way; this check only compares. `maxBorrowAmount` is the largest debt still
@@ -5,13 +5,16 @@ import "../helpers/index.js";
5
5
  //#region src/onchain/validation/checks/checkDebtLimits.ts
6
6
  /** A debt the facade would revert on. */
7
7
  function checkDebtLimits(args) {
8
- const { debt, minDebt, maxDebt, underlying, allowZero, maxBorrowAmount } = args;
8
+ const { debt, minDebt, maxDebt, underlying, allowZero, ceiling } = args;
9
9
  if (!(debt > maxDebt || debt < minDebt && !(allowZero && debt === 0n))) return [];
10
10
  return [debtOutOfRange({
11
11
  requested: amountOf(underlying, debt),
12
12
  minDebt: amountOf(underlying, minDebt),
13
13
  maxDebt: amountOf(underlying, maxDebt),
14
- maxBorrowAmount
14
+ ceiling: ceiling && {
15
+ amount: amountOf(underlying, ceiling.value),
16
+ limit: ceiling.limit
17
+ }
15
18
  })];
16
19
  }
17
20
  //#endregion
@@ -7,7 +7,7 @@ import "../helpers/index.js";
7
7
  * What the pool holds, against what is being taken out of it.
8
8
  *
9
9
  * The operator is not `checkBorrowLimit`'s: a pool holding exactly the amount
10
- * requested still cannot serve it, so equality is already a refusal. That is
10
+ * asked for still cannot serve it, so equality is already a refusal. That is
11
11
  * the rule the legacy withdrawal validator enforced and it is preserved to the
12
12
  * unit.
13
13
  */
@@ -22,11 +22,11 @@ import { checkAccountQuotas } from "./bundles/checkAccountQuotas.js";
22
22
  import { checkWalletAllowance } from "./bundles/checkWalletAllowance.js";
23
23
  import { checkWalletBalance } from "./bundles/checkWalletBalance.js";
24
24
  import { checkCollateralFunding } from "./bundles/checkCollateralFunding.js";
25
+ import { checkDraw } from "./bundles/checkDraw.js";
25
26
  import { checkHealthFactors } from "./bundles/checkHealthFactors.js";
26
- import { checkIncreaseDebt } from "./bundles/checkIncreaseDebt.js";
27
- import { checkIncreaseQuota } from "./bundles/checkIncreaseQuota.js";
28
27
  import { checkMarket } from "./bundles/checkMarket.js";
29
28
  import { checkObtained } from "./bundles/checkObtained.js";
29
+ import { checkQuotasAsked } from "./bundles/checkQuotasAsked.js";
30
30
  import { checkRWAOpenRequirements } from "./bundles/checkRWAOpenRequirements.js";
31
31
  import { checkRWAOpening } from "./bundles/checkRWAOpening.js";
32
32
  import { checkCreditOperation } from "./bundles/checkCreditOperation.js";
@@ -40,4 +40,4 @@ import { checkLiquidation } from "./checkLiquidation.js";
40
40
  import { checkOperation } from "./checkOperation.js";
41
41
  import { checkSimulation } from "./checkSimulation.js";
42
42
  import { raise } from "./raise.js";
43
- export { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, amountOf, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, raise, toToken, toTokenAmount };
43
+ export { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, amountOf, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkDraw, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkQuotasAsked, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, raise, toToken, toTokenAmount };
@@ -73,9 +73,9 @@ async function openTx(sdk, request) {
73
73
  async function openRwaOptions(sdk, request) {
74
74
  if (!request.targetToken) return;
75
75
  const requirements = await sdk.accounts.getOpenAccountRequirements(request.wallet, request.creditManager, { tokenOutAddress: request.targetToken });
76
- if (requirements?.protocol !== "securitize") return;
76
+ if (!requirements) return;
77
77
  return {
78
- protocol: "securitize",
78
+ type: requirements.type,
79
79
  tokensToRegister: requirements.tokensToRegister,
80
80
  signaturesToCache: request.signaturesToCache ?? []
81
81
  };
@@ -70,21 +70,15 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
70
70
  /**
71
71
  * {@inheritDoc IOpportunitiesBase.getStrategy}
72
72
  **/
73
- async getStrategy(key) {
73
+ async getStrategy(key, wallet) {
74
74
  return this.merged("get strategy opportunity", {
75
75
  chainIds: [key.chainId],
76
- fromChain: (source) => source.getStrategy(key),
77
- fromBackend: (source) => source.getStrategy(key),
76
+ fromChain: (source) => source.getStrategy(key, wallet),
77
+ fromBackend: (source) => source.getStrategy(key, wallet),
78
78
  merge: this.merge.strategy
79
79
  });
80
80
  }
81
81
  /**
82
- * {@inheritDoc IOpportunitiesOnchainOnly.isEligibleForStrategy}
83
- **/
84
- async isEligibleForStrategy(key, wallet) {
85
- return this.onchain.isEligibleForStrategy(key, wallet);
86
- }
87
- /**
88
82
  * {@inheritDoc IOpportunitiesBase.filter}
89
83
  **/
90
84
  filter(response, filter) {
@@ -1,8 +1,6 @@
1
1
  import { Bps, Token, TokenAmount } from "../primitives.js";
2
2
  import { IGearboxError } from "./base.js";
3
- import { RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAProtocol } from "../rwa.js";
4
- import { MaxBorrowAmount } from "../../onchain/market/credit/types.js";
5
- import "../../onchain/index.js";
3
+ import { RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements } from "../rwa.js";
6
4
  import { Address } from "viem";
7
5
  //#region src/model/errors/operation-errors.d.ts
8
6
  /**
@@ -55,7 +53,7 @@ interface PoolSunsetError extends IGearboxError {
55
53
  /** {@inheritDoc PoolSunsetError} */
56
54
  declare function poolSunset(pool: Address): PoolSunsetError;
57
55
  /**
58
- * The pool cannot lend what the operation wants to borrow.
56
+ * The pool cannot lend what the operation asks for.
59
57
  **/
60
58
  interface InsufficientPoolLiquidityError extends IGearboxError {
61
59
  code: "insufficientPoolLiquidity";
@@ -85,7 +83,10 @@ interface DebtOutOfRangeError extends IGearboxError {
85
83
  minDebt: TokenAmount;
86
84
  maxDebt: TokenAmount;
87
85
  /** What the market will really lend; absent where the raiser only throws. */
88
- maxBorrowAmount?: MaxBorrowAmount;
86
+ ceiling?: {
87
+ amount: TokenAmount;
88
+ limit: BorrowLimitCause;
89
+ };
89
90
  }
90
91
  /** {@inheritDoc DebtOutOfRangeError} */
91
92
  declare function debtOutOfRange(args: Omit<DebtOutOfRangeError, "code" | "message">): DebtOutOfRangeError;
@@ -140,7 +141,7 @@ declare function forbiddenToken(token: Token): ForbiddenTokenError;
140
141
  **/
141
142
  interface QuotaLimitReachedError extends IGearboxError {
142
143
  code: "quotaLimitReached";
143
- /** The token whose quota is increased. */
144
+ /** The token whose quota is asked for. */
144
145
  token: Token;
145
146
  /**
146
147
  * In the **underlying**, which is what a quota is measured in. Absent for a
@@ -201,19 +202,17 @@ interface InsufficientAllowanceError extends IGearboxError {
201
202
  /** {@inheritDoc InsufficientAllowanceError} */
202
203
  declare function insufficientAllowance(args: Omit<InsufficientAllowanceError, "code" | "message">): InsufficientAllowanceError;
203
204
  /**
204
- * The RWA protocol still wants something from the borrower before this token
205
+ * The RWA factory still wants something from the borrower before this token
205
206
  * can be opened on.
206
207
  **/
207
208
  interface RWAOpenRequirementsError extends IGearboxError {
208
209
  code: "rwaOpenRequirementsNotMet";
209
210
  token: Token;
210
211
  creditManager: Address;
211
- protocol: RWAProtocol;
212
- /** Where the wallet completes registration with {@link protocol}. */
213
- registrationLink: string;
212
+ factory: Address;
214
213
  /** Always present on the error. */
215
214
  requirements: RWAOpenAccountRequirements;
216
- /** Absent when only issuer-side registration is pending (or Midas greenlist). */
215
+ /** Absent when only issuer-side registration is pending. */
217
216
  missing?: RWAMissingOpenAccountRequirements;
218
217
  }
219
218
  /** {@inheritDoc RWAOpenRequirementsError} */
@@ -5,7 +5,7 @@ import { Curator, CuratorName } from "./curators.js";
5
5
  import { DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedWithdrawCollateralIntent } from "./delayed-intents.js";
6
6
  import { IGearboxError } from "./errors/base.js";
7
7
  import { CreditAccountFrozenError, LiquidatorNotEligibleError, NotEmergencyLiquidatorError, creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator } from "./errors/liquidation-errors.js";
8
- import { KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, MidasOpenAccountRequirements, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature } from "./rwa.js";
8
+ import { KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature } from "./rwa.js";
9
9
  import { BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet } from "./errors/operation-errors.js";
10
10
  import { UnpriceableTokenError, unpriceableTokenError } from "./errors/oracle-errors.js";
11
11
  import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./errors/prepare-errors.js";
@@ -30,7 +30,7 @@ import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema
30
30
  import { ChainFailed, ChainMetadata, ChainScoped, ChainSucceeded, DataResponse, DataSource, ResponseMetadata } from "./response.js";
31
31
  import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema } from "./response.schema.js";
32
32
  import { SDKError, SDKResult, SDKReturn, SafeValue, safeValue, sdkErr, sdkOk } from "./result.js";
33
- import { kycRequirementSchema, rwaProtocolSchema } from "./rwa.schema.js";
33
+ import { kycProtocolSchema, kycRequirementSchema } from "./rwa.schema.js";
34
34
  import { PositionClaimableWithdrawal, PositionPendingWithdrawal, PositionWithdrawals, WithdrawalOutputAmount } from "./withdrawals.js";
35
35
  import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
36
- export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, ForbiddenTokenError, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, Leverage, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MidasOpenAccountRequirements, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, Notice, NoticeKind, NoticeSubject, OpenNonRWAStrategyPositionPreview, OpenRWAStrategyPositionPreview, OpenStrategyPositionPreview, OperationPreview, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationPreviewError, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPausedError, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, PoolSunsetError, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAsset, QuotaCountExceededError, QuotaLimitReachedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, WithdrawalOutputAmount, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, rwaProtocolSchema, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
36
+ export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, Amount, AnalyticsChartQuery, AnalyticsLiquidationPosition, AnalyticsPoolPosition, AnalyticsPosition, AnalyticsPositionListOptions, AnalyticsPositionOwner, AnalyticsPositionPage, AnalyticsPositionSortField, AnalyticsSortDirection, AnalyticsStrategyPosition, ApyBreakdown, Asset, AssetType, BorrowLimitCause, BorrowRateBreakdown, Bps, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, ChainFailed, ChainId, ChainMetadata, ChainScoped, ChainScopedFilter, ChainSucceeded, ChartBundle, ChartDenomination, ChartMetric, ChartQuery, ChartRange, ChartSeries, ChartSeriesOk, ChartSeriesUnavailable, ChartUnavailableCode, ChartUnit, ChartValue, ChartWindow, CompareTag, CompareTolerance, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, CreditOperationMarket, Curator, CuratorName, DataResponse, DataSource, DebtOutOfRangeError, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedReceivedAsset, DelayedStrategyPositionOperationPreview, DelayedWithdrawCollateralIntent, Estimated, EstimatedProjection, ExitStrategyPositionPreview, FILTER_ALL, FilterAll, Filterable, ForbiddenTokenError, GridSampling, IGearboxError, InstantReceivedAsset, InstantStrategyPositionOperationPreview, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, Leverage, LeverageOutOfRangeError, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, Notice, NoticeKind, NoticeSubject, OpenNonRWAStrategyPositionPreview, OpenRWAStrategyPositionPreview, OpenStrategyPositionPreview, OperationPreview, Opportunity, OpportunityBase, OpportunityChartMetric, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, OpportunityTotals, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolOperationPreviewError, PoolOperationType, PoolOpportunity, PoolOpportunityChartMetric, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPausedError, PoolPosition, PoolPositionChartMetric, PoolPositionKey, PoolPositionOperationPreview, PoolPositionRef, PoolSunsetError, Position, PositionChartMetric, PositionClaimableWithdrawal, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionPendingWithdrawal, PositionTransaction, PositionTransactionKind, PositionWithdrawals, PositionsTotals, PreviewOperationInput, PreviewOperationOptions, PriceFeedData, PriceFeedSummary, ProtocolChartMetric, QuotaAsset, QuotaCountExceededError, QuotaLimitReachedError, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOpenRequirementsError, RWAOperationArgs, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RateCurve, RateCurvePoint, ReceivedAsset, RepayStrategyPositionPreview, ResponseMetadata, Rewards, RewardsPnL, RoutedField, SDKError, SDKResult, SDKReturn, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, SafeValue, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StrategyOpportunity, StrategyOpportunityChartMetric, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionChartMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenQuotaRate, TokenRewards, TokenRewardsPnL, ToleranceCompareTag, TxCall, UnderlyingToken, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, WithdrawalOutputAmount, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycProtocolSchema, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
@@ -221,7 +221,7 @@ interface StrategyOpportunity extends OpportunityBase {
221
221
  **/
222
222
  targetCollateral: Token;
223
223
  /**
224
- * Debt principal this credit manager has borrowed from the pool
224
+ * Debt principal this credit manager has drawn from the pool
225
225
  * (`pool.creditManagerBorrowed(creditManager)`). Denominated in the
226
226
  * underlying.
227
227
  **/
@@ -331,7 +331,7 @@ interface StrategyOpportunity extends OpportunityBase {
331
331
  **/
332
332
  minDebt: Amount;
333
333
  /**
334
- * Cap on the total debt this credit manager may borrow from the pool, shared
334
+ * Cap on the total debt this credit manager may draw from the pool, shared
335
335
  * by all of its accounts and denominated in the underlying
336
336
  * (`creditManagerDebtParams.limit`).
337
337
  **/
@@ -591,10 +591,11 @@ interface StrategyOpportunityDetail extends StrategyOpportunity {
591
591
  **/
592
592
  priceFeeds: PriceFeedSummary;
593
593
  /**
594
- * KYC gate of this strategy, independent of any wallet. `null` when the
595
- * strategy is not KYC-gated. `undefined` only in `offchain` mode, until the
596
- * backend serves it. In `both` mode `kyc` is taken from the chain whenever
597
- * that leg succeeded.
594
+ * Registration the wallet passed to `getStrategy` still needs before it may
595
+ * open this strategy. `null` when the strategy is not KYC-gated, when no
596
+ * wallet was given, or when the wallet is already eligible. `undefined`
597
+ * only in `offchain` mode, where the backend does not evaluate it. In
598
+ * `both` mode `kyc` is taken from the chain whenever that leg succeeded.
598
599
  **/
599
600
  kyc?: KycRequirement | null;
600
601
  }
@@ -72,22 +72,12 @@ declare const SECURITIZE_REGISTER_VAULT_TYPES: {
72
72
  * @see VaultRegistrar in https://github.com/Gearbox-protocol/periphery-v3
73
73
  **/
74
74
  type SecuritizeRegisterVaultMessage = TypedDataDefinition<typeof SECURITIZE_REGISTER_VAULT_TYPES, "RegisterVault">;
75
- /**
76
- * RWA protocols that require dedicated flows
77
- **/
78
- declare const RWA_PROTOCOLS: readonly ["securitize", "midas"];
79
- /** String literal union of {@link RWA_PROTOCOLS}. */
80
- type RWAProtocol = (typeof RWA_PROTOCOLS)[number];
81
- /**
82
- * KYC is only ever an RWA concern today, so the two names coincide.
83
- **/
84
- type KycProtocol = RWAProtocol;
85
75
  /**
86
76
  * Factory-specific args for a Securitize RWA factory `multicall` /
87
77
  * `openCreditAccount`.
88
78
  **/
89
79
  interface SecuritizeOperationArgs {
90
- protocol: "securitize";
80
+ type: typeof RWA_FACTORY_SECURITIZE;
91
81
  /** DSToken addresses to register for this operation. */
92
82
  tokensToRegister: Address[];
93
83
  /** Cached EIP-712 registration signatures to store on-chain. */
@@ -95,11 +85,12 @@ interface SecuritizeOperationArgs {
95
85
  }
96
86
  /**
97
87
  * Subset of {@link SecuritizeOpenAccountRequirements} still unfulfilled given
98
- * the params already carried by the transaction calldata. `undefined` there means the
88
+ * the params already carried by the transaction calldata. Returned by
89
+ * `SecuritizeRWAFactory.getMissingRequirements`; `undefined` there means the
99
90
  * requirements are satisfied.
100
91
  **/
101
92
  interface SecuritizeMissingOpenAccountRequirements {
102
- protocol: "securitize";
93
+ type: typeof RWA_FACTORY_SECURITIZE;
103
94
  /**
104
95
  * EIP-712 messages the investor still has to sign (not covered by
105
96
  * calldata-provided signatures). Once signed, they become the
@@ -109,12 +100,7 @@ interface SecuritizeMissingOpenAccountRequirements {
109
100
  requiredSignatures: SecuritizeRegisterVaultMessage[];
110
101
  }
111
102
  interface SecuritizeOpenAccountRequirements {
112
- protocol: "securitize";
113
- /**
114
- * RWA Factory contract address whose `openCreditAccount`/`multicall`
115
- * consume `tokensToRegister` and the signatures.
116
- */
117
- factory: Address;
103
+ type: typeof RWA_FACTORY_SECURITIZE;
118
104
  /**
119
105
  * User must visit securitize website to register these tokens
120
106
  * May be empty if user already registered all required tokens
@@ -133,41 +119,35 @@ interface SecuritizeOpenAccountRequirements {
133
119
  requiredSignatures: SecuritizeRegisterVaultMessage[];
134
120
  }
135
121
  /**
136
- * What a wallet still has to do before a Permissioned Midas market lets it
137
- * open. There are no tx args: Midas grants a role off-chain.
122
+ * Open-account requirements for a RWA factory, defaults to union of all factory types.
123
+ * Can be discriminated by type.
138
124
  **/
139
- interface MidasOpenAccountRequirements {
140
- protocol: "midas";
141
- /** mToken the gateway greenlists wallets for. */
142
- token: Address;
143
- /** `false` until Midas grants the greenlisted role; there is nothing else to do and no tx args. */
144
- greenlisted: boolean;
145
- }
125
+ type RWAOpenAccountRequirements<T extends RWAFactoryType = RWAFactoryType> = Extract<SecuritizeOpenAccountRequirements, {
126
+ type: T;
127
+ }>;
146
128
  /**
147
- * Open-account requirements for an RWA protocol, defaults to the union of all
148
- * protocols. Discriminated by {@link RWAProtocol}.
129
+ * Subset of {@link RWAOpenAccountRequirements} that is still unfulfilled,
130
+ * defaults to union of all factory types.
131
+ * Can be discriminated by type.
149
132
  **/
150
- type RWAOpenAccountRequirements<P extends RWAProtocol = RWAProtocol> = Extract<SecuritizeOpenAccountRequirements | MidasOpenAccountRequirements, {
151
- protocol: P;
133
+ type RWAMissingOpenAccountRequirements<T extends RWAFactoryType = RWAFactoryType> = Extract<SecuritizeMissingOpenAccountRequirements, {
134
+ type: T;
152
135
  }>;
153
136
  /**
154
- * Subset of {@link RWAOpenAccountRequirements} that is still unfulfilled given
155
- * the params already on the transaction. Midas has none (`never`).
137
+ * Open credit account/Multicall extra params type for a RWA factory, defaults to union of all factory types.
138
+ * Can be discriminated by type.
156
139
  **/
157
- type RWAMissingOpenAccountRequirements<P extends RWAProtocol = RWAProtocol> = Extract<SecuritizeMissingOpenAccountRequirements, {
158
- protocol: P;
140
+ type RWAOperationArgs<T extends RWAFactoryType = RWAFactoryType> = Extract<SecuritizeOperationArgs, {
141
+ type: T;
159
142
  }>;
160
143
  /**
161
- * Open credit account/Multicall extra params for an RWA protocol. Midas has
162
- * none (`never`): accounts open through the plain facade.
144
+ * KYC providers a strategy may be gated by
163
145
  **/
164
- type RWAOperationArgs<P extends RWAProtocol = RWAProtocol> = Extract<SecuritizeOperationArgs, {
165
- protocol: P;
166
- }>;
146
+ declare const KYC_PROTOCOLS: readonly ["securitize", "midas"];
147
+ /** String literal union of {@link KYC_PROTOCOLS}. */
148
+ type KycProtocol = (typeof KYC_PROTOCOLS)[number];
167
149
  /**
168
- * What a wallet still has to do before it may open a KYC-gated strategy —
169
- * the gate itself, independent of any particular wallet. `null` on a
170
- * strategy that is not gated.
150
+ * What a wallet still has to do before it may open a KYC-gated strategy.
171
151
  **/
172
152
  interface KycRequirement {
173
153
  protocol: KycProtocol;
@@ -180,8 +160,8 @@ interface KycRequirement {
180
160
  registrationLink: string;
181
161
  }
182
162
  /**
183
- * Hardcoded registration URLs for each {@link RWAProtocol}.
163
+ * Hardcoded registration URLs for each {@link KycProtocol}.
184
164
  **/
185
- declare const KYC_REGISTRATION_LINKS: Record<RWAProtocol, string>;
165
+ declare const KYC_REGISTRATION_LINKS: Record<KycProtocol, string>;
186
166
  //#endregion
187
- export { KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, MidasOpenAccountRequirements, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_PROTOCOLS, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature };
167
+ export { KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, KycProtocol, KycRequirement, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature };
@@ -1,9 +1,9 @@
1
1
  import { z } from "zod/v4";
2
2
  //#region src/model/rwa.schema.d.ts
3
3
  /**
4
- * {@link ./rwa.js#RWAProtocol}
4
+ * {@link ./rwa.js#KycProtocol}
5
5
  **/
6
- declare const rwaProtocolSchema: z.ZodEnum<{
6
+ declare const kycProtocolSchema: z.ZodEnum<{
7
7
  midas: "midas";
8
8
  securitize: "securitize";
9
9
  }>;
@@ -26,4 +26,4 @@ declare const kycRequirementSchema: z.ZodObject<{
26
26
  registrationLink: z.ZodString;
27
27
  }, z.core.$strip>;
28
28
  //#endregion
29
- export { kycRequirementSchema, rwaProtocolSchema };
29
+ export { kycProtocolSchema, kycRequirementSchema };
@@ -4,6 +4,7 @@ import { DataResponse } from "../../model/response.js";
4
4
  import { GearboxAPIOptions } from "../types.js";
5
5
  import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
6
6
  import { IOffchainOpportunities, OpportunityChartMetricFor } from "./types.js";
7
+ import { Address } from "viem";
7
8
  //#region src/offchain/opportunities/OffchainOpportunities.d.ts
8
9
  /**
9
10
  * Backend counterpart of the `opportunities` namespace.
@@ -22,7 +23,7 @@ declare class OffchainOpportunities extends AbstractOffchainNamespace implements
22
23
  /**
23
24
  * {@inheritDoc IOffchainOpportunities.getStrategy}
24
25
  **/
25
- getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
26
+ getStrategy(key: StrategyOpportunityKey, _wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
26
27
  /**
27
28
  * {@inheritDoc IOffchainOpportunities.getTotals}
28
29
  **/
@@ -1,6 +1,7 @@
1
1
  import { ChartBundle, ChartRange, PoolOpportunityChartMetric, StrategyOpportunityChartMetric } from "../../model/charts.js";
2
2
  import { Opportunity, OpportunityFilter, OpportunityKey, OpportunityTotals, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
+ import { Address } from "viem";
4
5
  //#region src/offchain/opportunities/types.d.ts
5
6
  type OpportunityChartMetricFor<K extends OpportunityKey> = {
6
7
  pool: PoolOpportunityChartMetric;
@@ -21,8 +22,10 @@ interface IOffchainOpportunities {
21
22
  getPool(key: PoolOpportunityKey): Promise<DataResponse<PoolOpportunityDetail>>;
22
23
  /**
23
24
  * Detailed view of one strategy opportunity.
25
+ *
26
+ * @param wallet - Optional wallet address to check KYC status for.
24
27
  **/
25
- getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
28
+ getStrategy(key: StrategyOpportunityKey, wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
26
29
  /**
27
30
  * Protocol-wide totals across every opportunity the backend serves.
28
31
  **/
@@ -490,13 +490,11 @@ interface ICreditAccountsService extends Construct {
490
490
  */
491
491
  getApprovalAddress(props: GetApprovalAddressProps): Promise<Address>;
492
492
  /**
493
- * Returns open account requirements for a borrower. `undefined` when the
494
- * credit manager has no KYC gate.
495
- *
493
+ * Returns open account requirements for a borrower
496
494
  * @param borrower - Borrower address
497
495
  * @param creditManager - Credit manager address
498
496
  * @param props - {@link GetOpenAccountRequirementsProps} you can pass StrategyConfigPayload here
499
- * @returns Open account requirements, or `undefined` when there is no KYC gate
497
+ * @returns Open account requirements or undefined if the user can open a credit account without any further actions
500
498
  */
501
499
  getOpenAccountRequirements(borrower: Address, creditManager: Address, props: GetOpenAccountRequirementsProps): Promise<RWAOpenAccountRequirements | undefined>;
502
500
  /**