@gearbox-protocol/sdk 14.11.0-next.1 → 14.11.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/dev/index.js +3 -1
- package/dist/cjs/dev/verifyTestnet.js +124 -0
- package/dist/cjs/preview/parse/index.js +6 -6
- package/dist/cjs/preview/parse/{parseCreditFacadeOperation.js → parseFacadeOperationCalldata.js} +6 -6
- package/dist/cjs/preview/parse/{parseTransaction.js → parseOperationCalldata.js} +10 -10
- package/dist/cjs/preview/parse/{parsePoolOperation.js → parsePoolOperationCalldata.js} +6 -6
- package/dist/cjs/preview/simulate/index.js +4 -0
- package/dist/cjs/preview/simulate/simulateFacadeOperation.js +30 -0
- package/dist/cjs/preview/simulate/simulateOperation.js +37 -0
- package/dist/esm/dev/index.js +1 -0
- package/dist/esm/dev/verifyTestnet.js +98 -0
- package/dist/esm/preview/parse/index.js +3 -3
- package/dist/esm/preview/parse/{parseCreditFacadeOperation.js → parseFacadeOperationCalldata.js} +2 -2
- package/dist/esm/preview/parse/{parseTransaction.js → parseOperationCalldata.js} +6 -6
- package/dist/esm/preview/parse/{parsePoolOperation.js → parsePoolOperationCalldata.js} +2 -2
- package/dist/esm/preview/simulate/index.js +2 -0
- package/dist/esm/preview/simulate/simulateFacadeOperation.js +6 -0
- package/dist/esm/preview/simulate/simulateOperation.js +13 -0
- package/dist/types/dev/index.d.ts +1 -0
- package/dist/types/dev/verifyTestnet.d.ts +82 -0
- package/dist/types/preview/parse/index.d.ts +3 -3
- package/dist/types/preview/parse/{parseCreditFacadeOperation.d.ts → parseFacadeOperationCalldata.d.ts} +2 -2
- package/dist/types/preview/parse/{parseTransaction.d.ts → parseOperationCalldata.d.ts} +4 -4
- package/dist/types/preview/parse/{parsePoolOperation.d.ts → parsePoolOperationCalldata.d.ts} +2 -2
- package/dist/types/preview/parse/types.d.ts +6 -6
- package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +3 -3
- package/dist/types/preview/simulate/index.d.ts +2 -0
- package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +27 -0
- package/dist/types/preview/simulate/simulateOperation.d.ts +26 -0
- package/package.json +1 -1
package/dist/cjs/dev/index.js
CHANGED
|
@@ -44,6 +44,7 @@ __reExport(dev_exports, require("./replaceStorage.js"), module.exports);
|
|
|
44
44
|
__reExport(dev_exports, require("./resilientTransport.js"), module.exports);
|
|
45
45
|
__reExport(dev_exports, require("./transports.js"), module.exports);
|
|
46
46
|
__reExport(dev_exports, require("./types.js"), module.exports);
|
|
47
|
+
__reExport(dev_exports, require("./verifyTestnet.js"), module.exports);
|
|
47
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
49
|
0 && (module.exports = {
|
|
49
50
|
isRangeError,
|
|
@@ -67,5 +68,6 @@ __reExport(dev_exports, require("./types.js"), module.exports);
|
|
|
67
68
|
...require("./replaceStorage.js"),
|
|
68
69
|
...require("./resilientTransport.js"),
|
|
69
70
|
...require("./transports.js"),
|
|
70
|
-
...require("./types.js")
|
|
71
|
+
...require("./types.js"),
|
|
72
|
+
...require("./verifyTestnet.js")
|
|
71
73
|
});
|
|
@@ -0,0 +1,124 @@
|
|
|
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 verifyTestnet_exports = {};
|
|
20
|
+
__export(verifyTestnet_exports, {
|
|
21
|
+
ONCHAIN_EXECUTION_ID_ADDRESS: () => ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
22
|
+
iOnchainExecutionIdAbi: () => iOnchainExecutionIdAbi,
|
|
23
|
+
verifyTestnet: () => verifyTestnet
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(verifyTestnet_exports);
|
|
26
|
+
const ONCHAIN_EXECUTION_ID_ADDRESS = "0x34131bc13eaa4ef5f98c2a423f93bc88d6ee01ba";
|
|
27
|
+
const iOnchainExecutionIdAbi = [
|
|
28
|
+
{
|
|
29
|
+
type: "function",
|
|
30
|
+
name: "deployer",
|
|
31
|
+
inputs: [],
|
|
32
|
+
outputs: [
|
|
33
|
+
{
|
|
34
|
+
name: "",
|
|
35
|
+
type: "string",
|
|
36
|
+
internalType: "string"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
stateMutability: "view"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "function",
|
|
43
|
+
name: "executionId",
|
|
44
|
+
inputs: [],
|
|
45
|
+
outputs: [
|
|
46
|
+
{
|
|
47
|
+
name: "",
|
|
48
|
+
type: "string",
|
|
49
|
+
internalType: "string"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
stateMutability: "view"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: "function",
|
|
56
|
+
name: "forkAlias",
|
|
57
|
+
inputs: [],
|
|
58
|
+
outputs: [
|
|
59
|
+
{
|
|
60
|
+
name: "",
|
|
61
|
+
type: "string",
|
|
62
|
+
internalType: "string"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
stateMutability: "view"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: "function",
|
|
69
|
+
name: "info",
|
|
70
|
+
inputs: [],
|
|
71
|
+
outputs: [
|
|
72
|
+
{
|
|
73
|
+
name: "",
|
|
74
|
+
type: "tuple",
|
|
75
|
+
internalType: "struct ExecutionId.Info",
|
|
76
|
+
components: [
|
|
77
|
+
{
|
|
78
|
+
name: "deployer",
|
|
79
|
+
type: "string",
|
|
80
|
+
internalType: "string"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "executionId",
|
|
84
|
+
type: "string",
|
|
85
|
+
internalType: "string"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "forkAlias",
|
|
89
|
+
type: "string",
|
|
90
|
+
internalType: "string"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
stateMutability: "view"
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
async function verifyTestnet(client, expected) {
|
|
99
|
+
try {
|
|
100
|
+
const { deployer, executionId, forkAlias } = await client.readContract({
|
|
101
|
+
abi: iOnchainExecutionIdAbi,
|
|
102
|
+
address: ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
103
|
+
functionName: "info"
|
|
104
|
+
});
|
|
105
|
+
if (deployer !== "anvil-manager") {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if ("executionId" in expected && expected.executionId && expected.executionId !== executionId) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if ("alias" in expected && expected.alias && expected.alias !== forkAlias) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
} catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
120
|
+
0 && (module.exports = {
|
|
121
|
+
ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
122
|
+
iOnchainExecutionIdAbi,
|
|
123
|
+
verifyTestnet
|
|
124
|
+
});
|
|
@@ -17,16 +17,16 @@ var parse_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(parse_exports);
|
|
18
18
|
__reExport(parse_exports, require("./classifyInnerOperations.js"), module.exports);
|
|
19
19
|
__reExport(parse_exports, require("./errors.js"), module.exports);
|
|
20
|
-
__reExport(parse_exports, require("./
|
|
21
|
-
__reExport(parse_exports, require("./
|
|
22
|
-
__reExport(parse_exports, require("./
|
|
20
|
+
__reExport(parse_exports, require("./parseFacadeOperationCalldata.js"), module.exports);
|
|
21
|
+
__reExport(parse_exports, require("./parseOperationCalldata.js"), module.exports);
|
|
22
|
+
__reExport(parse_exports, require("./parsePoolOperationCalldata.js"), module.exports);
|
|
23
23
|
__reExport(parse_exports, require("./types.js"), module.exports);
|
|
24
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
25
|
0 && (module.exports = {
|
|
26
26
|
...require("./classifyInnerOperations.js"),
|
|
27
27
|
...require("./errors.js"),
|
|
28
|
-
...require("./
|
|
29
|
-
...require("./
|
|
30
|
-
...require("./
|
|
28
|
+
...require("./parseFacadeOperationCalldata.js"),
|
|
29
|
+
...require("./parseOperationCalldata.js"),
|
|
30
|
+
...require("./parsePoolOperationCalldata.js"),
|
|
31
31
|
...require("./types.js")
|
|
32
32
|
});
|
package/dist/cjs/preview/parse/{parseCreditFacadeOperation.js → parseFacadeOperationCalldata.js}
RENAMED
|
@@ -16,14 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var parseFacadeOperationCalldata_exports = {};
|
|
20
|
+
__export(parseFacadeOperationCalldata_exports, {
|
|
21
|
+
parseFacadeOperationCalldata: () => parseFacadeOperationCalldata
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(parseFacadeOperationCalldata_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
25
|
var import_classifyInnerOperations = require("./classifyInnerOperations.js");
|
|
26
|
-
function
|
|
26
|
+
function parseFacadeOperationCalldata(props) {
|
|
27
27
|
const { sdk, facade, calldata } = props;
|
|
28
28
|
const parsed = sdk.parseFunctionDataV2(facade.address, calldata);
|
|
29
29
|
const functionName = parsed.functionName.split("(")[0];
|
|
@@ -107,5 +107,5 @@ function parseCreditFacadeOperation(props) {
|
|
|
107
107
|
}
|
|
108
108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
109
109
|
0 && (module.exports = {
|
|
110
|
-
|
|
110
|
+
parseFacadeOperationCalldata
|
|
111
111
|
});
|
|
@@ -16,23 +16,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var parseOperationCalldata_exports = {};
|
|
20
|
+
__export(parseOperationCalldata_exports, {
|
|
21
|
+
parseOperationCalldata: () => parseOperationCalldata
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(parseOperationCalldata_exports);
|
|
24
24
|
var import_sdk = require("../../sdk/index.js");
|
|
25
25
|
var import_errors = require("./errors.js");
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
function
|
|
26
|
+
var import_parseFacadeOperationCalldata = require("./parseFacadeOperationCalldata.js");
|
|
27
|
+
var import_parsePoolOperationCalldata = require("./parsePoolOperationCalldata.js");
|
|
28
|
+
function parseOperationCalldata(input) {
|
|
29
29
|
const { sdk, to, calldata } = input;
|
|
30
30
|
const contract = sdk.getContract(to);
|
|
31
31
|
if (contract instanceof import_sdk.PoolV310Contract) {
|
|
32
|
-
return (0,
|
|
32
|
+
return (0, import_parsePoolOperationCalldata.parsePoolOperationCalldata)({ sdk, pool: contract, calldata });
|
|
33
33
|
}
|
|
34
34
|
if (contract instanceof import_sdk.CreditFacadeV310Contract) {
|
|
35
|
-
return (0,
|
|
35
|
+
return (0, import_parseFacadeOperationCalldata.parseFacadeOperationCalldata)({
|
|
36
36
|
sdk,
|
|
37
37
|
facade: contract,
|
|
38
38
|
calldata
|
|
@@ -42,5 +42,5 @@ function parseTransaction(input) {
|
|
|
42
42
|
}
|
|
43
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
44
44
|
0 && (module.exports = {
|
|
45
|
-
|
|
45
|
+
parseOperationCalldata
|
|
46
46
|
});
|
|
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var parsePoolOperationCalldata_exports = {};
|
|
20
|
+
__export(parsePoolOperationCalldata_exports, {
|
|
21
|
+
parsePoolOperationCalldata: () => parsePoolOperationCalldata
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(parsePoolOperationCalldata_exports);
|
|
24
24
|
var import_errors = require("./errors.js");
|
|
25
|
-
function
|
|
25
|
+
function parsePoolOperationCalldata(props) {
|
|
26
26
|
const { sdk, pool, calldata } = props;
|
|
27
27
|
const parsed = sdk.parseFunctionDataV2(pool.address, calldata);
|
|
28
28
|
const functionName = parsed.functionName.split("(")[0];
|
|
@@ -58,5 +58,5 @@ function parsePoolOperation(props) {
|
|
|
58
58
|
}
|
|
59
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60
60
|
0 && (module.exports = {
|
|
61
|
-
|
|
61
|
+
parsePoolOperationCalldata
|
|
62
62
|
});
|
|
@@ -17,12 +17,16 @@ var simulate_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(simulate_exports);
|
|
18
18
|
__reExport(simulate_exports, require("./decodeSimulationError.js"), module.exports);
|
|
19
19
|
__reExport(simulate_exports, require("./extractERC20Transfers.js"), module.exports);
|
|
20
|
+
__reExport(simulate_exports, require("./simulateFacadeOperation.js"), module.exports);
|
|
21
|
+
__reExport(simulate_exports, require("./simulateOperation.js"), module.exports);
|
|
20
22
|
__reExport(simulate_exports, require("./simulatePoolOperation.js"), module.exports);
|
|
21
23
|
__reExport(simulate_exports, require("./types.js"), module.exports);
|
|
22
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23
25
|
0 && (module.exports = {
|
|
24
26
|
...require("./decodeSimulationError.js"),
|
|
25
27
|
...require("./extractERC20Transfers.js"),
|
|
28
|
+
...require("./simulateFacadeOperation.js"),
|
|
29
|
+
...require("./simulateOperation.js"),
|
|
26
30
|
...require("./simulatePoolOperation.js"),
|
|
27
31
|
...require("./types.js")
|
|
28
32
|
});
|
|
@@ -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 simulateFacadeOperation_exports = {};
|
|
20
|
+
__export(simulateFacadeOperation_exports, {
|
|
21
|
+
simulateFacadeOperation: () => simulateFacadeOperation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(simulateFacadeOperation_exports);
|
|
24
|
+
async function simulateFacadeOperation(_input) {
|
|
25
|
+
throw new Error("not yet implemented");
|
|
26
|
+
}
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
simulateFacadeOperation
|
|
30
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
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 simulateOperation_exports = {};
|
|
20
|
+
__export(simulateOperation_exports, {
|
|
21
|
+
simulateOperation: () => simulateOperation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(simulateOperation_exports);
|
|
24
|
+
var import_parse = require("../parse/index.js");
|
|
25
|
+
var import_simulateFacadeOperation = require("./simulateFacadeOperation.js");
|
|
26
|
+
var import_simulatePoolOperation = require("./simulatePoolOperation.js");
|
|
27
|
+
async function simulateOperation(input) {
|
|
28
|
+
const { operation } = input;
|
|
29
|
+
if ((0, import_parse.isPoolOperation)(operation)) {
|
|
30
|
+
return (0, import_simulatePoolOperation.simulatePoolOperation)({ ...input, operation });
|
|
31
|
+
}
|
|
32
|
+
return (0, import_simulateFacadeOperation.simulateFacadeOperation)({ ...input, operation });
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
simulateOperation
|
|
37
|
+
});
|
package/dist/esm/dev/index.js
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const ONCHAIN_EXECUTION_ID_ADDRESS = "0x34131bc13eaa4ef5f98c2a423f93bc88d6ee01ba";
|
|
2
|
+
const iOnchainExecutionIdAbi = [
|
|
3
|
+
{
|
|
4
|
+
type: "function",
|
|
5
|
+
name: "deployer",
|
|
6
|
+
inputs: [],
|
|
7
|
+
outputs: [
|
|
8
|
+
{
|
|
9
|
+
name: "",
|
|
10
|
+
type: "string",
|
|
11
|
+
internalType: "string"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
stateMutability: "view"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "function",
|
|
18
|
+
name: "executionId",
|
|
19
|
+
inputs: [],
|
|
20
|
+
outputs: [
|
|
21
|
+
{
|
|
22
|
+
name: "",
|
|
23
|
+
type: "string",
|
|
24
|
+
internalType: "string"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
stateMutability: "view"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "function",
|
|
31
|
+
name: "forkAlias",
|
|
32
|
+
inputs: [],
|
|
33
|
+
outputs: [
|
|
34
|
+
{
|
|
35
|
+
name: "",
|
|
36
|
+
type: "string",
|
|
37
|
+
internalType: "string"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
stateMutability: "view"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "function",
|
|
44
|
+
name: "info",
|
|
45
|
+
inputs: [],
|
|
46
|
+
outputs: [
|
|
47
|
+
{
|
|
48
|
+
name: "",
|
|
49
|
+
type: "tuple",
|
|
50
|
+
internalType: "struct ExecutionId.Info",
|
|
51
|
+
components: [
|
|
52
|
+
{
|
|
53
|
+
name: "deployer",
|
|
54
|
+
type: "string",
|
|
55
|
+
internalType: "string"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "executionId",
|
|
59
|
+
type: "string",
|
|
60
|
+
internalType: "string"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "forkAlias",
|
|
64
|
+
type: "string",
|
|
65
|
+
internalType: "string"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
stateMutability: "view"
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
async function verifyTestnet(client, expected) {
|
|
74
|
+
try {
|
|
75
|
+
const { deployer, executionId, forkAlias } = await client.readContract({
|
|
76
|
+
abi: iOnchainExecutionIdAbi,
|
|
77
|
+
address: ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
78
|
+
functionName: "info"
|
|
79
|
+
});
|
|
80
|
+
if (deployer !== "anvil-manager") {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if ("executionId" in expected && expected.executionId && expected.executionId !== executionId) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if ("alias" in expected && expected.alias && expected.alias !== forkAlias) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
} catch {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
ONCHAIN_EXECUTION_ID_ADDRESS,
|
|
96
|
+
iOnchainExecutionIdAbi,
|
|
97
|
+
verifyTestnet
|
|
98
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./classifyInnerOperations.js";
|
|
2
2
|
export * from "./errors.js";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
3
|
+
export * from "./parseFacadeOperationCalldata.js";
|
|
4
|
+
export * from "./parseOperationCalldata.js";
|
|
5
|
+
export * from "./parsePoolOperationCalldata.js";
|
|
6
6
|
export * from "./types.js";
|
package/dist/esm/preview/parse/{parseCreditFacadeOperation.js → parseFacadeOperationCalldata.js}
RENAMED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
zeroHash
|
|
5
5
|
} from "viem";
|
|
6
6
|
import { classifyInnerOperations } from "./classifyInnerOperations.js";
|
|
7
|
-
function
|
|
7
|
+
function parseFacadeOperationCalldata(props) {
|
|
8
8
|
const { sdk, facade, calldata } = props;
|
|
9
9
|
const parsed = sdk.parseFunctionDataV2(facade.address, calldata);
|
|
10
10
|
const functionName = parsed.functionName.split("(")[0];
|
|
@@ -87,5 +87,5 @@ function parseCreditFacadeOperation(props) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
export {
|
|
90
|
-
|
|
90
|
+
parseFacadeOperationCalldata
|
|
91
91
|
};
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
PoolV310Contract
|
|
4
4
|
} from "../../sdk/index.js";
|
|
5
5
|
import { UnsupportedTargetError } from "./errors.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
function
|
|
6
|
+
import { parseFacadeOperationCalldata } from "./parseFacadeOperationCalldata.js";
|
|
7
|
+
import { parsePoolOperationCalldata } from "./parsePoolOperationCalldata.js";
|
|
8
|
+
function parseOperationCalldata(input) {
|
|
9
9
|
const { sdk, to, calldata } = input;
|
|
10
10
|
const contract = sdk.getContract(to);
|
|
11
11
|
if (contract instanceof PoolV310Contract) {
|
|
12
|
-
return
|
|
12
|
+
return parsePoolOperationCalldata({ sdk, pool: contract, calldata });
|
|
13
13
|
}
|
|
14
14
|
if (contract instanceof CreditFacadeV310Contract) {
|
|
15
|
-
return
|
|
15
|
+
return parseFacadeOperationCalldata({
|
|
16
16
|
sdk,
|
|
17
17
|
facade: contract,
|
|
18
18
|
calldata
|
|
@@ -21,5 +21,5 @@ function parseTransaction(input) {
|
|
|
21
21
|
throw new UnsupportedTargetError(to);
|
|
22
22
|
}
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
parseOperationCalldata
|
|
25
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnsupportedPoolFunctionError } from "./errors.js";
|
|
2
|
-
function
|
|
2
|
+
function parsePoolOperationCalldata(props) {
|
|
3
3
|
const { sdk, pool, calldata } = props;
|
|
4
4
|
const parsed = sdk.parseFunctionDataV2(pool.address, calldata);
|
|
5
5
|
const functionName = parsed.functionName.split("(")[0];
|
|
@@ -34,5 +34,5 @@ function parsePoolOperation(props) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
export {
|
|
37
|
-
|
|
37
|
+
parsePoolOperationCalldata
|
|
38
38
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isPoolOperation } from "../parse/index.js";
|
|
2
|
+
import { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
3
|
+
import { simulatePoolOperation } from "./simulatePoolOperation.js";
|
|
4
|
+
async function simulateOperation(input) {
|
|
5
|
+
const { operation } = input;
|
|
6
|
+
if (isPoolOperation(operation)) {
|
|
7
|
+
return simulatePoolOperation({ ...input, operation });
|
|
8
|
+
}
|
|
9
|
+
return simulateFacadeOperation({ ...input, operation });
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
simulateOperation
|
|
13
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Address, PublicClient } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Address is stable, contract deployed via create2
|
|
4
|
+
*/
|
|
5
|
+
export declare const ONCHAIN_EXECUTION_ID_ADDRESS: Address;
|
|
6
|
+
/**
|
|
7
|
+
* This contract is deployed on every Gearbox testnet and contains
|
|
8
|
+
* execution id and alias of the testnet
|
|
9
|
+
*/
|
|
10
|
+
export declare const iOnchainExecutionIdAbi: readonly [{
|
|
11
|
+
readonly type: "function";
|
|
12
|
+
readonly name: "deployer";
|
|
13
|
+
readonly inputs: readonly [];
|
|
14
|
+
readonly outputs: readonly [{
|
|
15
|
+
readonly name: "";
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly internalType: "string";
|
|
18
|
+
}];
|
|
19
|
+
readonly stateMutability: "view";
|
|
20
|
+
}, {
|
|
21
|
+
readonly type: "function";
|
|
22
|
+
readonly name: "executionId";
|
|
23
|
+
readonly inputs: readonly [];
|
|
24
|
+
readonly outputs: readonly [{
|
|
25
|
+
readonly name: "";
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly internalType: "string";
|
|
28
|
+
}];
|
|
29
|
+
readonly stateMutability: "view";
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "function";
|
|
32
|
+
readonly name: "forkAlias";
|
|
33
|
+
readonly inputs: readonly [];
|
|
34
|
+
readonly outputs: readonly [{
|
|
35
|
+
readonly name: "";
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
readonly internalType: "string";
|
|
38
|
+
}];
|
|
39
|
+
readonly stateMutability: "view";
|
|
40
|
+
}, {
|
|
41
|
+
readonly type: "function";
|
|
42
|
+
readonly name: "info";
|
|
43
|
+
readonly inputs: readonly [];
|
|
44
|
+
readonly outputs: readonly [{
|
|
45
|
+
readonly name: "";
|
|
46
|
+
readonly type: "tuple";
|
|
47
|
+
readonly internalType: "struct ExecutionId.Info";
|
|
48
|
+
readonly components: readonly [{
|
|
49
|
+
readonly name: "deployer";
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
readonly internalType: "string";
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "executionId";
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
readonly internalType: "string";
|
|
56
|
+
}, {
|
|
57
|
+
readonly name: "forkAlias";
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
readonly internalType: "string";
|
|
60
|
+
}];
|
|
61
|
+
}];
|
|
62
|
+
readonly stateMutability: "view";
|
|
63
|
+
}];
|
|
64
|
+
export type VerifyTestnetParams = {
|
|
65
|
+
executionId: string;
|
|
66
|
+
} | {
|
|
67
|
+
alias: string;
|
|
68
|
+
} | {
|
|
69
|
+
executionId: string;
|
|
70
|
+
alias: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Tries to read the contract that is deployed on every Gearbox testnet
|
|
74
|
+
* and verify that we're on expected testnet.
|
|
75
|
+
*
|
|
76
|
+
* Used to check that wallet is using correct RPC for the testnet.
|
|
77
|
+
*
|
|
78
|
+
* @param client - Public client
|
|
79
|
+
* @param expected - Expected tesnet alias or execution id
|
|
80
|
+
* @returns True if we're on expected testnet
|
|
81
|
+
*/
|
|
82
|
+
export declare function verifyTestnet(client: PublicClient, expected: VerifyTestnetParams): Promise<boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./classifyInnerOperations.js";
|
|
2
2
|
export * from "./errors.js";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
3
|
+
export * from "./parseFacadeOperationCalldata.js";
|
|
4
|
+
export * from "./parseOperationCalldata.js";
|
|
5
|
+
export * from "./parsePoolOperationCalldata.js";
|
|
6
6
|
export * from "./types.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Hex } from "viem";
|
|
2
2
|
import type { OuterFacadeOperation } from "../../history/index.js";
|
|
3
3
|
import type { CreditFacadeV310Contract, OnchainSDK } from "../../sdk/index.js";
|
|
4
|
-
export interface
|
|
4
|
+
export interface ParseFacadeOperationCalldataProps {
|
|
5
5
|
sdk: OnchainSDK;
|
|
6
6
|
/** Resolved credit facade contract for the transaction target. */
|
|
7
7
|
facade: CreditFacadeV310Contract;
|
|
@@ -15,4 +15,4 @@ export interface ParseCreditFacadeOperationProps {
|
|
|
15
15
|
* those are only known once the transaction is mined. `creditAccount` is
|
|
16
16
|
* `zeroAddress` for `openCreditAccount` (the address is assigned on-chain).
|
|
17
17
|
*/
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function parseFacadeOperationCalldata(props: ParseFacadeOperationCalldataProps): OuterFacadeOperation;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address, Hex } from "viem";
|
|
2
2
|
import { type PluginsMap } from "../../sdk/index.js";
|
|
3
|
-
import type {
|
|
4
|
-
export interface
|
|
3
|
+
import type { Operation, SdkWithAdapters } from "./types.js";
|
|
4
|
+
export interface ParseOperationCalldataInput<P extends PluginsMap = PluginsMap> {
|
|
5
5
|
/**
|
|
6
6
|
* Already-attached SDK; chain, RPC and block are baked in at attach time.
|
|
7
7
|
* Must be created with the adapters plugin (enforced at compile time) so
|
|
@@ -14,10 +14,10 @@ export interface ParseTransactionInput<P extends PluginsMap = PluginsMap> {
|
|
|
14
14
|
sender: Address;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Decodes raw
|
|
17
|
+
* Decodes raw operation calldata into an {@link Operation}.
|
|
18
18
|
*
|
|
19
19
|
* Routes by the resolved contract at `to`: a pool yields a deposit/redeem
|
|
20
20
|
* operation, a credit facade yields one facade operation. Anything else throws
|
|
21
21
|
* {@link UnsupportedTargetError}.
|
|
22
22
|
*/
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function parseOperationCalldata<P extends PluginsMap>(input: ParseOperationCalldataInput<P>): Operation;
|
package/dist/types/preview/parse/{parsePoolOperation.d.ts → parsePoolOperationCalldata.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Hex } from "viem";
|
|
2
2
|
import type { OnchainSDK, PoolV310Contract } from "../../sdk/index.js";
|
|
3
3
|
import type { PoolOperation } from "./types.js";
|
|
4
|
-
export interface
|
|
4
|
+
export interface ParsePoolOperationCalldataProps {
|
|
5
5
|
sdk: OnchainSDK;
|
|
6
6
|
/** Resolved pool contract for the transaction target. */
|
|
7
7
|
pool: PoolV310Contract;
|
|
@@ -12,4 +12,4 @@ export interface ParsePoolOperationProps {
|
|
|
12
12
|
* Gearbox pool into a {@link PoolOperation}. Any other selector throws
|
|
13
13
|
* {@link UnsupportedPoolFunctionError}.
|
|
14
14
|
*/
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function parsePoolOperationCalldata(props: ParsePoolOperationCalldataProps): PoolOperation;
|
|
@@ -66,13 +66,13 @@ export interface PoolRedeemOperation {
|
|
|
66
66
|
}
|
|
67
67
|
export type PoolOperation = PoolDepositOperation | PoolRedeemOperation;
|
|
68
68
|
/**
|
|
69
|
-
* Narrows
|
|
70
|
-
*
|
|
71
|
-
*
|
|
69
|
+
* Narrows an {@link Operation} to a {@link PoolOperation} (deposit or redeem).
|
|
70
|
+
* Used by the UI to decide whether a custom view exists for the parsed result;
|
|
71
|
+
* everything else falls back to the raw JSON view.
|
|
72
72
|
*/
|
|
73
|
-
export declare function isPoolOperation(tx:
|
|
73
|
+
export declare function isPoolOperation(tx: Operation): tx is PoolOperation;
|
|
74
74
|
/**
|
|
75
|
-
* Result of decoding a single raw
|
|
75
|
+
* Result of decoding a single raw operation calldata: either a pool
|
|
76
76
|
* deposit/redeem or one of the credit-facade operations from `sdk/history`.
|
|
77
77
|
*/
|
|
78
|
-
export type
|
|
78
|
+
export type Operation = PoolOperation | OuterFacadeOperation;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Operation } from "../parse/index.js";
|
|
2
2
|
import type { AnyPrerequisite } from "./Prerequisite.js";
|
|
3
3
|
import type { PrerequisiteContext } from "./types.js";
|
|
4
4
|
/**
|
|
5
|
-
* Derives the on-chain prerequisites for a parsed
|
|
5
|
+
* Derives the on-chain prerequisites for a parsed operation: the conditions
|
|
6
6
|
* that must hold for the call not to revert and that we can verify with the
|
|
7
7
|
* SDK (token approvals, wallet balances).
|
|
8
8
|
*
|
|
@@ -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:
|
|
16
|
+
export declare function buildPrerequisites(tx: Operation, ctx: PrerequisiteContext): AnyPrerequisite[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { OuterFacadeOperation } from "../../history/index.js";
|
|
3
|
+
import type { OnchainSDK } from "../../sdk/index.js";
|
|
4
|
+
import type { PoolSimulationResult } from "./types.js";
|
|
5
|
+
export interface SimulateFacadeOperationInput {
|
|
6
|
+
/** Only `client` is used, so any OnchainSDK works. */
|
|
7
|
+
sdk: OnchainSDK;
|
|
8
|
+
/** Parsed credit-facade operation to simulate. */
|
|
9
|
+
operation: OuterFacadeOperation;
|
|
10
|
+
/** Target contract the calldata is sent to (the credit facade). */
|
|
11
|
+
to: Address;
|
|
12
|
+
/** Raw credit-facade calldata to simulate. */
|
|
13
|
+
calldata: Hex;
|
|
14
|
+
/** Wallet whose balance changes and transfers we track. */
|
|
15
|
+
wallet: Address;
|
|
16
|
+
/** Block to simulate at; defaults to latest. Only set for testnet forks. */
|
|
17
|
+
blockNumber?: bigint;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Simulates a credit-facade operation.
|
|
21
|
+
*
|
|
22
|
+
* Not yet implemented: credit-facade simulation requires multicall-aware
|
|
23
|
+
* balance/transfer accounting that the pool simulation does not cover. The
|
|
24
|
+
* signature mirrors {@link simulatePoolOperation} so the
|
|
25
|
+
* {@link simulateOperation} wrapper can delegate uniformly once implemented.
|
|
26
|
+
*/
|
|
27
|
+
export declare function simulateFacadeOperation(_input: SimulateFacadeOperationInput): Promise<PoolSimulationResult>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import type { OnchainSDK } from "../../sdk/index.js";
|
|
3
|
+
import { type Operation } from "../parse/index.js";
|
|
4
|
+
import type { PoolSimulationResult } from "./types.js";
|
|
5
|
+
export interface SimulateOperationInput {
|
|
6
|
+
/** Only `client` is used, so any OnchainSDK works. */
|
|
7
|
+
sdk: OnchainSDK;
|
|
8
|
+
/** Parsed operation, used to route to the matching simulation. */
|
|
9
|
+
operation: Operation;
|
|
10
|
+
/** Target contract the calldata is sent to. */
|
|
11
|
+
to: Address;
|
|
12
|
+
/** Raw operation calldata to simulate. */
|
|
13
|
+
calldata: Hex;
|
|
14
|
+
/** Wallet whose balance changes and transfers we track. */
|
|
15
|
+
wallet: Address;
|
|
16
|
+
/** Block to simulate at; defaults to latest. Only set for testnet forks. */
|
|
17
|
+
blockNumber?: bigint;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Simulates a parsed {@link Operation} by delegating to the matching simulator:
|
|
21
|
+
* pool deposit/redeem operations go to {@link simulatePoolOperation}, and
|
|
22
|
+
* credit-facade operations go to {@link simulateFacadeOperation} (currently a
|
|
23
|
+
* stub). Returns the recovered transfers, balance changes and gas on success,
|
|
24
|
+
* or a decoded revert on failure.
|
|
25
|
+
*/
|
|
26
|
+
export declare function simulateOperation(input: SimulateOperationInput): Promise<PoolSimulationResult>;
|