@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
|
@@ -9,6 +9,86 @@ import {
|
|
|
9
9
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
10
10
|
import { toWithdrawalStatus } from "./types.js";
|
|
11
11
|
const abi = iWithdrawalCompressorV313Abi;
|
|
12
|
+
const iExternalWithdrawalsBatchAbi = [
|
|
13
|
+
{
|
|
14
|
+
type: "function",
|
|
15
|
+
name: "getExternalAccountCurrentWithdrawals",
|
|
16
|
+
inputs: [
|
|
17
|
+
{
|
|
18
|
+
name: "withdrawalTokens",
|
|
19
|
+
type: "address[]",
|
|
20
|
+
internalType: "address[]"
|
|
21
|
+
},
|
|
22
|
+
{ name: "account", type: "address", internalType: "address" }
|
|
23
|
+
],
|
|
24
|
+
outputs: [
|
|
25
|
+
{
|
|
26
|
+
name: "",
|
|
27
|
+
type: "tuple[]",
|
|
28
|
+
internalType: "struct ClaimableWithdrawal[]",
|
|
29
|
+
components: [
|
|
30
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
31
|
+
{
|
|
32
|
+
name: "withdrawalPhantomToken",
|
|
33
|
+
type: "address",
|
|
34
|
+
internalType: "address"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "withdrawalTokenSpent",
|
|
38
|
+
type: "uint256",
|
|
39
|
+
internalType: "uint256"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "outputs",
|
|
43
|
+
type: "tuple[]",
|
|
44
|
+
internalType: "struct WithdrawalOutput[]",
|
|
45
|
+
components: [
|
|
46
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
47
|
+
{ name: "isDelayed", type: "bool", internalType: "bool" },
|
|
48
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "claimCalls",
|
|
53
|
+
type: "tuple[]",
|
|
54
|
+
internalType: "struct MultiCall[]",
|
|
55
|
+
components: [
|
|
56
|
+
{ name: "target", type: "address", internalType: "address" },
|
|
57
|
+
{ name: "callData", type: "bytes", internalType: "bytes" }
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "",
|
|
65
|
+
type: "tuple[]",
|
|
66
|
+
internalType: "struct PendingWithdrawal[]",
|
|
67
|
+
components: [
|
|
68
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
69
|
+
{
|
|
70
|
+
name: "withdrawalPhantomToken",
|
|
71
|
+
type: "address",
|
|
72
|
+
internalType: "address"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "expectedOutputs",
|
|
76
|
+
type: "tuple[]",
|
|
77
|
+
internalType: "struct WithdrawalOutput[]",
|
|
78
|
+
components: [
|
|
79
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
80
|
+
{ name: "isDelayed", type: "bool", internalType: "bool" },
|
|
81
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{ name: "claimableAt", type: "uint256", internalType: "uint256" },
|
|
85
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
stateMutability: "view"
|
|
90
|
+
}
|
|
91
|
+
];
|
|
12
92
|
const iWithdrawalStatusBatchAbi = [
|
|
13
93
|
{
|
|
14
94
|
type: "function",
|
|
@@ -34,11 +114,16 @@ class WithdrawalCompressorV313Contract extends AbstractWithdrawalCompressorContr
|
|
|
34
114
|
/**
|
|
35
115
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
36
116
|
**/
|
|
37
|
-
async getExternalAccountCurrentWithdrawals(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
]
|
|
117
|
+
async getExternalAccountCurrentWithdrawals(account, ...withdrawalTokens) {
|
|
118
|
+
if (withdrawalTokens.length === 0) {
|
|
119
|
+
return { claimable: [], pending: [] };
|
|
120
|
+
}
|
|
121
|
+
const [claimable, pending] = await this.client.readContract({
|
|
122
|
+
address: this.address,
|
|
123
|
+
abi: iExternalWithdrawalsBatchAbi,
|
|
124
|
+
functionName: "getExternalAccountCurrentWithdrawals",
|
|
125
|
+
args: [withdrawalTokens, account]
|
|
126
|
+
});
|
|
42
127
|
return {
|
|
43
128
|
claimable: claimable.map((w) => toClaimableWithdrawal(w, void 0)),
|
|
44
129
|
pending: pending.map((w) => toPendingWithdrawal(w, void 0)).sort((a, b) => a.claimableAt < b.claimableAt ? -1 : 1)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AP_REDEMPTION_LOGGER,
|
|
3
|
+
isV310,
|
|
4
|
+
VERSION_RANGE_310
|
|
5
|
+
} from "../../constants/index.js";
|
|
6
|
+
import { RedemptionLoggerV310Contract } from "./RedemptionLoggerV310Contract.js";
|
|
7
|
+
function createRedemptionLogger(sdk) {
|
|
8
|
+
const latest = sdk.addressProvider.getLatest(
|
|
9
|
+
AP_REDEMPTION_LOGGER,
|
|
10
|
+
VERSION_RANGE_310
|
|
11
|
+
);
|
|
12
|
+
if (!latest) {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
const [address, version] = latest;
|
|
16
|
+
if (isV310(version)) {
|
|
17
|
+
return new RedemptionLoggerV310Contract(sdk, address, version);
|
|
18
|
+
}
|
|
19
|
+
throw new Error(`Unsupported redemption logger version: ${version}`);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
createRedemptionLogger
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class InvalidDelayedIntentError extends Error {
|
|
2
|
+
/** Raw `extraData` that failed to decode. */
|
|
3
|
+
extraData;
|
|
4
|
+
constructor(extraData, cause) {
|
|
5
|
+
super(`cannot decode delayed intent from extraData ${extraData}`, {
|
|
6
|
+
cause
|
|
7
|
+
});
|
|
8
|
+
this.name = "InvalidDelayedIntentError";
|
|
9
|
+
this.extraData = extraData;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
InvalidDelayedIntentError
|
|
14
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from "./AbstractWithdrawalCompressorContract.js";
|
|
2
2
|
export * from "./addresses.js";
|
|
3
|
+
export * from "./createRedemptionLogger.js";
|
|
3
4
|
export * from "./createWithdrawalCompressor.js";
|
|
5
|
+
export * from "./errors.js";
|
|
4
6
|
export * from "./intent-codec.js";
|
|
7
|
+
export * from "./RedemptionLoggerV310Contract.js";
|
|
5
8
|
export * from "./types.js";
|
|
6
9
|
export * from "./WithdrawalCompressorV310Contract.js";
|
|
7
10
|
export * from "./WithdrawalCompressorV311Contract.js";
|
|
@@ -32,6 +32,7 @@ const AP_WETH_TOKEN = "WETH_TOKEN";
|
|
|
32
32
|
const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
|
|
33
33
|
const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
|
|
34
34
|
const AP_RWA_COMPRESSOR = "GLOBAL::RWA_COMPRESSOR";
|
|
35
|
+
const AP_REDEMPTION_LOGGER = "LOCAL::REDEMPTION_LOGGER";
|
|
35
36
|
const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
|
|
36
37
|
export {
|
|
37
38
|
ADDRESS_PROVIDER_V310,
|
|
@@ -59,6 +60,7 @@ export {
|
|
|
59
60
|
AP_PRICE_FEED_COMPRESSOR,
|
|
60
61
|
AP_PRICE_FEED_STORE,
|
|
61
62
|
AP_PRICE_ORACLE,
|
|
63
|
+
AP_REDEMPTION_LOGGER,
|
|
62
64
|
AP_REWARDS_COMPRESSOR,
|
|
63
65
|
AP_ROUTER,
|
|
64
66
|
AP_RWA_COMPRESSOR,
|
|
@@ -210,6 +210,109 @@ export declare const iWithdrawalCompressorV313Abi: readonly [{
|
|
|
210
210
|
}];
|
|
211
211
|
}];
|
|
212
212
|
readonly stateMutability: "view";
|
|
213
|
+
}, {
|
|
214
|
+
readonly type: "function";
|
|
215
|
+
readonly name: "getExternalAccountCurrentWithdrawals";
|
|
216
|
+
readonly inputs: readonly [{
|
|
217
|
+
readonly name: "withdrawalTokens";
|
|
218
|
+
readonly type: "address[]";
|
|
219
|
+
readonly internalType: "address[]";
|
|
220
|
+
}, {
|
|
221
|
+
readonly name: "account";
|
|
222
|
+
readonly type: "address";
|
|
223
|
+
readonly internalType: "address";
|
|
224
|
+
}];
|
|
225
|
+
readonly outputs: readonly [{
|
|
226
|
+
readonly name: "";
|
|
227
|
+
readonly type: "tuple[]";
|
|
228
|
+
readonly internalType: "struct ClaimableWithdrawal[]";
|
|
229
|
+
readonly components: readonly [{
|
|
230
|
+
readonly name: "token";
|
|
231
|
+
readonly type: "address";
|
|
232
|
+
readonly internalType: "address";
|
|
233
|
+
}, {
|
|
234
|
+
readonly name: "withdrawalPhantomToken";
|
|
235
|
+
readonly type: "address";
|
|
236
|
+
readonly internalType: "address";
|
|
237
|
+
}, {
|
|
238
|
+
readonly name: "withdrawalTokenSpent";
|
|
239
|
+
readonly type: "uint256";
|
|
240
|
+
readonly internalType: "uint256";
|
|
241
|
+
}, {
|
|
242
|
+
readonly name: "outputs";
|
|
243
|
+
readonly type: "tuple[]";
|
|
244
|
+
readonly internalType: "struct WithdrawalOutput[]";
|
|
245
|
+
readonly components: readonly [{
|
|
246
|
+
readonly name: "token";
|
|
247
|
+
readonly type: "address";
|
|
248
|
+
readonly internalType: "address";
|
|
249
|
+
}, {
|
|
250
|
+
readonly name: "isDelayed";
|
|
251
|
+
readonly type: "bool";
|
|
252
|
+
readonly internalType: "bool";
|
|
253
|
+
}, {
|
|
254
|
+
readonly name: "amount";
|
|
255
|
+
readonly type: "uint256";
|
|
256
|
+
readonly internalType: "uint256";
|
|
257
|
+
}];
|
|
258
|
+
}, {
|
|
259
|
+
readonly name: "claimCalls";
|
|
260
|
+
readonly type: "tuple[]";
|
|
261
|
+
readonly internalType: "struct MultiCall[]";
|
|
262
|
+
readonly components: readonly [{
|
|
263
|
+
readonly name: "target";
|
|
264
|
+
readonly type: "address";
|
|
265
|
+
readonly internalType: "address";
|
|
266
|
+
}, {
|
|
267
|
+
readonly name: "callData";
|
|
268
|
+
readonly type: "bytes";
|
|
269
|
+
readonly internalType: "bytes";
|
|
270
|
+
}];
|
|
271
|
+
}, {
|
|
272
|
+
readonly name: "extraData";
|
|
273
|
+
readonly type: "bytes";
|
|
274
|
+
readonly internalType: "bytes";
|
|
275
|
+
}];
|
|
276
|
+
}, {
|
|
277
|
+
readonly name: "";
|
|
278
|
+
readonly type: "tuple[]";
|
|
279
|
+
readonly internalType: "struct PendingWithdrawal[]";
|
|
280
|
+
readonly components: readonly [{
|
|
281
|
+
readonly name: "token";
|
|
282
|
+
readonly type: "address";
|
|
283
|
+
readonly internalType: "address";
|
|
284
|
+
}, {
|
|
285
|
+
readonly name: "withdrawalPhantomToken";
|
|
286
|
+
readonly type: "address";
|
|
287
|
+
readonly internalType: "address";
|
|
288
|
+
}, {
|
|
289
|
+
readonly name: "expectedOutputs";
|
|
290
|
+
readonly type: "tuple[]";
|
|
291
|
+
readonly internalType: "struct WithdrawalOutput[]";
|
|
292
|
+
readonly components: readonly [{
|
|
293
|
+
readonly name: "token";
|
|
294
|
+
readonly type: "address";
|
|
295
|
+
readonly internalType: "address";
|
|
296
|
+
}, {
|
|
297
|
+
readonly name: "isDelayed";
|
|
298
|
+
readonly type: "bool";
|
|
299
|
+
readonly internalType: "bool";
|
|
300
|
+
}, {
|
|
301
|
+
readonly name: "amount";
|
|
302
|
+
readonly type: "uint256";
|
|
303
|
+
readonly internalType: "uint256";
|
|
304
|
+
}];
|
|
305
|
+
}, {
|
|
306
|
+
readonly name: "claimableAt";
|
|
307
|
+
readonly type: "uint256";
|
|
308
|
+
readonly internalType: "uint256";
|
|
309
|
+
}, {
|
|
310
|
+
readonly name: "extraData";
|
|
311
|
+
readonly type: "bytes";
|
|
312
|
+
readonly internalType: "bytes";
|
|
313
|
+
}];
|
|
314
|
+
}];
|
|
315
|
+
readonly stateMutability: "view";
|
|
213
316
|
}, {
|
|
214
317
|
readonly type: "function";
|
|
215
318
|
readonly name: "getWithdrawalStatus";
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ABI of `IRedemptionLogger` from `@gearbox-protocol/integrations-v3`,
|
|
3
|
+
* copied from the forge artifact `out/IRedemptionLogger.sol/IRedemptionLogger.json`
|
|
4
|
+
*/
|
|
5
|
+
export declare const iRedemptionLoggerV310Abi: readonly [{
|
|
6
|
+
readonly type: "function";
|
|
7
|
+
readonly name: "allowedGateways";
|
|
8
|
+
readonly inputs: readonly [{
|
|
9
|
+
readonly name: "gateway";
|
|
10
|
+
readonly type: "address";
|
|
11
|
+
readonly internalType: "address";
|
|
12
|
+
}];
|
|
13
|
+
readonly outputs: readonly [{
|
|
14
|
+
readonly name: "";
|
|
15
|
+
readonly type: "bool";
|
|
16
|
+
readonly internalType: "bool";
|
|
17
|
+
}];
|
|
18
|
+
readonly stateMutability: "view";
|
|
19
|
+
}, {
|
|
20
|
+
readonly type: "function";
|
|
21
|
+
readonly name: "contractType";
|
|
22
|
+
readonly inputs: readonly [];
|
|
23
|
+
readonly outputs: readonly [{
|
|
24
|
+
readonly name: "";
|
|
25
|
+
readonly type: "bytes32";
|
|
26
|
+
readonly internalType: "bytes32";
|
|
27
|
+
}];
|
|
28
|
+
readonly stateMutability: "view";
|
|
29
|
+
}, {
|
|
30
|
+
readonly type: "function";
|
|
31
|
+
readonly name: "logRedemption";
|
|
32
|
+
readonly inputs: readonly [{
|
|
33
|
+
readonly name: "creditAccount";
|
|
34
|
+
readonly type: "address";
|
|
35
|
+
readonly internalType: "address";
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: "redeemer";
|
|
38
|
+
readonly type: "address";
|
|
39
|
+
readonly internalType: "address";
|
|
40
|
+
}, {
|
|
41
|
+
readonly name: "extraData";
|
|
42
|
+
readonly type: "bytes";
|
|
43
|
+
readonly internalType: "bytes";
|
|
44
|
+
}];
|
|
45
|
+
readonly outputs: readonly [];
|
|
46
|
+
readonly stateMutability: "nonpayable";
|
|
47
|
+
}, {
|
|
48
|
+
readonly type: "function";
|
|
49
|
+
readonly name: "redemptionLogs";
|
|
50
|
+
readonly inputs: readonly [{
|
|
51
|
+
readonly name: "redeemer";
|
|
52
|
+
readonly type: "address";
|
|
53
|
+
readonly internalType: "address";
|
|
54
|
+
}];
|
|
55
|
+
readonly outputs: readonly [{
|
|
56
|
+
readonly name: "";
|
|
57
|
+
readonly type: "tuple";
|
|
58
|
+
readonly internalType: "struct IRedemptionLogger.RedemptionLog";
|
|
59
|
+
readonly components: readonly [{
|
|
60
|
+
readonly name: "creditAccount";
|
|
61
|
+
readonly type: "address";
|
|
62
|
+
readonly internalType: "address";
|
|
63
|
+
}, {
|
|
64
|
+
readonly name: "redeemer";
|
|
65
|
+
readonly type: "address";
|
|
66
|
+
readonly internalType: "address";
|
|
67
|
+
}, {
|
|
68
|
+
readonly name: "extraData";
|
|
69
|
+
readonly type: "bytes";
|
|
70
|
+
readonly internalType: "bytes";
|
|
71
|
+
}];
|
|
72
|
+
}];
|
|
73
|
+
readonly stateMutability: "view";
|
|
74
|
+
}, {
|
|
75
|
+
readonly type: "function";
|
|
76
|
+
readonly name: "setGatewayAllowed";
|
|
77
|
+
readonly inputs: readonly [{
|
|
78
|
+
readonly name: "gateway";
|
|
79
|
+
readonly type: "address";
|
|
80
|
+
readonly internalType: "address";
|
|
81
|
+
}, {
|
|
82
|
+
readonly name: "allowed";
|
|
83
|
+
readonly type: "bool";
|
|
84
|
+
readonly internalType: "bool";
|
|
85
|
+
}];
|
|
86
|
+
readonly outputs: readonly [];
|
|
87
|
+
readonly stateMutability: "nonpayable";
|
|
88
|
+
}, {
|
|
89
|
+
readonly type: "function";
|
|
90
|
+
readonly name: "version";
|
|
91
|
+
readonly inputs: readonly [];
|
|
92
|
+
readonly outputs: readonly [{
|
|
93
|
+
readonly name: "";
|
|
94
|
+
readonly type: "uint256";
|
|
95
|
+
readonly internalType: "uint256";
|
|
96
|
+
}];
|
|
97
|
+
readonly stateMutability: "view";
|
|
98
|
+
}, {
|
|
99
|
+
readonly type: "event";
|
|
100
|
+
readonly name: "RedemptionLogged";
|
|
101
|
+
readonly inputs: readonly [{
|
|
102
|
+
readonly name: "creditAccount";
|
|
103
|
+
readonly type: "address";
|
|
104
|
+
readonly indexed: true;
|
|
105
|
+
readonly internalType: "address";
|
|
106
|
+
}, {
|
|
107
|
+
readonly name: "redeemer";
|
|
108
|
+
readonly type: "address";
|
|
109
|
+
readonly indexed: true;
|
|
110
|
+
readonly internalType: "address";
|
|
111
|
+
}, {
|
|
112
|
+
readonly name: "extraData";
|
|
113
|
+
readonly type: "bytes";
|
|
114
|
+
readonly indexed: false;
|
|
115
|
+
readonly internalType: "bytes";
|
|
116
|
+
}];
|
|
117
|
+
readonly anonymous: false;
|
|
118
|
+
}, {
|
|
119
|
+
readonly type: "error";
|
|
120
|
+
readonly name: "GatewayNotAllowedException";
|
|
121
|
+
readonly inputs: readonly [];
|
|
122
|
+
}];
|
|
@@ -3,7 +3,7 @@ import { type CallTrace } from "../../../common-utils/utils/trace.js";
|
|
|
3
3
|
import type { AssetsMap, OnchainSDK, ParsedCallV2, RelaxedBaseParams } from "../../../sdk/index.js";
|
|
4
4
|
import { BaseContract } from "../../../sdk/index.js";
|
|
5
5
|
import type { LegacyAdapterOperation, Transfers } from "../legacyAdapterOperations.js";
|
|
6
|
-
import type { AdapterContractStateHuman, AdapterContractType, AdapterProtocolOperation, DelayedWithdrawalRequest } from "../types.js";
|
|
6
|
+
import type { AdapterContractStateHuman, AdapterContractType, AdapterProtocolOperation, DelayedWithdrawalClaim, DelayedWithdrawalRequest } from "../types.js";
|
|
7
7
|
export interface ConcreteAdapterContractOptions {
|
|
8
8
|
baseParams: RelaxedBaseParams;
|
|
9
9
|
}
|
|
@@ -74,6 +74,16 @@ export declare class AbstractAdapterContract<const abi extends Abi | readonly un
|
|
|
74
74
|
* {@link applyBalanceChanges} cases for the same methods.
|
|
75
75
|
*/
|
|
76
76
|
parseDelayedWithdrawalRequest(_calldata: Hex): DelayedWithdrawalRequest | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* When the given adapter calldata is a delayed-withdrawal claim (a call
|
|
79
|
+
* created by the withdrawal compressor that burns a withdrawal phantom
|
|
80
|
+
* token and receives the claim token from a redeemer), returns its
|
|
81
|
+
* descriptor; `undefined` for any other call.
|
|
82
|
+
*
|
|
83
|
+
* The base implementation returns `undefined`; adapters whose gateways log
|
|
84
|
+
* redemption intents (Securitize, Midas) override it.
|
|
85
|
+
*/
|
|
86
|
+
parseDelayedWithdrawalClaim(_calldata: Hex): DelayedWithdrawalClaim | undefined;
|
|
77
87
|
/**
|
|
78
88
|
* Diff-call semantics of a diff-style adapter call: the call spends the
|
|
79
89
|
* consumed token down to the exact `leftoverAmount` encoded in its
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType, type Hex } from "viem";
|
|
2
2
|
import { type AssetsMap, type OnchainSDK } from "../../../sdk/index.js";
|
|
3
|
-
import type { DelayedWithdrawalRequest } from "../types.js";
|
|
3
|
+
import type { DelayedWithdrawalClaim, DelayedWithdrawalRequest } from "../types.js";
|
|
4
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
5
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
6
|
declare const abi: readonly [{
|
|
@@ -604,6 +604,11 @@ export declare class MidasGatewayAdapterContract extends AbstractAdapterContract
|
|
|
604
604
|
* the intent `extraData`.
|
|
605
605
|
*/
|
|
606
606
|
parseDelayedWithdrawalRequest(calldata: Hex): DelayedWithdrawalRequest | undefined;
|
|
607
|
+
/**
|
|
608
|
+
* `withdrawFromRedeemer(address redeemer, uint256 amount)` claims a matured
|
|
609
|
+
* redemption from a redeemer contract.
|
|
610
|
+
*/
|
|
611
|
+
parseDelayedWithdrawalClaim(calldata: Hex): DelayedWithdrawalClaim | undefined;
|
|
607
612
|
protected applyBalanceChanges(balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
|
|
608
613
|
}
|
|
609
614
|
export {};
|
package/dist/types/plugins/adapters/contracts/SecuritizeRedemptionGatewayAdapterContract.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Address, type DecodeFunctionDataReturnType, type Hex } from "viem";
|
|
2
2
|
import { type AssetsMap, type OnchainSDK } from "../../../sdk/index.js";
|
|
3
|
-
import type { DelayedWithdrawalRequest } from "../types.js";
|
|
3
|
+
import type { DelayedWithdrawalClaim, DelayedWithdrawalRequest } from "../types.js";
|
|
4
4
|
import type { ConcreteAdapterContractOptions } from "./AbstractAdapter.js";
|
|
5
5
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
6
6
|
declare const abi: readonly [{
|
|
@@ -446,6 +446,12 @@ export declare class SecuritizeRedemptionGatewayAdapterContract extends Abstract
|
|
|
446
446
|
* intent `extraData`.
|
|
447
447
|
*/
|
|
448
448
|
parseDelayedWithdrawalRequest(calldata: Hex): DelayedWithdrawalRequest | undefined;
|
|
449
|
+
/**
|
|
450
|
+
* `claim(address[] redeemers)` claims matured redemptions from redeemer
|
|
451
|
+
* contracts. Transactions built by the withdrawal compressor always claim
|
|
452
|
+
* from a single redeemer, so only the first one is reported.
|
|
453
|
+
*/
|
|
454
|
+
parseDelayedWithdrawalClaim(calldata: Hex): DelayedWithdrawalClaim | undefined;
|
|
449
455
|
protected applyBalanceChanges(balances: AssetsMap, decoded: DecodeFunctionDataReturnType<abi>): Promise<void>;
|
|
450
456
|
}
|
|
451
457
|
export {};
|
|
@@ -89,6 +89,17 @@ export interface DelayedWithdrawalRequest {
|
|
|
89
89
|
*/
|
|
90
90
|
extraData?: Hex;
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Descriptor of a delayed-withdrawal claim performed by an adapter call
|
|
94
|
+
* (constructed by the withdrawal compressor): the withdrawal phantom token
|
|
95
|
+
* is burned and the claim token is received from the redeemer.
|
|
96
|
+
*/
|
|
97
|
+
export interface DelayedWithdrawalClaim {
|
|
98
|
+
/**
|
|
99
|
+
* Redeemer contract the withdrawal is claimed from
|
|
100
|
+
*/
|
|
101
|
+
redeemer: Address;
|
|
102
|
+
}
|
|
92
103
|
/**
|
|
93
104
|
* True when the plugin map `P` contains the {@link AdaptersPlugin} under any key
|
|
94
105
|
*/
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import { type SdkWithAdapters } from "../../plugins/adapters/index.js";
|
|
3
|
+
import type { DelayedIntent, PluginsMap } from "../../sdk/index.js";
|
|
4
|
+
import type { InnerOperation } from "../parse/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* A delayed-withdrawal claim detected in a credit-facade multicall,
|
|
7
|
+
* produced by `detectDelayedClaim`.
|
|
8
|
+
*/
|
|
9
|
+
export interface DetectedDelayedClaim {
|
|
10
|
+
/**
|
|
11
|
+
* Adapter the claim call is addressed to
|
|
12
|
+
*/
|
|
13
|
+
adapter: Address;
|
|
14
|
+
/**
|
|
15
|
+
* Redeemer contract the withdrawal is claimed from. Transactions built by
|
|
16
|
+
* the withdrawal compressor always claim from a single redeemer, so when
|
|
17
|
+
* the adapter method accepts multiple redeemers, only the first one is
|
|
18
|
+
* reported.
|
|
19
|
+
*/
|
|
20
|
+
redeemer: Address;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Scans a credit-facade multicall for a delayed-withdrawal claim call.
|
|
24
|
+
*
|
|
25
|
+
* @param sdk - SDK with the adapters plugin attached.
|
|
26
|
+
* @param multicall - Parsed inner operations of the multicall.
|
|
27
|
+
* @returns The detected claim, or `undefined` when the multicall contains no
|
|
28
|
+
* delayed-withdrawal claim call.
|
|
29
|
+
*/
|
|
30
|
+
export declare function detectDelayedClaim<P extends PluginsMap>(sdk: SdkWithAdapters<P>, multicall: InnerOperation[]): DetectedDelayedClaim | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the delayed intent of the withdrawal a multicall claims: detects
|
|
33
|
+
* the claim call and reads the recorded intent of the claimed redeemer from
|
|
34
|
+
* the `RedemptionLogger` contract.
|
|
35
|
+
*
|
|
36
|
+
* @param sdk - SDK with the adapters plugin attached.
|
|
37
|
+
* @param multicall - Parsed inner operations of the multicall.
|
|
38
|
+
* @param blockNumber - Optional block number to read the log at.
|
|
39
|
+
* @returns The decoded intent, or `undefined` when the multicall claims
|
|
40
|
+
* nothing, the redemption logger is not deployed, or the log carries no
|
|
41
|
+
* intent.
|
|
42
|
+
* @throws InvalidDelayedIntentError when the logged `extraData` is non-empty
|
|
43
|
+
* but cannot be decoded as a `DelayedIntent`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveDelayedClaimIntent<P extends PluginsMap>(sdk: SdkWithAdapters<P>, multicall: InnerOperation[], blockNumber?: bigint): Promise<DelayedIntent | undefined>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
2
1
|
/**
|
|
3
2
|
* Thrown by `previewOperation` for parsed operations it cannot preview yet.
|
|
4
3
|
* Currently only pool operations and credit account opening are supported.
|
|
@@ -8,17 +7,3 @@ export declare class UnsupportedOperationError extends Error {
|
|
|
8
7
|
readonly operation: string;
|
|
9
8
|
constructor(operation: string);
|
|
10
9
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Thrown when a delayed-withdrawal request carries non-empty `extraData`
|
|
13
|
-
* that cannot be decoded as a `DelayedIntent`. Requests produced by our
|
|
14
|
-
* stack always encode a valid intent, so garbage here means a
|
|
15
|
-
* malformed/foreign transaction that must not be previewed as if it were
|
|
16
|
-
* fine.
|
|
17
|
-
*/
|
|
18
|
-
export declare class InvalidDelayedIntentError extends Error {
|
|
19
|
-
/** Adapter the withdrawal request was addressed to. */
|
|
20
|
-
readonly adapter: Address;
|
|
21
|
-
/** Raw `extraData` that failed to decode. */
|
|
22
|
-
readonly extraData: Hex;
|
|
23
|
-
constructor(adapter: Address, extraData: Hex, cause?: unknown);
|
|
24
|
-
}
|
|
@@ -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";
|
|
@@ -194,6 +194,11 @@ export interface AdjustCreditAccountPreview {
|
|
|
194
194
|
* Assets after minus assets before
|
|
195
195
|
*/
|
|
196
196
|
assetsChange: Asset[];
|
|
197
|
+
/**
|
|
198
|
+
* Intent of the delayed withdrawal this transaction claims; set when the
|
|
199
|
+
* multicall claims a delayed withdrawal
|
|
200
|
+
*/
|
|
201
|
+
intent?: DelayedIntent;
|
|
197
202
|
/**
|
|
198
203
|
* Set when preview encountered non-fatal errors, all fields are
|
|
199
204
|
* still computed best-effort, but derived fields (`assets`, `assetsChange`,
|
|
@@ -225,6 +230,11 @@ export interface CloseCreditAccountPreview {
|
|
|
225
230
|
* underlying share converts 1:1 into)
|
|
226
231
|
*/
|
|
227
232
|
receivedAmount: Asset;
|
|
233
|
+
/**
|
|
234
|
+
* Intent of the delayed withdrawal this transaction claims; set when the
|
|
235
|
+
* multicall claims a delayed withdrawal
|
|
236
|
+
*/
|
|
237
|
+
intent?: DelayedIntent;
|
|
228
238
|
/**
|
|
229
239
|
* Set when preview encountered non-fatal errors, all fields are
|
|
230
240
|
* still computed best-effort, but the
|
|
@@ -265,6 +275,11 @@ export interface RepayCreditAccountPreview {
|
|
|
265
275
|
* Total debt repaid: principal + accrued interest + fees, in underlying
|
|
266
276
|
*/
|
|
267
277
|
debtRepaid: bigint;
|
|
278
|
+
/**
|
|
279
|
+
* Intent of the delayed withdrawal this transaction claims; set when the
|
|
280
|
+
* multicall claims a delayed withdrawal
|
|
281
|
+
*/
|
|
282
|
+
intent?: DelayedIntent;
|
|
268
283
|
/**
|
|
269
284
|
* Set when preview encountered non-fatal errors, all fields are
|
|
270
285
|
* still computed best-effort, but the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address } from "viem";
|
|
2
2
|
import { type PublicClient, type Transport } from "viem";
|
|
3
3
|
import type { HttpRpcClientOptions } from "viem/utils";
|
|
4
|
-
import { type ICreditAccountsService, type ILiquidationsService, type IWithdrawalCompressorContract } from "./accounts/index.js";
|
|
4
|
+
import { type ICreditAccountsService, type ILiquidationsService, type IRedemptionLoggerContract, type IWithdrawalCompressorContract } from "./accounts/index.js";
|
|
5
5
|
import type { BaseState, IBaseContract } from "./base/index.js";
|
|
6
6
|
import { ChainContractsRegister } from "./base/index.js";
|
|
7
7
|
import type { GearboxChain, NetworkType } from "./chain/chains.js";
|
|
@@ -295,4 +295,11 @@ export declare class OnchainSDK<const Plugins extends PluginsMap = {}> extends C
|
|
|
295
295
|
* when no withdrawal compressor is supported on it.
|
|
296
296
|
**/
|
|
297
297
|
get withdrawalCompressor(): IWithdrawalCompressorContract | undefined;
|
|
298
|
+
/**
|
|
299
|
+
* `RedemptionLogger` contract for the current chain, or `undefined` when
|
|
300
|
+
* it is not deployed on it. Created lazily on first access: the contract
|
|
301
|
+
* is resolved from the address provider, which is only available after
|
|
302
|
+
* the SDK is attached or hydrated.
|
|
303
|
+
**/
|
|
304
|
+
get redemptionLogger(): IRedemptionLoggerContract | undefined;
|
|
298
305
|
}
|
package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ export declare abstract class AbstractWithdrawalCompressorContract<abi extends A
|
|
|
78
78
|
/**
|
|
79
79
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
80
80
|
**/
|
|
81
|
-
getExternalAccountCurrentWithdrawals(
|
|
81
|
+
getExternalAccountCurrentWithdrawals(_account: Address, ..._withdrawalTokens: Address[]): Promise<CurrentWithdrawals>;
|
|
82
82
|
/**
|
|
83
83
|
* {@inheritDoc IWithdrawalCompressorContract.getWithdrawalStatus}
|
|
84
84
|
**/
|