@gearbox-protocol/sdk 14.12.0-next.2 → 14.12.0-next.3
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.
- package/dist/cjs/preview/parse/index.js +2 -0
- package/dist/cjs/preview/parse/parseOperationCalldata.js +8 -0
- package/dist/cjs/preview/parse/parseRWAFactoryOperationCalldata.js +92 -0
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +23 -10
- package/dist/cjs/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +20 -0
- package/dist/esm/preview/parse/index.js +1 -0
- package/dist/esm/preview/parse/parseOperationCalldata.js +9 -0
- package/dist/esm/preview/parse/parseRWAFactoryOperationCalldata.js +71 -0
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +23 -10
- package/dist/esm/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +23 -1
- package/dist/types/preview/parse/classifyInnerOperations.d.ts +0 -2
- package/dist/types/preview/parse/index.d.ts +1 -0
- package/dist/types/preview/parse/parseRWAFactoryOperationCalldata.d.ts +23 -0
- package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +1 -1
- package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -1
- package/package.json +1 -1
|
@@ -21,6 +21,7 @@ __reExport(parse_exports, require("./extractExpectedBalanceChanges.js"), module.
|
|
|
21
21
|
__reExport(parse_exports, require("./parseFacadeOperationCalldata.js"), module.exports);
|
|
22
22
|
__reExport(parse_exports, require("./parseOperationCalldata.js"), module.exports);
|
|
23
23
|
__reExport(parse_exports, require("./parsePoolOperationCalldata.js"), module.exports);
|
|
24
|
+
__reExport(parse_exports, require("./parseRWAFactoryOperationCalldata.js"), module.exports);
|
|
24
25
|
__reExport(parse_exports, require("./types.js"), module.exports);
|
|
25
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
27
|
0 && (module.exports = {
|
|
@@ -30,5 +31,6 @@ __reExport(parse_exports, require("./types.js"), module.exports);
|
|
|
30
31
|
...require("./parseFacadeOperationCalldata.js"),
|
|
31
32
|
...require("./parseOperationCalldata.js"),
|
|
32
33
|
...require("./parsePoolOperationCalldata.js"),
|
|
34
|
+
...require("./parseRWAFactoryOperationCalldata.js"),
|
|
33
35
|
...require("./types.js")
|
|
34
36
|
});
|
|
@@ -25,6 +25,7 @@ var import_sdk = require("../../sdk/index.js");
|
|
|
25
25
|
var import_errors = require("./errors.js");
|
|
26
26
|
var import_parseFacadeOperationCalldata = require("./parseFacadeOperationCalldata.js");
|
|
27
27
|
var import_parsePoolOperationCalldata = require("./parsePoolOperationCalldata.js");
|
|
28
|
+
var import_parseRWAFactoryOperationCalldata = require("./parseRWAFactoryOperationCalldata.js");
|
|
28
29
|
function parseOperationCalldata(input) {
|
|
29
30
|
const { sdk, to, calldata, value, sender } = input;
|
|
30
31
|
const contract = sdk.getContract(to);
|
|
@@ -67,6 +68,13 @@ function parseOperationCalldata(input) {
|
|
|
67
68
|
calldata
|
|
68
69
|
});
|
|
69
70
|
}
|
|
71
|
+
if (contract instanceof import_sdk.SecuritizeRWAFactory) {
|
|
72
|
+
return (0, import_parseRWAFactoryOperationCalldata.parseRWAFactoryOperationCalldata)({
|
|
73
|
+
sdk,
|
|
74
|
+
factory: contract,
|
|
75
|
+
calldata
|
|
76
|
+
});
|
|
77
|
+
}
|
|
70
78
|
throw new import_errors.UnsupportedTargetError(to);
|
|
71
79
|
}
|
|
72
80
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var parseRWAFactoryOperationCalldata_exports = {};
|
|
20
|
+
__export(parseRWAFactoryOperationCalldata_exports, {
|
|
21
|
+
parseRWAFactoryOperationCalldata: () => parseRWAFactoryOperationCalldata
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(parseRWAFactoryOperationCalldata_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
var import_adapters = require("../../plugins/adapters/index.js");
|
|
26
|
+
var import_sdk = require("../../sdk/index.js");
|
|
27
|
+
var import_classifyInnerOperations = require("./classifyInnerOperations.js");
|
|
28
|
+
var import_extractExpectedBalanceChanges = require("./extractExpectedBalanceChanges.js");
|
|
29
|
+
function parseRWAFactoryOperationCalldata(props) {
|
|
30
|
+
const { sdk, factory, calldata } = props;
|
|
31
|
+
const parsed = sdk.parseFunctionDataV2(factory.address, calldata);
|
|
32
|
+
const functionName = parsed.functionName.split("(")[0];
|
|
33
|
+
const { rawArgs } = parsed;
|
|
34
|
+
const innerCalls = rawArgs.calls ?? [];
|
|
35
|
+
const suite = functionName === "openCreditAccount" ? sdk.marketRegister.findCreditManager(rawArgs.creditManager) : resolveSuiteForMulticall(sdk, factory, innerCalls);
|
|
36
|
+
const metadata = {
|
|
37
|
+
creditManager: suite.creditManager.address,
|
|
38
|
+
creditFacade: suite.creditFacade.address
|
|
39
|
+
};
|
|
40
|
+
const multicall = (0, import_classifyInnerOperations.classifyInnerOperations)(innerCalls, {
|
|
41
|
+
sdk,
|
|
42
|
+
underlying: suite.underlying
|
|
43
|
+
});
|
|
44
|
+
const expectedBalanceChanges = (0, import_extractExpectedBalanceChanges.extractExpectedBalanceChanges)(innerCalls);
|
|
45
|
+
switch (functionName) {
|
|
46
|
+
case "openCreditAccount":
|
|
47
|
+
return {
|
|
48
|
+
...metadata,
|
|
49
|
+
operation: "OpenCreditAccount",
|
|
50
|
+
creditAccount: import_viem.zeroAddress,
|
|
51
|
+
onBehalfOf: import_viem.zeroAddress,
|
|
52
|
+
referralCode: 0n,
|
|
53
|
+
multicall,
|
|
54
|
+
expectedBalanceChanges
|
|
55
|
+
};
|
|
56
|
+
case "multicall":
|
|
57
|
+
return {
|
|
58
|
+
...metadata,
|
|
59
|
+
operation: "MultiCall",
|
|
60
|
+
creditAccount: rawArgs.creditAccount,
|
|
61
|
+
multicall,
|
|
62
|
+
expectedBalanceChanges
|
|
63
|
+
};
|
|
64
|
+
default:
|
|
65
|
+
throw new Error(
|
|
66
|
+
`unsupported RWA factory function "${parsed.functionName}" on ${factory.address}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function resolveSuiteForMulticall(sdk, factory, innerCalls) {
|
|
71
|
+
for (const call of innerCalls) {
|
|
72
|
+
const contract = sdk.getContract(call.target);
|
|
73
|
+
if (contract instanceof import_sdk.CreditFacadeV310Contract) {
|
|
74
|
+
const suite = sdk.marketRegister.creditManagers.find(
|
|
75
|
+
(cm) => (0, import_sdk.hexEq)(cm.creditFacade.address, call.target)
|
|
76
|
+
);
|
|
77
|
+
if (suite) {
|
|
78
|
+
return suite;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (contract instanceof import_adapters.AbstractAdapterContract) {
|
|
82
|
+
return sdk.marketRegister.findCreditManager(contract.creditManager);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw new Error(
|
|
86
|
+
`cannot resolve credit manager for RWA factory multicall on ${factory.address}`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
parseRWAFactoryOperationCalldata
|
|
92
|
+
});
|
|
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(buildPrerequisites_exports);
|
|
|
24
24
|
var import_viem = require("viem");
|
|
25
25
|
var import_AllowancePrerequisite = require("./AllowancePrerequisite.js");
|
|
26
26
|
var import_BalancePrerequisite = require("./BalancePrerequisite.js");
|
|
27
|
-
function buildPrerequisites(tx, ctx) {
|
|
27
|
+
async function buildPrerequisites(tx, ctx) {
|
|
28
28
|
const { wallet } = ctx;
|
|
29
29
|
switch (tx.operation) {
|
|
30
30
|
// Deposit and Mint both pull the underlying from the caller into the pool;
|
|
@@ -150,7 +150,13 @@ function buildPrerequisites(tx, ctx) {
|
|
|
150
150
|
case "OpenCreditAccount":
|
|
151
151
|
case "CloseCreditAccount":
|
|
152
152
|
case "LiquidateCreditAccount":
|
|
153
|
-
return collateralPrerequisites(
|
|
153
|
+
return collateralPrerequisites(
|
|
154
|
+
tx.operation,
|
|
155
|
+
tx.multicall,
|
|
156
|
+
tx.creditManager,
|
|
157
|
+
tx.creditAccount,
|
|
158
|
+
ctx
|
|
159
|
+
);
|
|
154
160
|
case "PartiallyLiquidateCreditAccount": {
|
|
155
161
|
const underlying = underlyingOf(ctx.sdk, tx.creditManager);
|
|
156
162
|
if (!underlying || tx.repaidAmount === 0n) {
|
|
@@ -176,28 +182,35 @@ function buildPrerequisites(tx, ctx) {
|
|
|
176
182
|
return [];
|
|
177
183
|
}
|
|
178
184
|
}
|
|
179
|
-
function collateralPrerequisites(multicall, creditManager,
|
|
185
|
+
async function collateralPrerequisites(op, multicall, creditManager, creditAccount, ctx) {
|
|
186
|
+
const { sdk, wallet } = ctx;
|
|
180
187
|
const required = /* @__PURE__ */ new Map();
|
|
181
|
-
for (const
|
|
182
|
-
if (
|
|
188
|
+
for (const op2 of multicall) {
|
|
189
|
+
if (op2.operation !== "AddCollateral" || op2.amount === 0n) {
|
|
183
190
|
continue;
|
|
184
191
|
}
|
|
185
|
-
const key =
|
|
192
|
+
const key = op2.token.toLowerCase();
|
|
186
193
|
const existing = required.get(key);
|
|
187
194
|
required.set(key, {
|
|
188
|
-
token:
|
|
189
|
-
amount: (existing?.amount ?? 0n) +
|
|
195
|
+
token: op2.token,
|
|
196
|
+
amount: (existing?.amount ?? 0n) + op2.amount
|
|
190
197
|
});
|
|
191
198
|
}
|
|
199
|
+
if (required.size === 0) {
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
const spender = await sdk.accounts.getApprovalAddress(
|
|
203
|
+
op === "OpenCreditAccount" ? { creditManager, borrower: wallet } : { creditManager, creditAccount }
|
|
204
|
+
);
|
|
192
205
|
const prereqs = [];
|
|
193
206
|
for (const { token, amount } of required.values()) {
|
|
194
207
|
prereqs.push(
|
|
195
208
|
new import_AllowancePrerequisite.AllowancePrerequisite({
|
|
196
209
|
token,
|
|
197
210
|
owner: wallet,
|
|
198
|
-
spender
|
|
211
|
+
spender,
|
|
199
212
|
required: amount,
|
|
200
|
-
title: "Collateral approved
|
|
213
|
+
title: "Collateral approved"
|
|
201
214
|
}),
|
|
202
215
|
new import_BalancePrerequisite.BalancePrerequisite({
|
|
203
216
|
token,
|
|
@@ -70,6 +70,26 @@ class SecuritizeRWAFactory extends import_base.BaseContract {
|
|
|
70
70
|
operators: [...t.operators]
|
|
71
71
|
}));
|
|
72
72
|
}
|
|
73
|
+
parseFunctionParamsV2(params, strict) {
|
|
74
|
+
switch (params.functionName) {
|
|
75
|
+
case "openCreditAccount": {
|
|
76
|
+
const [creditManager, calls] = params.args;
|
|
77
|
+
return {
|
|
78
|
+
creditManager,
|
|
79
|
+
calls: this.register.parseMultiCallV2([...calls], strict)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
case "multicall": {
|
|
83
|
+
const [creditAccount, calls] = params.args;
|
|
84
|
+
return {
|
|
85
|
+
creditAccount,
|
|
86
|
+
calls: this.register.parseMultiCallV2([...calls], strict)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
default:
|
|
90
|
+
return super.parseFunctionParamsV2(params, strict);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
73
93
|
/**
|
|
74
94
|
* {@inheritDoc IRWAFactory.decodeInvestorData}
|
|
75
95
|
*/
|
|
@@ -4,4 +4,5 @@ export * from "./extractExpectedBalanceChanges.js";
|
|
|
4
4
|
export * from "./parseFacadeOperationCalldata.js";
|
|
5
5
|
export * from "./parseOperationCalldata.js";
|
|
6
6
|
export * from "./parsePoolOperationCalldata.js";
|
|
7
|
+
export * from "./parseRWAFactoryOperationCalldata.js";
|
|
7
8
|
export * from "./types.js";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CreditFacadeV310Contract,
|
|
3
3
|
PoolV310Contract,
|
|
4
|
+
SecuritizeRWAFactory,
|
|
4
5
|
ZapperContract
|
|
5
6
|
} from "../../sdk/index.js";
|
|
6
7
|
import { UnsupportedTargetError } from "./errors.js";
|
|
7
8
|
import { parseFacadeOperationCalldata } from "./parseFacadeOperationCalldata.js";
|
|
8
9
|
import { parsePoolOperationCalldata } from "./parsePoolOperationCalldata.js";
|
|
10
|
+
import { parseRWAFactoryOperationCalldata } from "./parseRWAFactoryOperationCalldata.js";
|
|
9
11
|
function parseOperationCalldata(input) {
|
|
10
12
|
const { sdk, to, calldata, value, sender } = input;
|
|
11
13
|
const contract = sdk.getContract(to);
|
|
@@ -48,6 +50,13 @@ function parseOperationCalldata(input) {
|
|
|
48
50
|
calldata
|
|
49
51
|
});
|
|
50
52
|
}
|
|
53
|
+
if (contract instanceof SecuritizeRWAFactory) {
|
|
54
|
+
return parseRWAFactoryOperationCalldata({
|
|
55
|
+
sdk,
|
|
56
|
+
factory: contract,
|
|
57
|
+
calldata
|
|
58
|
+
});
|
|
59
|
+
}
|
|
51
60
|
throw new UnsupportedTargetError(to);
|
|
52
61
|
}
|
|
53
62
|
export {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { zeroAddress } from "viem";
|
|
2
|
+
import { AbstractAdapterContract } from "../../plugins/adapters/index.js";
|
|
3
|
+
import {
|
|
4
|
+
CreditFacadeV310Contract,
|
|
5
|
+
hexEq
|
|
6
|
+
} from "../../sdk/index.js";
|
|
7
|
+
import { classifyInnerOperations } from "./classifyInnerOperations.js";
|
|
8
|
+
import { extractExpectedBalanceChanges } from "./extractExpectedBalanceChanges.js";
|
|
9
|
+
function parseRWAFactoryOperationCalldata(props) {
|
|
10
|
+
const { sdk, factory, calldata } = props;
|
|
11
|
+
const parsed = sdk.parseFunctionDataV2(factory.address, calldata);
|
|
12
|
+
const functionName = parsed.functionName.split("(")[0];
|
|
13
|
+
const { rawArgs } = parsed;
|
|
14
|
+
const innerCalls = rawArgs.calls ?? [];
|
|
15
|
+
const suite = functionName === "openCreditAccount" ? sdk.marketRegister.findCreditManager(rawArgs.creditManager) : resolveSuiteForMulticall(sdk, factory, innerCalls);
|
|
16
|
+
const metadata = {
|
|
17
|
+
creditManager: suite.creditManager.address,
|
|
18
|
+
creditFacade: suite.creditFacade.address
|
|
19
|
+
};
|
|
20
|
+
const multicall = classifyInnerOperations(innerCalls, {
|
|
21
|
+
sdk,
|
|
22
|
+
underlying: suite.underlying
|
|
23
|
+
});
|
|
24
|
+
const expectedBalanceChanges = extractExpectedBalanceChanges(innerCalls);
|
|
25
|
+
switch (functionName) {
|
|
26
|
+
case "openCreditAccount":
|
|
27
|
+
return {
|
|
28
|
+
...metadata,
|
|
29
|
+
operation: "OpenCreditAccount",
|
|
30
|
+
creditAccount: zeroAddress,
|
|
31
|
+
onBehalfOf: zeroAddress,
|
|
32
|
+
referralCode: 0n,
|
|
33
|
+
multicall,
|
|
34
|
+
expectedBalanceChanges
|
|
35
|
+
};
|
|
36
|
+
case "multicall":
|
|
37
|
+
return {
|
|
38
|
+
...metadata,
|
|
39
|
+
operation: "MultiCall",
|
|
40
|
+
creditAccount: rawArgs.creditAccount,
|
|
41
|
+
multicall,
|
|
42
|
+
expectedBalanceChanges
|
|
43
|
+
};
|
|
44
|
+
default:
|
|
45
|
+
throw new Error(
|
|
46
|
+
`unsupported RWA factory function "${parsed.functionName}" on ${factory.address}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function resolveSuiteForMulticall(sdk, factory, innerCalls) {
|
|
51
|
+
for (const call of innerCalls) {
|
|
52
|
+
const contract = sdk.getContract(call.target);
|
|
53
|
+
if (contract instanceof CreditFacadeV310Contract) {
|
|
54
|
+
const suite = sdk.marketRegister.creditManagers.find(
|
|
55
|
+
(cm) => hexEq(cm.creditFacade.address, call.target)
|
|
56
|
+
);
|
|
57
|
+
if (suite) {
|
|
58
|
+
return suite;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (contract instanceof AbstractAdapterContract) {
|
|
62
|
+
return sdk.marketRegister.findCreditManager(contract.creditManager);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
throw new Error(
|
|
66
|
+
`cannot resolve credit manager for RWA factory multicall on ${factory.address}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
parseRWAFactoryOperationCalldata
|
|
71
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isAddressEqual } from "viem";
|
|
2
2
|
import { AllowancePrerequisite } from "./AllowancePrerequisite.js";
|
|
3
3
|
import { BalancePrerequisite } from "./BalancePrerequisite.js";
|
|
4
|
-
function buildPrerequisites(tx, ctx) {
|
|
4
|
+
async function buildPrerequisites(tx, ctx) {
|
|
5
5
|
const { wallet } = ctx;
|
|
6
6
|
switch (tx.operation) {
|
|
7
7
|
// Deposit and Mint both pull the underlying from the caller into the pool;
|
|
@@ -127,7 +127,13 @@ function buildPrerequisites(tx, ctx) {
|
|
|
127
127
|
case "OpenCreditAccount":
|
|
128
128
|
case "CloseCreditAccount":
|
|
129
129
|
case "LiquidateCreditAccount":
|
|
130
|
-
return collateralPrerequisites(
|
|
130
|
+
return collateralPrerequisites(
|
|
131
|
+
tx.operation,
|
|
132
|
+
tx.multicall,
|
|
133
|
+
tx.creditManager,
|
|
134
|
+
tx.creditAccount,
|
|
135
|
+
ctx
|
|
136
|
+
);
|
|
131
137
|
case "PartiallyLiquidateCreditAccount": {
|
|
132
138
|
const underlying = underlyingOf(ctx.sdk, tx.creditManager);
|
|
133
139
|
if (!underlying || tx.repaidAmount === 0n) {
|
|
@@ -153,28 +159,35 @@ function buildPrerequisites(tx, ctx) {
|
|
|
153
159
|
return [];
|
|
154
160
|
}
|
|
155
161
|
}
|
|
156
|
-
function collateralPrerequisites(multicall, creditManager,
|
|
162
|
+
async function collateralPrerequisites(op, multicall, creditManager, creditAccount, ctx) {
|
|
163
|
+
const { sdk, wallet } = ctx;
|
|
157
164
|
const required = /* @__PURE__ */ new Map();
|
|
158
|
-
for (const
|
|
159
|
-
if (
|
|
165
|
+
for (const op2 of multicall) {
|
|
166
|
+
if (op2.operation !== "AddCollateral" || op2.amount === 0n) {
|
|
160
167
|
continue;
|
|
161
168
|
}
|
|
162
|
-
const key =
|
|
169
|
+
const key = op2.token.toLowerCase();
|
|
163
170
|
const existing = required.get(key);
|
|
164
171
|
required.set(key, {
|
|
165
|
-
token:
|
|
166
|
-
amount: (existing?.amount ?? 0n) +
|
|
172
|
+
token: op2.token,
|
|
173
|
+
amount: (existing?.amount ?? 0n) + op2.amount
|
|
167
174
|
});
|
|
168
175
|
}
|
|
176
|
+
if (required.size === 0) {
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
const spender = await sdk.accounts.getApprovalAddress(
|
|
180
|
+
op === "OpenCreditAccount" ? { creditManager, borrower: wallet } : { creditManager, creditAccount }
|
|
181
|
+
);
|
|
169
182
|
const prereqs = [];
|
|
170
183
|
for (const { token, amount } of required.values()) {
|
|
171
184
|
prereqs.push(
|
|
172
185
|
new AllowancePrerequisite({
|
|
173
186
|
token,
|
|
174
187
|
owner: wallet,
|
|
175
|
-
spender
|
|
188
|
+
spender,
|
|
176
189
|
required: amount,
|
|
177
|
-
title: "Collateral approved
|
|
190
|
+
title: "Collateral approved"
|
|
178
191
|
}),
|
|
179
192
|
new BalancePrerequisite({
|
|
180
193
|
token,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
decodeAbiParameters
|
|
3
|
+
} from "viem";
|
|
2
4
|
import { iSecuritizeRWAFactoryAbi } from "../../../../abi/rwa/iSecuritizeRWAFactory.js";
|
|
3
5
|
import { BaseContract } from "../../../base/index.js";
|
|
4
6
|
import { AddressMap, AddressSet } from "../../../utils/index.js";
|
|
@@ -49,6 +51,26 @@ class SecuritizeRWAFactory extends BaseContract {
|
|
|
49
51
|
operators: [...t.operators]
|
|
50
52
|
}));
|
|
51
53
|
}
|
|
54
|
+
parseFunctionParamsV2(params, strict) {
|
|
55
|
+
switch (params.functionName) {
|
|
56
|
+
case "openCreditAccount": {
|
|
57
|
+
const [creditManager, calls] = params.args;
|
|
58
|
+
return {
|
|
59
|
+
creditManager,
|
|
60
|
+
calls: this.register.parseMultiCallV2([...calls], strict)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
case "multicall": {
|
|
64
|
+
const [creditAccount, calls] = params.args;
|
|
65
|
+
return {
|
|
66
|
+
creditAccount,
|
|
67
|
+
calls: this.register.parseMultiCallV2([...calls], strict)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
default:
|
|
71
|
+
return super.parseFunctionParamsV2(params, strict);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
52
74
|
/**
|
|
53
75
|
* {@inheritDoc IRWAFactory.decodeInvestorData}
|
|
54
76
|
*/
|
|
@@ -7,8 +7,6 @@ export interface ClassifyInnerOperationsProps {
|
|
|
7
7
|
underlying: Address;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Calldata-only counterpart of the SDK's `classifyMulticallOperations`.
|
|
11
|
-
*
|
|
12
10
|
* Maps each inner multicall entry to an {@link InnerOperation}:
|
|
13
11
|
* - adapter and unknown targets become a pure-descriptor `Execute`
|
|
14
12
|
* {@link AdapterOperation};
|
|
@@ -4,4 +4,5 @@ export * from "./extractExpectedBalanceChanges.js";
|
|
|
4
4
|
export * from "./parseFacadeOperationCalldata.js";
|
|
5
5
|
export * from "./parseOperationCalldata.js";
|
|
6
6
|
export * from "./parsePoolOperationCalldata.js";
|
|
7
|
+
export * from "./parseRWAFactoryOperationCalldata.js";
|
|
7
8
|
export * from "./types.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Hex } from "viem";
|
|
2
|
+
import { type OnchainSDK, type SecuritizeRWAFactory } from "../../sdk/index.js";
|
|
3
|
+
import type { OuterFacadeOperation } from "./types.js";
|
|
4
|
+
export interface ParseRWAFactoryOperationCalldataProps {
|
|
5
|
+
sdk: OnchainSDK;
|
|
6
|
+
/** Resolved RWA factory contract for the transaction target. */
|
|
7
|
+
factory: SecuritizeRWAFactory;
|
|
8
|
+
calldata: Hex;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Decodes a RWA-factory entry-point call into the matching
|
|
12
|
+
* {@link OuterFacadeOperation}.
|
|
13
|
+
*
|
|
14
|
+
* RWA credit accounts are opened and managed through the market's RWA factory
|
|
15
|
+
* (see `CreditAccountsServiceV310`) rather than the credit facade, but the inner
|
|
16
|
+
* `calls` share the credit-facade multicall shape, so classification is
|
|
17
|
+
* identical to {@link parseFacadeOperationCalldata}.
|
|
18
|
+
*
|
|
19
|
+
* The RWA factory calldata does not carry `onBehalfOf`, `referralCode` or the
|
|
20
|
+
* new account address (all derived on-chain), so those are left as
|
|
21
|
+
* `zeroAddress`/`0n`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseRWAFactoryOperationCalldata(props: ParseRWAFactoryOperationCalldataProps): OuterFacadeOperation;
|
|
@@ -13,4 +13,4 @@ import type { PrerequisiteContext } from "./types.js";
|
|
|
13
13
|
* bot permissions) is intentionally out of scope, since the user cannot
|
|
14
14
|
* resolve it. New {@link AnyPrerequisite} subclasses must follow the same rule.
|
|
15
15
|
*/
|
|
16
|
-
export declare function buildPrerequisites(tx: Operation, ctx: PrerequisiteContext): AnyPrerequisite[]
|
|
16
|
+
export declare function buildPrerequisites(tx: Operation, ctx: PrerequisiteContext): Promise<AnyPrerequisite[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Address } from "viem";
|
|
1
|
+
import { type Address, type DecodeFunctionDataReturnType } from "viem";
|
|
2
2
|
import type { GetOpenAccountRequirementsProps } from "../../../accounts/types.js";
|
|
3
3
|
import { BaseContract } from "../../../base/index.js";
|
|
4
4
|
import type { OnchainSDK } from "../../../OnchainSDK.js";
|
|
@@ -463,6 +463,7 @@ export declare class SecuritizeRWAFactory extends BaseContract<abi> implements I
|
|
|
463
463
|
readonly dsTokens: DStokenData[];
|
|
464
464
|
readonly contractType = "RWA_FACTORY::SECURITIZE";
|
|
465
465
|
constructor(sdk: OnchainSDK, data: RWAFactoryData);
|
|
466
|
+
protected parseFunctionParamsV2(params: DecodeFunctionDataReturnType<abi>, strict?: boolean): Record<string, unknown>;
|
|
466
467
|
/**
|
|
467
468
|
* {@inheritDoc IRWAFactory.decodeInvestorData}
|
|
468
469
|
*/
|