@gearbox-protocol/sdk 14.12.0-next.11 → 14.12.0-next.13

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 (75) hide show
  1. package/dist/cjs/preview/parse/parseRWAFactoryOperationCalldata.js +13 -12
  2. package/dist/cjs/preview/parse/types.js +1 -1
  3. package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +10 -16
  4. package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +17 -33
  5. package/dist/cjs/preview/prerequisites/Prerequisite.js +13 -18
  6. package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +36 -15
  7. package/dist/cjs/preview/prerequisites/buildCollateralPrerequisites.js +57 -0
  8. package/dist/cjs/preview/prerequisites/{prepareAction.js → buildPartialLiquidationPrerequisites.js} +18 -24
  9. package/dist/cjs/preview/prerequisites/buildPoolPrerequisites.js +125 -0
  10. package/dist/cjs/preview/prerequisites/buildRWAPrerequisites.js +57 -0
  11. package/dist/cjs/preview/prerequisites/checkPrerequisites.js +85 -0
  12. package/dist/cjs/preview/prerequisites/helpers.js +47 -0
  13. package/dist/cjs/preview/prerequisites/index.js +2 -6
  14. package/dist/cjs/preview/preview/detectCloseOrRepay.js +51 -0
  15. package/dist/cjs/preview/preview/index.js +4 -0
  16. package/dist/cjs/preview/preview/previewCloseOrRepay.js +94 -0
  17. package/dist/cjs/preview/preview/previewOperation.js +10 -2
  18. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +104 -49
  19. package/dist/cjs/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +26 -4
  20. package/dist/cjs/sdk/utils/AddressSet.js +7 -0
  21. package/dist/esm/preview/parse/parseRWAFactoryOperationCalldata.js +13 -12
  22. package/dist/esm/preview/parse/types.js +1 -1
  23. package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +11 -20
  24. package/dist/esm/preview/prerequisites/BalancePrerequisite.js +18 -37
  25. package/dist/esm/preview/prerequisites/Prerequisite.js +13 -20
  26. package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +36 -15
  27. package/dist/esm/preview/prerequisites/buildCollateralPrerequisites.js +35 -0
  28. package/dist/esm/preview/prerequisites/buildPartialLiquidationPrerequisites.js +18 -0
  29. package/dist/esm/preview/prerequisites/buildPoolPrerequisites.js +101 -0
  30. package/dist/esm/preview/prerequisites/buildRWAPrerequisites.js +33 -0
  31. package/dist/esm/preview/prerequisites/checkPrerequisites.js +63 -0
  32. package/dist/esm/preview/prerequisites/helpers.js +23 -0
  33. package/dist/esm/preview/prerequisites/index.js +1 -3
  34. package/dist/esm/preview/preview/detectCloseOrRepay.js +26 -0
  35. package/dist/esm/preview/preview/index.js +2 -0
  36. package/dist/esm/preview/preview/previewCloseOrRepay.js +76 -0
  37. package/dist/esm/preview/preview/previewOperation.js +10 -2
  38. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +104 -49
  39. package/dist/esm/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +26 -4
  40. package/dist/esm/sdk/utils/AddressSet.js +7 -0
  41. package/dist/types/preview/parse/parseRWAFactoryOperationCalldata.d.ts +1 -1
  42. package/dist/types/preview/parse/types-rwa.d.ts +11 -23
  43. package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +4 -5
  44. package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +4 -6
  45. package/dist/types/preview/prerequisites/Prerequisite.d.ts +16 -40
  46. package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +22 -16
  47. package/dist/types/preview/prerequisites/buildCollateralPrerequisites.d.ts +14 -0
  48. package/dist/types/preview/prerequisites/buildPartialLiquidationPrerequisites.d.ts +8 -0
  49. package/dist/types/preview/prerequisites/buildPoolPrerequisites.d.ts +8 -0
  50. package/dist/types/preview/prerequisites/buildRWAPrerequisites.d.ts +21 -0
  51. package/dist/types/preview/prerequisites/checkPrerequisites.d.ts +27 -0
  52. package/dist/types/preview/prerequisites/helpers.d.ts +15 -0
  53. package/dist/types/preview/prerequisites/index.d.ts +1 -3
  54. package/dist/types/preview/prerequisites/types.d.ts +21 -2
  55. package/dist/types/preview/preview/detectCloseOrRepay.d.ts +18 -0
  56. package/dist/types/preview/preview/index.d.ts +2 -0
  57. package/dist/types/preview/preview/previewAdjustCreditAccount.d.ts +2 -2
  58. package/dist/types/preview/preview/previewCloseOrRepay.d.ts +10 -0
  59. package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +2 -2
  60. package/dist/types/preview/preview/types.d.ts +60 -3
  61. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +6 -1
  62. package/dist/types/sdk/accounts/types.d.ts +66 -3
  63. package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +11 -3
  64. package/dist/types/sdk/market/rwa/securitize/types.d.ts +18 -2
  65. package/dist/types/sdk/market/rwa/types.d.ts +26 -9
  66. package/dist/types/sdk/utils/AddressSet.d.ts +1 -0
  67. package/package.json +1 -1
  68. package/dist/cjs/preview/prerequisites/buildPrerequisites.js +0 -297
  69. package/dist/cjs/preview/prerequisites/runPrerequisites.js +0 -71
  70. package/dist/esm/preview/prerequisites/buildPrerequisites.js +0 -279
  71. package/dist/esm/preview/prerequisites/prepareAction.js +0 -23
  72. package/dist/esm/preview/prerequisites/runPrerequisites.js +0 -47
  73. package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +0 -25
  74. package/dist/types/preview/prerequisites/prepareAction.d.ts +0 -52
  75. package/dist/types/preview/prerequisites/runPrerequisites.d.ts +0 -12
@@ -0,0 +1,18 @@
1
+ import type { Address } from "viem";
2
+ import type { InnerOperation } from "../parse/index.js";
3
+ /**
4
+ * Detects whether a credit-facade multicall fully closes or repays the
5
+ * account.
6
+ *
7
+ * Note that closing/repaying an account whose debt is already zero emits no
8
+ * `decreaseDebt` call at all and is not detected (previews as an adjustment).
9
+ */
10
+ export declare function isCloseOrRepay(multicall: InnerOperation[]): boolean;
11
+ /**
12
+ * Distinguishes a closure from a repayment by how collateral leaves the
13
+ * account:
14
+ * - close swaps all assets into underlying and withdraws only the underlying
15
+ * - repay returns collateral in-kind: it adds collateral from the wallet to
16
+ * cover the debt and/or withdraws non-underlying tokens.
17
+ */
18
+ export declare function classifyCloseOrRepay(multicall: InnerOperation[], underlying: Address): "close" | "repay";
@@ -1,5 +1,7 @@
1
1
  export * from "./applyInnerOperations.js";
2
+ export * from "./detectCloseOrRepay.js";
2
3
  export * from "./errors.js";
3
4
  export * from "./previewAdjustCreditAccount.js";
5
+ export * from "./previewCloseOrRepay.js";
4
6
  export * from "./previewOperation.js";
5
7
  export * from "./types.js";
@@ -1,5 +1,5 @@
1
1
  import { type PluginsMap } from "../../sdk/index.js";
2
- import type { MulticallOperation, SecuritizeMulticallOperation } from "../parse/index.js";
2
+ import type { MulticallOperation, RWAMulticallOperation } from "../parse/index.js";
3
3
  import type { AdjustCreditAccountPreview, PreviewOperationInput, PreviewOperationOptions } from "./types.js";
4
4
  /**
5
5
  * Previews a `multicall`/`botMulticall` operation on an existing credit
@@ -8,4 +8,4 @@ import type { AdjustCreditAccountPreview, PreviewOperationInput, PreviewOperatio
8
8
  * minimal guaranteed post-state alongside the changes relative to the
9
9
  * pre-state.
10
10
  */
11
- export declare function previewAdjustCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: MulticallOperation | SecuritizeMulticallOperation, options?: PreviewOperationOptions): Promise<AdjustCreditAccountPreview>;
11
+ export declare function previewAdjustCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: MulticallOperation | RWAMulticallOperation, options?: PreviewOperationOptions): Promise<AdjustCreditAccountPreview>;
@@ -0,0 +1,10 @@
1
+ import { type PluginsMap } from "../../sdk/index.js";
2
+ import type { CloseCreditAccountOperation, MulticallOperation, RWAMulticallOperation } from "../parse/index.js";
3
+ import type { OperationPreview, PreviewOperationInput, PreviewOperationOptions } from "./types.js";
4
+ /**
5
+ * Any parsed operation that fully closes or repays a credit account: the
6
+ * facade `closeCreditAccount` entry point (permanent closure) or a plain
7
+ * multicall detected by `isCloseOrRepay` (zero-debt closure/repay).
8
+ */
9
+ export type CloseOrRepayOperation = CloseCreditAccountOperation | MulticallOperation | RWAMulticallOperation;
10
+ export declare function previewCloseOrRepay<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: CloseOrRepayOperation, permanent: boolean, options?: PreviewOperationOptions): Promise<OperationPreview>;
@@ -1,4 +1,4 @@
1
1
  import { type PluginsMap } from "../../sdk/index.js";
2
- import type { OpenCreditAccountOperation, SecuritizeOpenCreditAccountOperation } from "../parse/index.js";
2
+ import type { OpenCreditAccountOperation, RWAOpenCreditAccountOperation } from "../parse/index.js";
3
3
  import type { OpenCreditAccountPreview, PreviewOperationInput } from "./types.js";
4
- export declare function previewOpenCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: OpenCreditAccountOperation | SecuritizeOpenCreditAccountOperation): OpenCreditAccountPreview;
4
+ export declare function previewOpenCreditAccount<P extends PluginsMap>(input: PreviewOperationInput<P>, operation: OpenCreditAccountOperation | RWAOpenCreditAccountOperation): OpenCreditAccountPreview;
@@ -82,7 +82,7 @@ export interface PoolOperationPreview {
82
82
  tokenOut: PreviewedAsset;
83
83
  }
84
84
  export interface OpenCreditAccountPreview {
85
- operation: "OpenCreditAccount" | "SecuritizeOpenCreditAccount";
85
+ operation: "OpenCreditAccount" | "RWAOpenCreditAccount";
86
86
  /**
87
87
  * Credit manager the account is opened in
88
88
  */
@@ -170,8 +170,65 @@ export interface AdjustCreditAccountPreview {
170
170
  */
171
171
  assetsChange: Asset[];
172
172
  }
173
+ export interface CloseCreditAccountPreview {
174
+ operation: "CloseCreditAccount";
175
+ /**
176
+ * True when the account is closed permanently (facade `closeCreditAccount`
177
+ * entry point), false when the debt is zeroed but the account stays open
178
+ * (plain multicall).
179
+ */
180
+ permanent: boolean;
181
+ /**
182
+ * Credit manager the account belongs to
183
+ */
184
+ creditManager: Address;
185
+ /**
186
+ * Credit account that is being closed
187
+ */
188
+ creditAccount: Address;
189
+ /**
190
+ * Underlying withdrawn to the user: minimal guaranteed amount, from the
191
+ * multicall replay (all collateral is swapped into underlying before
192
+ * withdrawal)
193
+ */
194
+ receivedAmount: bigint;
195
+ }
196
+ export interface RepayCreditAccountPreview {
197
+ operation: "RepayCreditAccount";
198
+ /**
199
+ * True when the account is closed permanently (facade `closeCreditAccount`
200
+ * entry point), false when the debt is zeroed but the account stays open
201
+ * (plain multicall).
202
+ */
203
+ permanent: boolean;
204
+ /**
205
+ * Credit manager the account belongs to
206
+ */
207
+ creditManager: Address;
208
+ /**
209
+ * Credit account that is being repaid
210
+ */
211
+ creditAccount: Address;
212
+ /**
213
+ * Tokens added from the wallet to cover the debt (`addCollateral` calls).
214
+ *
215
+ * When the transaction has native value attached, it is represented as a
216
+ * `NATIVE_ADDRESS` entry, with the wrapped native token amount reduced
217
+ * accordingly (omitted entirely when it reaches zero).
218
+ */
219
+ collateralAdded: Asset[];
220
+ /**
221
+ * Tokens returned to the user in-kind (`withdrawCollateral` calls, with the
222
+ * MAX_UINT256 sentinel resolved against replayed balances)
223
+ */
224
+ collateralWithdrawn: Asset[];
225
+ /**
226
+ * Total debt repaid: principal + accrued interest + fees, in underlying
227
+ */
228
+ debtRepaid: bigint;
229
+ }
173
230
  /**
174
231
  * Result of previewing a raw operation calldata: currently pool operations and
175
- * credit account opening are supported.
232
+ * credit account opening, adjustment, closure and repayment are supported.
176
233
  */
177
- export type OperationPreview = PoolOperationPreview | OpenCreditAccountPreview | AdjustCreditAccountPreview;
234
+ export type OperationPreview = PoolOperationPreview | OpenCreditAccountPreview | AdjustCreditAccountPreview | CloseCreditAccountPreview | RepayCreditAccountPreview;
@@ -6,7 +6,7 @@ import type { RWAOpenAccountRequirements } from "../market/rwa/index.js";
6
6
  import type { OnchainSDK } from "../OnchainSDK.js";
7
7
  import type { RouterCASlice } from "../router/index.js";
8
8
  import type { MultiCall, RawTx } from "../types/index.js";
9
- import type { AccountToCheck, AddCollateralProps, AssembleCaUpdateCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
9
+ import type { AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleCaUpdateCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerOperationResult, DefaultPartialLiquidationParams, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
10
10
  /**
11
11
  * Options for configuring the credit account service.
12
12
  **/
@@ -218,8 +218,13 @@ export declare class CreditAccountsServiceV310 extends SDKConstruct implements I
218
218
  prependPriceUpdates(creditManager: Address, calls: MultiCall[], creditAccount?: RouterCASlice, options?: {
219
219
  ignoreReservePrices?: boolean;
220
220
  }): Promise<MultiCall[]>;
221
+ /**
222
+ * {@inheritDoc ICreditAccountsService.assembleCaOperations}
223
+ */
224
+ assembleCaOperations({ operations, creditFacade, withdrawTo, }: AssembleCaOperationsProps): MultiCall[];
221
225
  /**
222
226
  * {@inheritDoc ICreditAccountsService.assembleCaUpdateCalls}
227
+ * @deprecated Prefer {@link CreditAccountsServiceV310.assembleCaOperations}.
223
228
  */
224
229
  assembleCaUpdateCalls({ operations, routerCallGroups, creditFacade, withdrawTo, creditAccount, underlyingToken, }: AssembleCaUpdateCallsProps): MultiCall[];
225
230
  /**
@@ -2,7 +2,7 @@ import type { Address, ContractFunctionArgs, GetContractReturnType, Hex, PublicC
2
2
  import type { creditAccountCompressorAbi } from "../../abi/compressors/creditAccountCompressor.js";
3
3
  import type { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
4
4
  import type { Asset, ConnectedBotData, Construct, CreditAccountData } from "../base/index.js";
5
- import type { CreditSuite, PriceUpdate, RWAOperationParams } from "../market/index.js";
5
+ import type { CreditSuite, PriceUpdate, RWAOperationArgs } from "../market/index.js";
6
6
  import type { RWAOpenAccountRequirements } from "../market/rwa/index.js";
7
7
  import type { OnchainSDK } from "../OnchainSDK.js";
8
8
  import type { RouterCASlice, RouterCloseResult } from "../router/index.js";
@@ -467,11 +467,11 @@ export interface OpenCAProps extends PrepareUpdateQuotasProps {
467
467
  * RWA options to open credit account with, required for RWA factories
468
468
  * First we ask for getOpenAccountRequirements,
469
469
  * then perform necessary actions (e.g. for Securitize, convert requiredSignatures to signaturesToCache)
470
- * to produce RWAOperationParams
470
+ * to produce RWAOperationArgs
471
471
  * If getOpenAccountRequirements returned undefined, we need to pass undefined here too;
472
472
  * It means that no RWA actions are required (e.g. when we open second credit account)
473
473
  */
474
- rwaOptions?: RWAOperationParams;
474
+ rwaOptions?: RWAOperationArgs;
475
475
  }
476
476
  export interface ChangeDeptProps {
477
477
  /**
@@ -713,6 +713,10 @@ export type GetApprovalAddressProps = {
713
713
  *
714
714
  * Used by {@link ICreditAccountsService.assembleCaUpdateCalls} to build the
715
715
  * underlying credit facade multicall calls.
716
+ *
717
+ * @deprecated Prefer {@link EncodableCreditAccountOperation} with
718
+ * {@link ICreditAccountsService.assembleCaOperations}. Close stays on dedicated
719
+ * assemblers / this deprecated path only.
716
720
  */
717
721
  export type CreditAccountUpdateOperation = {
718
722
  type: "increaseDebt";
@@ -739,6 +743,9 @@ export type CreditAccountUpdateOperation = {
739
743
  };
740
744
  /**
741
745
  * Input for {@link ICreditAccountsService.assembleCaUpdateCalls}.
746
+ *
747
+ * @deprecated Prefer {@link AssembleCaOperationsProps} /
748
+ * {@link ICreditAccountsService.assembleCaOperations}.
742
749
  */
743
750
  export type AssembleCaUpdateCallsProps = {
744
751
  operations: Array<CreditAccountUpdateOperation>;
@@ -755,6 +762,47 @@ export type AssembleCaUpdateCallsProps = {
755
762
  };
756
763
  underlyingToken: Address;
757
764
  };
765
+ /**
766
+ * An enriched credit-account operation ready for encoding.
767
+ * Each op carries everything needed to build facade / adapter multicalls —
768
+ * swap and wrap attach concrete `calls` (no external routerCallGroups).
769
+ *
770
+ * Used by {@link ICreditAccountsService.assembleCaOperations}. Does not include
771
+ * close / repay (use dedicated assemblers).
772
+ */
773
+ export type EncodableCreditAccountOperation = {
774
+ type: "increaseDebt";
775
+ amount: bigint;
776
+ } | {
777
+ type: "decreaseDebt";
778
+ amount: bigint;
779
+ } | {
780
+ type: "addCollateral";
781
+ token: Address;
782
+ amount: bigint;
783
+ } | {
784
+ type: "withdrawCollateral";
785
+ token: Address;
786
+ amount: bigint;
787
+ } | {
788
+ type: "swap";
789
+ calls: Array<MultiCall>;
790
+ } | {
791
+ type: "wrapRwaCollateral";
792
+ calls: Array<MultiCall>;
793
+ } | {
794
+ type: "changeQuota";
795
+ quotaIncrease: Array<Asset>;
796
+ quotaDecrease: Array<Asset>;
797
+ };
798
+ /**
799
+ * Input for {@link ICreditAccountsService.assembleCaOperations}.
800
+ */
801
+ export type AssembleCaOperationsProps = {
802
+ operations: Array<EncodableCreditAccountOperation>;
803
+ creditFacade: Address;
804
+ withdrawTo: Address;
805
+ };
758
806
  export interface ICreditAccountsService extends Construct {
759
807
  sdk: OnchainSDK;
760
808
  /**
@@ -989,11 +1037,26 @@ export interface ICreditAccountsService extends Construct {
989
1037
  prependPriceUpdates(creditManager: Address, calls: Array<MultiCall>, creditAccount?: RouterCASlice, options?: {
990
1038
  ignoreReservePrices?: boolean;
991
1039
  }): Promise<Array<MultiCall>>;
1040
+ /**
1041
+ * Builds credit facade multicall calls from an enriched operation list.
1042
+ * Each operation must already carry concrete encoding data (e.g. swap/wrap
1043
+ * `calls`). Unknown operation types throw.
1044
+ *
1045
+ * Does not handle close or repay — use
1046
+ * {@link ICreditAccountsService.assembleCloseCreditAccountCalls} /
1047
+ * {@link ICreditAccountsService.assembleRepayCreditAccountCalls}.
1048
+ *
1049
+ * @param props - Encodable operations and account context
1050
+ * @returns Array of facade / adapter multicall calls (without price feed updates)
1051
+ */
1052
+ assembleCaOperations(props: AssembleCaOperationsProps): Array<MultiCall>;
992
1053
  /**
993
1054
  * Builds the credit facade multicall calls for a chain of update operations.
994
1055
  *
995
1056
  * @param props - Operation chain, router call groups and account context
996
1057
  * @returns Array of facade multicall calls (without price feed updates)
1058
+ * @deprecated Prefer {@link ICreditAccountsService.assembleCaOperations}. Close
1059
+ * remains on this method / dedicated close assembler only.
997
1060
  */
998
1061
  assembleCaUpdateCalls(props: AssembleCaUpdateCallsProps): Array<MultiCall>;
999
1062
  /**
@@ -6,7 +6,7 @@ import type { MultiCall, RawTx } from "../../../types/index.js";
6
6
  import type { IRWAFactory, RWACompressorInvestorData, RWAFactoryData } from "../types.js";
7
7
  import { RWA_FACTORY_SECURITIZE } from "./constants.js";
8
8
  import { SecuritizeDegenNFT } from "./SecuritizeDegenNFT.js";
9
- import { type DStokenData, type SecuritizeInvestorData, type SecuritizeOpenAccountRequirements, type SecuritizeOperationParams, type SecuritizeRWAFactoryStateHuman } from "./types.js";
9
+ import { type DStokenData, type SecuritizeInvestorData, type SecuritizeMissingOpenAccountRequirements, type SecuritizeOpenAccountRequirements, type SecuritizeOperationArgs, type SecuritizeRWAFactoryStateHuman } from "./types.js";
10
10
  declare const abi: readonly [{
11
11
  readonly type: "function";
12
12
  readonly name: "contractType";
@@ -493,15 +493,23 @@ export declare class SecuritizeRWAFactory extends BaseContract<abi> implements I
493
493
  /**
494
494
  * {@inheritDoc IRWAFactory.multicall}
495
495
  */
496
- multicall(creditAccount: Address, calls: MultiCall[], options?: SecuritizeOperationParams): RawTx;
496
+ multicall(creditAccount: Address, calls: MultiCall[], args?: SecuritizeOperationArgs): RawTx;
497
497
  /**
498
498
  * {@inheritDoc IRWAFactory.getOpenAccountRequirements}
499
499
  */
500
500
  getOpenAccountRequirements(investor: Address, props: GetOpenAccountRequirementsProps): Promise<SecuritizeOpenAccountRequirements | undefined>;
501
+ /**
502
+ * {@inheritDoc IRWAFactory.getMissingRequirements}
503
+ *
504
+ * A required signature is omitted when `providedArgs.signaturesToCache`
505
+ * already carries a signature for the same token: the transaction caches it
506
+ * on-chain as part of the operation.
507
+ */
508
+ getMissingRequirements(requirements: SecuritizeOpenAccountRequirements, providedArgs?: SecuritizeOperationArgs): SecuritizeMissingOpenAccountRequirements | undefined;
501
509
  /**
502
510
  * {@inheritDoc IRWAFactory.openCreditAccount}
503
511
  */
504
- openCreditAccount(creditManager: Address, calls: MultiCall[], options?: SecuritizeOperationParams): RawTx;
512
+ openCreditAccount(creditManager: Address, calls: MultiCall[], args?: SecuritizeOperationArgs): RawTx;
505
513
  stateHuman(_raw?: boolean): SecuritizeRWAFactoryStateHuman;
506
514
  }
507
515
  export {};
@@ -120,16 +120,32 @@ export interface SecuritizeRWAFactoryStateHuman extends BaseContractStateHuman {
120
120
  }[];
121
121
  }
122
122
  /**
123
- * Factory-specific parameters for {@link SecuritizeRWAFactory.multicall}
123
+ * Factory-specific args for {@link SecuritizeRWAFactory.multicall}
124
124
  * and {@link SecuritizeRWAFactory.openCreditAccount}.
125
125
  **/
126
- export interface SecuritizeOperationParams {
126
+ export interface SecuritizeOperationArgs {
127
127
  type: typeof RWA_FACTORY_SECURITIZE;
128
128
  /** DSToken addresses to register for this operation. */
129
129
  tokensToRegister: Address[];
130
130
  /** Cached EIP-712 registration signatures to store on-chain. */
131
131
  signaturesToCache: SecuritizeRegisterMessage[];
132
132
  }
133
+ /**
134
+ * Subset of {@link SecuritizeOpenAccountRequirements} still unfulfilled given
135
+ * the params already carried by the transaction calldata. Returned by
136
+ * `SecuritizeRWAFactory.getMissingRequirements`; `undefined` there means the
137
+ * requirements are satisfied.
138
+ **/
139
+ export interface SecuritizeMissingOpenAccountRequirements {
140
+ type: typeof RWA_FACTORY_SECURITIZE;
141
+ /**
142
+ * EIP-712 messages the investor still has to sign (not covered by
143
+ * calldata-provided signatures). Once signed, they become the
144
+ * `signaturesToCache` arg of the factory's `openCreditAccount`/`multicall`
145
+ * calls (see {@link SecuritizeOperationArgs}).
146
+ */
147
+ requiredSignatures: SecuritizeRegisterVaultMessage[];
148
+ }
133
149
  export interface SecuritizeOpenAccountRequirements {
134
150
  type: typeof RWA_FACTORY_SECURITIZE;
135
151
  /**
@@ -4,7 +4,7 @@ import type { iRWACompressorAbi } from "../../../abi/rwa/iRWACompressor.js";
4
4
  import type { GetOpenAccountRequirementsProps } from "../../accounts/types.js";
5
5
  import type { IBaseContract, Unarray } from "../../base/index.js";
6
6
  import type { MultiCall, RawTx } from "../../types/index.js";
7
- import type { SecuritizeInvestorData, SecuritizeOpenAccountRequirements, SecuritizeOperationParams, SecuritizeRWAFactoryStateHuman } from "./securitize/index.js";
7
+ import type { SecuritizeInvestorData, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRWAFactoryStateHuman } from "./securitize/index.js";
8
8
  import { RWA_FACTORY_SECURITIZE } from "./securitize/index.js";
9
9
  /**
10
10
  * Discriminated union of all known RWA factory contract type strings.
@@ -25,8 +25,9 @@ interface RWAFactoryTypeMap {
25
25
  [RWA_FACTORY_SECURITIZE]: {
26
26
  investorData: SecuritizeInvestorData;
27
27
  openAccountRequirements: SecuritizeOpenAccountRequirements;
28
+ missingOpenAccountRequirements: SecuritizeMissingOpenAccountRequirements;
28
29
  stateHuman: SecuritizeRWAFactoryStateHuman;
29
- operationParams: SecuritizeOperationParams;
30
+ operationArgs: SecuritizeOperationArgs;
30
31
  };
31
32
  }
32
33
  /**
@@ -39,11 +40,17 @@ export type RWAInvestorData<T extends RWAFactoryType = RWAFactoryType> = RWAFact
39
40
  * Can be discriminated by type
40
41
  **/
41
42
  export type RWAOpenAccountRequirements<T extends RWAFactoryType = RWAFactoryType> = RWAFactoryTypeMap[T]["openAccountRequirements"];
43
+ /**
44
+ * Subset of {@link RWAOpenAccountRequirements} that is still unfulfilled,
45
+ * defaults to union of all factory types.
46
+ * Can be discriminated by type
47
+ **/
48
+ export type RWAMissingOpenAccountRequirements<T extends RWAFactoryType = RWAFactoryType> = RWAFactoryTypeMap[T]["missingOpenAccountRequirements"];
42
49
  /**
43
50
  * Open credit account/Multicall extra params type for a RWA factory, defaults to union of all factory types
44
51
  * Can be discriminated by type
45
52
  **/
46
- export type RWAOperationParams<T extends RWAFactoryType = RWAFactoryType> = RWAFactoryTypeMap[T]["operationParams"];
53
+ export type RWAOperationArgs<T extends RWAFactoryType = RWAFactoryType> = RWAFactoryTypeMap[T]["operationArgs"];
47
54
  /**
48
55
  * Raw return type of `RWACompressor.getRWAMarketsData`.
49
56
  **/
@@ -142,10 +149,10 @@ export interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends
142
149
  *
143
150
  * @param creditAccount - credit account address
144
151
  * @param calls - calls to perform
145
- * @param options - factory-specific parameters (e.g. tokens to
146
- * register, signatures to cache). Undefined value means that no RWA actions are required
152
+ * @param args - factory-specific args (e.g. tokens to register, signatures to cache).
153
+ * Undefined value means that no RWA actions are required
147
154
  **/
148
- multicall(creditAccount: Address, calls: MultiCall[], options?: RWAOperationParams<T>): RawTx;
155
+ multicall(creditAccount: Address, calls: MultiCall[], args?: RWAOperationArgs<T>): RawTx;
149
156
  /**
150
157
  * Checks if the user can open a credit account with this factory.
151
158
  * @param investor - investor address
@@ -154,17 +161,27 @@ export interface IRWAFactory<T extends RWAFactoryType = RWAFactoryType> extends
154
161
  * user can open a credit account without any further actions
155
162
  **/
156
163
  getOpenAccountRequirements(investor: Address, props: GetOpenAccountRequirementsProps): Promise<RWAOpenAccountRequirements<T> | undefined>;
164
+ /**
165
+ * Computes the subset of `requirements` still unfulfilled, given the
166
+ * factory-specific params already carried by the transaction calldata.
167
+ *
168
+ * @param requirements - requirements fetched via {@link getOpenAccountRequirements}
169
+ * @param providedArgs - params decoded from the transaction calldata, if
170
+ * any; e.g. signatures already included there need not be signed again
171
+ * @returns the missing requirements, or `undefined` when everything is
172
+ * satisfied
173
+ **/
174
+ getMissingRequirements(requirements: RWAOpenAccountRequirements<T>, providedArgs?: RWAOperationArgs<T>): RWAMissingOpenAccountRequirements<T> | undefined;
157
175
  /**
158
176
  * Creates a raw transaction to open a credit account.
159
177
  * Similar to {@link CreditFacadeV310Contract.openCreditAccount}.
160
178
  *
161
179
  * @param creditManager - credit manager address
162
180
  * @param calls - initial calls to perform
163
- * @param options - factory-specific parameters (e.g. tokens to
164
- * register, signatures to cache).
181
+ * @param args - factory-specific args (e.g. tokens to register, signatures to cache).
165
182
  * Undefined value means that no RWA actions are required (e.g. when we open second credit account)
166
183
  **/
167
- openCreditAccount(creditManager: Address, calls: MultiCall[], options?: RWAOperationParams<T>): RawTx;
184
+ openCreditAccount(creditManager: Address, calls: MultiCall[], args?: RWAOperationArgs<T>): RawTx;
168
185
  }
169
186
  /**
170
187
  * Narrows any contract to an {@link IRWAFactory}.
@@ -13,6 +13,7 @@ export declare class AddressSet extends Set<Address> {
13
13
  add(value: Address): this;
14
14
  delete(value: Address): boolean;
15
15
  has(value: Address): boolean;
16
+ difference<U>(other: ReadonlySetLike<U>): AddressSet;
16
17
  /**
17
18
  * Returns all addresses as an array.
18
19
  **/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.12.0-next.11",
3
+ "version": "14.12.0-next.13",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {