@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
|
@@ -176,6 +176,84 @@ const iWithdrawalCompressorV313Abi = [
|
|
|
176
176
|
],
|
|
177
177
|
stateMutability: "view"
|
|
178
178
|
},
|
|
179
|
+
{
|
|
180
|
+
type: "function",
|
|
181
|
+
name: "getExternalAccountCurrentWithdrawals",
|
|
182
|
+
inputs: [
|
|
183
|
+
{
|
|
184
|
+
name: "withdrawalTokens",
|
|
185
|
+
type: "address[]",
|
|
186
|
+
internalType: "address[]"
|
|
187
|
+
},
|
|
188
|
+
{ name: "account", type: "address", internalType: "address" }
|
|
189
|
+
],
|
|
190
|
+
outputs: [
|
|
191
|
+
{
|
|
192
|
+
name: "",
|
|
193
|
+
type: "tuple[]",
|
|
194
|
+
internalType: "struct ClaimableWithdrawal[]",
|
|
195
|
+
components: [
|
|
196
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
197
|
+
{
|
|
198
|
+
name: "withdrawalPhantomToken",
|
|
199
|
+
type: "address",
|
|
200
|
+
internalType: "address"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: "withdrawalTokenSpent",
|
|
204
|
+
type: "uint256",
|
|
205
|
+
internalType: "uint256"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: "outputs",
|
|
209
|
+
type: "tuple[]",
|
|
210
|
+
internalType: "struct WithdrawalOutput[]",
|
|
211
|
+
components: [
|
|
212
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
213
|
+
{ name: "isDelayed", type: "bool", internalType: "bool" },
|
|
214
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "claimCalls",
|
|
219
|
+
type: "tuple[]",
|
|
220
|
+
internalType: "struct MultiCall[]",
|
|
221
|
+
components: [
|
|
222
|
+
{ name: "target", type: "address", internalType: "address" },
|
|
223
|
+
{ name: "callData", type: "bytes", internalType: "bytes" }
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
227
|
+
]
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: "",
|
|
231
|
+
type: "tuple[]",
|
|
232
|
+
internalType: "struct PendingWithdrawal[]",
|
|
233
|
+
components: [
|
|
234
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
235
|
+
{
|
|
236
|
+
name: "withdrawalPhantomToken",
|
|
237
|
+
type: "address",
|
|
238
|
+
internalType: "address"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "expectedOutputs",
|
|
242
|
+
type: "tuple[]",
|
|
243
|
+
internalType: "struct WithdrawalOutput[]",
|
|
244
|
+
components: [
|
|
245
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
246
|
+
{ name: "isDelayed", type: "bool", internalType: "bool" },
|
|
247
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
{ name: "claimableAt", type: "uint256", internalType: "uint256" },
|
|
251
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
stateMutability: "view"
|
|
256
|
+
},
|
|
179
257
|
{
|
|
180
258
|
type: "function",
|
|
181
259
|
name: "getWithdrawalStatus",
|
|
@@ -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 = {
|
|
@@ -191,7 +191,7 @@ class AbstractWithdrawalCompressorContract extends import_base.BaseContract {
|
|
|
191
191
|
/**
|
|
192
192
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
193
193
|
**/
|
|
194
|
-
async getExternalAccountCurrentWithdrawals(
|
|
194
|
+
async getExternalAccountCurrentWithdrawals(_account, ..._withdrawalTokens) {
|
|
195
195
|
this.#reportUnsupported("external account withdrawals");
|
|
196
196
|
return { claimable: [], pending: [] };
|
|
197
197
|
}
|
|
@@ -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
|
+
});
|
|
@@ -26,6 +26,86 @@ var import_AbstractWithdrawalCompressorContract = require("./AbstractWithdrawalC
|
|
|
26
26
|
var import_intent_codec = require("./intent-codec.js");
|
|
27
27
|
var import_types = require("./types.js");
|
|
28
28
|
const abi = import_IWithdrawalCompressorV313.iWithdrawalCompressorV313Abi;
|
|
29
|
+
const iExternalWithdrawalsBatchAbi = [
|
|
30
|
+
{
|
|
31
|
+
type: "function",
|
|
32
|
+
name: "getExternalAccountCurrentWithdrawals",
|
|
33
|
+
inputs: [
|
|
34
|
+
{
|
|
35
|
+
name: "withdrawalTokens",
|
|
36
|
+
type: "address[]",
|
|
37
|
+
internalType: "address[]"
|
|
38
|
+
},
|
|
39
|
+
{ name: "account", type: "address", internalType: "address" }
|
|
40
|
+
],
|
|
41
|
+
outputs: [
|
|
42
|
+
{
|
|
43
|
+
name: "",
|
|
44
|
+
type: "tuple[]",
|
|
45
|
+
internalType: "struct ClaimableWithdrawal[]",
|
|
46
|
+
components: [
|
|
47
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
48
|
+
{
|
|
49
|
+
name: "withdrawalPhantomToken",
|
|
50
|
+
type: "address",
|
|
51
|
+
internalType: "address"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "withdrawalTokenSpent",
|
|
55
|
+
type: "uint256",
|
|
56
|
+
internalType: "uint256"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "outputs",
|
|
60
|
+
type: "tuple[]",
|
|
61
|
+
internalType: "struct WithdrawalOutput[]",
|
|
62
|
+
components: [
|
|
63
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
64
|
+
{ name: "isDelayed", type: "bool", internalType: "bool" },
|
|
65
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "claimCalls",
|
|
70
|
+
type: "tuple[]",
|
|
71
|
+
internalType: "struct MultiCall[]",
|
|
72
|
+
components: [
|
|
73
|
+
{ name: "target", type: "address", internalType: "address" },
|
|
74
|
+
{ name: "callData", type: "bytes", internalType: "bytes" }
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "",
|
|
82
|
+
type: "tuple[]",
|
|
83
|
+
internalType: "struct PendingWithdrawal[]",
|
|
84
|
+
components: [
|
|
85
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
86
|
+
{
|
|
87
|
+
name: "withdrawalPhantomToken",
|
|
88
|
+
type: "address",
|
|
89
|
+
internalType: "address"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "expectedOutputs",
|
|
93
|
+
type: "tuple[]",
|
|
94
|
+
internalType: "struct WithdrawalOutput[]",
|
|
95
|
+
components: [
|
|
96
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
97
|
+
{ name: "isDelayed", type: "bool", internalType: "bool" },
|
|
98
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{ name: "claimableAt", type: "uint256", internalType: "uint256" },
|
|
102
|
+
{ name: "extraData", type: "bytes", internalType: "bytes" }
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
stateMutability: "view"
|
|
107
|
+
}
|
|
108
|
+
];
|
|
29
109
|
const iWithdrawalStatusBatchAbi = [
|
|
30
110
|
{
|
|
31
111
|
type: "function",
|
|
@@ -51,11 +131,16 @@ class WithdrawalCompressorV313Contract extends import_AbstractWithdrawalCompress
|
|
|
51
131
|
/**
|
|
52
132
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
53
133
|
**/
|
|
54
|
-
async getExternalAccountCurrentWithdrawals(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
]
|
|
134
|
+
async getExternalAccountCurrentWithdrawals(account, ...withdrawalTokens) {
|
|
135
|
+
if (withdrawalTokens.length === 0) {
|
|
136
|
+
return { claimable: [], pending: [] };
|
|
137
|
+
}
|
|
138
|
+
const [claimable, pending] = await this.client.readContract({
|
|
139
|
+
address: this.address,
|
|
140
|
+
abi: iExternalWithdrawalsBatchAbi,
|
|
141
|
+
functionName: "getExternalAccountCurrentWithdrawals",
|
|
142
|
+
args: [withdrawalTokens, account]
|
|
143
|
+
});
|
|
59
144
|
return {
|
|
60
145
|
claimable: claimable.map((w) => (0, import_AbstractWithdrawalCompressorContract.toClaimableWithdrawal)(w, void 0)),
|
|
61
146
|
pending: pending.map((w) => (0, import_AbstractWithdrawalCompressorContract.toPendingWithdrawal)(w, void 0)).sort((a, b) => a.claimableAt < b.claimableAt ? -1 : 1)
|