@eulerxyz/euler-v2-sdk 2.0.0 → 2.1.0

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.
Files changed (84) hide show
  1. package/dist/src/plugins/pyth/pythPlugin.d.ts +13 -3
  2. package/dist/src/plugins/pyth/pythPlugin.d.ts.map +1 -1
  3. package/dist/src/plugins/pyth/pythPlugin.js +195 -59
  4. package/dist/src/plugins/pyth/pythPlugin.js.map +1 -1
  5. package/dist/src/plugins/types.d.ts +10 -1
  6. package/dist/src/plugins/types.d.ts.map +1 -1
  7. package/dist/src/plugins/types.js +24 -0
  8. package/dist/src/plugins/types.js.map +1 -1
  9. package/dist/src/sdk/sdk.d.ts +4 -2
  10. package/dist/src/sdk/sdk.d.ts.map +1 -1
  11. package/dist/src/sdk/sdk.js +7 -21
  12. package/dist/src/sdk/sdk.js.map +1 -1
  13. package/dist/src/services/executionService/encode.d.ts.map +1 -1
  14. package/dist/src/services/executionService/encode.js +3 -0
  15. package/dist/src/services/executionService/encode.js.map +1 -1
  16. package/dist/src/services/executionService/executionService.d.ts +70 -9
  17. package/dist/src/services/executionService/executionService.d.ts.map +1 -1
  18. package/dist/src/services/executionService/executionService.js +79 -25
  19. package/dist/src/services/executionService/executionService.js.map +1 -1
  20. package/dist/src/services/executionService/executionServiceTypes.d.ts +21 -1
  21. package/dist/src/services/executionService/executionServiceTypes.d.ts.map +1 -1
  22. package/dist/src/services/executionService/executionServiceTypes.js.map +1 -1
  23. package/dist/src/services/executionService/index.d.ts +2 -1
  24. package/dist/src/services/executionService/index.d.ts.map +1 -1
  25. package/dist/src/services/executionService/index.js +1 -0
  26. package/dist/src/services/executionService/index.js.map +1 -1
  27. package/dist/src/services/executionService/materializedExecution.d.ts +153 -0
  28. package/dist/src/services/executionService/materializedExecution.d.ts.map +1 -0
  29. package/dist/src/services/executionService/materializedExecution.js +475 -0
  30. package/dist/src/services/executionService/materializedExecution.js.map +1 -0
  31. package/dist/src/services/executionService/migrationAuthorization.d.ts +10 -0
  32. package/dist/src/services/executionService/migrationAuthorization.d.ts.map +1 -0
  33. package/dist/src/services/executionService/migrationAuthorization.js +142 -0
  34. package/dist/src/services/executionService/migrationAuthorization.js.map +1 -0
  35. package/dist/src/services/executionService/simulate.d.ts.map +1 -1
  36. package/dist/src/services/executionService/simulate.js +53 -1
  37. package/dist/src/services/executionService/simulate.js.map +1 -1
  38. package/dist/src/services/feeFlowService/feeFlowService.d.ts +4 -1
  39. package/dist/src/services/feeFlowService/feeFlowService.d.ts.map +1 -1
  40. package/dist/src/services/feeFlowService/feeFlowService.js +100 -39
  41. package/dist/src/services/feeFlowService/feeFlowService.js.map +1 -1
  42. package/dist/src/services/feeFlowService/feeFlowServiceTypes.d.ts +13 -0
  43. package/dist/src/services/feeFlowService/feeFlowServiceTypes.d.ts.map +1 -1
  44. package/dist/src/services/feeFlowService/index.d.ts +2 -2
  45. package/dist/src/services/feeFlowService/index.d.ts.map +1 -1
  46. package/dist/src/services/feeFlowService/index.js +1 -1
  47. package/dist/src/services/feeFlowService/index.js.map +1 -1
  48. package/dist/src/services/positionMigrationService/connectors/aave/aaveConnectorTypes.d.ts +2 -0
  49. package/dist/src/services/positionMigrationService/connectors/aave/aaveConnectorTypes.d.ts.map +1 -1
  50. package/dist/src/services/positionMigrationService/connectors/metamorpho/metamorphoConnectorTypes.d.ts +1 -0
  51. package/dist/src/services/positionMigrationService/connectors/metamorpho/metamorphoConnectorTypes.d.ts.map +1 -1
  52. package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnector.d.ts +4 -4
  53. package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnector.d.ts.map +1 -1
  54. package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnector.js +7 -10
  55. package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnector.js.map +1 -1
  56. package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnectorTypes.d.ts +5 -1
  57. package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnectorTypes.d.ts.map +1 -1
  58. package/dist/src/services/positionMigrationService/index.d.ts +1 -1
  59. package/dist/src/services/positionMigrationService/index.d.ts.map +1 -1
  60. package/dist/src/services/positionMigrationService/index.js.map +1 -1
  61. package/dist/src/services/positionMigrationService/positionMigrationService.d.ts +7 -1
  62. package/dist/src/services/positionMigrationService/positionMigrationService.d.ts.map +1 -1
  63. package/dist/src/services/positionMigrationService/positionMigrationService.js +188 -3
  64. package/dist/src/services/positionMigrationService/positionMigrationService.js.map +1 -1
  65. package/dist/src/services/positionMigrationService/positionMigrationServiceTypes.d.ts +49 -15
  66. package/dist/src/services/positionMigrationService/positionMigrationServiceTypes.d.ts.map +1 -1
  67. package/dist/src/services/rewardsService/adapters/rewardsDirectAdapter/rewardsDirectAdapter.d.ts.map +1 -1
  68. package/dist/src/services/rewardsService/adapters/rewardsDirectAdapter/rewardsDirectAdapter.js +7 -1
  69. package/dist/src/services/rewardsService/adapters/rewardsDirectAdapter/rewardsDirectAdapter.js.map +1 -1
  70. package/dist/src/services/rewardsService/adapters/rewardsV3Adapter/rewardsV3Adapter.d.ts.map +1 -1
  71. package/dist/src/services/rewardsService/adapters/rewardsV3Adapter/rewardsV3Adapter.js +3 -0
  72. package/dist/src/services/rewardsService/adapters/rewardsV3Adapter/rewardsV3Adapter.js.map +1 -1
  73. package/dist/src/services/rewardsService/adapters/rewardsV3Adapter/rewardsV3AdapterTypes.d.ts +2 -0
  74. package/dist/src/services/rewardsService/adapters/rewardsV3Adapter/rewardsV3AdapterTypes.d.ts.map +1 -1
  75. package/dist/src/services/rewardsService/rewardsService.d.ts.map +1 -1
  76. package/dist/src/services/rewardsService/rewardsService.js +37 -6
  77. package/dist/src/services/rewardsService/rewardsService.js.map +1 -1
  78. package/dist/src/services/rewardsService/rewardsServiceTypes.d.ts +4 -0
  79. package/dist/src/services/rewardsService/rewardsServiceTypes.d.ts.map +1 -1
  80. package/dist/src/utils/healthCheckSets.d.ts +9 -2
  81. package/dist/src/utils/healthCheckSets.d.ts.map +1 -1
  82. package/dist/src/utils/healthCheckSets.js +52 -14
  83. package/dist/src/utils/healthCheckSets.js.map +1 -1
  84. package/package.json +1 -1
@@ -0,0 +1,475 @@
1
+ import { decodeFunctionData, encodeFunctionData, encodePacked, getAddress, hashTypedData, keccak256, } from "viem";
2
+ import { decodeSmartContractErrors, } from "../../utils/decodeSmartContractErrors.js";
3
+ import { ethereumVaultConnectorAbi } from "./abis/ethereumVaultConnectorAbi.js";
4
+ import { assertNoCowSwapPlanItems, flattenBatchEntries, } from "./executionServiceTypes.js";
5
+ const PLACEHOLDER_SIGNATURE = `0x${"00".repeat(65)}`;
6
+ const PERMIT2_ALLOWANCE_ABI = [
7
+ {
8
+ name: "allowance",
9
+ type: "function",
10
+ stateMutability: "view",
11
+ inputs: [
12
+ { name: "owner", type: "address" },
13
+ { name: "token", type: "address" },
14
+ { name: "spender", type: "address" },
15
+ ],
16
+ outputs: [
17
+ { name: "amount", type: "uint160" },
18
+ { name: "expiration", type: "uint48" },
19
+ { name: "nonce", type: "uint48" },
20
+ ],
21
+ },
22
+ ];
23
+ export class MaterializedExecutionError extends Error {
24
+ decodedErrors;
25
+ originalError;
26
+ constructor(message, originalError, decodedErrors) {
27
+ super(message);
28
+ this.name = "MaterializedExecutionError";
29
+ this.originalError = originalError;
30
+ this.decodedErrors = decodedErrors;
31
+ }
32
+ }
33
+ export class MaterializedTransactionRevertedError extends Error {
34
+ hash;
35
+ constructor(hash) {
36
+ super(`Transaction ${hash} reverted`);
37
+ this.name = "MaterializedTransactionRevertedError";
38
+ this.hash = hash;
39
+ }
40
+ }
41
+ function ownerOf(account) {
42
+ return getAddress(typeof account === "string" ? account : account.owner);
43
+ }
44
+ function deepFreeze(value) {
45
+ if (value && typeof value === "object" && !Object.isFrozen(value)) {
46
+ for (const child of Object.values(value))
47
+ deepFreeze(child);
48
+ Object.freeze(value);
49
+ }
50
+ return value;
51
+ }
52
+ function cloneTypedData(typedData) {
53
+ return {
54
+ domain: { ...typedData.domain },
55
+ types: {
56
+ PermitDetails: [
57
+ { ...typedData.types.PermitDetails[0] },
58
+ { ...typedData.types.PermitDetails[1] },
59
+ { ...typedData.types.PermitDetails[2] },
60
+ { ...typedData.types.PermitDetails[3] },
61
+ ],
62
+ PermitSingle: [
63
+ { ...typedData.types.PermitSingle[0] },
64
+ { ...typedData.types.PermitSingle[1] },
65
+ { ...typedData.types.PermitSingle[2] },
66
+ ],
67
+ },
68
+ primaryType: "PermitSingle",
69
+ message: {
70
+ details: { ...typedData.message.details },
71
+ spender: typedData.message.spender,
72
+ sigDeadline: typedData.message.sigDeadline,
73
+ },
74
+ };
75
+ }
76
+ function inputKey(planItemIndex, resolvedIndex) {
77
+ return `${planItemIndex}:${resolvedIndex}`;
78
+ }
79
+ function assertMaterializationInput(input) {
80
+ if (!Number.isSafeInteger(input.planItemIndex) ||
81
+ input.planItemIndex < 0 ||
82
+ !Number.isSafeInteger(input.resolvedIndex) ||
83
+ input.resolvedIndex < 0) {
84
+ throw new Error("Permit2 materialization coordinates are invalid");
85
+ }
86
+ if (!Number.isSafeInteger(input.nonce) || input.nonce < 0) {
87
+ throw new Error("Permit2 materialization nonce is invalid");
88
+ }
89
+ if (input.sigDeadline <= 0n) {
90
+ throw new Error("Permit2 materialization signature deadline is invalid");
91
+ }
92
+ if (!Number.isSafeInteger(input.expiration) || input.expiration <= 0) {
93
+ throw new Error("Permit2 materialization expiration is invalid");
94
+ }
95
+ }
96
+ function decodeBatchItems(data) {
97
+ const decoded = decodeFunctionData({
98
+ abi: ethereumVaultConnectorAbi,
99
+ data,
100
+ });
101
+ if (decoded.functionName !== "batch") {
102
+ throw new Error("Materialized EVC request does not encode batch()");
103
+ }
104
+ return decoded.args[0].map((item) => ({
105
+ targetContract: getAddress(item.targetContract),
106
+ onBehalfOfAccount: getAddress(item.onBehalfOfAccount),
107
+ value: item.value,
108
+ data: item.data,
109
+ }));
110
+ }
111
+ function makeSafeCalls(requests) {
112
+ return requests.map(({ to, data, value }) => ({ to, data, value }));
113
+ }
114
+ /**
115
+ * Purely compose a prepared plan into deterministic transaction templates.
116
+ * All live values used by composition are explicit inputs. Permit2 signatures
117
+ * are represented by typed signature slots and a fixed placeholder.
118
+ */
119
+ export function materializeExecution(encoder, args) {
120
+ const { prepared, inputs } = args;
121
+ assertNoCowSwapPlanItems(prepared.plan, "materializeExecution");
122
+ const from = ownerOf(prepared.account);
123
+ const evcAddress = getAddress(inputs.evcAddress);
124
+ const permitInputs = new Map();
125
+ for (const input of inputs.permit2) {
126
+ assertMaterializationInput(input);
127
+ const key = inputKey(input.planItemIndex, input.resolvedIndex);
128
+ if (permitInputs.has(key)) {
129
+ throw new Error(`Duplicate Permit2 materialization input ${key}`);
130
+ }
131
+ permitInputs.set(key, input);
132
+ }
133
+ const requests = [];
134
+ const signatureSlots = [];
135
+ const pendingPermitItems = [];
136
+ const consumedPermitInputs = new Set();
137
+ for (const [planItemIndex, item] of prepared.plan.entries()) {
138
+ if (item.type === "cowSwap") {
139
+ throw new Error("ExecutionService.materializeExecution does not support CoW swap plans");
140
+ }
141
+ if (item.type === "requiredApproval") {
142
+ if (!item.resolved) {
143
+ throw new Error(`Approval at plan item ${planItemIndex} is unresolved`);
144
+ }
145
+ for (const [resolvedIndex, resolved] of item.resolved.entries()) {
146
+ if (resolved.type === "approve") {
147
+ requests.push({
148
+ requestIndex: requests.length,
149
+ sourcePlanItemIndex: planItemIndex,
150
+ kind: "approval",
151
+ chainId: prepared.chainId,
152
+ from,
153
+ to: getAddress(resolved.token),
154
+ data: resolved.data,
155
+ value: 0n,
156
+ });
157
+ continue;
158
+ }
159
+ const key = inputKey(planItemIndex, resolvedIndex);
160
+ const input = permitInputs.get(key);
161
+ if (!input) {
162
+ throw new Error(`Permit2 materialization input ${key} is missing`);
163
+ }
164
+ consumedPermitInputs.add(key);
165
+ const typedData = cloneTypedData(encoder.getPermit2TypedData({
166
+ chainId: prepared.chainId,
167
+ token: getAddress(resolved.token),
168
+ amount: resolved.amount,
169
+ spender: getAddress(resolved.spender),
170
+ nonce: input.nonce,
171
+ sigDeadline: input.sigDeadline,
172
+ expiration: input.expiration,
173
+ }));
174
+ const typedDataHash = hashTypedData(typedData);
175
+ pendingPermitItems.push({
176
+ planItemIndex,
177
+ resolvedIndex,
178
+ item: encoder.encodePermit2Call({
179
+ chainId: prepared.chainId,
180
+ owner: getAddress(resolved.owner),
181
+ message: typedData.message,
182
+ signature: PLACEHOLDER_SIGNATURE,
183
+ }),
184
+ slot: {
185
+ kind: "permit2",
186
+ signer: getAddress(resolved.owner),
187
+ chainId: prepared.chainId,
188
+ planItemIndex,
189
+ resolvedIndex,
190
+ nonce: input.nonce,
191
+ validUntil: input.sigDeadline,
192
+ typedDataHash,
193
+ typedData,
194
+ },
195
+ });
196
+ }
197
+ continue;
198
+ }
199
+ if (item.type === "evcBatch") {
200
+ const batchItems = [
201
+ ...pendingPermitItems.map((pending) => pending.item),
202
+ ...flattenBatchEntries(item.items),
203
+ ];
204
+ const requestIndex = requests.length;
205
+ requests.push({
206
+ requestIndex,
207
+ sourcePlanItemIndex: planItemIndex,
208
+ kind: "evcBatch",
209
+ chainId: prepared.chainId,
210
+ from,
211
+ to: evcAddress,
212
+ data: encoder.encodeBatch(batchItems),
213
+ value: batchItems.reduce((sum, batchItem) => sum + batchItem.value, 0n),
214
+ });
215
+ for (const [batchItemIndex, pending] of pendingPermitItems.entries()) {
216
+ const slotId = keccak256(encodePacked(["bytes32", "uint256", "uint256", "uint256", "uint256"], [
217
+ pending.slot.typedDataHash,
218
+ BigInt(pending.planItemIndex),
219
+ BigInt(pending.resolvedIndex),
220
+ BigInt(requestIndex),
221
+ BigInt(batchItemIndex),
222
+ ]));
223
+ signatureSlots.push({
224
+ ...pending.slot,
225
+ slotId,
226
+ insertion: { requestIndex, batchItemIndex },
227
+ });
228
+ }
229
+ pendingPermitItems.length = 0;
230
+ continue;
231
+ }
232
+ if (pendingPermitItems.length > 0) {
233
+ throw new Error("Permit2 signature has no following EVC batch insertion point");
234
+ }
235
+ if (item.chainId !== prepared.chainId) {
236
+ throw new Error(`Plan item targets chain ${item.chainId}, but materialization targets chain ${prepared.chainId}`);
237
+ }
238
+ requests.push({
239
+ requestIndex: requests.length,
240
+ sourcePlanItemIndex: planItemIndex,
241
+ kind: "contractCall",
242
+ chainId: prepared.chainId,
243
+ from,
244
+ to: getAddress(item.to),
245
+ data: encodeFunctionData({
246
+ abi: item.abi,
247
+ functionName: item.functionName,
248
+ args: item.args,
249
+ }),
250
+ value: item.value,
251
+ });
252
+ }
253
+ if (pendingPermitItems.length > 0) {
254
+ throw new Error("Permit2 signature has no following EVC batch insertion point");
255
+ }
256
+ if (consumedPermitInputs.size !== permitInputs.size) {
257
+ const unused = [...permitInputs.keys()].filter((key) => !consumedPermitInputs.has(key));
258
+ throw new Error(`Unused Permit2 materialization inputs: ${unused.join(", ")}`);
259
+ }
260
+ return deepFreeze({
261
+ __materialized: true,
262
+ chainId: prepared.chainId,
263
+ from,
264
+ evcAddress,
265
+ requests,
266
+ signatureSlots,
267
+ safeCalls: makeSafeCalls(requests),
268
+ });
269
+ }
270
+ /** Purely insert the exact provided signatures without changing any other byte. */
271
+ export function finalizeMaterializedExecution(encoder, materialized, signatures) {
272
+ if (signatures.length !== materialized.signatureSlots.length) {
273
+ throw new Error("Signature values do not exactly match materialized slots");
274
+ }
275
+ const signatureById = new Map(signatures.map((value) => [value.slotId, value]));
276
+ if (signatureById.size !== signatures.length) {
277
+ throw new Error("Duplicate materialized signature value");
278
+ }
279
+ for (const slot of materialized.signatureSlots) {
280
+ if (!signatureById.has(slot.slotId)) {
281
+ throw new Error(`Materialized signature ${slot.slotId} is missing`);
282
+ }
283
+ if (hashTypedData(slot.typedData) !== slot.typedDataHash) {
284
+ throw new Error(`Materialized signature slot ${slot.slotId} was mutated`);
285
+ }
286
+ }
287
+ const requests = materialized.requests.map((request) => ({ ...request }));
288
+ for (const [requestIndex, request] of requests.entries()) {
289
+ const slots = materialized.signatureSlots.filter((slot) => slot.insertion.requestIndex === requestIndex);
290
+ if (slots.length === 0)
291
+ continue;
292
+ if (request.kind !== "evcBatch") {
293
+ throw new Error("Materialized signature points outside an EVC batch");
294
+ }
295
+ const batchItems = decodeBatchItems(request.data);
296
+ if (encoder.encodeBatch(batchItems) !== request.data) {
297
+ throw new Error("Materialized EVC request is not canonically encoded");
298
+ }
299
+ for (const slot of slots) {
300
+ const signature = signatureById.get(slot.slotId);
301
+ const reviewedItem = batchItems[slot.insertion.batchItemIndex];
302
+ if (!signature || !reviewedItem) {
303
+ throw new Error("Materialized signature insertion point is invalid");
304
+ }
305
+ const expectedPlaceholder = encoder.encodePermit2Call({
306
+ chainId: slot.chainId,
307
+ owner: slot.signer,
308
+ message: slot.typedData.message,
309
+ signature: PLACEHOLDER_SIGNATURE,
310
+ });
311
+ if (reviewedItem.targetContract !== expectedPlaceholder.targetContract ||
312
+ reviewedItem.onBehalfOfAccount !== expectedPlaceholder.onBehalfOfAccount ||
313
+ reviewedItem.value !== expectedPlaceholder.value ||
314
+ reviewedItem.data !== expectedPlaceholder.data) {
315
+ throw new Error("Materialized Permit2 placeholder was mutated");
316
+ }
317
+ batchItems[slot.insertion.batchItemIndex] = encoder.encodePermit2Call({
318
+ chainId: slot.chainId,
319
+ owner: slot.signer,
320
+ message: slot.typedData.message,
321
+ signature: signature.signature,
322
+ });
323
+ }
324
+ request.data = encoder.encodeBatch(batchItems);
325
+ request.value = batchItems.reduce((sum, item) => sum + item.value, 0n);
326
+ }
327
+ return deepFreeze({
328
+ __materialized: true,
329
+ __finalized: true,
330
+ chainId: materialized.chainId,
331
+ from: materialized.from,
332
+ evcAddress: materialized.evcAddress,
333
+ requests,
334
+ signatureSlots: materialized.signatureSlots.map((slot) => ({ ...slot })),
335
+ signatureValues: signatures.map((value) => ({ ...value })),
336
+ safeCalls: makeSafeCalls(requests),
337
+ });
338
+ }
339
+ async function executeWithDecodedErrors(fn) {
340
+ try {
341
+ return await fn();
342
+ }
343
+ catch (error) {
344
+ if (error instanceof MaterializedTransactionRevertedError)
345
+ throw error;
346
+ const decoded = await decodeSmartContractErrors(error);
347
+ if (decoded.length > 0) {
348
+ throw new MaterializedExecutionError("Materialized execution failed", error, decoded);
349
+ }
350
+ throw error;
351
+ }
352
+ }
353
+ function permit2Address(slot) {
354
+ const verifyingContract = slot.typedData.domain.verifyingContract;
355
+ if (typeof verifyingContract !== "string") {
356
+ throw new Error("Materialized Permit2 domain has no verifying contract");
357
+ }
358
+ return getAddress(verifyingContract);
359
+ }
360
+ async function assertPinnedPermit2Nonce(providerService, slot) {
361
+ const publicClient = providerService.getProvider(slot.chainId);
362
+ const allowance = (await publicClient.readContract({
363
+ address: permit2Address(slot),
364
+ abi: PERMIT2_ALLOWANCE_ABI,
365
+ functionName: "allowance",
366
+ args: [
367
+ slot.signer,
368
+ slot.typedData.message.details.token,
369
+ slot.typedData.message.spender,
370
+ ],
371
+ }));
372
+ if (Number(allowance[2]) !== slot.nonce) {
373
+ throw new Error("Permit2 nonce changed after materialization");
374
+ }
375
+ }
376
+ /**
377
+ * Dispatch static prerequisites that precede the first signed batch, collect
378
+ * the declared signatures, finalize a new immutable request vector, then
379
+ * dispatch its remaining exact requests. No transaction is recomposed during
380
+ * dispatch. A supplied FinalizedMaterializedExecution is not authenticated by
381
+ * the SDK; this function assumes the application already authenticated the
382
+ * complete finalized input against its accepted review digest.
383
+ */
384
+ export async function executeMaterialized(encoder, providerService, materialized, options) {
385
+ const publicClient = providerService.getProvider(materialized.chainId);
386
+ const alreadyFinalized = "__finalized" in materialized && materialized.__finalized === true;
387
+ const firstSignedRequestIndex = materialized.signatureSlots.length
388
+ ? Math.min(...materialized.signatureSlots.map((slot) => slot.insertion.requestIndex))
389
+ : 0;
390
+ let execution = alreadyFinalized
391
+ ? materialized
392
+ : undefined;
393
+ const hashes = [];
394
+ const receipts = [];
395
+ const dispatchRequest = async (request, index) => {
396
+ if (options.revalidate?.permit2NonceMustEqualPinned) {
397
+ for (const slot of materialized.signatureSlots) {
398
+ if (slot.insertion.requestIndex === index) {
399
+ await assertPinnedPermit2Nonce(providerService, slot);
400
+ }
401
+ }
402
+ }
403
+ await options.onBeforeStep?.(request, index);
404
+ options.onProgress?.({
405
+ completed: hashes.length,
406
+ total: materialized.requests.length,
407
+ request,
408
+ status: "transaction",
409
+ });
410
+ const hash = await options.sendTransaction(request);
411
+ hashes.push(hash);
412
+ await options.onTransactionHash?.(request, index, hash);
413
+ const receipt = await publicClient.waitForTransactionReceipt({ hash });
414
+ if (receipt.status !== "success") {
415
+ throw new MaterializedTransactionRevertedError(hash);
416
+ }
417
+ receipts.push(receipt);
418
+ await options.onAfterStep?.(request, index, hash, receipt);
419
+ options.onProgress?.({
420
+ completed: hashes.length,
421
+ total: materialized.requests.length,
422
+ request,
423
+ status: "transaction",
424
+ hash,
425
+ });
426
+ };
427
+ await executeWithDecodedErrors(async () => {
428
+ let nextRequestIndex = 0;
429
+ if (options.revalidate?.permit2NonceMustEqualPinned &&
430
+ materialized.signatureSlots.length > 0 &&
431
+ (alreadyFinalized || firstSignedRequestIndex > 0)) {
432
+ for (const slot of materialized.signatureSlots) {
433
+ await assertPinnedPermit2Nonce(providerService, slot);
434
+ }
435
+ }
436
+ if (!alreadyFinalized) {
437
+ for (; nextRequestIndex < firstSignedRequestIndex; nextRequestIndex++) {
438
+ await dispatchRequest(materialized.requests[nextRequestIndex], nextRequestIndex);
439
+ }
440
+ const signatures = [];
441
+ options.onProgress?.({
442
+ completed: hashes.length,
443
+ total: materialized.requests.length,
444
+ status: "signature",
445
+ });
446
+ for (const [index, slot] of materialized.signatureSlots.entries()) {
447
+ if (!options.signTypedData) {
448
+ throw new Error("ExecutionService.executeMaterialized requires signTypedData when Permit2 approval is needed");
449
+ }
450
+ if (options.revalidate?.permit2NonceMustEqualPinned) {
451
+ await assertPinnedPermit2Nonce(providerService, slot);
452
+ }
453
+ await options.onBeforeSignature?.(slot, index);
454
+ const signature = await options.signTypedData(slot.typedData);
455
+ signatures.push({ slotId: slot.slotId, signature });
456
+ }
457
+ execution = finalizeMaterializedExecution(encoder, materialized, signatures);
458
+ }
459
+ if (!execution)
460
+ throw new Error("Materialized execution was not finalized");
461
+ await options.onFinalized?.(execution);
462
+ for (; nextRequestIndex < execution.requests.length; nextRequestIndex++) {
463
+ await dispatchRequest(execution.requests[nextRequestIndex], nextRequestIndex);
464
+ }
465
+ });
466
+ if (!execution)
467
+ throw new Error("Materialized execution was not finalized");
468
+ options.onProgress?.({
469
+ completed: execution.requests.length,
470
+ total: execution.requests.length,
471
+ status: "completed",
472
+ });
473
+ return { execution, hashes, receipts };
474
+ }
475
+ //# sourceMappingURL=materializedExecution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"materializedExecution.js","sourceRoot":"","sources":["../../../../src/services/executionService/materializedExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,aAAa,EACb,SAAS,GAIT,MAAM,MAAM,CAAC;AAEd,OAAO,EAEN,yBAAyB,GACzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAMhF,OAAO,EACN,wBAAwB,EACxB,mBAAmB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,qBAAqB,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAS,CAAC;AAE5D,MAAM,qBAAqB,GAAG;IAC7B;QACC,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE;YACP,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE;YACR,EAAE,IAAI,EAAE,QAAQ,EAAE,IA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IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC5E,OAAO,CAAC,UAAU,EAAE,CAAC;QACpB,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,MAAM;QACpC,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC,MAAM;QAChC,MAAM,EAAE,WAAW;KACnB,CAAC,CAAC;IACH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACxC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type Hash } from "viem";
2
+ import type { EncodeMigrationAuthorizationCallArgs, EVCBatchItem } from "./executionServiceTypes.js";
3
+ export declare function hashMigrationAuthorizationItem(item: EVCBatchItem): Hash;
4
+ /**
5
+ * Replace only the declared signature fields in a reviewed built-in migration
6
+ * authorization item. The versioned path seals the EIP-712 hash and the
7
+ * complete stub-signed batch item.
8
+ */
9
+ export declare function encodeMigrationAuthorizationCall(args: EncodeMigrationAuthorizationCallArgs): EVCBatchItem;
10
+ //# sourceMappingURL=migrationAuthorization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrationAuthorization.d.ts","sourceRoot":"","sources":["../../../../src/services/executionService/migrationAuthorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,KAAK,IAAI,EAET,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACX,oCAAoC,EACpC,YAAY,EACZ,MAAM,4BAA4B,CAAC;AAwBpC,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAiBvE;AA2ED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC/C,IAAI,EAAE,oCAAoC,GACxC,YAAY,CAkEd"}
@@ -0,0 +1,142 @@
1
+ import { decodeFunctionData, encodeAbiParameters, encodeFunctionData, getAddress, keccak256, } from "viem";
2
+ import { aaveATokenAbi, aaveDebtTokenAbi, } from "../positionMigrationService/connectors/aave/abis/aaveV3Abi.js";
3
+ import { metamorphoAbi } from "../positionMigrationService/connectors/metamorpho/abis/metamorphoAbi.js";
4
+ import { morphoBlueAbi } from "../positionMigrationService/connectors/morpho/abis/morphoBlueAbi.js";
5
+ const EXPECTED_ARGUMENT_PATHS = {
6
+ "aave-permit": [4, 5, 6],
7
+ "aave-delegation": [4, 5, 6],
8
+ "metamorpho-permit": [4, 5, 6],
9
+ "morpho-authorization": [1, 0, 1, 2],
10
+ };
11
+ export function hashMigrationAuthorizationItem(item) {
12
+ return keccak256(encodeAbiParameters([
13
+ { type: "address" },
14
+ { type: "address" },
15
+ { type: "uint256" },
16
+ { type: "bytes" },
17
+ ], [
18
+ getAddress(item.targetContract),
19
+ getAddress(item.onBehalfOfAccount),
20
+ item.value,
21
+ item.data,
22
+ ]));
23
+ }
24
+ function splitSignature(signature) {
25
+ if (signature.length !== 132) {
26
+ throw new Error("Migration authorization signature must be 65 bytes");
27
+ }
28
+ const recoveryId = Number.parseInt(signature.slice(130, 132), 16);
29
+ const v = recoveryId === 0 || recoveryId === 1 ? recoveryId + 27 : recoveryId;
30
+ if (v !== 27 && v !== 28) {
31
+ throw new Error("Migration authorization signature recovery ID is invalid");
32
+ }
33
+ return {
34
+ v,
35
+ r: signature.slice(0, 66),
36
+ s: `0x${signature.slice(66, 130)}`,
37
+ };
38
+ }
39
+ function parsePath(args) {
40
+ const [version, rawKind, sealedTypedDataHash, sealedReviewedItemHash, ...argumentPath] = args.abiArgumentPath;
41
+ if (version !== "migration-signature-v2") {
42
+ throw new Error("Unsupported migration authorization insertion version");
43
+ }
44
+ if (rawKind !== "aave-permit" &&
45
+ rawKind !== "aave-delegation" &&
46
+ rawKind !== "metamorpho-permit" &&
47
+ rawKind !== "morpho-authorization") {
48
+ throw new Error("Unsupported migration authorization insertion kind");
49
+ }
50
+ if (sealedTypedDataHash !== args.typedDataHash) {
51
+ throw new Error("Migration authorization typed-data hash changed");
52
+ }
53
+ if (sealedReviewedItemHash !== hashMigrationAuthorizationItem(args.reviewedItem)) {
54
+ throw new Error("Migration authorization reviewed item changed");
55
+ }
56
+ const expected = EXPECTED_ARGUMENT_PATHS[rawKind];
57
+ if (argumentPath.length !== expected.length ||
58
+ argumentPath.some((value, index) => value !== expected[index])) {
59
+ throw new Error("Migration authorization ABI argument path changed");
60
+ }
61
+ return rawKind;
62
+ }
63
+ function assertReviewedBinding(args) {
64
+ if (args.chainId <= 0 || !Number.isSafeInteger(args.chainId)) {
65
+ throw new Error("Migration authorization chain ID is invalid");
66
+ }
67
+ if (getAddress(args.reviewedItem.onBehalfOfAccount) !== getAddress(args.signer)) {
68
+ throw new Error("Migration authorization signer changed");
69
+ }
70
+ if (args.reviewedItem.value !== 0n) {
71
+ throw new Error("Migration authorization item must not transfer native value");
72
+ }
73
+ }
74
+ /**
75
+ * Replace only the declared signature fields in a reviewed built-in migration
76
+ * authorization item. The versioned path seals the EIP-712 hash and the
77
+ * complete stub-signed batch item.
78
+ */
79
+ export function encodeMigrationAuthorizationCall(args) {
80
+ assertReviewedBinding(args);
81
+ const kind = parsePath(args);
82
+ const signature = splitSignature(args.signature);
83
+ let data;
84
+ if (kind === "aave-permit" || kind === "metamorpho-permit") {
85
+ const abi = kind === "aave-permit" ? aaveATokenAbi : metamorphoAbi;
86
+ const decoded = decodeFunctionData({ abi, data: args.reviewedItem.data });
87
+ if (decoded.functionName !== "permit") {
88
+ throw new Error("Reviewed migration authorization is not permit()");
89
+ }
90
+ data = encodeFunctionData({
91
+ abi,
92
+ functionName: "permit",
93
+ args: [
94
+ decoded.args[0],
95
+ decoded.args[1],
96
+ decoded.args[2],
97
+ decoded.args[3],
98
+ signature.v,
99
+ signature.r,
100
+ signature.s,
101
+ ],
102
+ });
103
+ }
104
+ else if (kind === "aave-delegation") {
105
+ const decoded = decodeFunctionData({
106
+ abi: aaveDebtTokenAbi,
107
+ data: args.reviewedItem.data,
108
+ });
109
+ if (decoded.functionName !== "delegationWithSig") {
110
+ throw new Error("Reviewed migration authorization is not delegationWithSig()");
111
+ }
112
+ data = encodeFunctionData({
113
+ abi: aaveDebtTokenAbi,
114
+ functionName: "delegationWithSig",
115
+ args: [
116
+ decoded.args[0],
117
+ decoded.args[1],
118
+ decoded.args[2],
119
+ decoded.args[3],
120
+ signature.v,
121
+ signature.r,
122
+ signature.s,
123
+ ],
124
+ });
125
+ }
126
+ else {
127
+ const decoded = decodeFunctionData({
128
+ abi: morphoBlueAbi,
129
+ data: args.reviewedItem.data,
130
+ });
131
+ if (decoded.functionName !== "setAuthorizationWithSig") {
132
+ throw new Error("Reviewed migration authorization is not setAuthorizationWithSig()");
133
+ }
134
+ data = encodeFunctionData({
135
+ abi: morphoBlueAbi,
136
+ functionName: "setAuthorizationWithSig",
137
+ args: [decoded.args[0], signature],
138
+ });
139
+ }
140
+ return { ...args.reviewedItem, data };
141
+ }
142
+ //# sourceMappingURL=migrationAuthorization.js.map