feat: add beforeShip hook for native ETH wrapping#39
Conversation
Add IShipHook interface and modify ship() to support native ETH:
- Add IShipHook interface with beforeShip() callback
- Make ship() payable to accept native ETH
- Call beforeShip hook on the app when ETH is sent
- App can wrap ETH to WETH and send to maker
This enables apps (like Fusion SwapVM) to handle native ETH
in a single transaction: user sends ETH with ship(), app wraps
it to WETH and sends to maker, then normal Aqua flow continues.
Flow:
1. User calls Aqua.ship{value: X}(app, strategy, [WETH,...], [X,...])
2. Aqua calls app.beforeShip{value: X}(maker, strategyHash, tokens, amounts)
3. App wraps ETH to WETH and transfers to maker
4. Aqua continues with normal ship flow (virtual balance tracking)
5. Aqua.pull() works normally (maker now has WETH)
|
Claude finished @deacix's task —— View job Review of PR #39: Add beforeShip hook for native ETH wrappingI've analyzed the changes and here's my comprehensive feedback: Review Checklist:
Code Quality and Best Practices ✅The code follows good practices overall:
Suggestions:
Potential Bugs or Issues
|
Extend ship hooks to support both before and after callbacks: - Add afterShip() to IShipHook interface - Add hooks flags parameter to ship(): - HOOK_NONE (0x00): No hooks called - HOOK_BEFORE (0x01): Call beforeShip before balance storage - HOOK_AFTER (0x02): Call afterShip after balance storage - HOOK_BOTH (0x03): Call both hooks - ETH can only be sent when HOOK_BEFORE flag is set - beforeShip: Use for ETH wrapping, pre-validation, setup - afterShip: Use for notifications, state setup, external calls This makes hooks completely optional - apps that don't need hooks can pass hooks=0 for zero overhead.
|
Claude finished @deacix's task —— View job Review of PR #39: Add beforeShip hook for native ETH wrappingI've analyzed the changes and here's my comprehensive feedback: Review Checklist:
Code Quality and Best Practices ✅The code follows good practices overall:
Minor Issues:
Potential Bugs or Issues
|
Errors are already declared in IAqua.sol interface and inherited by Aqua contract. Removes ShipHookFailed and ETHSentWithoutBeforeHook from Aqua.sol to fix compilation.
|
Claude finished @deacix's task —— View job PR Review: Add beforeShip hook for native ETH wrappingI've thoroughly analyzed the implementation. Here's my comprehensive feedback: Review Checklist:
Code Quality and Best Practices ✅Strengths:
Minor Issues:
Potential Bugs or Issues
|
Add the 5th argument (hooks=0) to all aqua.ship() calls to match the updated function signature that now includes the hooks flags.
|
Claude finished @deacix's task —— View job Code Review: Add beforeShip hook for native ETH wrappingI've thoroughly analyzed this PR. Here are my findings: Todo List:
Code Quality and Best Practices ✅Strengths:
Minor Issues:
Potential Bugs or Issues
|
Gas values slightly increased due to the new hooks parameter in ship(). All tests pass with 5% tolerance.
|
Claude finished @deacix's task —— View job PR Review: Add beforeShip hook for native ETH wrappingI've thoroughly analyzed the implementation. Here's my comprehensive feedback: Review Checklist:
Code Quality and Best Practices ✅Strengths:
Minor Issues:
Potential Bugs or Issues
|
Tests cover: - Hook flag combinations (HOOK_NONE, HOOK_BEFORE, HOOK_AFTER, HOOK_BOTH) - ETH wrapping via beforeShip hook - ETH validation (requires HOOK_BEFORE flag) - Hook failure scenarios (revert, return false) - Non-hook app compatibility - Strategy hash verification - Multiple tokens with ETH - Fuzz tests for flags and ETH amounts
|
Claude finished @deacix's task —— View job Code Review: Add beforeShip hook for native ETH wrappingI've thoroughly analyzed this PR. Here's my comprehensive feedback: Review Checklist:
Code Quality and Best Practices ✅Strengths:
Potential Bugs or Issues
|
- Added ReentrancyGuardTransient to Aqua contract - Added nonReentrant modifier to ship() function - Added 3 new reentrancy tests to verify protection works - Total hook tests: 21 (including 3 reentrancy tests) - Total tests: 47 (all passing) This addresses the security review concern about reentrancy in hooks.
|
Claude finished @deacix's task —— View job Code Review: Add beforeShip hook for native ETH wrappingI've thoroughly analyzed this PR. Here's my comprehensive feedback: Review Checklist:
Code Quality and Best Practices ✅Strengths:
Minor Issue:
Potential Bugs or Issues
|
…ndling Addresses code review feedback: 1. Interface Validation: Documented that Aqua intentionally does NOT verify apps implement IShipHook (saves ~2600 gas). Apps should only set hook flags if they implement the corresponding hook methods. 2. Inconsistent Error Handling: Documented the intentional difference: - beforeShip returns bool for graceful failure signaling - afterShip has no return (follows callback pattern, reverts on failure) This is by design, not an oversight. 3. Hook Failure Semantics: Added clear guidance: - Return false: Expected failures with ShipHookFailed error - Revert: Unexpected failures with detailed error info Both cause ship() to revert.
|
Claude finished @deacix's task —— View job PR Review: Add beforeShip hook for native ETH wrappingI've thoroughly analyzed this PR. Here's my comprehensive feedback: Code Quality and Best Practices ✅Strengths:
Minor Issues:
Potential Bugs or Issues
|
Add IShipHook interface and modify ship() to support native ETH:
This enables apps (like Fusion SwapVM) to handle native ETH in a single transaction: user sends ETH with ship(), app wraps it to WETH and sends to maker, then normal Aqua flow continues.
Flow:
Change Summary
What does this PR change?
Related Issue/Ticket:
Testing & Verification
How was this tested?
Risk Assessment
Risk Level:
Risks & Impact