@gearbox-protocol/sdk 14.12.0-next.35 → 14.12.0-next.37
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/abi/iRedemptionLoggerV310.js +119 -0
- package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +12 -0
- package/dist/cjs/plugins/adapters/contracts/MidasGatewayAdapterContract.js +12 -0
- package/dist/cjs/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +16 -0
- package/dist/cjs/preview/preview/detectDelayedClaim.js +53 -0
- package/dist/cjs/preview/preview/detectDelayedOperation.js +1 -2
- package/dist/cjs/preview/preview/errors.js +0 -17
- package/dist/cjs/preview/preview/index.js +2 -0
- package/dist/cjs/preview/preview/previewOperation.js +18 -1
- package/dist/cjs/sdk/OnchainSDK.js +11 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +72 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/addresses.js +1 -1
- package/dist/cjs/sdk/accounts/withdrawal-compressor/createRedemptionLogger.js +43 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/errors.js +38 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/index.js +6 -0
- package/dist/cjs/sdk/constants/address-provider.js +3 -0
- package/dist/esm/abi/iRedemptionLoggerV310.js +95 -0
- package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +12 -0
- package/dist/esm/plugins/adapters/contracts/MidasGatewayAdapterContract.js +12 -0
- package/dist/esm/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.js +16 -0
- package/dist/esm/preview/preview/detectDelayedClaim.js +30 -0
- package/dist/esm/preview/preview/detectDelayedOperation.js +3 -3
- package/dist/esm/preview/preview/errors.js +0 -16
- package/dist/esm/preview/preview/index.js +1 -0
- package/dist/esm/preview/preview/previewOperation.js +18 -1
- package/dist/esm/sdk/OnchainSDK.js +12 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +48 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/addresses.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/createRedemptionLogger.js +23 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/errors.js +14 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/index.js +3 -0
- package/dist/esm/sdk/constants/address-provider.js +2 -0
- package/dist/types/abi/iRedemptionLoggerV310.d.ts +122 -0
- package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +11 -1
- package/dist/types/plugins/adapters/contracts/MidasGatewayAdapterContract.d.ts +6 -1
- package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts +7 -1
- package/dist/types/plugins/adapters/types.d.ts +11 -0
- package/dist/types/preview/preview/detectDelayedClaim.d.ts +45 -0
- package/dist/types/preview/preview/errors.d.ts +0 -15
- package/dist/types/preview/preview/index.d.ts +1 -0
- package/dist/types/preview/preview/types.d.ts +15 -0
- package/dist/types/sdk/OnchainSDK.d.ts +8 -1
- package/dist/types/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +149 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/createRedemptionLogger.d.ts +10 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/errors.d.ts +13 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +3 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +43 -1
- package/dist/types/sdk/constants/address-provider.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
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 iRedemptionLoggerV310_exports = {};
|
|
20
|
+
__export(iRedemptionLoggerV310_exports, {
|
|
21
|
+
iRedemptionLoggerV310Abi: () => iRedemptionLoggerV310Abi
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(iRedemptionLoggerV310_exports);
|
|
24
|
+
const iRedemptionLoggerV310Abi = [
|
|
25
|
+
{
|
|
26
|
+
type: "function",
|
|
27
|
+
name: "allowedGateways",
|
|
28
|
+
inputs: [{ name: "gateway", type: "address", internalType: "address" }],
|
|
29
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
30
|
+
stateMutability: "view"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "function",
|
|
34
|
+
name: "contractType",
|
|
35
|
+
inputs: [],
|
|
36
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
37
|
+
stateMutability: "view"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: "function",
|
|
41
|
+
name: "logRedemption",
|
|
42
|
+
inputs: [
|
|
43
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
44
|
+
{ name: "redeemer", type: "address", internalType: "address" },
|
|
45
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
46
|
+
],
|
|
47
|
+
outputs: [],
|
|
48
|
+
stateMutability: "nonpayable"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "function",
|
|
52
|
+
name: "redemptionLogs",
|
|
53
|
+
inputs: [{ name: "redeemer", type: "address", internalType: "address" }],
|
|
54
|
+
outputs: [
|
|
55
|
+
{
|
|
56
|
+
name: "",
|
|
57
|
+
type: "tuple",
|
|
58
|
+
internalType: "struct IRedemptionLogger.RedemptionLog",
|
|
59
|
+
components: [
|
|
60
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
61
|
+
{ name: "redeemer", type: "address", internalType: "address" },
|
|
62
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
stateMutability: "view"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: "function",
|
|
70
|
+
name: "setGatewayAllowed",
|
|
71
|
+
inputs: [
|
|
72
|
+
{ name: "gateway", type: "address", internalType: "address" },
|
|
73
|
+
{ name: "allowed", type: "bool", internalType: "bool" }
|
|
74
|
+
],
|
|
75
|
+
outputs: [],
|
|
76
|
+
stateMutability: "nonpayable"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: "function",
|
|
80
|
+
name: "version",
|
|
81
|
+
inputs: [],
|
|
82
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
83
|
+
stateMutability: "view"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: "event",
|
|
87
|
+
name: "RedemptionLogged",
|
|
88
|
+
inputs: [
|
|
89
|
+
{
|
|
90
|
+
name: "creditAccount",
|
|
91
|
+
type: "address",
|
|
92
|
+
indexed: true,
|
|
93
|
+
internalType: "address"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "redeemer",
|
|
97
|
+
type: "address",
|
|
98
|
+
indexed: true,
|
|
99
|
+
internalType: "address"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "extraData",
|
|
103
|
+
type: "bytes",
|
|
104
|
+
indexed: false,
|
|
105
|
+
internalType: "bytes"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
anonymous: false
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
type: "error",
|
|
112
|
+
name: "GatewayNotAllowedException",
|
|
113
|
+
inputs: []
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {
|
|
118
|
+
iRedemptionLoggerV310Abi
|
|
119
|
+
});
|
|
@@ -174,6 +174,18 @@ class AbstractAdapterContract extends import_sdk.BaseContract {
|
|
|
174
174
|
parseDelayedWithdrawalRequest(_calldata) {
|
|
175
175
|
return void 0;
|
|
176
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* When the given adapter calldata is a delayed-withdrawal claim (a call
|
|
179
|
+
* created by the withdrawal compressor that burns a withdrawal phantom
|
|
180
|
+
* token and receives the claim token from a redeemer), returns its
|
|
181
|
+
* descriptor; `undefined` for any other call.
|
|
182
|
+
*
|
|
183
|
+
* The base implementation returns `undefined`; adapters whose gateways log
|
|
184
|
+
* redemption intents (Securitize, Midas) override it.
|
|
185
|
+
*/
|
|
186
|
+
parseDelayedWithdrawalClaim(_calldata) {
|
|
187
|
+
return void 0;
|
|
188
|
+
}
|
|
177
189
|
/**
|
|
178
190
|
* Diff-call semantics of a diff-style adapter call: the call spends the
|
|
179
191
|
* consumed token down to the exact `leftoverAmount` encoded in its
|
|
@@ -112,6 +112,18 @@ class MidasGatewayAdapterContract extends import_AbstractAdapter.AbstractAdapter
|
|
|
112
112
|
extraData
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* `withdrawFromRedeemer(address redeemer, uint256 amount)` claims a matured
|
|
117
|
+
* redemption from a redeemer contract.
|
|
118
|
+
*/
|
|
119
|
+
parseDelayedWithdrawalClaim(calldata) {
|
|
120
|
+
const decoded = (0, import_viem.decodeFunctionData)({ abi: this.abi, data: calldata });
|
|
121
|
+
if (decoded.functionName !== "withdrawFromRedeemer") {
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
const [redeemer] = decoded.args;
|
|
125
|
+
return { redeemer };
|
|
126
|
+
}
|
|
115
127
|
async applyBalanceChanges(balances, decoded) {
|
|
116
128
|
switch (decoded.functionName) {
|
|
117
129
|
case "depositInstantDiff": {
|
|
@@ -90,6 +90,22 @@ class SecuritizeRedemptionGatewayAdapterContract extends import_AbstractAdapter.
|
|
|
90
90
|
extraData
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* `claim(address[] redeemers)` claims matured redemptions from redeemer
|
|
95
|
+
* contracts. Transactions built by the withdrawal compressor always claim
|
|
96
|
+
* from a single redeemer, so only the first one is reported.
|
|
97
|
+
*/
|
|
98
|
+
parseDelayedWithdrawalClaim(calldata) {
|
|
99
|
+
const decoded = (0, import_viem.decodeFunctionData)({ abi: this.abi, data: calldata });
|
|
100
|
+
if (decoded.functionName !== "claim") {
|
|
101
|
+
return void 0;
|
|
102
|
+
}
|
|
103
|
+
const [redeemers] = decoded.args;
|
|
104
|
+
if (redeemers.length === 0) {
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
return { redeemer: redeemers[0] };
|
|
108
|
+
}
|
|
93
109
|
async applyBalanceChanges(balances, decoded) {
|
|
94
110
|
switch (decoded.functionName) {
|
|
95
111
|
// no-op:
|
|
@@ -0,0 +1,53 @@
|
|
|
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 detectDelayedClaim_exports = {};
|
|
20
|
+
__export(detectDelayedClaim_exports, {
|
|
21
|
+
detectDelayedClaim: () => detectDelayedClaim,
|
|
22
|
+
resolveDelayedClaimIntent: () => resolveDelayedClaimIntent
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(detectDelayedClaim_exports);
|
|
25
|
+
var import_adapters = require("../../plugins/adapters/index.js");
|
|
26
|
+
function detectDelayedClaim(sdk, multicall) {
|
|
27
|
+
for (const op of multicall) {
|
|
28
|
+
if (op.operation !== "Execute") {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const adapter = sdk.getContract(op.adapter);
|
|
32
|
+
if (!(adapter instanceof import_adapters.AbstractAdapterContract)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const claim = adapter.parseDelayedWithdrawalClaim(op.calldata);
|
|
36
|
+
if (claim) {
|
|
37
|
+
return { adapter: op.adapter, redeemer: claim.redeemer };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
async function resolveDelayedClaimIntent(sdk, multicall, blockNumber) {
|
|
43
|
+
const claim = detectDelayedClaim(sdk, multicall);
|
|
44
|
+
if (!claim) {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
return sdk.redemptionLogger?.getDelayedIntent(claim.redeemer, blockNumber);
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
detectDelayedClaim,
|
|
52
|
+
resolveDelayedClaimIntent
|
|
53
|
+
});
|
|
@@ -24,7 +24,6 @@ module.exports = __toCommonJS(detectDelayedOperation_exports);
|
|
|
24
24
|
var import_viem = require("viem");
|
|
25
25
|
var import_adapters = require("../../plugins/adapters/index.js");
|
|
26
26
|
var import_sdk = require("../../sdk/index.js");
|
|
27
|
-
var import_errors = require("./errors.js");
|
|
28
27
|
function detectDelayedOperation(sdk, multicall) {
|
|
29
28
|
let bracketDeltas = [];
|
|
30
29
|
for (const op of multicall) {
|
|
@@ -58,7 +57,7 @@ function detectDelayedOperation(sdk, multicall) {
|
|
|
58
57
|
try {
|
|
59
58
|
intent = (0, import_sdk.decodeDelayedIntent)(request.extraData);
|
|
60
59
|
} catch (e) {
|
|
61
|
-
throw new
|
|
60
|
+
throw new import_sdk.InvalidDelayedIntentError(request.extraData, e);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
return { request, intent };
|
|
@@ -18,7 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var errors_exports = {};
|
|
20
20
|
__export(errors_exports, {
|
|
21
|
-
InvalidDelayedIntentError: () => InvalidDelayedIntentError,
|
|
22
21
|
UnsupportedOperationError: () => UnsupportedOperationError
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(errors_exports);
|
|
@@ -31,23 +30,7 @@ class UnsupportedOperationError extends Error {
|
|
|
31
30
|
this.operation = operation;
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
class InvalidDelayedIntentError extends Error {
|
|
35
|
-
/** Adapter the withdrawal request was addressed to. */
|
|
36
|
-
adapter;
|
|
37
|
-
/** Raw `extraData` that failed to decode. */
|
|
38
|
-
extraData;
|
|
39
|
-
constructor(adapter, extraData, cause) {
|
|
40
|
-
super(
|
|
41
|
-
`cannot decode delayed intent from extraData ${extraData} of withdrawal request to adapter ${adapter}`,
|
|
42
|
-
{ cause }
|
|
43
|
-
);
|
|
44
|
-
this.name = "InvalidDelayedIntentError";
|
|
45
|
-
this.adapter = adapter;
|
|
46
|
-
this.extraData = extraData;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
34
|
0 && (module.exports = {
|
|
51
|
-
InvalidDelayedIntentError,
|
|
52
35
|
UnsupportedOperationError
|
|
53
36
|
});
|
|
@@ -18,6 +18,7 @@ module.exports = __toCommonJS(preview_exports);
|
|
|
18
18
|
__reExport(preview_exports, require("./buildDelayedPreview.js"), module.exports);
|
|
19
19
|
__reExport(preview_exports, require("./CreditAccountState.js"), module.exports);
|
|
20
20
|
__reExport(preview_exports, require("./detectCloseOrRepay.js"), module.exports);
|
|
21
|
+
__reExport(preview_exports, require("./detectDelayedClaim.js"), module.exports);
|
|
21
22
|
__reExport(preview_exports, require("./detectDelayedOperation.js"), module.exports);
|
|
22
23
|
__reExport(preview_exports, require("./errors.js"), module.exports);
|
|
23
24
|
__reExport(preview_exports, require("./previewAdjustCreditAccount.js"), module.exports);
|
|
@@ -31,6 +32,7 @@ __reExport(preview_exports, require("./types.js"), module.exports);
|
|
|
31
32
|
...require("./buildDelayedPreview.js"),
|
|
32
33
|
...require("./CreditAccountState.js"),
|
|
33
34
|
...require("./detectCloseOrRepay.js"),
|
|
35
|
+
...require("./detectDelayedClaim.js"),
|
|
34
36
|
...require("./detectDelayedOperation.js"),
|
|
35
37
|
...require("./errors.js"),
|
|
36
38
|
...require("./previewAdjustCreditAccount.js"),
|
|
@@ -24,6 +24,7 @@ module.exports = __toCommonJS(previewOperation_exports);
|
|
|
24
24
|
var import_parse = require("../parse/index.js");
|
|
25
25
|
var import_buildDelayedPreview = require("./buildDelayedPreview.js");
|
|
26
26
|
var import_detectCloseOrRepay = require("./detectCloseOrRepay.js");
|
|
27
|
+
var import_detectDelayedClaim = require("./detectDelayedClaim.js");
|
|
27
28
|
var import_detectDelayedOperation = require("./detectDelayedOperation.js");
|
|
28
29
|
var import_errors = require("./errors.js");
|
|
29
30
|
var import_previewAdjustCreditAccount = require("./previewAdjustCreditAccount.js");
|
|
@@ -41,7 +42,18 @@ async function previewOperation(input, options) {
|
|
|
41
42
|
}
|
|
42
43
|
if (operation.operation === "CloseCreditAccount") {
|
|
43
44
|
const resolved = await resolveCreditAccount(input, operation, options);
|
|
44
|
-
|
|
45
|
+
const preview = await (0, import_previewCloseOrRepayCreditAccount.previewCloseOrRepayCreditAccount)(
|
|
46
|
+
input,
|
|
47
|
+
operation,
|
|
48
|
+
true,
|
|
49
|
+
resolved
|
|
50
|
+
);
|
|
51
|
+
preview.intent = await (0, import_detectDelayedClaim.resolveDelayedClaimIntent)(
|
|
52
|
+
input.sdk,
|
|
53
|
+
operation.multicall,
|
|
54
|
+
options?.blockNumber
|
|
55
|
+
);
|
|
56
|
+
return preview;
|
|
45
57
|
}
|
|
46
58
|
if (operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "RWAMulticall") {
|
|
47
59
|
const resolved = await resolveCreditAccount(input, operation, options);
|
|
@@ -67,6 +79,11 @@ async function previewMulticallOperation(input, operation, options) {
|
|
|
67
79
|
const instantPreview = (0, import_detectCloseOrRepay.isCloseOrRepay)(operation.multicall) ? await (0, import_previewCloseOrRepayCreditAccount.previewCloseOrRepayCreditAccount)(input, operation, false, options) : await (0, import_previewAdjustCreditAccount.previewAdjustCreditAccount)(input, operation, options);
|
|
68
80
|
const delayed = (0, import_detectDelayedOperation.detectDelayedOperation)(sdk, operation.multicall);
|
|
69
81
|
if (!delayed) {
|
|
82
|
+
instantPreview.intent = await (0, import_detectDelayedClaim.resolveDelayedClaimIntent)(
|
|
83
|
+
sdk,
|
|
84
|
+
operation.multicall,
|
|
85
|
+
options?.blockNumber
|
|
86
|
+
);
|
|
70
87
|
return instantPreview;
|
|
71
88
|
}
|
|
72
89
|
const { before, after } = await (0, import_replayMulticall.replayMulticall)(sdk, operation, options);
|
|
@@ -68,6 +68,7 @@ class OnchainSDK extends import_base.ChainContractsRegister {
|
|
|
68
68
|
#marketRegister;
|
|
69
69
|
#priceFeeds;
|
|
70
70
|
#withdrawalCompressor;
|
|
71
|
+
#redemptionLogger;
|
|
71
72
|
/**
|
|
72
73
|
* Gas limit applied to read-only `eth_call` requests.
|
|
73
74
|
**/
|
|
@@ -553,6 +554,16 @@ class OnchainSDK extends import_base.ChainContractsRegister {
|
|
|
553
554
|
get withdrawalCompressor() {
|
|
554
555
|
return this.#withdrawalCompressor;
|
|
555
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* `RedemptionLogger` contract for the current chain, or `undefined` when
|
|
559
|
+
* it is not deployed on it. Created lazily on first access: the contract
|
|
560
|
+
* is resolved from the address provider, which is only available after
|
|
561
|
+
* the SDK is attached or hydrated.
|
|
562
|
+
**/
|
|
563
|
+
get redemptionLogger() {
|
|
564
|
+
this.#redemptionLogger ??= (0, import_accounts.createRedemptionLogger)(this);
|
|
565
|
+
return this.#redemptionLogger;
|
|
566
|
+
}
|
|
556
567
|
}
|
|
557
568
|
// Annotate the CommonJS export names for ESM import in node:
|
|
558
569
|
0 && (module.exports = {
|
|
@@ -0,0 +1,72 @@
|
|
|
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 RedemptionLoggerV310Contract_exports = {};
|
|
20
|
+
__export(RedemptionLoggerV310Contract_exports, {
|
|
21
|
+
RedemptionLoggerV310Contract: () => RedemptionLoggerV310Contract
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(RedemptionLoggerV310Contract_exports);
|
|
24
|
+
var import_iRedemptionLoggerV310 = require("../../../abi/iRedemptionLoggerV310.js");
|
|
25
|
+
var import_base = require("../../base/index.js");
|
|
26
|
+
var import_errors = require("./errors.js");
|
|
27
|
+
var import_intent_codec = require("./intent-codec.js");
|
|
28
|
+
const abi = import_iRedemptionLoggerV310.iRedemptionLoggerV310Abi;
|
|
29
|
+
class RedemptionLoggerV310Contract extends import_base.BaseContract {
|
|
30
|
+
constructor(sdk, address, version) {
|
|
31
|
+
super(sdk, {
|
|
32
|
+
addr: address,
|
|
33
|
+
name: "RedemptionLogger",
|
|
34
|
+
abi,
|
|
35
|
+
version
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the redemption data logged for a redeemer; all-zero fields when
|
|
40
|
+
* nothing was logged for it.
|
|
41
|
+
**/
|
|
42
|
+
async getRedemptionLog(redeemer, blockNumber) {
|
|
43
|
+
return this.contract.read.redemptionLogs([redeemer], {
|
|
44
|
+
blockNumber
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Reads the redemption log of a redeemer and decodes the recorded intent.
|
|
49
|
+
*
|
|
50
|
+
* @param redeemer - Redeemer contract the withdrawal is claimed from.
|
|
51
|
+
* @param blockNumber - Optional block number to read the log at.
|
|
52
|
+
* @returns The decoded intent, or `undefined` when the log carries none
|
|
53
|
+
* (including when nothing was logged for the redeemer).
|
|
54
|
+
* @throws InvalidDelayedIntentError when the logged `extraData` is
|
|
55
|
+
* non-empty but cannot be decoded as a `DelayedIntent`.
|
|
56
|
+
**/
|
|
57
|
+
async getDelayedIntent(redeemer, blockNumber) {
|
|
58
|
+
const log = await this.getRedemptionLog(redeemer, blockNumber);
|
|
59
|
+
if (!log.extraData || log.extraData === "0x") {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
return (0, import_intent_codec.decodeDelayedIntent)(log.extraData);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
throw new import_errors.InvalidDelayedIntentError(log.extraData, e);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
RedemptionLoggerV310Contract
|
|
72
|
+
});
|
|
@@ -23,7 +23,7 @@ __export(addresses_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(addresses_exports);
|
|
24
24
|
const WITHDRAWAL_COMPRESSORS = {
|
|
25
25
|
Mainnet: {
|
|
26
|
-
address: "
|
|
26
|
+
address: "0x5c80d7e7b18eCb00Cc9FAd57c59eEC4eF7516597",
|
|
27
27
|
version: 313
|
|
28
28
|
},
|
|
29
29
|
Monad: {
|
|
@@ -0,0 +1,43 @@
|
|
|
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 createRedemptionLogger_exports = {};
|
|
20
|
+
__export(createRedemptionLogger_exports, {
|
|
21
|
+
createRedemptionLogger: () => createRedemptionLogger
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(createRedemptionLogger_exports);
|
|
24
|
+
var import_constants = require("../../constants/index.js");
|
|
25
|
+
var import_RedemptionLoggerV310Contract = require("./RedemptionLoggerV310Contract.js");
|
|
26
|
+
function createRedemptionLogger(sdk) {
|
|
27
|
+
const latest = sdk.addressProvider.getLatest(
|
|
28
|
+
import_constants.AP_REDEMPTION_LOGGER,
|
|
29
|
+
import_constants.VERSION_RANGE_310
|
|
30
|
+
);
|
|
31
|
+
if (!latest) {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
const [address, version] = latest;
|
|
35
|
+
if ((0, import_constants.isV310)(version)) {
|
|
36
|
+
return new import_RedemptionLoggerV310Contract.RedemptionLoggerV310Contract(sdk, address, version);
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Unsupported redemption logger version: ${version}`);
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
createRedemptionLogger
|
|
43
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
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 errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
InvalidDelayedIntentError: () => InvalidDelayedIntentError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(errors_exports);
|
|
24
|
+
class InvalidDelayedIntentError extends Error {
|
|
25
|
+
/** Raw `extraData` that failed to decode. */
|
|
26
|
+
extraData;
|
|
27
|
+
constructor(extraData, cause) {
|
|
28
|
+
super(`cannot decode delayed intent from extraData ${extraData}`, {
|
|
29
|
+
cause
|
|
30
|
+
});
|
|
31
|
+
this.name = "InvalidDelayedIntentError";
|
|
32
|
+
this.extraData = extraData;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
InvalidDelayedIntentError
|
|
38
|
+
});
|
|
@@ -17,8 +17,11 @@ var withdrawal_compressor_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(withdrawal_compressor_exports);
|
|
18
18
|
__reExport(withdrawal_compressor_exports, require("./AbstractWithdrawalCompressorContract.js"), module.exports);
|
|
19
19
|
__reExport(withdrawal_compressor_exports, require("./addresses.js"), module.exports);
|
|
20
|
+
__reExport(withdrawal_compressor_exports, require("./createRedemptionLogger.js"), module.exports);
|
|
20
21
|
__reExport(withdrawal_compressor_exports, require("./createWithdrawalCompressor.js"), module.exports);
|
|
22
|
+
__reExport(withdrawal_compressor_exports, require("./errors.js"), module.exports);
|
|
21
23
|
__reExport(withdrawal_compressor_exports, require("./intent-codec.js"), module.exports);
|
|
24
|
+
__reExport(withdrawal_compressor_exports, require("./RedemptionLoggerV310Contract.js"), module.exports);
|
|
22
25
|
__reExport(withdrawal_compressor_exports, require("./types.js"), module.exports);
|
|
23
26
|
__reExport(withdrawal_compressor_exports, require("./WithdrawalCompressorV310Contract.js"), module.exports);
|
|
24
27
|
__reExport(withdrawal_compressor_exports, require("./WithdrawalCompressorV311Contract.js"), module.exports);
|
|
@@ -27,8 +30,11 @@ __reExport(withdrawal_compressor_exports, require("./WithdrawalCompressorV313Con
|
|
|
27
30
|
0 && (module.exports = {
|
|
28
31
|
...require("./AbstractWithdrawalCompressorContract.js"),
|
|
29
32
|
...require("./addresses.js"),
|
|
33
|
+
...require("./createRedemptionLogger.js"),
|
|
30
34
|
...require("./createWithdrawalCompressor.js"),
|
|
35
|
+
...require("./errors.js"),
|
|
31
36
|
...require("./intent-codec.js"),
|
|
37
|
+
...require("./RedemptionLoggerV310Contract.js"),
|
|
32
38
|
...require("./types.js"),
|
|
33
39
|
...require("./WithdrawalCompressorV310Contract.js"),
|
|
34
40
|
...require("./WithdrawalCompressorV311Contract.js"),
|
|
@@ -43,6 +43,7 @@ __export(address_provider_exports, {
|
|
|
43
43
|
AP_PRICE_FEED_COMPRESSOR: () => AP_PRICE_FEED_COMPRESSOR,
|
|
44
44
|
AP_PRICE_FEED_STORE: () => AP_PRICE_FEED_STORE,
|
|
45
45
|
AP_PRICE_ORACLE: () => AP_PRICE_ORACLE,
|
|
46
|
+
AP_REDEMPTION_LOGGER: () => AP_REDEMPTION_LOGGER,
|
|
46
47
|
AP_REWARDS_COMPRESSOR: () => AP_REWARDS_COMPRESSOR,
|
|
47
48
|
AP_ROUTER: () => AP_ROUTER,
|
|
48
49
|
AP_RWA_COMPRESSOR: () => AP_RWA_COMPRESSOR,
|
|
@@ -89,6 +90,7 @@ const AP_WETH_TOKEN = "WETH_TOKEN";
|
|
|
89
90
|
const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
|
|
90
91
|
const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
|
|
91
92
|
const AP_RWA_COMPRESSOR = "GLOBAL::RWA_COMPRESSOR";
|
|
93
|
+
const AP_REDEMPTION_LOGGER = "LOCAL::REDEMPTION_LOGGER";
|
|
92
94
|
const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
|
|
93
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
94
96
|
0 && (module.exports = {
|
|
@@ -117,6 +119,7 @@ const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
|
|
|
117
119
|
AP_PRICE_FEED_COMPRESSOR,
|
|
118
120
|
AP_PRICE_FEED_STORE,
|
|
119
121
|
AP_PRICE_ORACLE,
|
|
122
|
+
AP_REDEMPTION_LOGGER,
|
|
120
123
|
AP_REWARDS_COMPRESSOR,
|
|
121
124
|
AP_ROUTER,
|
|
122
125
|
AP_RWA_COMPRESSOR,
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const iRedemptionLoggerV310Abi = [
|
|
2
|
+
{
|
|
3
|
+
type: "function",
|
|
4
|
+
name: "allowedGateways",
|
|
5
|
+
inputs: [{ name: "gateway", type: "address", internalType: "address" }],
|
|
6
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
7
|
+
stateMutability: "view"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
type: "function",
|
|
11
|
+
name: "contractType",
|
|
12
|
+
inputs: [],
|
|
13
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
14
|
+
stateMutability: "view"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "function",
|
|
18
|
+
name: "logRedemption",
|
|
19
|
+
inputs: [
|
|
20
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
21
|
+
{ name: "redeemer", type: "address", internalType: "address" },
|
|
22
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
23
|
+
],
|
|
24
|
+
outputs: [],
|
|
25
|
+
stateMutability: "nonpayable"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: "function",
|
|
29
|
+
name: "redemptionLogs",
|
|
30
|
+
inputs: [{ name: "redeemer", type: "address", internalType: "address" }],
|
|
31
|
+
outputs: [
|
|
32
|
+
{
|
|
33
|
+
name: "",
|
|
34
|
+
type: "tuple",
|
|
35
|
+
internalType: "struct IRedemptionLogger.RedemptionLog",
|
|
36
|
+
components: [
|
|
37
|
+
{ name: "creditAccount", type: "address", internalType: "address" },
|
|
38
|
+
{ name: "redeemer", type: "address", internalType: "address" },
|
|
39
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
stateMutability: "view"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "function",
|
|
47
|
+
name: "setGatewayAllowed",
|
|
48
|
+
inputs: [
|
|
49
|
+
{ name: "gateway", type: "address", internalType: "address" },
|
|
50
|
+
{ name: "allowed", type: "bool", internalType: "bool" }
|
|
51
|
+
],
|
|
52
|
+
outputs: [],
|
|
53
|
+
stateMutability: "nonpayable"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: "function",
|
|
57
|
+
name: "version",
|
|
58
|
+
inputs: [],
|
|
59
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
60
|
+
stateMutability: "view"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: "event",
|
|
64
|
+
name: "RedemptionLogged",
|
|
65
|
+
inputs: [
|
|
66
|
+
{
|
|
67
|
+
name: "creditAccount",
|
|
68
|
+
type: "address",
|
|
69
|
+
indexed: true,
|
|
70
|
+
internalType: "address"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "redeemer",
|
|
74
|
+
type: "address",
|
|
75
|
+
indexed: true,
|
|
76
|
+
internalType: "address"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "extraData",
|
|
80
|
+
type: "bytes",
|
|
81
|
+
indexed: false,
|
|
82
|
+
internalType: "bytes"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
anonymous: false
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: "error",
|
|
89
|
+
name: "GatewayNotAllowedException",
|
|
90
|
+
inputs: []
|
|
91
|
+
}
|
|
92
|
+
];
|
|
93
|
+
export {
|
|
94
|
+
iRedemptionLoggerV310Abi
|
|
95
|
+
};
|