@gearbox-protocol/sdk 14.12.0-next.12 → 14.12.0-next.14

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/abi/IWithdrawalCompressorV312.js +186 -0
  2. package/dist/cjs/preview/parse/parseRWAFactoryOperationCalldata.js +13 -12
  3. package/dist/cjs/preview/parse/types.js +1 -1
  4. package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +10 -16
  5. package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +17 -33
  6. package/dist/cjs/preview/prerequisites/Prerequisite.js +13 -18
  7. package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +36 -15
  8. package/dist/cjs/preview/prerequisites/buildCollateralPrerequisites.js +57 -0
  9. package/dist/cjs/preview/prerequisites/{prepareAction.js → buildPartialLiquidationPrerequisites.js} +18 -24
  10. package/dist/cjs/preview/prerequisites/buildPoolPrerequisites.js +125 -0
  11. package/dist/cjs/preview/prerequisites/buildRWAPrerequisites.js +57 -0
  12. package/dist/cjs/preview/prerequisites/checkPrerequisites.js +85 -0
  13. package/dist/cjs/preview/prerequisites/helpers.js +47 -0
  14. package/dist/cjs/preview/prerequisites/index.js +2 -6
  15. package/dist/cjs/preview/preview/detectCloseOrRepay.js +51 -0
  16. package/dist/cjs/preview/preview/index.js +4 -0
  17. package/dist/cjs/preview/preview/previewCloseOrRepay.js +94 -0
  18. package/dist/cjs/preview/preview/previewOperation.js +10 -2
  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/abi/IWithdrawalCompressorV312.js +162 -0
  22. package/dist/esm/preview/parse/parseRWAFactoryOperationCalldata.js +13 -12
  23. package/dist/esm/preview/parse/types.js +1 -1
  24. package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +11 -20
  25. package/dist/esm/preview/prerequisites/BalancePrerequisite.js +18 -37
  26. package/dist/esm/preview/prerequisites/Prerequisite.js +13 -20
  27. package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +36 -15
  28. package/dist/esm/preview/prerequisites/buildCollateralPrerequisites.js +35 -0
  29. package/dist/esm/preview/prerequisites/buildPartialLiquidationPrerequisites.js +18 -0
  30. package/dist/esm/preview/prerequisites/buildPoolPrerequisites.js +101 -0
  31. package/dist/esm/preview/prerequisites/buildRWAPrerequisites.js +33 -0
  32. package/dist/esm/preview/prerequisites/checkPrerequisites.js +63 -0
  33. package/dist/esm/preview/prerequisites/helpers.js +23 -0
  34. package/dist/esm/preview/prerequisites/index.js +1 -3
  35. package/dist/esm/preview/preview/detectCloseOrRepay.js +26 -0
  36. package/dist/esm/preview/preview/index.js +2 -0
  37. package/dist/esm/preview/preview/previewCloseOrRepay.js +76 -0
  38. package/dist/esm/preview/preview/previewOperation.js +10 -2
  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/abi/IWithdrawalCompressorV312.d.ts +216 -0
  42. package/dist/types/preview/parse/parseRWAFactoryOperationCalldata.d.ts +1 -1
  43. package/dist/types/preview/parse/types-rwa.d.ts +11 -23
  44. package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +4 -5
  45. package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +4 -6
  46. package/dist/types/preview/prerequisites/Prerequisite.d.ts +16 -40
  47. package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +22 -16
  48. package/dist/types/preview/prerequisites/buildCollateralPrerequisites.d.ts +14 -0
  49. package/dist/types/preview/prerequisites/buildPartialLiquidationPrerequisites.d.ts +8 -0
  50. package/dist/types/preview/prerequisites/buildPoolPrerequisites.d.ts +8 -0
  51. package/dist/types/preview/prerequisites/buildRWAPrerequisites.d.ts +21 -0
  52. package/dist/types/preview/prerequisites/checkPrerequisites.d.ts +27 -0
  53. package/dist/types/preview/prerequisites/helpers.d.ts +15 -0
  54. package/dist/types/preview/prerequisites/index.d.ts +1 -3
  55. package/dist/types/preview/prerequisites/types.d.ts +21 -2
  56. package/dist/types/preview/preview/detectCloseOrRepay.d.ts +18 -0
  57. package/dist/types/preview/preview/index.d.ts +2 -0
  58. package/dist/types/preview/preview/previewAdjustCreditAccount.d.ts +2 -2
  59. package/dist/types/preview/preview/previewCloseOrRepay.d.ts +10 -0
  60. package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +2 -2
  61. package/dist/types/preview/preview/types.d.ts +60 -3
  62. package/dist/types/sdk/accounts/types.d.ts +3 -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,63 @@
1
+ import {
2
+ parseOperationCalldata
3
+ } from "../parse/parseOperationCalldata.js";
4
+ import { buildCollateralPrerequisites } from "./buildCollateralPrerequisites.js";
5
+ import { buildPartialLiquidationPrerequisites } from "./buildPartialLiquidationPrerequisites.js";
6
+ import { buildPoolPrerequisites } from "./buildPoolPrerequisites.js";
7
+ import { buildRWAPrerequisites } from "./buildRWAPrerequisites.js";
8
+ async function checkPrerequisites(input) {
9
+ const { sdk, sender: wallet, blockNumber } = input;
10
+ const tx = parseOperationCalldata(input);
11
+ const ctx = { sdk, wallet, blockNumber };
12
+ const prereqs = await buildPrerequisites(tx, ctx);
13
+ return Promise.all(
14
+ // Each prereq pairs its own kind with its detail, so the widened
15
+ // `verify` return is safe to narrow back to the discriminated union.
16
+ prereqs.map((p) => p.verify(ctx))
17
+ );
18
+ }
19
+ async function buildPrerequisites(tx, ctx) {
20
+ const { wallet } = ctx;
21
+ switch (tx.operation) {
22
+ case "Deposit":
23
+ case "Mint":
24
+ case "Redeem":
25
+ case "Withdraw":
26
+ return buildPoolPrerequisites(tx, wallet);
27
+ case "MultiCall":
28
+ case "BotMulticall":
29
+ case "OpenCreditAccount":
30
+ case "CloseCreditAccount":
31
+ case "LiquidateCreditAccount":
32
+ return buildCollateralPrerequisites(
33
+ tx.operation === "OpenCreditAccount" ? { creditManager: tx.creditManager, borrower: wallet } : {
34
+ creditManager: tx.creditManager,
35
+ creditAccount: tx.creditAccount
36
+ },
37
+ tx.multicall,
38
+ ctx
39
+ );
40
+ case "RWAOpenCreditAccount":
41
+ return [
42
+ ...await buildCollateralPrerequisites(
43
+ { creditManager: tx.creditManager, borrower: wallet },
44
+ tx.multicall,
45
+ ctx
46
+ ),
47
+ ...buildRWAPrerequisites(tx.multicall, tx.creditManager, tx.args, ctx)
48
+ ];
49
+ case "RWAMulticall":
50
+ return buildCollateralPrerequisites(
51
+ { creditManager: tx.creditManager, creditAccount: tx.creditAccount },
52
+ tx.multicall,
53
+ ctx
54
+ );
55
+ case "PartiallyLiquidateCreditAccount":
56
+ return buildPartialLiquidationPrerequisites(tx, ctx);
57
+ default:
58
+ return [];
59
+ }
60
+ }
61
+ export {
62
+ checkPrerequisites
63
+ };
@@ -0,0 +1,23 @@
1
+ import { AllowancePrerequisite } from "./AllowancePrerequisite.js";
2
+ import { BalancePrerequisite } from "./BalancePrerequisite.js";
3
+ function allowanceAndBalance(props) {
4
+ const { token, owner, spender, required } = props;
5
+ return [
6
+ new AllowancePrerequisite({
7
+ token,
8
+ owner,
9
+ spender,
10
+ required,
11
+ title: props.allowanceTitle
12
+ }),
13
+ new BalancePrerequisite({
14
+ token,
15
+ owner,
16
+ required,
17
+ title: props.balanceTitle
18
+ })
19
+ ];
20
+ }
21
+ export {
22
+ allowanceAndBalance
23
+ };
@@ -1,8 +1,6 @@
1
1
  export * from "./AllowancePrerequisite.js";
2
2
  export * from "./BalancePrerequisite.js";
3
- export * from "./buildPrerequisites.js";
3
+ export * from "./checkPrerequisites.js";
4
4
  export * from "./Prerequisite.js";
5
- export * from "./prepareAction.js";
6
5
  export * from "./RWAOpenRequirementsPrerequisite.js";
7
- export * from "./runPrerequisites.js";
8
6
  export * from "./types.js";
@@ -0,0 +1,26 @@
1
+ import { isAddressEqual } from "viem";
2
+ import { MAX_UINT256 } from "../../sdk/index.js";
3
+ function isCloseOrRepay(multicall) {
4
+ const repaysFullDebt = multicall.some(
5
+ (op) => op.operation === "DecreaseBorrowedAmount" && op.amount === MAX_UINT256
6
+ );
7
+ const withdrawsEverything = multicall.some(
8
+ (op) => op.operation === "WithdrawCollateral" && op.amount === MAX_UINT256
9
+ );
10
+ return repaysFullDebt && withdrawsEverything;
11
+ }
12
+ function classifyCloseOrRepay(multicall, underlying) {
13
+ for (const op of multicall) {
14
+ if (op.operation === "AddCollateral") {
15
+ return "repay";
16
+ }
17
+ if (op.operation === "WithdrawCollateral" && !isAddressEqual(op.token, underlying)) {
18
+ return "repay";
19
+ }
20
+ }
21
+ return "close";
22
+ }
23
+ export {
24
+ classifyCloseOrRepay,
25
+ isCloseOrRepay
26
+ };
@@ -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";
@@ -0,0 +1,76 @@
1
+ import {
2
+ AP_WETH_TOKEN,
3
+ NO_VERSION
4
+ } from "../../sdk/index.js";
5
+ import {
6
+ applyInnerOperations,
7
+ makeInnerOperationsState
8
+ } from "./applyInnerOperations.js";
9
+ import { classifyCloseOrRepay } from "./detectCloseOrRepay.js";
10
+ import { unwrapNativeCollateral } from "./unwrapNativeCollateral.js";
11
+ async function previewCloseOrRepay(input, operation, permanent, options) {
12
+ const { sdk } = input;
13
+ const market = sdk.marketRegister.findByCreditManager(
14
+ operation.creditManager
15
+ );
16
+ const kind = classifyCloseOrRepay(operation.multicall, market.underlying);
17
+ return kind === "close" ? previewCloseCreditAccount(input, operation, permanent, options) : previewRepayCreditAccount(input, operation, permanent, options);
18
+ }
19
+ async function previewCloseCreditAccount(input, operation, permanent, options) {
20
+ const { sdk } = input;
21
+ const market = sdk.marketRegister.findByCreditManager(
22
+ operation.creditManager
23
+ );
24
+ const { state } = await replayMulticall(sdk, operation, options);
25
+ return {
26
+ operation: "CloseCreditAccount",
27
+ permanent,
28
+ creditManager: operation.creditManager,
29
+ creditAccount: operation.creditAccount,
30
+ receivedAmount: state.collateralWithdrawn.getOrZero(market.underlying)
31
+ };
32
+ }
33
+ async function previewRepayCreditAccount(input, operation, permanent, options) {
34
+ const { sdk, value = 0n } = input;
35
+ const { ca, state } = await replayMulticall(sdk, operation, options);
36
+ const collateralAdded = unwrapNativeCollateral(
37
+ state.collateralAdded.toAssets(),
38
+ value,
39
+ sdk.addressProvider.getAddress(AP_WETH_TOKEN, NO_VERSION)
40
+ );
41
+ const initialTotalDebt = ca.debt + ca.accruedInterest + ca.accruedFees;
42
+ return {
43
+ operation: "RepayCreditAccount",
44
+ permanent,
45
+ creditManager: operation.creditManager,
46
+ creditAccount: operation.creditAccount,
47
+ collateralAdded,
48
+ debtRepaid: initialTotalDebt - state.totalDebt,
49
+ collateralWithdrawn: state.collateralWithdrawn.toAssets()
50
+ };
51
+ }
52
+ async function replayMulticall(sdk, operation, options) {
53
+ let ca = options?.creditAccount;
54
+ if (!ca) {
55
+ ca = await sdk.accounts.getCreditAccountData(
56
+ operation.creditAccount,
57
+ options?.blockNumber
58
+ );
59
+ }
60
+ if (!ca) {
61
+ throw new Error(`credit account ${operation.creditAccount} not found`);
62
+ }
63
+ const state = makeInnerOperationsState();
64
+ for (const t of ca.tokens) {
65
+ if (t.balance > 1n) {
66
+ state.balances.upsert(t.token, t.balance);
67
+ }
68
+ }
69
+ state.debt = ca.debt;
70
+ state.totalDebt = ca.debt + ca.accruedInterest + ca.accruedFees;
71
+ applyInnerOperations(sdk, operation.multicall, state);
72
+ return { ca, state };
73
+ }
74
+ export {
75
+ previewCloseOrRepay
76
+ };
@@ -1,6 +1,8 @@
1
1
  import { isPoolOperation, parseOperationCalldata } from "../parse/index.js";
2
+ import { isCloseOrRepay } from "./detectCloseOrRepay.js";
2
3
  import { UnsupportedOperationError } from "./errors.js";
3
4
  import { previewAdjustCreditAccount } from "./previewAdjustCreditAccount.js";
5
+ import { previewCloseOrRepay } from "./previewCloseOrRepay.js";
4
6
  import { previewOpenCreditAccount } from "./previewOpenCreditAccount.js";
5
7
  import { previewPoolOperation } from "./previewPoolOperation.js";
6
8
  async function previewOperation(input, options) {
@@ -8,10 +10,16 @@ async function previewOperation(input, options) {
8
10
  if (isPoolOperation(operation)) {
9
11
  return previewPoolOperation(input, operation, options);
10
12
  }
11
- if (operation.operation === "OpenCreditAccount" || operation.operation === "SecuritizeOpenCreditAccount") {
13
+ if (operation.operation === "OpenCreditAccount" || operation.operation === "RWAOpenCreditAccount") {
12
14
  return previewOpenCreditAccount(input, operation);
13
15
  }
14
- if (operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "SecuritizeMulticall") {
16
+ if (operation.operation === "CloseCreditAccount") {
17
+ return previewCloseOrRepay(input, operation, true, options);
18
+ }
19
+ if (operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "RWAMulticall") {
20
+ if (isCloseOrRepay(operation.multicall)) {
21
+ return previewCloseOrRepay(input, operation, false, options);
22
+ }
15
23
  return previewAdjustCreditAccount(input, operation, options);
16
24
  }
17
25
  throw new UnsupportedOperationError(operation.operation);
@@ -170,8 +170,8 @@ class SecuritizeRWAFactory extends BaseContract {
170
170
  /**
171
171
  * {@inheritDoc IRWAFactory.multicall}
172
172
  */
173
- multicall(creditAccount, calls, options) {
174
- const { tokensToRegister = [], signaturesToCache = [] } = options ?? {};
173
+ multicall(creditAccount, calls, args) {
174
+ const { tokensToRegister = [], signaturesToCache = [] } = args ?? {};
175
175
  return this.createRawTx({
176
176
  functionName: "multicall",
177
177
  args: [creditAccount, calls, tokensToRegister, signaturesToCache]
@@ -201,11 +201,33 @@ class SecuritizeRWAFactory extends BaseContract {
201
201
  requiredSignatures
202
202
  };
203
203
  }
204
+ /**
205
+ * {@inheritDoc IRWAFactory.getMissingRequirements}
206
+ *
207
+ * A required signature is omitted when `providedArgs.signaturesToCache`
208
+ * already carries a signature for the same token: the transaction caches it
209
+ * on-chain as part of the operation.
210
+ */
211
+ getMissingRequirements(requirements, providedArgs) {
212
+ const providedTokens = new AddressSet(
213
+ (providedArgs?.signaturesToCache ?? []).map((s) => s.token)
214
+ );
215
+ const requiredSignatures = requirements.requiredSignatures.filter(
216
+ (message) => !providedTokens.has(message.message.token)
217
+ );
218
+ if (requiredSignatures.length === 0) {
219
+ return void 0;
220
+ }
221
+ return {
222
+ type: RWA_FACTORY_SECURITIZE,
223
+ requiredSignatures
224
+ };
225
+ }
204
226
  /**
205
227
  * {@inheritDoc IRWAFactory.openCreditAccount}
206
228
  */
207
- openCreditAccount(creditManager, calls, options) {
208
- const { tokensToRegister = [], signaturesToCache = [] } = options ?? {};
229
+ openCreditAccount(creditManager, calls, args) {
230
+ const { tokensToRegister = [], signaturesToCache = [] } = args ?? {};
209
231
  return this.createRawTx({
210
232
  functionName: "openCreditAccount",
211
233
  args: [creditManager, calls, tokensToRegister, signaturesToCache]
@@ -15,6 +15,13 @@ class AddressSet extends Set {
15
15
  has(value) {
16
16
  return super.has(getAddress(value));
17
17
  }
18
+ difference(other) {
19
+ const result = new AddressSet(this.keys());
20
+ for (const key of other) {
21
+ result.delete(getAddress(key));
22
+ }
23
+ return result;
24
+ }
18
25
  /**
19
26
  * Returns all addresses as an array.
20
27
  **/
@@ -0,0 +1,216 @@
1
+ export declare const iWithdrawalCompressorV312Abi: readonly [{
2
+ readonly type: "function";
3
+ readonly name: "contractType";
4
+ readonly inputs: readonly [];
5
+ readonly outputs: readonly [{
6
+ readonly name: "";
7
+ readonly type: "bytes32";
8
+ readonly internalType: "bytes32";
9
+ }];
10
+ readonly stateMutability: "view";
11
+ }, {
12
+ readonly type: "function";
13
+ readonly name: "getCurrentWithdrawals";
14
+ readonly inputs: readonly [{
15
+ readonly name: "creditAccount";
16
+ readonly type: "address";
17
+ readonly internalType: "address";
18
+ }];
19
+ readonly outputs: readonly [{
20
+ readonly name: "";
21
+ readonly type: "tuple[]";
22
+ readonly internalType: "struct ClaimableWithdrawal[]";
23
+ readonly components: readonly [{
24
+ readonly name: "token";
25
+ readonly type: "address";
26
+ readonly internalType: "address";
27
+ }, {
28
+ readonly name: "withdrawalPhantomToken";
29
+ readonly type: "address";
30
+ readonly internalType: "address";
31
+ }, {
32
+ readonly name: "withdrawalTokenSpent";
33
+ readonly type: "uint256";
34
+ readonly internalType: "uint256";
35
+ }, {
36
+ readonly name: "outputs";
37
+ readonly type: "tuple[]";
38
+ readonly internalType: "struct WithdrawalOutput[]";
39
+ readonly components: readonly [{
40
+ readonly name: "token";
41
+ readonly type: "address";
42
+ readonly internalType: "address";
43
+ }, {
44
+ readonly name: "isDelayed";
45
+ readonly type: "bool";
46
+ readonly internalType: "bool";
47
+ }, {
48
+ readonly name: "amount";
49
+ readonly type: "uint256";
50
+ readonly internalType: "uint256";
51
+ }];
52
+ }, {
53
+ readonly name: "claimCalls";
54
+ readonly type: "tuple[]";
55
+ readonly internalType: "struct MultiCall[]";
56
+ readonly components: readonly [{
57
+ readonly name: "target";
58
+ readonly type: "address";
59
+ readonly internalType: "address";
60
+ }, {
61
+ readonly name: "callData";
62
+ readonly type: "bytes";
63
+ readonly internalType: "bytes";
64
+ }];
65
+ }, {
66
+ readonly name: "extraData";
67
+ readonly type: "bytes";
68
+ readonly internalType: "bytes";
69
+ }];
70
+ }, {
71
+ readonly name: "";
72
+ readonly type: "tuple[]";
73
+ readonly internalType: "struct PendingWithdrawal[]";
74
+ readonly components: readonly [{
75
+ readonly name: "token";
76
+ readonly type: "address";
77
+ readonly internalType: "address";
78
+ }, {
79
+ readonly name: "withdrawalPhantomToken";
80
+ readonly type: "address";
81
+ readonly internalType: "address";
82
+ }, {
83
+ readonly name: "expectedOutputs";
84
+ readonly type: "tuple[]";
85
+ readonly internalType: "struct WithdrawalOutput[]";
86
+ readonly components: readonly [{
87
+ readonly name: "token";
88
+ readonly type: "address";
89
+ readonly internalType: "address";
90
+ }, {
91
+ readonly name: "isDelayed";
92
+ readonly type: "bool";
93
+ readonly internalType: "bool";
94
+ }, {
95
+ readonly name: "amount";
96
+ readonly type: "uint256";
97
+ readonly internalType: "uint256";
98
+ }];
99
+ }, {
100
+ readonly name: "claimableAt";
101
+ readonly type: "uint256";
102
+ readonly internalType: "uint256";
103
+ }];
104
+ }];
105
+ readonly stateMutability: "view";
106
+ }, {
107
+ readonly type: "function";
108
+ readonly name: "getWithdrawableAssets";
109
+ readonly inputs: readonly [{
110
+ readonly name: "creditManager";
111
+ readonly type: "address";
112
+ readonly internalType: "address";
113
+ }];
114
+ readonly outputs: readonly [{
115
+ readonly name: "";
116
+ readonly type: "tuple[]";
117
+ readonly internalType: "struct WithdrawableAsset[]";
118
+ readonly components: readonly [{
119
+ readonly name: "token";
120
+ readonly type: "address";
121
+ readonly internalType: "address";
122
+ }, {
123
+ readonly name: "withdrawalPhantomToken";
124
+ readonly type: "address";
125
+ readonly internalType: "address";
126
+ }, {
127
+ readonly name: "underlying";
128
+ readonly type: "address";
129
+ readonly internalType: "address";
130
+ }, {
131
+ readonly name: "withdrawalLength";
132
+ readonly type: "uint256";
133
+ readonly internalType: "uint256";
134
+ }, {
135
+ readonly name: "maxWithdrawals";
136
+ readonly type: "uint256";
137
+ readonly internalType: "uint256";
138
+ }];
139
+ }];
140
+ readonly stateMutability: "view";
141
+ }, {
142
+ readonly type: "function";
143
+ readonly name: "getWithdrawalRequestResult";
144
+ readonly inputs: readonly [{
145
+ readonly name: "creditAccount";
146
+ readonly type: "address";
147
+ readonly internalType: "address";
148
+ }, {
149
+ readonly name: "token";
150
+ readonly type: "address";
151
+ readonly internalType: "address";
152
+ }, {
153
+ readonly name: "amount";
154
+ readonly type: "uint256";
155
+ readonly internalType: "uint256";
156
+ }];
157
+ readonly outputs: readonly [{
158
+ readonly name: "";
159
+ readonly type: "tuple";
160
+ readonly internalType: "struct RequestableWithdrawal";
161
+ readonly components: readonly [{
162
+ readonly name: "token";
163
+ readonly type: "address";
164
+ readonly internalType: "address";
165
+ }, {
166
+ readonly name: "amountIn";
167
+ readonly type: "uint256";
168
+ readonly internalType: "uint256";
169
+ }, {
170
+ readonly name: "outputs";
171
+ readonly type: "tuple[]";
172
+ readonly internalType: "struct WithdrawalOutput[]";
173
+ readonly components: readonly [{
174
+ readonly name: "token";
175
+ readonly type: "address";
176
+ readonly internalType: "address";
177
+ }, {
178
+ readonly name: "isDelayed";
179
+ readonly type: "bool";
180
+ readonly internalType: "bool";
181
+ }, {
182
+ readonly name: "amount";
183
+ readonly type: "uint256";
184
+ readonly internalType: "uint256";
185
+ }];
186
+ }, {
187
+ readonly name: "requestCalls";
188
+ readonly type: "tuple[]";
189
+ readonly internalType: "struct MultiCall[]";
190
+ readonly components: readonly [{
191
+ readonly name: "target";
192
+ readonly type: "address";
193
+ readonly internalType: "address";
194
+ }, {
195
+ readonly name: "callData";
196
+ readonly type: "bytes";
197
+ readonly internalType: "bytes";
198
+ }];
199
+ }, {
200
+ readonly name: "claimableAt";
201
+ readonly type: "uint256";
202
+ readonly internalType: "uint256";
203
+ }];
204
+ }];
205
+ readonly stateMutability: "view";
206
+ }, {
207
+ readonly type: "function";
208
+ readonly name: "version";
209
+ readonly inputs: readonly [];
210
+ readonly outputs: readonly [{
211
+ readonly name: "";
212
+ readonly type: "uint256";
213
+ readonly internalType: "uint256";
214
+ }];
215
+ readonly stateMutability: "view";
216
+ }];
@@ -17,6 +17,6 @@ export interface ParseRWAFactoryOperationCalldataProps {
17
17
  * identical to {@link parseFacadeOperationCalldata}.
18
18
  *
19
19
  * Dispatches on the factory's contract type; supporting a new factory type
20
- * requires a new branch here plus new operation types in `types-rwa.ts`.
20
+ * requires a new branch here.
21
21
  */
22
22
  export declare function parseRWAFactoryOperationCalldata(props: ParseRWAFactoryOperationCalldataProps): RWAOperation;
@@ -1,5 +1,5 @@
1
1
  import type { Address } from "viem";
2
- import type { SecuritizeRegisterMessage } from "../../sdk/index.js";
2
+ import type { RWAOperationArgs } from "../../sdk/index.js";
3
3
  import type { InnerOperation } from "./types-facades.js";
4
4
  /**
5
5
  * Metadata shared by all RWA factory operations. RWA credit accounts are
@@ -13,36 +13,24 @@ export interface RWAOperationMetadata {
13
13
  creditManager: Address;
14
14
  creditFacade: Address;
15
15
  }
16
- export interface SecuritizeOpenCreditAccountOperation<Ext extends object = {}> extends RWAOperationMetadata {
17
- operation: "SecuritizeOpenCreditAccount";
16
+ export interface RWAOpenCreditAccountOperation<Ext extends object = {}> extends RWAOperationMetadata {
17
+ operation: "RWAOpenCreditAccount";
18
18
  multicall: InnerOperation<Ext>[];
19
19
  /**
20
- * DSToken addresses to register, decoded from calldata. Empty in the
21
- * template flow, where the real value comes from the factory's open-account
22
- * requirements.
20
+ * Factory-specific registration args decoded from calldata (for
21
+ * Securitize: `tokensToRegister`/`signaturesToCache`).
23
22
  */
24
- tokensToRegister: Address[];
25
- /**
26
- * EIP-712 registration signatures to store on-chain, decoded from calldata.
27
- * Empty in the template flow.
28
- */
29
- signaturesToCache: SecuritizeRegisterMessage[];
23
+ args: RWAOperationArgs;
30
24
  }
31
- /**
32
- * `SecuritizeRWAFactory.multicall` call: like the facade's `multicall`, plus
33
- * the factory-specific registration args.
34
- */
35
- export interface SecuritizeMulticallOperation<Ext extends object = {}> extends RWAOperationMetadata {
36
- operation: "SecuritizeMulticall";
25
+ export interface RWAMulticallOperation<Ext extends object = {}> extends RWAOperationMetadata {
26
+ operation: "RWAMulticall";
37
27
  creditAccount: Address;
38
28
  multicall: InnerOperation<Ext>[];
39
- /** DSToken addresses to register, decoded from calldata. */
40
- tokensToRegister: Address[];
41
- /** EIP-712 registration signatures to store on-chain, decoded from calldata. */
42
- signaturesToCache: SecuritizeRegisterMessage[];
29
+ /** Factory-specific registration args decoded from calldata. */
30
+ args: RWAOperationArgs;
43
31
  }
44
32
  /**
45
33
  * Discriminated union of all RWA factory operation types. Extend it when
46
34
  * adding support for a new RWA factory type.
47
35
  */
48
- export type RWAOperation<Ext extends object = {}> = SecuritizeOpenCreditAccountOperation<Ext> | SecuritizeMulticallOperation<Ext>;
36
+ export type RWAOperation<Ext extends object = {}> = RWAOpenCreditAccountOperation<Ext> | RWAMulticallOperation<Ext>;
@@ -1,6 +1,6 @@
1
- import { type Address, type ContractFunctionParameters } from "viem";
2
- import { type MulticallCallResult, Prerequisite } from "./Prerequisite.js";
3
- import type { PrerequisiteDetail, PrerequisiteResult } from "./types.js";
1
+ import { type Address } from "viem";
2
+ import { Prerequisite } from "./Prerequisite.js";
3
+ import type { PrerequisiteContext, PrerequisiteDetail, PrerequisiteResult } from "./types.js";
4
4
  export interface AllowancePrerequisiteProps {
5
5
  token: Address;
6
6
  owner: Address;
@@ -17,6 +17,5 @@ export declare class AllowancePrerequisite extends Prerequisite<"allowance"> {
17
17
  get kind(): "allowance";
18
18
  get title(): string;
19
19
  get detail(): PrerequisiteDetail<"allowance">;
20
- calls(): ContractFunctionParameters[];
21
- resolve(slice: MulticallCallResult[]): PrerequisiteResult<"allowance">;
20
+ protected check(ctx: PrerequisiteContext): Promise<PrerequisiteResult<"allowance">>;
22
21
  }
@@ -1,5 +1,5 @@
1
- import { type Address, type ContractFunctionParameters } from "viem";
2
- import { type MulticallCallResult, Prerequisite } from "./Prerequisite.js";
1
+ import { type Address } from "viem";
2
+ import { Prerequisite } from "./Prerequisite.js";
3
3
  import type { PrerequisiteContext, PrerequisiteDetail, PrerequisiteResult } from "./types.js";
4
4
  export interface BalancePrerequisiteProps {
5
5
  token: Address;
@@ -11,8 +11,7 @@ export interface BalancePrerequisiteProps {
11
11
  /**
12
12
  * Checks that `owner` holds a token balance >= `required`. The token is read
13
13
  * as an ERC-20, except for the native pseudo-address ({@link NATIVE_ADDRESS},
14
- * e.g. ETH-zapper deposits) whose balance is read via multicall3's
15
- * `getEthBalance`.
14
+ * e.g. ETH-zapper deposits) whose balance is read via `getBalance`.
16
15
  */
17
16
  export declare class BalancePrerequisite extends Prerequisite<"balance"> {
18
17
  #private;
@@ -21,6 +20,5 @@ export declare class BalancePrerequisite extends Prerequisite<"balance"> {
21
20
  get kind(): "balance";
22
21
  get title(): string;
23
22
  get detail(): PrerequisiteDetail<"balance">;
24
- calls(ctx: PrerequisiteContext): ContractFunctionParameters[];
25
- resolve(slice: MulticallCallResult[]): PrerequisiteResult<"balance">;
23
+ protected check(ctx: PrerequisiteContext): Promise<PrerequisiteResult<"balance">>;
26
24
  }