@gearbox-protocol/sdk 14.12.0-next.36 → 14.12.0-next.38
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/IWithdrawalCompressorV313.js +78 -0
- 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/AbstractWithdrawalCompressorContract.js +1 -1
- package/dist/cjs/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +72 -0
- package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +90 -5
- 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/IWithdrawalCompressorV313.js +78 -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/AbstractWithdrawalCompressorContract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +48 -0
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +90 -5
- 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/IWithdrawalCompressorV313.d.ts +103 -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/AbstractWithdrawalCompressorContract.d.ts +1 -1
- package/dist/types/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +149 -0
- package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +104 -1
- 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 +46 -3
- package/dist/types/sdk/constants/address-provider.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -153,6 +153,84 @@ const iWithdrawalCompressorV313Abi = [
|
|
|
153
153
|
],
|
|
154
154
|
stateMutability: "view"
|
|
155
155
|
},
|
|
156
|
+
{
|
|
157
|
+
type: "function",
|
|
158
|
+
name: "getExternalAccountCurrentWithdrawals",
|
|
159
|
+
inputs: [
|
|
160
|
+
{
|
|
161
|
+
name: "withdrawalTokens",
|
|
162
|
+
type: "address[]",
|
|
163
|
+
internalType: "address[]"
|
|
164
|
+
},
|
|
165
|
+
{ name: "account", type: "address", internalType: "address" }
|
|
166
|
+
],
|
|
167
|
+
outputs: [
|
|
168
|
+
{
|
|
169
|
+
name: "",
|
|
170
|
+
type: "tuple[]",
|
|
171
|
+
internalType: "struct ClaimableWithdrawal[]",
|
|
172
|
+
components: [
|
|
173
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
174
|
+
{
|
|
175
|
+
name: "withdrawalPhantomToken",
|
|
176
|
+
type: "address",
|
|
177
|
+
internalType: "address"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "withdrawalTokenSpent",
|
|
181
|
+
type: "uint256",
|
|
182
|
+
internalType: "uint256"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "outputs",
|
|
186
|
+
type: "tuple[]",
|
|
187
|
+
internalType: "struct WithdrawalOutput[]",
|
|
188
|
+
components: [
|
|
189
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
190
|
+
{ name: "isDelayed", type: "bool", internalType: "bool" },
|
|
191
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "claimCalls",
|
|
196
|
+
type: "tuple[]",
|
|
197
|
+
internalType: "struct MultiCall[]",
|
|
198
|
+
components: [
|
|
199
|
+
{ name: "target", type: "address", internalType: "address" },
|
|
200
|
+
{ name: "callData", type: "bytes", internalType: "bytes" }
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "",
|
|
208
|
+
type: "tuple[]",
|
|
209
|
+
internalType: "struct PendingWithdrawal[]",
|
|
210
|
+
components: [
|
|
211
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
212
|
+
{
|
|
213
|
+
name: "withdrawalPhantomToken",
|
|
214
|
+
type: "address",
|
|
215
|
+
internalType: "address"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "expectedOutputs",
|
|
219
|
+
type: "tuple[]",
|
|
220
|
+
internalType: "struct WithdrawalOutput[]",
|
|
221
|
+
components: [
|
|
222
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
223
|
+
{ name: "isDelayed", type: "bool", internalType: "bool" },
|
|
224
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
{ name: "claimableAt", type: "uint256", internalType: "uint256" },
|
|
228
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
stateMutability: "view"
|
|
233
|
+
},
|
|
156
234
|
{
|
|
157
235
|
type: "function",
|
|
158
236
|
name: "getWithdrawalStatus",
|
|
@@ -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
|
+
};
|
|
@@ -162,6 +162,18 @@ class AbstractAdapterContract extends BaseContract {
|
|
|
162
162
|
parseDelayedWithdrawalRequest(_calldata) {
|
|
163
163
|
return void 0;
|
|
164
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* When the given adapter calldata is a delayed-withdrawal claim (a call
|
|
167
|
+
* created by the withdrawal compressor that burns a withdrawal phantom
|
|
168
|
+
* token and receives the claim token from a redeemer), returns its
|
|
169
|
+
* descriptor; `undefined` for any other call.
|
|
170
|
+
*
|
|
171
|
+
* The base implementation returns `undefined`; adapters whose gateways log
|
|
172
|
+
* redemption intents (Securitize, Midas) override it.
|
|
173
|
+
*/
|
|
174
|
+
parseDelayedWithdrawalClaim(_calldata) {
|
|
175
|
+
return void 0;
|
|
176
|
+
}
|
|
165
177
|
/**
|
|
166
178
|
* Diff-call semantics of a diff-style adapter call: the call spends the
|
|
167
179
|
* consumed token down to the exact `leftoverAmount` encoded in its
|
|
@@ -99,6 +99,18 @@ class MidasGatewayAdapterContract extends AbstractAdapterContract {
|
|
|
99
99
|
extraData
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* `withdrawFromRedeemer(address redeemer, uint256 amount)` claims a matured
|
|
104
|
+
* redemption from a redeemer contract.
|
|
105
|
+
*/
|
|
106
|
+
parseDelayedWithdrawalClaim(calldata) {
|
|
107
|
+
const decoded = decodeFunctionData({ abi: this.abi, data: calldata });
|
|
108
|
+
if (decoded.functionName !== "withdrawFromRedeemer") {
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
const [redeemer] = decoded.args;
|
|
112
|
+
return { redeemer };
|
|
113
|
+
}
|
|
102
114
|
async applyBalanceChanges(balances, decoded) {
|
|
103
115
|
switch (decoded.functionName) {
|
|
104
116
|
case "depositInstantDiff": {
|
|
@@ -72,6 +72,22 @@ class SecuritizeRedemptionGatewayAdapterContract extends AbstractAdapterContract
|
|
|
72
72
|
extraData
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* `claim(address[] redeemers)` claims matured redemptions from redeemer
|
|
77
|
+
* contracts. Transactions built by the withdrawal compressor always claim
|
|
78
|
+
* from a single redeemer, so only the first one is reported.
|
|
79
|
+
*/
|
|
80
|
+
parseDelayedWithdrawalClaim(calldata) {
|
|
81
|
+
const decoded = decodeFunctionData({ abi: this.abi, data: calldata });
|
|
82
|
+
if (decoded.functionName !== "claim") {
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
const [redeemers] = decoded.args;
|
|
86
|
+
if (redeemers.length === 0) {
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
return { redeemer: redeemers[0] };
|
|
90
|
+
}
|
|
75
91
|
async applyBalanceChanges(balances, decoded) {
|
|
76
92
|
switch (decoded.functionName) {
|
|
77
93
|
// no-op:
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbstractAdapterContract
|
|
3
|
+
} from "../../plugins/adapters/index.js";
|
|
4
|
+
function detectDelayedClaim(sdk, multicall) {
|
|
5
|
+
for (const op of multicall) {
|
|
6
|
+
if (op.operation !== "Execute") {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
const adapter = sdk.getContract(op.adapter);
|
|
10
|
+
if (!(adapter instanceof AbstractAdapterContract)) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const claim = adapter.parseDelayedWithdrawalClaim(op.calldata);
|
|
14
|
+
if (claim) {
|
|
15
|
+
return { adapter: op.adapter, redeemer: claim.redeemer };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
async function resolveDelayedClaimIntent(sdk, multicall, blockNumber) {
|
|
21
|
+
const claim = detectDelayedClaim(sdk, multicall);
|
|
22
|
+
if (!claim) {
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
return sdk.redemptionLogger?.getDelayedIntent(claim.redeemer, blockNumber);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
detectDelayedClaim,
|
|
29
|
+
resolveDelayedClaimIntent
|
|
30
|
+
};
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
AbstractAdapterContract
|
|
4
4
|
} from "../../plugins/adapters/index.js";
|
|
5
5
|
import {
|
|
6
|
-
decodeDelayedIntent
|
|
6
|
+
decodeDelayedIntent,
|
|
7
|
+
InvalidDelayedIntentError
|
|
7
8
|
} from "../../sdk/index.js";
|
|
8
|
-
import { InvalidDelayedIntentError } from "./errors.js";
|
|
9
9
|
function detectDelayedOperation(sdk, multicall) {
|
|
10
10
|
let bracketDeltas = [];
|
|
11
11
|
for (const op of multicall) {
|
|
@@ -39,7 +39,7 @@ function detectDelayedOperation(sdk, multicall) {
|
|
|
39
39
|
try {
|
|
40
40
|
intent = decodeDelayedIntent(request.extraData);
|
|
41
41
|
} catch (e) {
|
|
42
|
-
throw new InvalidDelayedIntentError(
|
|
42
|
+
throw new InvalidDelayedIntentError(request.extraData, e);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
return { request, intent };
|
|
@@ -7,22 +7,6 @@ class UnsupportedOperationError extends Error {
|
|
|
7
7
|
this.operation = operation;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
class InvalidDelayedIntentError extends Error {
|
|
11
|
-
/** Adapter the withdrawal request was addressed to. */
|
|
12
|
-
adapter;
|
|
13
|
-
/** Raw `extraData` that failed to decode. */
|
|
14
|
-
extraData;
|
|
15
|
-
constructor(adapter, extraData, cause) {
|
|
16
|
-
super(
|
|
17
|
-
`cannot decode delayed intent from extraData ${extraData} of withdrawal request to adapter ${adapter}`,
|
|
18
|
-
{ cause }
|
|
19
|
-
);
|
|
20
|
-
this.name = "InvalidDelayedIntentError";
|
|
21
|
-
this.adapter = adapter;
|
|
22
|
-
this.extraData = extraData;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
10
|
export {
|
|
26
|
-
InvalidDelayedIntentError,
|
|
27
11
|
UnsupportedOperationError
|
|
28
12
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./buildDelayedPreview.js";
|
|
2
2
|
export * from "./CreditAccountState.js";
|
|
3
3
|
export * from "./detectCloseOrRepay.js";
|
|
4
|
+
export * from "./detectDelayedClaim.js";
|
|
4
5
|
export * from "./detectDelayedOperation.js";
|
|
5
6
|
export * from "./errors.js";
|
|
6
7
|
export * from "./previewAdjustCreditAccount.js";
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from "../parse/index.js";
|
|
5
5
|
import { buildDelayedPreview } from "./buildDelayedPreview.js";
|
|
6
6
|
import { isCloseOrRepay } from "./detectCloseOrRepay.js";
|
|
7
|
+
import { resolveDelayedClaimIntent } from "./detectDelayedClaim.js";
|
|
7
8
|
import { detectDelayedOperation } from "./detectDelayedOperation.js";
|
|
8
9
|
import { UnsupportedOperationError } from "./errors.js";
|
|
9
10
|
import { previewAdjustCreditAccount } from "./previewAdjustCreditAccount.js";
|
|
@@ -23,7 +24,18 @@ async function previewOperation(input, options) {
|
|
|
23
24
|
}
|
|
24
25
|
if (operation.operation === "CloseCreditAccount") {
|
|
25
26
|
const resolved = await resolveCreditAccount(input, operation, options);
|
|
26
|
-
|
|
27
|
+
const preview = await previewCloseOrRepayCreditAccount(
|
|
28
|
+
input,
|
|
29
|
+
operation,
|
|
30
|
+
true,
|
|
31
|
+
resolved
|
|
32
|
+
);
|
|
33
|
+
preview.intent = await resolveDelayedClaimIntent(
|
|
34
|
+
input.sdk,
|
|
35
|
+
operation.multicall,
|
|
36
|
+
options?.blockNumber
|
|
37
|
+
);
|
|
38
|
+
return preview;
|
|
27
39
|
}
|
|
28
40
|
if (operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "RWAMulticall") {
|
|
29
41
|
const resolved = await resolveCreditAccount(input, operation, options);
|
|
@@ -49,6 +61,11 @@ async function previewMulticallOperation(input, operation, options) {
|
|
|
49
61
|
const instantPreview = isCloseOrRepay(operation.multicall) ? await previewCloseOrRepayCreditAccount(input, operation, false, options) : await previewAdjustCreditAccount(input, operation, options);
|
|
50
62
|
const delayed = detectDelayedOperation(sdk, operation.multicall);
|
|
51
63
|
if (!delayed) {
|
|
64
|
+
instantPreview.intent = await resolveDelayedClaimIntent(
|
|
65
|
+
sdk,
|
|
66
|
+
operation.multicall,
|
|
67
|
+
options?.blockNumber
|
|
68
|
+
);
|
|
52
69
|
return instantPreview;
|
|
53
70
|
}
|
|
54
71
|
const { before, after } = await replayMulticall(sdk, operation, options);
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "viem";
|
|
7
7
|
import {
|
|
8
8
|
CreditAccountsServiceV310,
|
|
9
|
+
createRedemptionLogger,
|
|
9
10
|
createWithdrawalCompressor,
|
|
10
11
|
LiquidationsService
|
|
11
12
|
} from "./accounts/index.js";
|
|
@@ -69,6 +70,7 @@ class OnchainSDK extends ChainContractsRegister {
|
|
|
69
70
|
#marketRegister;
|
|
70
71
|
#priceFeeds;
|
|
71
72
|
#withdrawalCompressor;
|
|
73
|
+
#redemptionLogger;
|
|
72
74
|
/**
|
|
73
75
|
* Gas limit applied to read-only `eth_call` requests.
|
|
74
76
|
**/
|
|
@@ -554,6 +556,16 @@ class OnchainSDK extends ChainContractsRegister {
|
|
|
554
556
|
get withdrawalCompressor() {
|
|
555
557
|
return this.#withdrawalCompressor;
|
|
556
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* `RedemptionLogger` contract for the current chain, or `undefined` when
|
|
561
|
+
* it is not deployed on it. Created lazily on first access: the contract
|
|
562
|
+
* is resolved from the address provider, which is only available after
|
|
563
|
+
* the SDK is attached or hydrated.
|
|
564
|
+
**/
|
|
565
|
+
get redemptionLogger() {
|
|
566
|
+
this.#redemptionLogger ??= createRedemptionLogger(this);
|
|
567
|
+
return this.#redemptionLogger;
|
|
568
|
+
}
|
|
557
569
|
}
|
|
558
570
|
export {
|
|
559
571
|
OnchainSDK,
|
|
@@ -164,7 +164,7 @@ class AbstractWithdrawalCompressorContract extends BaseContract {
|
|
|
164
164
|
/**
|
|
165
165
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
166
166
|
**/
|
|
167
|
-
async getExternalAccountCurrentWithdrawals(
|
|
167
|
+
async getExternalAccountCurrentWithdrawals(_account, ..._withdrawalTokens) {
|
|
168
168
|
this.#reportUnsupported("external account withdrawals");
|
|
169
169
|
return { claimable: [], pending: [] };
|
|
170
170
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
2
|
+
import { BaseContract } from "../../base/index.js";
|
|
3
|
+
import { InvalidDelayedIntentError } from "./errors.js";
|
|
4
|
+
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
5
|
+
const abi = iRedemptionLoggerV310Abi;
|
|
6
|
+
class RedemptionLoggerV310Contract extends BaseContract {
|
|
7
|
+
constructor(sdk, address, version) {
|
|
8
|
+
super(sdk, {
|
|
9
|
+
addr: address,
|
|
10
|
+
name: "RedemptionLogger",
|
|
11
|
+
abi,
|
|
12
|
+
version
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the redemption data logged for a redeemer; all-zero fields when
|
|
17
|
+
* nothing was logged for it.
|
|
18
|
+
**/
|
|
19
|
+
async getRedemptionLog(redeemer, blockNumber) {
|
|
20
|
+
return this.contract.read.redemptionLogs([redeemer], {
|
|
21
|
+
blockNumber
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Reads the redemption log of a redeemer and decodes the recorded intent.
|
|
26
|
+
*
|
|
27
|
+
* @param redeemer - Redeemer contract the withdrawal is claimed from.
|
|
28
|
+
* @param blockNumber - Optional block number to read the log at.
|
|
29
|
+
* @returns The decoded intent, or `undefined` when the log carries none
|
|
30
|
+
* (including when nothing was logged for the redeemer).
|
|
31
|
+
* @throws InvalidDelayedIntentError when the logged `extraData` is
|
|
32
|
+
* non-empty but cannot be decoded as a `DelayedIntent`.
|
|
33
|
+
**/
|
|
34
|
+
async getDelayedIntent(redeemer, blockNumber) {
|
|
35
|
+
const log = await this.getRedemptionLog(redeemer, blockNumber);
|
|
36
|
+
if (!log.extraData || log.extraData === "0x") {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return decodeDelayedIntent(log.extraData);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
throw new InvalidDelayedIntentError(log.extraData, e);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
RedemptionLoggerV310Contract
|
|
48
|
+
};
|