@gearbox-protocol/sdk 16.3.0-next.3 → 16.3.0-next.4

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 (62) 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 +1 -3
  7. package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  8. package/dist/cjs/onchain/market/credit/CreditSuite.js +19 -9
  9. package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
  10. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +56 -12
  11. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
  12. package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
  13. package/dist/cjs/onchain/opportunities/OpportunitiesService.js +16 -4
  14. package/dist/cjs/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
  15. package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +1 -1
  16. package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
  17. package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +6 -5
  18. package/dist/cjs/sdk/execute/ExecuteApi.js +2 -2
  19. package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +9 -3
  20. package/dist/esm/model/errors/operation-errors.js +1 -1
  21. package/dist/esm/model/index.js +3 -3
  22. package/dist/esm/model/rwa.js +4 -4
  23. package/dist/esm/model/rwa.schema.js +5 -5
  24. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
  25. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +1 -3
  26. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  27. package/dist/esm/onchain/market/credit/CreditSuite.js +19 -9
  28. package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
  29. package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +55 -10
  30. package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
  31. package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
  32. package/dist/esm/onchain/opportunities/OpportunitiesService.js +16 -4
  33. package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
  34. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +1 -1
  35. package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
  36. package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +6 -5
  37. package/dist/esm/sdk/execute/ExecuteApi.js +2 -2
  38. package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +9 -3
  39. package/dist/types/model/errors/operation-errors.d.ts +6 -4
  40. package/dist/types/model/index.d.ts +3 -3
  41. package/dist/types/model/opportunities.d.ts +4 -5
  42. package/dist/types/model/rwa.d.ts +47 -27
  43. package/dist/types/model/rwa.schema.d.ts +3 -3
  44. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -2
  45. package/dist/types/offchain/opportunities/types.d.ts +1 -4
  46. package/dist/types/onchain/accounts/types.d.ts +4 -2
  47. package/dist/types/onchain/index.d.ts +2 -2
  48. package/dist/types/onchain/market/credit/CreditSuite.d.ts +8 -3
  49. package/dist/types/onchain/market/index.d.ts +2 -2
  50. package/dist/types/onchain/market/rwa/index.d.ts +2 -2
  51. package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +19 -4
  52. package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +24 -4
  53. package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -14
  54. package/dist/types/onchain/market/rwa/types.d.ts +39 -37
  55. package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +5 -1
  56. package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +10 -3
  57. package/dist/types/onchain/opportunities/types.d.ts +6 -1
  58. package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +2 -2
  59. package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +3 -3
  60. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +5 -1
  61. package/dist/types/sdk/opportunities/types.d.ts +9 -3
  62. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { iRWACompressorAbi } from "../../../abi/rwa/iRWACompressor.js";
2
- import { KycProtocol, RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWA_FACTORY_SECURITIZE } from "../../../model/rwa.js";
2
+ import { RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWAProtocol, RWA_FACTORY_SECURITIZE } from "../../../model/rwa.js";
3
3
  import "../../../model/index.js";
4
4
  import { IBaseContract, Unarray } from "../../base/types.js";
5
5
  import { SecuritizeInvestorData, SecuritizeRWAFactoryStateHuman } from "./securitize/types.js";
@@ -19,10 +19,15 @@ import { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype";
19
19
  **/
20
20
  interface RWAFactoryTypeMap {
21
21
  [RWA_FACTORY_SECURITIZE]: {
22
+ protocol: "securitize";
22
23
  investorData: SecuritizeInvestorData;
23
24
  stateHuman: SecuritizeRWAFactoryStateHuman;
24
25
  };
25
26
  }
27
+ /**
28
+ * {@link RWAProtocol} of the factory type `T`.
29
+ **/
30
+ type RWAFactoryProtocol<T extends RWAFactoryType> = RWAFactoryTypeMap[T]["protocol"];
26
31
  /**
27
32
  * Investor data decoded from the RWA compressor, defaults to union of all factory types
28
33
  * Can be discriminated by type
@@ -151,26 +156,7 @@ interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends IBaseCo
151
156
  * @param args - factory-specific args (e.g. tokens to register, signatures to cache).
152
157
  * Undefined value means that no RWA actions are required
153
158
  **/
154
- multicall(creditAccount: Address, calls: MultiCall[], args?: RWAOperationArgs<T>): RawTx;
155
- /**
156
- * Checks if the user can open a credit account with this factory.
157
- * @param investor - investor address
158
- * @param props - {@link GetOpenAccountRequirementsProps}
159
- * @returns open account requirements for the investor, or `undefined` if the
160
- * user can open a credit account without any further actions
161
- **/
162
- getOpenAccountRequirements(investor: Address, props: GetOpenAccountRequirementsProps): Promise<RWAOpenAccountRequirements<T> | undefined>;
163
- /**
164
- * Computes the subset of `requirements` still unfulfilled, given the
165
- * factory-specific params already carried by the transaction calldata.
166
- *
167
- * @param requirements - requirements fetched via {@link getOpenAccountRequirements}
168
- * @param providedArgs - params decoded from the transaction calldata, if
169
- * any; e.g. signatures already included there need not be signed again
170
- * @returns the missing requirements, or `undefined` when everything is
171
- * satisfied
172
- **/
173
- getMissingRequirements(requirements: RWAOpenAccountRequirements<T>, providedArgs?: RWAOperationArgs<T>): RWAMissingOpenAccountRequirements<T> | undefined;
159
+ multicall(creditAccount: Address, calls: MultiCall[], args?: RWAOperationArgs<RWAFactoryProtocol<T>>): RawTx;
174
160
  /**
175
161
  * Creates a raw transaction to open a credit account.
176
162
  * Similar to {@link CreditFacadeV310Contract.openCreditAccount}.
@@ -180,25 +166,41 @@ interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends IBaseCo
180
166
  * @param args - factory-specific args (e.g. tokens to register, signatures to cache).
181
167
  * Undefined value means that no RWA actions are required (e.g. when we open second credit account)
182
168
  **/
183
- openCreditAccount(creditManager: Address, calls: MultiCall[], args?: RWAOperationArgs<T>): RawTx;
184
- }
185
- /**
186
- * Result of {@link IDegenNFT.checkKyc}.
187
- */
188
- interface KycCheckResult {
189
- eligible: boolean;
190
- /** Token the wallet must be registered for. */
191
- token: Address;
169
+ openCreditAccount(creditManager: Address, calls: MultiCall[], args?: RWAOperationArgs<RWAFactoryProtocol<T>>): RawTx;
170
+ /**
171
+ * Degen NFT this factory deploys as the KYC gate. Midas has no factory;
172
+ * its NFT is loaded separately via {@link createDegenNFT}.
173
+ **/
174
+ readonly degenNFT: IDegenNFT<RWAFactoryProtocol<T>>;
192
175
  }
193
176
  /**
194
- * Degen NFT that gates credit-account opening behind a KYC provider.
195
- */
196
- interface IDegenNFT extends IBaseContract {
197
- readonly protocol: KycProtocol;
177
+ * Degen NFT that gates credit-account opening behind an RWA KYC provider.
178
+ **/
179
+ interface IDegenNFT<P extends RWAProtocol = RWAProtocol> extends IBaseContract {
180
+ readonly protocol: P;
181
+ readonly registrationLink: string;
182
+ /**
183
+ * Tokens this gate is about: Securitize DS tokens, or the Midas mToken.
184
+ */
185
+ getTokens(): Promise<Address[]>;
186
+ /**
187
+ * What `wallet` still has to do before this gate lets it open on the
188
+ * strategy token in `props`.
189
+ */
190
+ getOpenAccountRequirements(wallet: Address, props: GetOpenAccountRequirementsProps): Promise<RWAOpenAccountRequirements<P>>;
191
+ /**
192
+ * Protocol-side KYC is done: registered at Securitize for every requested
193
+ * DS token, or greenlisted by Midas.
194
+ *
195
+ * User might still be required to do additional actions on Gearbox side,
196
+ * e.g. sign EIP-712 messages for Securitize
197
+ */
198
+ isRegistered(requirements: RWAOpenAccountRequirements<P>): boolean;
198
199
  /**
199
- * Same predicate the NFT's `burn` reverts on.
200
+ * Leftover Gearbox-tx work given `providedArgs` already on the calldata.
201
+ * Always `undefined` for Midas (no tx args).
200
202
  */
201
- checkKyc(wallet: Address, targetCollateral: Address): Promise<KycCheckResult>;
203
+ getMissingRequirements(requirements: RWAOpenAccountRequirements<P>, providedArgs?: RWAOperationArgs<P>): RWAMissingOpenAccountRequirements<P> | undefined;
202
204
  }
203
205
  /**
204
206
  * Narrows any contract to an {@link IRWAFactory}.
@@ -211,4 +213,4 @@ interface IDegenNFT extends IBaseContract {
211
213
  **/
212
214
  declare function isRWAFactory<T extends RWAFactoryType = RWAFactoryType>(contract: IBaseContract, type?: T): contract is IRWAFactory<T>;
213
215
  //#endregion
214
- export { GetInvestorOptions, GetOpenAccountRequirementsProps, IDegenNFT, IRWAFactory, KycCheckResult, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWAFactoryData, RWAFactoryStateHuman, RWAInvestorData, RWAState, RWAStateHuman, RWAUnderlyingData, isRWAFactory };
216
+ export { GetInvestorOptions, GetOpenAccountRequirementsProps, IDegenNFT, IRWAFactory, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWAFactoryData, RWAFactoryProtocol, RWAFactoryStateHuman, RWAInvestorData, RWAState, RWAStateHuman, RWAUnderlyingData, isRWAFactory };
@@ -33,7 +33,11 @@ declare class MultichainOpportunitiesService<const Plugins extends PluginsMap =
33
33
  *
34
34
  * See {@link MultichainOpportunitiesService.getPool}.
35
35
  **/
36
- getStrategy(key: StrategyOpportunityKey, wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
36
+ getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
37
+ /**
38
+ * {@inheritDoc OpportunitiesService.isEligibleForStrategy}
39
+ **/
40
+ isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
37
41
  }
38
42
  //#endregion
39
43
  export { MultichainOpportunitiesService };
@@ -34,13 +34,20 @@ declare class OpportunitiesService extends SDKConstruct {
34
34
  * A single strategy opportunity plus the rate curve of the pool it borrows
35
35
  * from and the price feeds its liquidation price depends on.
36
36
  *
37
- * @param wallet - When given, `kyc` says whether this wallet must register
38
- * with the strategy's KYC provider first; `null` otherwise.
37
+ * `kyc` is the strategy's KYC gate, independent of any wallet.
39
38
  *
40
39
  * @throws If the credit manager is unknown, or does not currently offer a
41
40
  * strategy.
42
41
  **/
43
- getStrategy(key: StrategyOpportunityKey, wallet?: Address): Promise<StrategyOpportunityDetail>;
42
+ getStrategy(key: StrategyOpportunityKey): Promise<StrategyOpportunityDetail>;
43
+ /**
44
+ * Whether `wallet` may open this strategy today: `true` when it is not
45
+ * KYC-gated or the wallet already passed the gate.
46
+ *
47
+ * @throws If the credit manager is unknown, or does not currently offer a
48
+ * strategy.
49
+ **/
50
+ isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
44
51
  }
45
52
  //#endregion
46
53
  export { OpportunitiesService };
@@ -22,7 +22,12 @@ interface IMultichainOpportunitiesService {
22
22
  /**
23
23
  * Detailed view of one strategy opportunity.
24
24
  **/
25
- getStrategy(key: StrategyOpportunityKey, wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
25
+ getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
26
+ /**
27
+ * Whether `wallet` may open this strategy today. Throws when that chain
28
+ * cannot answer.
29
+ **/
30
+ isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
26
31
  }
27
32
  //#endregion
28
33
  export { IMultichainOpportunitiesService };
@@ -10,10 +10,10 @@ interface CheckRWAOpenRequirementsInput {
10
10
  wallet: Address;
11
11
  creditManager: Address;
12
12
  token: Address;
13
- providedArgs: RWAOperationArgs;
13
+ providedArgs?: RWAOperationArgs;
14
14
  }
15
15
  /**
16
- * The RWA factory is satisfied that `wallet` may open on `token` with the
16
+ * The degen NFT is satisfied that `wallet` may open on `token` with the
17
17
  * registration args already on the transaction.
18
18
  */
19
19
  declare function checkRWAOpenRequirements(input: CheckRWAOpenRequirementsInput): Promise<(RWAOpenRequirementsError | UnexpectedFailureError)[]>;
@@ -1,17 +1,17 @@
1
1
  import { RWAOpenRequirementsError } from "../../../model/errors/operation-errors.js";
2
2
  import { UnexpectedFailureError } from "../../../model/errors/prepare-errors.js";
3
- import { OpenRWAStrategyPositionPreview } from "../../../model/previews.js";
3
+ import { OpenStrategyPositionPreview } from "../../../model/previews.js";
4
4
  import "../../../model/index.js";
5
5
  import { OnchainSDK } from "../../OnchainSDK.js";
6
6
  import { Address } from "viem";
7
7
  //#region src/onchain/validation/bundles/checkRWAOpening.d.ts
8
8
  interface CheckRWAOpeningInput {
9
9
  sdk: OnchainSDK;
10
- preview: OpenRWAStrategyPositionPreview;
10
+ preview: OpenStrategyPositionPreview;
11
11
  sender: Address;
12
12
  }
13
13
  /**
14
- * Per factory-gated token among `collateralAdded ∪ quotas`, whether the
14
+ * Per KYC-gated token among `collateralAdded ∪ quotas`, whether the
15
15
  * borrower still has to register or sign before this opening can land.
16
16
  */
17
17
  declare function checkRWAOpening(input: CheckRWAOpeningInput): Promise<(RWAOpenRequirementsError | UnexpectedFailureError)[]>;
@@ -47,7 +47,11 @@ declare class OpportunitiesNamespace extends AbstractNamespace<MultichainSDK["op
47
47
  /**
48
48
  * {@inheritDoc IOpportunitiesBase.getStrategy}
49
49
  **/
50
- getStrategy(key: StrategyOpportunityKey, wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
50
+ getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
51
+ /**
52
+ * {@inheritDoc IOpportunitiesOnchainOnly.isEligibleForStrategy}
53
+ **/
54
+ isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
51
55
  /**
52
56
  * {@inheritDoc IOpportunitiesBase.filter}
53
57
  **/
@@ -30,10 +30,11 @@ interface IOpportunitiesBase {
30
30
  **/
31
31
  getPool(key: PoolOpportunityKey): Promise<DataResponse<PoolOpportunityDetail>>;
32
32
  /**
33
- * Detailed view of one strategy opportunity. With `wallet`, `kyc` tells whether
34
- * that wallet must register with the strategy's KYC provider before opening.
33
+ * Detailed view of one strategy opportunity. `kyc` is the strategy's KYC
34
+ * gate, independent of any wallet. Use {@link IOpportunitiesOnchainOnly.isEligibleForStrategy}
35
+ * for a wallet verdict.
35
36
  **/
36
- getStrategy(key: StrategyOpportunityKey, wallet?: Address): Promise<DataResponse<StrategyOpportunityDetail>>;
37
+ getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
37
38
  /**
38
39
  * Narrows an already-read list, rows and metadata alike. `undefined` passes
39
40
  * through, so a read still in flight stays that way, and a list already read
@@ -88,6 +89,11 @@ interface IOpportunitiesOnchainOnly {
88
89
  * same reason as {@link prepare}: it encodes against live chain state.
89
90
  **/
90
91
  readonly execute: IOpportunitiesExecute;
92
+ /**
93
+ * Whether `wallet` may open this strategy today: `true` when it is not
94
+ * KYC-gated or the wallet already passed the gate. Chain-only.
95
+ **/
96
+ isEligibleForStrategy(key: StrategyOpportunityKey, wallet: Address): Promise<boolean>;
91
97
  }
92
98
  /**
93
99
  * The chain on its own, for a consumer that shows each source as it arrives.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.3.0-next.3",
3
+ "version": "16.3.0-next.4",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {