generated from ethaccount/vue-dapp-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Currently, swap parameters (sqrtPriceLimitX96, amountOutMinimum, fee) are calculated at job registration time and encoded into the UserOp. When the backend executes scheduled swaps later, these parameters are often stale due to price fluctuations, causing swap failures.
SAManager/src/lib/scheduling/registerJob.ts
Lines 46 to 57 in c05925e
| const { sqrtPriceLimitX96, amountOutMinimum, fee } = await getSwapParameters(client, swapParams) | |
| execution = { | |
| to: ADDRESS.ScheduledOrders, | |
| value: 0n, | |
| data: INTERFACES.ScheduledOrders.encodeFunctionData('executeOrder', [ | |
| jobId, | |
| sqrtPriceLimitX96, | |
| amountOutMinimum, | |
| fee, | |
| ]), | |
| } |
Current Flow
- User schedules swap → calculates price parameters with current market data
- Backend stores UserOp with encoded parameters
- Backend executes UserOp later → parameters may be outdated → swap fails
Proposed Solution
Move price-sensitive parameter calculation to execution time:
- Registration: Store swap intent (tokens, amount, user preferences) instead of exact parameters
- Execution: Backend calculates fresh price parameters using current market data
- Safety: Preserve user-defined minimum output amount as absolute floor
Files to modify
src/lib/scheduling/registerJob.ts- Remove price calculation from registration- SAManaber-backend - Add logic to calculate fresh parameters at execution
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels