@gearbox-protocol/sdk 14.12.0-next.2 → 14.12.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.
- 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 +108 -0
- package/dist/cjs/preview/parse/types-rwa.js +16 -0
- package/dist/cjs/preview/parse/types.js +9 -2
- package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +13 -13
- package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +13 -13
- package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +66 -0
- package/dist/cjs/preview/prerequisites/buildPrerequisites.js +77 -5
- package/dist/cjs/preview/prerequisites/index.js +2 -0
- package/dist/cjs/preview/simulate/index.js +5 -2
- package/dist/cjs/preview/simulate/simulateOperation.js +4 -0
- package/dist/cjs/preview/simulate/simulateRWAOperation.js +30 -0
- package/dist/cjs/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +30 -0
- package/dist/cjs/sdk/market/rwa/types.js +5 -2
- 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 +89 -0
- package/dist/esm/preview/parse/types-rwa.js +0 -0
- package/dist/esm/preview/parse/types.js +6 -1
- package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +13 -13
- package/dist/esm/preview/prerequisites/BalancePrerequisite.js +13 -13
- package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +42 -0
- package/dist/esm/preview/prerequisites/buildPrerequisites.js +79 -5
- package/dist/esm/preview/prerequisites/index.js +1 -0
- package/dist/esm/preview/simulate/index.js +3 -1
- package/dist/esm/preview/simulate/simulateOperation.js +8 -1
- package/dist/esm/preview/simulate/simulateRWAOperation.js +6 -0
- package/dist/esm/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +33 -1
- package/dist/esm/sdk/market/rwa/types.js +5 -2
- 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 +22 -0
- package/dist/types/preview/parse/types-rwa.d.ts +60 -0
- package/dist/types/preview/parse/types.d.ts +11 -6
- package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +1 -3
- package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +1 -3
- package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +36 -0
- package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +1 -1
- package/dist/types/preview/prerequisites/index.d.ts +1 -0
- package/dist/types/preview/prerequisites/types.d.ts +10 -8
- package/dist/types/preview/simulate/index.d.ts +2 -0
- package/dist/types/preview/simulate/simulateRWAOperation.d.ts +25 -0
- package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +6 -1
- package/dist/types/sdk/market/rwa/types.d.ts +13 -5
- 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 && (0, import_sdk.isRWAFactory)(contract)) {
|
|
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,108 @@
|
|
|
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_adapters = require("../../plugins/adapters/index.js");
|
|
25
|
+
var import_sdk = require("../../sdk/index.js");
|
|
26
|
+
var import_classifyInnerOperations = require("./classifyInnerOperations.js");
|
|
27
|
+
var import_extractExpectedBalanceChanges = require("./extractExpectedBalanceChanges.js");
|
|
28
|
+
function parseRWAFactoryOperationCalldata(props) {
|
|
29
|
+
const { contractType, address } = props.factory;
|
|
30
|
+
if ((0, import_sdk.isRWAFactory)(props.factory, import_sdk.RWA_FACTORY_SECURITIZE)) {
|
|
31
|
+
return parseSecuritizeOperationCalldata(props);
|
|
32
|
+
}
|
|
33
|
+
throw new Error(
|
|
34
|
+
`unsupported RWA factory type "${contractType}" on ${address}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
function parseSecuritizeOperationCalldata(props) {
|
|
38
|
+
const { sdk, factory, calldata } = props;
|
|
39
|
+
const parsed = sdk.parseFunctionDataV2(factory.address, calldata);
|
|
40
|
+
const functionName = parsed.functionName.split("(")[0];
|
|
41
|
+
const { rawArgs } = parsed;
|
|
42
|
+
const innerCalls = rawArgs.calls ?? [];
|
|
43
|
+
const tokensToRegister = [
|
|
44
|
+
...rawArgs.tokensToRegister ?? []
|
|
45
|
+
];
|
|
46
|
+
const signaturesToCache = [
|
|
47
|
+
...rawArgs.signaturesToCache ?? []
|
|
48
|
+
];
|
|
49
|
+
const suite = functionName === "openCreditAccount" ? sdk.marketRegister.findCreditManager(rawArgs.creditManager) : resolveSuiteForMulticall(sdk, factory, innerCalls);
|
|
50
|
+
const metadata = {
|
|
51
|
+
factory: factory.address,
|
|
52
|
+
creditManager: suite.creditManager.address,
|
|
53
|
+
creditFacade: suite.creditFacade.address
|
|
54
|
+
};
|
|
55
|
+
const multicall = (0, import_classifyInnerOperations.classifyInnerOperations)(innerCalls, {
|
|
56
|
+
sdk,
|
|
57
|
+
underlying: suite.underlying
|
|
58
|
+
});
|
|
59
|
+
const expectedBalanceChanges = (0, import_extractExpectedBalanceChanges.extractExpectedBalanceChanges)(innerCalls);
|
|
60
|
+
switch (functionName) {
|
|
61
|
+
case "openCreditAccount":
|
|
62
|
+
return {
|
|
63
|
+
...metadata,
|
|
64
|
+
operation: "SecuritizeOpenCreditAccount",
|
|
65
|
+
multicall,
|
|
66
|
+
expectedBalanceChanges,
|
|
67
|
+
tokensToRegister,
|
|
68
|
+
signaturesToCache
|
|
69
|
+
};
|
|
70
|
+
case "multicall":
|
|
71
|
+
return {
|
|
72
|
+
...metadata,
|
|
73
|
+
operation: "SecuritizeMulticall",
|
|
74
|
+
creditAccount: rawArgs.creditAccount,
|
|
75
|
+
multicall,
|
|
76
|
+
expectedBalanceChanges,
|
|
77
|
+
tokensToRegister,
|
|
78
|
+
signaturesToCache
|
|
79
|
+
};
|
|
80
|
+
default:
|
|
81
|
+
throw new Error(
|
|
82
|
+
`unsupported RWA factory function "${parsed.functionName}" on ${factory.address}`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function resolveSuiteForMulticall(sdk, factory, innerCalls) {
|
|
87
|
+
for (const call of innerCalls) {
|
|
88
|
+
const contract = sdk.getContract(call.target);
|
|
89
|
+
if (contract instanceof import_sdk.CreditFacadeV310Contract) {
|
|
90
|
+
const suite = sdk.marketRegister.creditManagers.find(
|
|
91
|
+
(cm) => (0, import_sdk.hexEq)(cm.creditFacade.address, call.target)
|
|
92
|
+
);
|
|
93
|
+
if (suite) {
|
|
94
|
+
return suite;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (contract instanceof import_adapters.AbstractAdapterContract) {
|
|
98
|
+
return sdk.marketRegister.findCreditManager(contract.creditManager);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
throw new Error(
|
|
102
|
+
`cannot resolve credit manager for RWA factory multicall on ${factory.address}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
parseRWAFactoryOperationCalldata
|
|
108
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_rwa_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_rwa_exports);
|
|
@@ -19,19 +19,26 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var types_exports = {};
|
|
21
21
|
__export(types_exports, {
|
|
22
|
-
isPoolOperation: () => isPoolOperation
|
|
22
|
+
isPoolOperation: () => isPoolOperation,
|
|
23
|
+
isRWAOperation: () => isRWAOperation
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(types_exports);
|
|
25
26
|
__reExport(types_exports, require("./types-adapters.js"), module.exports);
|
|
26
27
|
__reExport(types_exports, require("./types-facades.js"), module.exports);
|
|
27
28
|
__reExport(types_exports, require("./types-pools.js"), module.exports);
|
|
29
|
+
__reExport(types_exports, require("./types-rwa.js"), module.exports);
|
|
28
30
|
function isPoolOperation(tx) {
|
|
29
31
|
return tx.operation === "Deposit" || tx.operation === "Mint" || tx.operation === "Withdraw" || tx.operation === "Redeem";
|
|
30
32
|
}
|
|
33
|
+
function isRWAOperation(tx) {
|
|
34
|
+
return tx.operation === "SecuritizeOpenCreditAccount" || tx.operation === "SecuritizeMulticall";
|
|
35
|
+
}
|
|
31
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
37
|
0 && (module.exports = {
|
|
33
38
|
isPoolOperation,
|
|
39
|
+
isRWAOperation,
|
|
34
40
|
...require("./types-adapters.js"),
|
|
35
41
|
...require("./types-facades.js"),
|
|
36
|
-
...require("./types-pools.js")
|
|
42
|
+
...require("./types-pools.js"),
|
|
43
|
+
...require("./types-rwa.js")
|
|
37
44
|
});
|
|
@@ -24,14 +24,14 @@ module.exports = __toCommonJS(AllowancePrerequisite_exports);
|
|
|
24
24
|
var import_viem = require("viem");
|
|
25
25
|
var import_Prerequisite = require("./Prerequisite.js");
|
|
26
26
|
class AllowancePrerequisite extends import_Prerequisite.Prerequisite {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
#id;
|
|
28
|
+
#title;
|
|
29
|
+
#detail;
|
|
30
30
|
constructor(props) {
|
|
31
31
|
super();
|
|
32
|
-
this
|
|
33
|
-
this
|
|
34
|
-
this
|
|
32
|
+
this.#id = props.id ?? `allowance:${props.token}:${props.owner}:${props.spender}`;
|
|
33
|
+
this.#title = props.title ?? "Token approval";
|
|
34
|
+
this.#detail = {
|
|
35
35
|
token: props.token,
|
|
36
36
|
owner: props.owner,
|
|
37
37
|
spender: props.spender,
|
|
@@ -39,24 +39,24 @@ class AllowancePrerequisite extends import_Prerequisite.Prerequisite {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
get id() {
|
|
42
|
-
return this
|
|
42
|
+
return this.#id;
|
|
43
43
|
}
|
|
44
44
|
get kind() {
|
|
45
45
|
return "allowance";
|
|
46
46
|
}
|
|
47
47
|
get title() {
|
|
48
|
-
return this
|
|
48
|
+
return this.#title;
|
|
49
49
|
}
|
|
50
50
|
get detail() {
|
|
51
|
-
return this
|
|
51
|
+
return this.#detail;
|
|
52
52
|
}
|
|
53
53
|
calls() {
|
|
54
54
|
return [
|
|
55
55
|
{
|
|
56
|
-
address: this.
|
|
56
|
+
address: this.#detail.token,
|
|
57
57
|
abi: import_viem.erc20Abi,
|
|
58
58
|
functionName: "allowance",
|
|
59
|
-
args: [this.
|
|
59
|
+
args: [this.#detail.owner, this.#detail.spender]
|
|
60
60
|
}
|
|
61
61
|
];
|
|
62
62
|
}
|
|
@@ -66,8 +66,8 @@ class AllowancePrerequisite extends import_Prerequisite.Prerequisite {
|
|
|
66
66
|
return this.errorResult((0, import_Prerequisite.toPrerequisiteError)(res?.error));
|
|
67
67
|
}
|
|
68
68
|
const actual = res.result;
|
|
69
|
-
return this.satisfiedResult(actual >= this.
|
|
70
|
-
...this
|
|
69
|
+
return this.satisfiedResult(actual >= this.#detail.required, {
|
|
70
|
+
...this.#detail,
|
|
71
71
|
actual
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -24,38 +24,38 @@ module.exports = __toCommonJS(BalancePrerequisite_exports);
|
|
|
24
24
|
var import_viem = require("viem");
|
|
25
25
|
var import_Prerequisite = require("./Prerequisite.js");
|
|
26
26
|
class BalancePrerequisite extends import_Prerequisite.Prerequisite {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
#id;
|
|
28
|
+
#title;
|
|
29
|
+
#detail;
|
|
30
30
|
constructor(props) {
|
|
31
31
|
super();
|
|
32
|
-
this
|
|
33
|
-
this
|
|
34
|
-
this
|
|
32
|
+
this.#id = props.id ?? `balance:${props.token}:${props.owner}`;
|
|
33
|
+
this.#title = props.title ?? "Sufficient balance";
|
|
34
|
+
this.#detail = {
|
|
35
35
|
token: props.token,
|
|
36
36
|
owner: props.owner,
|
|
37
37
|
required: props.required
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
get id() {
|
|
41
|
-
return this
|
|
41
|
+
return this.#id;
|
|
42
42
|
}
|
|
43
43
|
get kind() {
|
|
44
44
|
return "balance";
|
|
45
45
|
}
|
|
46
46
|
get title() {
|
|
47
|
-
return this
|
|
47
|
+
return this.#title;
|
|
48
48
|
}
|
|
49
49
|
get detail() {
|
|
50
|
-
return this
|
|
50
|
+
return this.#detail;
|
|
51
51
|
}
|
|
52
52
|
calls() {
|
|
53
53
|
return [
|
|
54
54
|
{
|
|
55
|
-
address: this.
|
|
55
|
+
address: this.#detail.token,
|
|
56
56
|
abi: import_viem.erc20Abi,
|
|
57
57
|
functionName: "balanceOf",
|
|
58
|
-
args: [this.
|
|
58
|
+
args: [this.#detail.owner]
|
|
59
59
|
}
|
|
60
60
|
];
|
|
61
61
|
}
|
|
@@ -65,8 +65,8 @@ class BalancePrerequisite extends import_Prerequisite.Prerequisite {
|
|
|
65
65
|
return this.errorResult((0, import_Prerequisite.toPrerequisiteError)(res?.error));
|
|
66
66
|
}
|
|
67
67
|
const actual = res.result;
|
|
68
|
-
return this.satisfiedResult(actual >= this.
|
|
69
|
-
...this
|
|
68
|
+
return this.satisfiedResult(actual >= this.#detail.required, {
|
|
69
|
+
...this.#detail,
|
|
70
70
|
actual
|
|
71
71
|
});
|
|
72
72
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 RWAOpenRequirementsPrerequisite_exports = {};
|
|
20
|
+
__export(RWAOpenRequirementsPrerequisite_exports, {
|
|
21
|
+
RWAOpenRequirementsPrerequisite: () => RWAOpenRequirementsPrerequisite
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(RWAOpenRequirementsPrerequisite_exports);
|
|
24
|
+
var import_Prerequisite = require("./Prerequisite.js");
|
|
25
|
+
class RWAOpenRequirementsPrerequisite extends import_Prerequisite.Prerequisite {
|
|
26
|
+
#id;
|
|
27
|
+
#title;
|
|
28
|
+
#detail;
|
|
29
|
+
constructor(props) {
|
|
30
|
+
super();
|
|
31
|
+
this.#id = props.id ?? `rwaOpenRequirements:${props.factory}:${props.token}`;
|
|
32
|
+
this.#title = props.title ?? "RWA account requirements fulfilled";
|
|
33
|
+
this.#detail = props.requirements;
|
|
34
|
+
}
|
|
35
|
+
get id() {
|
|
36
|
+
return this.#id;
|
|
37
|
+
}
|
|
38
|
+
get kind() {
|
|
39
|
+
return "rwaOpenRequirements";
|
|
40
|
+
}
|
|
41
|
+
get title() {
|
|
42
|
+
return this.#title;
|
|
43
|
+
}
|
|
44
|
+
get detail() {
|
|
45
|
+
return this.#detail;
|
|
46
|
+
}
|
|
47
|
+
/** Pre-resolved: no on-chain reads to contribute. */
|
|
48
|
+
calls() {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
resolve() {
|
|
52
|
+
return this.satisfiedResult(this.#satisfied(), this.#detail);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Satisfied when the borrower has nothing left to do: no tokens pending
|
|
56
|
+
* issuer-side registration and no messages left to sign.
|
|
57
|
+
*/
|
|
58
|
+
#satisfied() {
|
|
59
|
+
const { securitizeTokensToRegister, requiredSignatures } = this.#detail;
|
|
60
|
+
return securitizeTokensToRegister.length === 0 && requiredSignatures.length === 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
RWAOpenRequirementsPrerequisite
|
|
66
|
+
});
|
|
@@ -22,9 +22,11 @@ __export(buildPrerequisites_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(buildPrerequisites_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
|
+
var import_sdk = require("../../sdk/index.js");
|
|
25
26
|
var import_AllowancePrerequisite = require("./AllowancePrerequisite.js");
|
|
26
27
|
var import_BalancePrerequisite = require("./BalancePrerequisite.js");
|
|
27
|
-
|
|
28
|
+
var import_RWAOpenRequirementsPrerequisite = require("./RWAOpenRequirementsPrerequisite.js");
|
|
29
|
+
async function buildPrerequisites(tx, ctx) {
|
|
28
30
|
const { wallet } = ctx;
|
|
29
31
|
switch (tx.operation) {
|
|
30
32
|
// Deposit and Mint both pull the underlying from the caller into the pool;
|
|
@@ -150,7 +152,37 @@ function buildPrerequisites(tx, ctx) {
|
|
|
150
152
|
case "OpenCreditAccount":
|
|
151
153
|
case "CloseCreditAccount":
|
|
152
154
|
case "LiquidateCreditAccount":
|
|
153
|
-
return collateralPrerequisites(
|
|
155
|
+
return collateralPrerequisites(
|
|
156
|
+
tx.operation === "OpenCreditAccount" ? { creditManager: tx.creditManager, borrower: wallet } : {
|
|
157
|
+
creditManager: tx.creditManager,
|
|
158
|
+
creditAccount: tx.creditAccount
|
|
159
|
+
},
|
|
160
|
+
tx.multicall,
|
|
161
|
+
ctx
|
|
162
|
+
);
|
|
163
|
+
// RWA-factory operations: same collateral checks as facade operations,
|
|
164
|
+
// plus (for opening) the factory's open-account requirements. The parsed
|
|
165
|
+
// operation carries template (empty) `tokensToRegister`/`signaturesToCache`;
|
|
166
|
+
// the prerequisite detail provides the real values.
|
|
167
|
+
case "SecuritizeOpenCreditAccount":
|
|
168
|
+
return [
|
|
169
|
+
...await collateralPrerequisites(
|
|
170
|
+
{ creditManager: tx.creditManager, borrower: wallet },
|
|
171
|
+
tx.multicall,
|
|
172
|
+
ctx
|
|
173
|
+
),
|
|
174
|
+
...await rwaOpenRequirementsPrerequisites(
|
|
175
|
+
tx.multicall,
|
|
176
|
+
tx.creditManager,
|
|
177
|
+
ctx
|
|
178
|
+
)
|
|
179
|
+
];
|
|
180
|
+
case "SecuritizeMulticall":
|
|
181
|
+
return collateralPrerequisites(
|
|
182
|
+
{ creditManager: tx.creditManager, creditAccount: tx.creditAccount },
|
|
183
|
+
tx.multicall,
|
|
184
|
+
ctx
|
|
185
|
+
);
|
|
154
186
|
case "PartiallyLiquidateCreditAccount": {
|
|
155
187
|
const underlying = underlyingOf(ctx.sdk, tx.creditManager);
|
|
156
188
|
if (!underlying || tx.repaidAmount === 0n) {
|
|
@@ -176,7 +208,8 @@ function buildPrerequisites(tx, ctx) {
|
|
|
176
208
|
return [];
|
|
177
209
|
}
|
|
178
210
|
}
|
|
179
|
-
function collateralPrerequisites(
|
|
211
|
+
async function collateralPrerequisites(spenderOptions, multicall, ctx) {
|
|
212
|
+
const { sdk, wallet } = ctx;
|
|
180
213
|
const required = /* @__PURE__ */ new Map();
|
|
181
214
|
for (const op of multicall) {
|
|
182
215
|
if (op.operation !== "AddCollateral" || op.amount === 0n) {
|
|
@@ -189,15 +222,19 @@ function collateralPrerequisites(multicall, creditManager, wallet) {
|
|
|
189
222
|
amount: (existing?.amount ?? 0n) + op.amount
|
|
190
223
|
});
|
|
191
224
|
}
|
|
225
|
+
if (required.size === 0) {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
const spender = await sdk.accounts.getApprovalAddress(spenderOptions);
|
|
192
229
|
const prereqs = [];
|
|
193
230
|
for (const { token, amount } of required.values()) {
|
|
194
231
|
prereqs.push(
|
|
195
232
|
new import_AllowancePrerequisite.AllowancePrerequisite({
|
|
196
233
|
token,
|
|
197
234
|
owner: wallet,
|
|
198
|
-
spender
|
|
235
|
+
spender,
|
|
199
236
|
required: amount,
|
|
200
|
-
title: "Collateral approved
|
|
237
|
+
title: "Collateral approved"
|
|
201
238
|
}),
|
|
202
239
|
new import_BalancePrerequisite.BalancePrerequisite({
|
|
203
240
|
token,
|
|
@@ -209,6 +246,41 @@ function collateralPrerequisites(multicall, creditManager, wallet) {
|
|
|
209
246
|
}
|
|
210
247
|
return prereqs;
|
|
211
248
|
}
|
|
249
|
+
async function rwaOpenRequirementsPrerequisites(multicall, creditManager, ctx) {
|
|
250
|
+
const { sdk, wallet } = ctx;
|
|
251
|
+
const { rwaFactory } = sdk.marketRegister.findByCreditManager(creditManager);
|
|
252
|
+
if (!rwaFactory) {
|
|
253
|
+
return [];
|
|
254
|
+
}
|
|
255
|
+
const rwaTokens = new import_sdk.AddressSet(rwaFactory.getTokens());
|
|
256
|
+
const candidates = new import_sdk.AddressSet();
|
|
257
|
+
for (const op of multicall) {
|
|
258
|
+
if (op.operation === "AddCollateral" || op.operation === "UpdateQuota") {
|
|
259
|
+
candidates.add(op.token);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const prereqs = [];
|
|
263
|
+
for (const token of candidates) {
|
|
264
|
+
if (!rwaTokens.has(token)) {
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
const requirements = await sdk.accounts.getOpenAccountRequirements(
|
|
268
|
+
wallet,
|
|
269
|
+
creditManager,
|
|
270
|
+
{ tokenOutAddress: token }
|
|
271
|
+
);
|
|
272
|
+
if (requirements) {
|
|
273
|
+
prereqs.push(
|
|
274
|
+
new import_RWAOpenRequirementsPrerequisite.RWAOpenRequirementsPrerequisite({
|
|
275
|
+
requirements,
|
|
276
|
+
token,
|
|
277
|
+
factory: rwaFactory.address
|
|
278
|
+
})
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return prereqs;
|
|
283
|
+
}
|
|
212
284
|
function underlyingOf(sdk, creditManager) {
|
|
213
285
|
const suite = sdk.marketRegister.creditManagers.find(
|
|
214
286
|
(cm) => (0, import_viem.isAddressEqual)(cm.creditManager.address, creditManager)
|
|
@@ -20,6 +20,7 @@ __reExport(prerequisites_exports, require("./BalancePrerequisite.js"), module.ex
|
|
|
20
20
|
__reExport(prerequisites_exports, require("./buildPrerequisites.js"), module.exports);
|
|
21
21
|
__reExport(prerequisites_exports, require("./Prerequisite.js"), module.exports);
|
|
22
22
|
__reExport(prerequisites_exports, require("./prepareAction.js"), module.exports);
|
|
23
|
+
__reExport(prerequisites_exports, require("./RWAOpenRequirementsPrerequisite.js"), module.exports);
|
|
23
24
|
__reExport(prerequisites_exports, require("./runPrerequisites.js"), module.exports);
|
|
24
25
|
__reExport(prerequisites_exports, require("./types.js"), module.exports);
|
|
25
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -29,6 +30,7 @@ __reExport(prerequisites_exports, require("./types.js"), module.exports);
|
|
|
29
30
|
...require("./buildPrerequisites.js"),
|
|
30
31
|
...require("./Prerequisite.js"),
|
|
31
32
|
...require("./prepareAction.js"),
|
|
33
|
+
...require("./RWAOpenRequirementsPrerequisite.js"),
|
|
32
34
|
...require("./runPrerequisites.js"),
|
|
33
35
|
...require("./types.js")
|
|
34
36
|
});
|
|
@@ -21,17 +21,20 @@ __export(simulate_exports, {
|
|
|
21
21
|
PreviewSimulationError: () => import_errors.PreviewSimulationError,
|
|
22
22
|
simulateFacadeOperation: () => import_simulateFacadeOperation.simulateFacadeOperation,
|
|
23
23
|
simulateOperation: () => import_simulateOperation.simulateOperation,
|
|
24
|
-
simulatePoolOperation: () => import_simulatePoolOperation.simulatePoolOperation
|
|
24
|
+
simulatePoolOperation: () => import_simulatePoolOperation.simulatePoolOperation,
|
|
25
|
+
simulateRWAOperation: () => import_simulateRWAOperation.simulateRWAOperation
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(simulate_exports);
|
|
27
28
|
var import_errors = require("./errors.js");
|
|
28
29
|
var import_simulateFacadeOperation = require("./simulateFacadeOperation.js");
|
|
29
30
|
var import_simulateOperation = require("./simulateOperation.js");
|
|
30
31
|
var import_simulatePoolOperation = require("./simulatePoolOperation.js");
|
|
32
|
+
var import_simulateRWAOperation = require("./simulateRWAOperation.js");
|
|
31
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
34
|
0 && (module.exports = {
|
|
33
35
|
PreviewSimulationError,
|
|
34
36
|
simulateFacadeOperation,
|
|
35
37
|
simulateOperation,
|
|
36
|
-
simulatePoolOperation
|
|
38
|
+
simulatePoolOperation,
|
|
39
|
+
simulateRWAOperation
|
|
37
40
|
});
|
|
@@ -24,11 +24,15 @@ module.exports = __toCommonJS(simulateOperation_exports);
|
|
|
24
24
|
var import_parse = require("../parse/index.js");
|
|
25
25
|
var import_simulateFacadeOperation = require("./simulateFacadeOperation.js");
|
|
26
26
|
var import_simulatePoolOperation = require("./simulatePoolOperation.js");
|
|
27
|
+
var import_simulateRWAOperation = require("./simulateRWAOperation.js");
|
|
27
28
|
async function simulateOperation(input, options) {
|
|
28
29
|
const { operation } = input;
|
|
29
30
|
if ((0, import_parse.isPoolOperation)(operation)) {
|
|
30
31
|
return (0, import_simulatePoolOperation.simulatePoolOperation)({ ...input, operation }, options);
|
|
31
32
|
}
|
|
33
|
+
if ((0, import_parse.isRWAOperation)(operation)) {
|
|
34
|
+
return (0, import_simulateRWAOperation.simulateRWAOperation)({ ...input, operation }, options);
|
|
35
|
+
}
|
|
32
36
|
return (0, import_simulateFacadeOperation.simulateFacadeOperation)({ ...input, operation }, options);
|
|
33
37
|
}
|
|
34
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,30 @@
|
|
|
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 simulateRWAOperation_exports = {};
|
|
20
|
+
__export(simulateRWAOperation_exports, {
|
|
21
|
+
simulateRWAOperation: () => simulateRWAOperation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(simulateRWAOperation_exports);
|
|
24
|
+
async function simulateRWAOperation(_input, _options) {
|
|
25
|
+
throw new Error("not yet implemented");
|
|
26
|
+
}
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
simulateRWAOperation
|
|
30
|
+
});
|
|
@@ -70,6 +70,30 @@ 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, tokensToRegister, signaturesToCache] = params.args;
|
|
77
|
+
return {
|
|
78
|
+
creditManager,
|
|
79
|
+
calls: this.register.parseMultiCallV2([...calls], strict),
|
|
80
|
+
tokensToRegister,
|
|
81
|
+
signaturesToCache
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
case "multicall": {
|
|
85
|
+
const [creditAccount, calls, tokensToRegister, signaturesToCache] = params.args;
|
|
86
|
+
return {
|
|
87
|
+
creditAccount,
|
|
88
|
+
calls: this.register.parseMultiCallV2([...calls], strict),
|
|
89
|
+
tokensToRegister,
|
|
90
|
+
signaturesToCache
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
default:
|
|
94
|
+
return super.parseFunctionParamsV2(params, strict);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
73
97
|
/**
|
|
74
98
|
* {@inheritDoc IRWAFactory.decodeInvestorData}
|
|
75
99
|
*/
|
|
@@ -125,6 +149,12 @@ class SecuritizeRWAFactory extends import_base.BaseContract {
|
|
|
125
149
|
})
|
|
126
150
|
};
|
|
127
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* {@inheritDoc IRWAFactory.getTokens}
|
|
154
|
+
*/
|
|
155
|
+
getTokens() {
|
|
156
|
+
return this.dsTokens.map((t) => t.address);
|
|
157
|
+
}
|
|
128
158
|
/**
|
|
129
159
|
* {@inheritDoc IRWAFactory.getInvestor}
|
|
130
160
|
*/
|
|
@@ -24,8 +24,11 @@ __export(types_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(types_exports);
|
|
25
25
|
var import_securitize = require("./securitize/index.js");
|
|
26
26
|
const RWA_FACTORY_TYPES = [import_securitize.RWA_FACTORY_SECURITIZE];
|
|
27
|
-
function isRWAFactory(
|
|
28
|
-
|
|
27
|
+
function isRWAFactory(contract, type) {
|
|
28
|
+
if (type) {
|
|
29
|
+
return contract.contractType === type;
|
|
30
|
+
}
|
|
31
|
+
return contract.contractType.startsWith("RWA_FACTORY::");
|
|
29
32
|
}
|
|
30
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
34
|
0 && (module.exports = {
|
|
@@ -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";
|